gimme-alpha 0.1

gcc_hints.h

Go to the documentation of this file.
00001 //Be very careful with some of these.
00002 //Their use is described at
00003 //http://blog.rlove.org/2005_10_01_archive.html
00004 
00005 #ifndef _GCC_HINTS_H
00006 #define _GCC_HINTS_H
00007 
00008 
00009 //Primarily, likely and unlikely are often used.
00010 
00011 #if __GNUC__ >= 3
00012 # define ___always_inline   inline __attribute__ ((always_inline))
00013 # define ___pure    __attribute__ ((pure))
00014 # define ___const __attribute__ ((const))
00015 # define ___noreturn  __attribute__ ((noreturn))
00016 # define ___malloc  __attribute__ ((malloc))
00017 # define ___must_check  __attribute__ ((warn_unused_result))
00018 # define ___deprecated  __attribute__ ((deprecated))
00019 # define ___used    __attribute__ ((used))
00020 # define ___unused  __attribute__ ((unused))
00021 # define ___packed  __attribute__ ((packed))
00022 # define likely(x)  __builtin_expect (!!(x), 1)
00023 # define unlikely(x)  __builtin_expect (!!(x), 0)
00024 #else
00025 # define ___always_inline inline  /* inline when possible */
00026 # define ___pure    /* no pure */
00027 # define ___const /* no const */
00028 # define ___noreturn  /* no noreturn */
00029 # define ___malloc  /* no malloc */
00030 # define ___must_check  /* no warn_unused_result */
00031 # define ___deprecated  /* no deprecated */
00032 # define ___used    /* no used */
00033 # define ___unused  /* no unused */
00034 # define ___packed  /* no packed */
00035 # define likely(x)  (x)
00036 # define unlikely(x)  (x)
00037 #endif
00038 
00039 //Cool new optimizing things for GNU compiler collection 4.3 and later
00040 #if __GNUC__ >= 4 && __GNUC_MINOR__ >= 3
00041 /*For functions that are hotspots (i.e. called a lot and should be
00042  *  more agressively optimized for speed) vs functions that are cold
00043  *  and should be optimized for space over speed.  This also affects
00044  *  where the functions are stored in the final binary, to try to hit
00045  *  the cache more often (i.e. cold functions are pushed away from
00046  *  everything else, while hot functions are clustered together.)
00047  */
00048 #define hotfunc __attribute__((hot))
00049 #define coldfunc __attribute__((cold))
00050 #else
00051 #define hotfunc 
00052 #define coldfunc
00053 #endif
00054 
00055 #endif
 All Classes Files Functions Variables Enumerations Enumerator Defines