Bug 531900 – Use __builtin_offsetof for G_STRUCT_OFFSET if building

with gcc 4.0 or newer
* glib/gmacros.h: Use __builtin_offsetof for G_STRUCT_OFFSET if
building with gcc 4.0 or newer.

svn path=/trunk/; revision=6996
This commit is contained in:
Sebastian Dröge 2008-06-11 07:37:45 +00:00
parent a689811a41
commit 8013b215cd
2 changed files with 17 additions and 2 deletions

View File

@ -1,3 +1,11 @@
2008-06-11 Sebastian Dröge <slomo@circular-chaos.org>
Bug 531900 Use __builtin_offsetof for G_STRUCT_OFFSET if building
with gcc 4.0 or newer
* glib/gmacros.h: Use __builtin_offsetof for G_STRUCT_OFFSET if
building with gcc 4.0 or newer.
2008-06-11 Tor Lillqvist <tml@novell.com>
* glib/gmain.c

View File

@ -209,8 +209,15 @@
/* Provide convenience macros for handling structure
* fields through their offsets.
*/
#define G_STRUCT_OFFSET(struct_type, member) \
((glong) ((guint8*) &((struct_type*) 0)->member))
#if defined(__GNUC__) && __GNUC__ >= 4
# define G_STRUCT_OFFSET(struct_type, member) \
((glong) __builtin_offsetof (struct_type, member))
#else
# define G_STRUCT_OFFSET(struct_type, member) \
((glong) ((guint8*) &((struct_type*) 0)->member))
#endif
#define G_STRUCT_MEMBER_P(struct_p, struct_offset) \
((gpointer) ((guint8*) (struct_p) + (glong) (struct_offset)))
#define G_STRUCT_MEMBER(member_type, struct_p, struct_offset) \