glib r6996 - in trunk: . glib
- From: sdroege svn gnome org
- To: svn-commits-list gnome org
- Subject: glib r6996 - in trunk: . glib
- Date: Wed, 11 Jun 2008 07:37:46 +0000 (UTC)
Author: sdroege
Date: Wed Jun 11 07:37:45 2008
New Revision: 6996
URL: http://svn.gnome.org/viewvc/glib?rev=6996&view=rev
Log:
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.
Modified:
trunk/ChangeLog
trunk/glib/gmacros.h
Modified: trunk/glib/gmacros.h
==============================================================================
--- trunk/glib/gmacros.h (original)
+++ trunk/glib/gmacros.h Wed Jun 11 07:37:45 2008
@@ -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) \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]