diff options
author | Nick Mathewson <nickm@torproject.org> | 2006-08-11 07:09:28 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2006-08-11 07:09:28 +0000 |
commit | 4eddbcf2626b1394e1eb1a9c3928002bb346e178 (patch) | |
tree | 6781a8a94701af7e41c18c0e3682e02f871c1b19 /src/common/util.h | |
parent | 09a895e222f446d400337a3b65b8563705364ec0 (diff) | |
download | tor-4eddbcf2626b1394e1eb1a9c3928002bb346e178.tar tor-4eddbcf2626b1394e1eb1a9c3928002bb346e178.tar.gz |
r7325@Kushana: nickm | 2006-08-10 23:37:31 -0700
Use gcc offsetof where available.
svn:r7021
Diffstat (limited to 'src/common/util.h')
-rw-r--r-- | src/common/util.h | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/common/util.h b/src/common/util.h index 7c0cc1c5a..da5d31904 100644 --- a/src/common/util.h +++ b/src/common/util.h @@ -91,8 +91,12 @@ extern int dmalloc_free(const char *file, const int line, void *pnt, #define tor_memdup(s, n) _tor_memdup(s, n DMALLOC_ARGS) /** Return the offset of <b>member</b> within the type <b>tp</b>, in bytes */ -#define STRUCT_OFFSET(tp, member) \ - ((off_t) (((char*)&((tp*)0)->member)-(char*)0)) +#ifdef __GNUC__ +#define STRUCT_OFFSET(tp, member) __builtin_offsetof(tp, member) +#else + #define STRUCT_OFFSET(tp, member) \ + ((off_t) (((char*)&((tp*)0)->member)-(char*)0)) +#endif /* String manipulation */ #define HEX_CHARACTERS "0123456789ABCDEFabcdef" |