Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

attributes.h

Go to the documentation of this file.
00001 #ifndef INCLUDED_attributes_h
00002 #define INCLUDED_attributes_h
00003 
00004 #if defined(__GNUC__) && __GNUC__ >= 3
00005 
00006 #  if __GNUC__ > 3 || __GNUC__ == 3 && (__GNUC_MINOR__ > 4)
00007 // Currently no 3.5 branch exists, so this boils down to 4.0 or better
00008 //! indicates that a warning should be given if caller doesn't use the return value, e.g. newly allocated memory regions
00009 #    define ATTR_must_check __attribute__ ((warn_unused_result))
00010 #  else
00011 // 3.3 doesn't even support warn_unused_result, and 3.4.2 generates spurious errors.
00012 //! indicates that a warning should be given if caller doesn't use the return value, e.g. newly allocated memory regions
00013 #    define ATTR_must_check /* no warn_unused_result */
00014 #  endif
00015 
00016 //! triggers inlining even when no optimization is specified
00017 #  define ATTR_always_inline    __attribute__ ((always_inline))
00018 
00019 //! compiler hint that the function has no side effects and return value depends only on arguments and non-volatile globals
00020 #  define ATTR_pure   __attribute__ ((pure))
00021 
00022 //! like #ATTR_pure, compiler hint that the function has no side effects and return value depends only on arguments -- unlike #ATTR_pure, cannot access globals or dereference pointer arguments.
00023 #  define ATTR_const  __attribute__ ((const))
00024 
00025 //! indicates that the function is 'fatal' and will not return; however, can still throw an exception!
00026 #  define ATTR_noreturn __attribute__ ((noreturn))
00027 
00028 //! compiler hint that a non-NULL pointer return value is guaranteed to be a unique address (e.g. malloc)
00029 #  define ATTR_malloc __attribute__ ((malloc))
00030 
00031 //! triggers a warning if the function/variable is referenced by any code which is not itself marked with #ATTR_deprecated
00032 #  define ATTR_deprecated __attribute__ ((deprecated))
00033 
00034 //! forces the code for the function to be emitted even if nothing appears to reference it -- handy when called by inline assembly
00035 #  define ATTR_used   __attribute__ ((used))
00036 
00037 //! indicates no warning should be given if the specified value goes unused, e.g. fulfilling an interface which requires superfluous arguments
00038 #  define ATTR_unused __attribute__ ((unused))
00039 
00040 //! requests that members of a struct or union be layed out a densely as possible to minimize memory usage; applied to enums requests smallest storage type be used
00041 #  define ATTR_packed __attribute__ ((packed))
00042 
00043 //! should be passed a value within an 'if' statement to hint that the value is likely to be 'true' (i.e. non-zero)
00044 #  define ATTR_likely(x)  __builtin_expect (!!(x), 1)
00045 
00046 //! should be passed a value within an 'if' statement to hint that the value is unlikely to be 'true' (i.e. likely to be 'false' or 0)
00047 #  define ATTR_unlikely(x)  __builtin_expect (!!(x), 0)
00048 
00049 #else
00050 
00051 //! triggers inlining even when no optimization is specified
00052 #  define ATTR_always_inline    /* no always_inline */
00053 
00054 //! compiler hint that the function has no side effects and return value depends only on arguments and non-volatile globals
00055 #  define ATTR_pure   /* no pure */
00056 
00057 //! like #ATTR_pure, compiler hint that the function has no side effects and return value depends only on arguments -- unlike #ATTR_pure, cannot access globals or dereference pointer arguments.
00058 #  define ATTR_const  /* no const */
00059 
00060 //! indicates that the function is 'fatal' and will not return; however, can still throw an exception!
00061 #  define ATTR_noreturn /* no noreturn */
00062 
00063 //! compiler hint that a non-NULL pointer return value is guaranteed to be a unique address (e.g. malloc)
00064 #  define ATTR_malloc /* no malloc */
00065 
00066 //! indicates that a warning should be given if caller doesn't use the return value, e.g. newly allocated memory regions
00067 #  define ATTR_must_check /* no warn_unused_result */
00068 
00069 //! triggers a warning if the function/variable is referenced by any code which is not itself marked with #ATTR_deprecated
00070 #  define ATTR_deprecated /* no deprecated */
00071 
00072 //! forces the code for the function to be emitted even if nothing appears to reference it -- handy when called by inline assembly
00073 #  define ATTR_used   /* no used */
00074 
00075 //! indicates no warning should be given if the specified value goes unused, e.g. fulfilling an interface which requires superfluous arguments
00076 #  define ATTR_unused /* no unused */
00077 
00078 //! requests that members of a struct or union be layed out a densely as possible to minimize memory usage; applied to enums requests smallest storage type be used
00079 #  define ATTR_packed /* no packed */
00080 
00081 //! should be passed a value within an 'if' statement to hint that the value is likely to be 'true' (i.e. non-zero)
00082 #  define ATTR_likely(x)  (x)
00083 
00084 //! should be passed a value within an 'if' statement to hint that the value is unlikely to be 'true' (i.e. likely to be 'false' or 0)
00085 #  define ATTR_unlikely(x)  (x)
00086 
00087 #endif
00088 
00089 #ifdef _MSC_VER
00090 #  ifdef BUILDING_DLL
00091 #    define EXPORT_SYMBOL __declspec(dllexport)
00092 #  else
00093 #    define EXPORT_SYMBOL __declspec(dllimport)
00094 #  endif
00095 #  define LOCAL_SYMBOL
00096 #elif defined(__GNUC__) && __GNUC__ >= 4
00097 #  define EXPORT_SYMBOL __attribute__ ((visibility("default")))
00098 #  define LOCAL_SYMBOL __attribute__ ((visibility("hidden")))
00099 #else
00100 #  define EXPORT_SYMBOL
00101 #  define LOCAL_SYMBOL
00102 #endif
00103 
00104 /*! @file
00105 * @brief Defines variants of the __attribute__ macros to provide better portability
00106 * @author Robert Love (Creator), ejt (more version specificity)
00107 *
00108 * Based on code published at http://rlove.org/log/2005102601
00109 */
00110 #endif

Tekkotsu v5.1CVS
Generated Mon May 9 04:58:36 2016 by Doxygen 1.6.3