From: Eugene Syromyatnikov Date: Sat, 3 Sep 2016 11:41:33 +0000 (+0300) Subject: defs.h: add offsetofend macro X-Git-Tag: v4.15~216 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6e6c11d9ddda53050e08ea152a7dab2fb0057902;p=strace defs.h: add offsetofend macro Analogous to offsetof but returns structure offset after the specified field. Useful for checking whether specific field is present in obtained data or specifying amount of data to copy based on the (last) field needed. * defs.h (offsetofend): New macro. --- diff --git a/defs.h b/defs.h index 2b4118b5..758fd8b9 100644 --- a/defs.h +++ b/defs.h @@ -68,6 +68,11 @@ const char *strerror(int); extern char *stpcpy(char *dst, const char *src); #endif +#ifndef offsetofend +# define offsetofend(type, member) \ + (offsetof(type, member) + sizeof(((type *)NULL)->member)) +#endif + #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) /* macros */