X-Git-Url: http://git.tuebingen.mpg.de/?p=dss.git;a=blobdiff_plain;f=gcc-compat.h;h=a15b0cef5c0f4b10672ab8a620429438baa1e1c2;hp=61c3c88d1c4551a965aaa22c626ddf8fabec31ba;hb=965855384d34b7f1c4730eb78f26d010adb9be42;hpb=c418d2188c9c2c542270023d6fc3bc6cf34f8d29 diff --git a/gcc-compat.h b/gcc-compat.h index 61c3c88..a15b0ce 100644 --- a/gcc-compat.h +++ b/gcc-compat.h @@ -1,14 +1,35 @@ -# define inline inline __attribute__ ((always_inline)) +#define HAVE_GNUC(maj, min) \ + defined(__GNUC__) && \ + (__GNUC__ > maj || (__GNUC__ == maj && __GNUC_MINOR__ >= min)) + +#if HAVE_GNUC(2,5) # define __noreturn __attribute__ ((noreturn)) +#else +# define __noreturn +#endif + +#if HAVE_GNUC(3,0) # define __malloc __attribute__ ((malloc)) +#else +# define __malloc +#endif + +#if HAVE_GNUC(2,7) # define __a_unused __attribute__ ((unused)) -# define likely(x) __builtin_expect (!!(x), 1) -# define unlikely(x) __builtin_expect (!!(x), 0) +#else +# define __a_unused +#endif + /* * p is the number of the "format string" parameter, and q is * the number of the first variadic parameter */ +#if HAVE_GNUC(2,3) # define __printf(p,q) __attribute__ ((format (printf, p, q))) +#else +# define __printf(p,q) +#endif + /* * as direct use of __printf(p,q) confuses doxygen, here are two extra macros * for those values p,q that are actually used by paraslash. @@ -16,10 +37,10 @@ #define __printf_1_2 __printf(1,2) #define __printf_2_3 __printf(2,3) -# if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 3) +#if HAVE_GNUC(3,3) # define __must_check __attribute__ ((warn_unused_result)) -# else +#else # define __must_check /* no warn_unused_result */ -# endif +#endif #define _static_inline_ static inline