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 #ifndef __G_MACROS_H__
00032 #define __G_MACROS_H__
00033
00034
00035
00036
00037
00038 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8)
00039 # define G_GNUC_EXTENSION __extension__
00040 #else
00041 # define G_GNUC_EXTENSION
00042 #endif
00043
00044
00045
00046 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
00047 #define G_GNUC_PURE \
00048 __attribute__((pure))
00049 #else
00050 #define G_GNUC_PURE
00051 #endif
00052
00053 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
00054 #define G_GNUC_PRINTF( format_idx, arg_idx ) \
00055 __attribute__((format (printf, format_idx, arg_idx)))
00056 #define G_GNUC_SCANF( format_idx, arg_idx ) \
00057 __attribute__((format (scanf, format_idx, arg_idx)))
00058 #define G_GNUC_FORMAT( arg_idx ) \
00059 __attribute__((format_arg (arg_idx)))
00060 #define G_GNUC_NORETURN \
00061 __attribute__((noreturn))
00062 #define G_GNUC_CONST \
00063 __attribute__((const))
00064 #define G_GNUC_UNUSED \
00065 __attribute__((unused))
00066 #else
00067 #define G_GNUC_PRINTF( format_idx, arg_idx )
00068 #define G_GNUC_SCANF( format_idx, arg_idx )
00069 #define G_GNUC_FORMAT( arg_idx )
00070 #define G_GNUC_NORETURN
00071 #define G_GNUC_CONST
00072 #define G_GNUC_UNUSED
00073 #endif
00074
00075
00076
00077
00078 #ifdef __GNUC__
00079 #define G_GNUC_FUNCTION __FUNCTION__
00080 #define G_GNUC_PRETTY_FUNCTION __PRETTY_FUNCTION__
00081 #else
00082 #define G_GNUC_FUNCTION ""
00083 #define G_GNUC_PRETTY_FUNCTION ""
00084 #endif
00085
00086 #define G_STRINGIFY(macro_or_string) G_STRINGIFY_ARG (macro_or_string)
00087 #define G_STRINGIFY_ARG(contents) #contents
00088
00089
00090 #ifdef __GNUC__
00091 # define G_STRLOC __FILE__ ":" G_STRINGIFY (__LINE__) ":" __PRETTY_FUNCTION__ "()"
00092 #else
00093 # define G_STRLOC __FILE__ ":" G_STRINGIFY (__LINE__)
00094 #endif
00095
00096
00097 #ifdef __cplusplus
00098 # define G_BEGIN_DECLS extern "C" {
00099 # define G_END_DECLS }
00100 #else
00101 # define G_BEGIN_DECLS
00102 # define G_END_DECLS
00103 #endif
00104
00105
00106
00107
00108
00109
00110 #ifndef NULL
00111 # ifdef __cplusplus
00112 # define NULL (0L)
00113 # else
00114 # define NULL ((void*) 0)
00115 # endif
00116 #endif
00117
00118 #ifndef FALSE
00119 #define FALSE (0)
00120 #endif
00121
00122 #ifndef TRUE
00123 #define TRUE (!FALSE)
00124 #endif
00125
00126 #undef MAX
00127 #define MAX(a, b) (((a) > (b)) ? (a) : (b))
00128
00129 #undef MIN
00130 #define MIN(a, b) (((a) < (b)) ? (a) : (b))
00131
00132 #undef ABS
00133 #define ABS(a) (((a) < 0) ? -(a) : (a))
00134
00135 #undef CLAMP
00136 #define CLAMP(x, low, high) (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x)))
00137
00138
00139
00140
00141
00142 #define G_N_ELEMENTS(arr) (sizeof (arr) / sizeof ((arr)[0]))
00143
00144
00145
00146
00147 #define G_STRUCT_OFFSET(struct_type, member) \
00148 ((glong) ((guint8*) &((struct_type*) 0)->member))
00149 #define G_STRUCT_MEMBER_P(struct_p, struct_offset) \
00150 ((gpointer) ((guint8*) (struct_p) + (glong) (struct_offset)))
00151 #define G_STRUCT_MEMBER(member_type, struct_p, struct_offset) \
00152 (*(member_type*) G_STRUCT_MEMBER_P ((struct_p), (struct_offset)))
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163 #if !(defined (G_STMT_START) && defined (G_STMT_END))
00164 # if defined (__GNUC__) && !defined (__STRICT_ANSI__) && !defined (__cplusplus)
00165 # define G_STMT_START (void)(
00166 # define G_STMT_END )
00167 # else
00168 # if (defined (sun) || defined (__sun__))
00169 # define G_STMT_START if (1)
00170 # define G_STMT_END else (void)0
00171 # else
00172 # define G_STMT_START do
00173 # define G_STMT_END while (0)
00174 # endif
00175 # endif
00176 #endif
00177
00178
00179
00180
00181
00182 #ifdef G_DISABLE_CONST_RETURNS
00183 #define G_CONST_RETURN
00184 #else
00185 #define G_CONST_RETURN const
00186 #endif
00187
00188 #endif