Fawkes API  Fawkes Development Version
macros.h
00001 
00002 /***************************************************************************
00003  *  macros.h - important macros
00004  *
00005  *  Created: Mon Dec 03 13:52:05 2007
00006  *  Copyright  2007  Tim Niemueller [www.niemueller.de]
00007  *
00008  ****************************************************************************/
00009 
00010 /*  This program is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; either version 2 of the License, or
00013  *  (at your option) any later version. A runtime exception applies to
00014  *  this software (see LICENSE.GPL_WRE file mentioned below for details).
00015  *
00016  *  This program is distributed in the hope that it will be useful,
00017  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  *  GNU Library General Public License for more details.
00020  *
00021  *  Read the full text in the LICENSE.GPL_WRE file in the doc directory.
00022  */
00023 
00024 #ifndef __CORE_MACROS_H_
00025 #define __CORE_MACROS_H_
00026 
00027 // from http://blog.rlove.org/2005_10_01_archive.html
00028 // Note that __GNUC__ is also set appropriately by the Intel compiler
00029 #if __GNUC__ >= 3
00030 #  ifndef __inline
00031 #    define __inline    inline __attribute__ ((__always_inline__))
00032 #  endif
00033 #  ifndef __pure
00034 #    define __pure      __attribute__ ((__pure__))
00035 #  endif
00036 #  define __const_      __attribute__ ((__const__))
00037 #  define __noreturn    __attribute__ ((__noreturn__))
00038 #  define __malloc      __attribute__ ((__malloc__))
00039 #  define __must_check  __attribute__ ((__warn_unused_result__))
00040 #  ifndef __deprecated
00041 #    define __deprecated        __attribute__ ((__deprecated__))
00042 #  endif
00043 #  ifndef __used
00044 #    define __used      __attribute__ ((__used__))
00045 #  endif
00046 #  ifndef __unused
00047 #    define __unused    __attribute__ ((__unused__))
00048 #  endif
00049 #  ifndef __packed
00050 #    define __packed    __attribute__ ((__packed__))
00051 #  endif
00052 #  ifndef __aligned
00053 #    define __aligned(x)   __attribute__ ((__aligned__ (x)))
00054 #  endif
00055 #  define likely(x)     __builtin_expect (!!(x), 1)
00056 #  define unlikely(x)   __builtin_expect (!!(x), 0)
00057 #else
00058 #  ifndef __inline
00059 #    define __inline    /* no inline */
00060 #  endif
00061 #  ifndef __pure
00062 #    define __pure              /* no pure */
00063 #  endif
00064 #  define __const_      /* no const */
00065 #  define __noreturn    /* no noreturn */
00066 #  define __malloc      /* no malloc */
00067 #  define __must_check  /* no warn_unused_result */
00068 #  define __deprecated  /* no deprecated */
00069 #  ifndef __used
00070 #    define __used              /* no used */
00071 #  endif
00072 #  ifndef __unused
00073 #    define __unused    /* no unused */
00074 #  endif
00075 #  ifndef __packed
00076 #    define __packed    /* no packed */
00077 #  endif
00078 #  ifndef __aligned
00079 #    define __aligned(x)   /* no align */
00080 #  endif
00081 #  define likely(x)     (x)
00082 #  define unlikely(x)   (x)
00083 #endif
00084 
00085 #endif