00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #ifndef CX_MACROS_H
00034 #define CX_MACROS_H
00035
00036
00037
00038
00039
00040
00041 #include <stddef.h>
00042
00043
00044
00045
00046
00047
00048 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8)
00049 # define CX_GNUC_EXTENSION __extension__
00050 #else
00051 # define CX_GNUC_EXTENSION
00052 #endif
00053
00054
00055
00056
00057
00058
00059 #if defined (__GNUC__) && (__GNUC__ < 3)
00060 # define CX_GNUC_FUNCTION __FUNCTION__
00061 # define CX_GNUC_PRETTY_FUNCTION __PRETTY_FUNCTION__
00062 #else
00063 # define CX_GNUC_FUNCTION ""
00064 # define CX_GNUC_PRETTY_FUNCTION ""
00065 #endif
00066
00067 #define CX_STRINGIFY(macro) CX_STRINGIFY_ARG(macro)
00068 #define CX_STRINGIFY_ARG(contents) #contents
00069
00070
00071
00072
00073
00074
00075 #if defined (__GNUC__) && (__GNUC__ < 3)
00076 # define CX_CODE_POS __FILE__ ":" CX_STRINGIFY(__LINE__) ":" __PRETTY_FUNCTION__ "()"
00077 #else
00078 # define CX_CODE_POS __FILE__ ":" CX_STRINGIFY(__LINE__)
00079 #endif
00080
00081
00082
00083
00084
00085
00086 #undef CX_BEGIN_DECLS
00087 #undef CX_END_DECLS
00088
00089 #ifdef __cplusplus
00090 # define CX_BEGIN_DECLS extern "C" {
00091 # define CX_END_DECLS }
00092 #else
00093 # define CX_BEGIN_DECLS
00094 # define CX_END_DECLS
00095 #endif
00096
00097
00098
00099
00100
00101
00102
00103 #ifndef NULL
00104 # ifdef __cplusplus
00105 # define NULL (0L)
00106 # else
00107 # define NULL ((void *) 0)
00108 # endif
00109 #endif
00110
00111 #ifndef FALSE
00112 # define FALSE (0)
00113 #endif
00114
00115 #ifndef TRUE
00116 # define TRUE (!FALSE)
00117 #endif
00118
00119 #ifndef CX_MIN
00120 # define CX_MIN(a, b) ((a) < (b) ? (a) : (b))
00121 #endif
00122
00123
00124
00125 #ifndef CX_MAX
00126 # define CX_MAX(a, b) ((a) > (b) ? (a) : (b))
00127 #endif
00128
00129
00130
00131 #ifndef CX_ABS
00132 # define CX_ABS(a) ((a) < (0) ? -(a) : (a))
00133 #endif
00134
00135
00136
00137 #ifndef CX_CLAMP
00138 # define CX_CLAMP(a, low, high) (((a) > (high)) ? (high) : (((a) < (low)) ? (low) : (a)))
00139 #endif
00140
00141
00142
00143
00144
00145
00146
00147
00148 #define CX_N_ELEMENTS(array) (sizeof (array) / sizeof ((array)[0]))
00149
00150 #endif