adding G_GNUC_MAY_ALIAS macro to gmacros.h



Hi,

Latest GNU C compilers can produce a great number of warning messages 
about type-punned pointers, which can be worked around by

1) using unions (IMHO ugly)
2) turning off strict aliasing (-fno-strict-aliasing)
3) using extra variables which _might_ be optimized away
4) using the may_alias gcc specific attribute keyword

Currently GLib has no macro for __attribute__((__may_alias__)), the following 
patch adds it to gmacros.h. My question is whether you consider it for 
inclusion.


--- gmacros.h.old        2005-01-16 17:13:49.000000000 +0100
+++ gmacros.h   2005-02-02 12:01:35.000000000 +0100
@@ -72,6 +72,8 @@
   __attribute__((__unused__))
 #define G_GNUC_NO_INSTRUMENT                   \
   __attribute__((__no_instrument_function__))
+#define G_GNUC_MAY_ALIAS                       \
+  __attribute__((__may_alias__))
 #else   /* !__GNUC__ */
 #define G_GNUC_PRINTF( format_idx, arg_idx )
 #define G_GNUC_SCANF( format_idx, arg_idx )
@@ -80,6 +82,7 @@
 #define G_GNUC_CONST
 #define G_GNUC_UNUSED
 #define G_GNUC_NO_INSTRUMENT
+#define G_GNUC_MAY_ALIAS
 #endif  /* !__GNUC__ */

 #if    __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)

-- 
Bazsi





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]