epoc32/include/stdapis/glib-2.0/glib/gmacros.h
branchSymbian2
changeset 2 2fe1408b6811
parent 0 061f57f2323e
     1.1 --- a/epoc32/include/stdapis/glib-2.0/glib/gmacros.h	Tue Nov 24 13:55:44 2009 +0000
     1.2 +++ b/epoc32/include/stdapis/glib-2.0/glib/gmacros.h	Tue Mar 16 16:12:26 2010 +0000
     1.3 @@ -1,1 +1,261 @@
     1.4 -gmacros.h
     1.5 +/* GLIB - Library of useful routines for C programming
     1.6 + * Copyright (C) 1995-1997  Peter Mattis, Spencer Kimball and Josh MacDonald
     1.7 + *
     1.8 + * This library is free software; you can redistribute it and/or
     1.9 + * modify it under the terms of the GNU Lesser General Public
    1.10 + * License as published by the Free Software Foundation; either
    1.11 + * version 2 of the License, or (at your option) any later version.
    1.12 + *
    1.13 + * This library is distributed in the hope that it will be useful,
    1.14 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.15 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
    1.16 + * Lesser General Public License for more details.
    1.17 + *
    1.18 + * You should have received a copy of the GNU Lesser General Public
    1.19 + * License along with this library; if not, write to the
    1.20 + * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    1.21 + * Boston, MA 02111-1307, USA.
    1.22 + */
    1.23 +
    1.24 +/*
    1.25 + * Modified by the GLib Team and others 1997-2000.  See the AUTHORS
    1.26 + * file for a list of people on the GLib Team.  See the ChangeLog
    1.27 + * files for a list of changes.  These files are distributed with
    1.28 + * GLib at ftp://ftp.gtk.org/pub/gtk/. 
    1.29 + */
    1.30 +
    1.31 +/* This file must not include any other glib header file and must thus
    1.32 + * not refer to variables from glibconfig.h 
    1.33 + */
    1.34 +
    1.35 +#ifndef __G_MACROS_H__
    1.36 +#define __G_MACROS_H__
    1.37 +
    1.38 +/* We include stddef.h to get the system's definition of NULL
    1.39 + */
    1.40 +#include <stddef.h>
    1.41 +
    1.42 +/* Here we provide G_GNUC_EXTENSION as an alias for __extension__,
    1.43 + * where this is valid. This allows for warningless compilation of
    1.44 + * "long long" types even in the presence of '-ansi -pedantic'. 
    1.45 + */
    1.46 +#if     __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8)
    1.47 +#  define G_GNUC_EXTENSION __extension__
    1.48 +#else
    1.49 +#  define G_GNUC_EXTENSION
    1.50 +#endif
    1.51 +
    1.52 +/* Provide macros to feature the GCC function attribute.
    1.53 + */
    1.54 +#if    __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
    1.55 +#define G_GNUC_PURE                            \
    1.56 +  __attribute__((__pure__))
    1.57 +#define G_GNUC_MALLOC    			\
    1.58 +  __attribute__((__malloc__))
    1.59 +#else
    1.60 +#define G_GNUC_PURE
    1.61 +#define G_GNUC_MALLOC
    1.62 +#endif
    1.63 +
    1.64 +#if     __GNUC__ >= 4
    1.65 +#define G_GNUC_NULL_TERMINATED __attribute__((__sentinel__))
    1.66 +#else
    1.67 +#define G_GNUC_NULL_TERMINATED
    1.68 +#endif
    1.69 +
    1.70 +#if     __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
    1.71 +#define G_GNUC_PRINTF( format_idx, arg_idx )    \
    1.72 +  __attribute__((__format__ (__printf__, format_idx, arg_idx)))
    1.73 +#define G_GNUC_SCANF( format_idx, arg_idx )     \
    1.74 +  __attribute__((__format__ (__scanf__, format_idx, arg_idx)))
    1.75 +#define G_GNUC_FORMAT( arg_idx )                \
    1.76 +  __attribute__((__format_arg__ (arg_idx)))
    1.77 +#define G_GNUC_NORETURN                         \
    1.78 +  __attribute__((__noreturn__))
    1.79 +#define G_GNUC_CONST                            \
    1.80 +  __attribute__((__const__))
    1.81 +#define G_GNUC_UNUSED                           \
    1.82 +  __attribute__((__unused__))
    1.83 +#define G_GNUC_NO_INSTRUMENT			\
    1.84 +  __attribute__((__no_instrument_function__))
    1.85 +#else   /* !__GNUC__ */
    1.86 +#define G_GNUC_PRINTF( format_idx, arg_idx )
    1.87 +#define G_GNUC_SCANF( format_idx, arg_idx )
    1.88 +#define G_GNUC_FORMAT( arg_idx )
    1.89 +#define G_GNUC_NORETURN
    1.90 +#define G_GNUC_CONST
    1.91 +#define G_GNUC_UNUSED
    1.92 +#define G_GNUC_NO_INSTRUMENT
    1.93 +#endif  /* !__GNUC__ */
    1.94 +
    1.95 +#if    __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
    1.96 +#define G_GNUC_DEPRECATED                            \
    1.97 +  __attribute__((__deprecated__))
    1.98 +#else
    1.99 +#define G_GNUC_DEPRECATED
   1.100 +#endif /* __GNUC__ */
   1.101 +
   1.102 +#if    __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
   1.103 +#define G_GNUC_WARN_UNUSED_RESULT 		\
   1.104 +  __attribute__((warn_unused_result))
   1.105 +#else
   1.106 +#define G_GNUC_WARN_UNUSED_RESULT
   1.107 +#endif /* __GNUC__ */
   1.108 +
   1.109 +/* Wrap the gcc __PRETTY_FUNCTION__ and __FUNCTION__ variables with
   1.110 + * macros, so we can refer to them as strings unconditionally.
   1.111 + * usage not-recommended since gcc-3.0
   1.112 + */
   1.113 +#if defined (__GNUC__) && (__GNUC__ < 3)
   1.114 +#define G_GNUC_FUNCTION         __FUNCTION__
   1.115 +#define G_GNUC_PRETTY_FUNCTION  __PRETTY_FUNCTION__
   1.116 +#else   /* !__GNUC__ */
   1.117 +#define G_GNUC_FUNCTION         ""
   1.118 +#define G_GNUC_PRETTY_FUNCTION  ""
   1.119 +#endif  /* !__GNUC__ */
   1.120 +
   1.121 +#define G_STRINGIFY(macro_or_string)	G_STRINGIFY_ARG (macro_or_string)
   1.122 +#define	G_STRINGIFY_ARG(contents)	#contents
   1.123 +
   1.124 +/* Provide a string identifying the current code position */
   1.125 +#if defined(__GNUC__) && (__GNUC__ < 3) && !defined(__cplusplus)
   1.126 +#  define G_STRLOC	__FILE__ ":" G_STRINGIFY (__LINE__) ":" __PRETTY_FUNCTION__ "()"
   1.127 +#else
   1.128 +#  define G_STRLOC	__FILE__ ":" G_STRINGIFY (__LINE__)
   1.129 +#endif
   1.130 +
   1.131 +/* Provide a string identifying the current function, non-concatenatable */
   1.132 +#if defined (__GNUC__)
   1.133 +#  define G_STRFUNC     ((const char*) (__PRETTY_FUNCTION__))
   1.134 +#elif defined (G_HAVE_ISO_VARARGS)
   1.135 +#  define G_STRFUNC     ((const char*) (__func__))
   1.136 +#else
   1.137 +#  define G_STRFUNC     ((const char*) ("???"))
   1.138 +#endif
   1.139 +
   1.140 +/* Guard C code in headers, while including them from C++ */
   1.141 +#ifdef  __cplusplus
   1.142 +# define G_BEGIN_DECLS  extern "C" {
   1.143 +# define G_END_DECLS    }
   1.144 +#else
   1.145 +# define G_BEGIN_DECLS
   1.146 +# define G_END_DECLS
   1.147 +#endif
   1.148 +
   1.149 +/* Provide definitions for some commonly used macros.
   1.150 + *  Some of them are only provided if they haven't already
   1.151 + *  been defined. It is assumed that if they are already
   1.152 + *  defined then the current definition is correct.
   1.153 + */
   1.154 +#ifndef NULL
   1.155 +#  ifdef __cplusplus
   1.156 +#    define NULL        (0L)
   1.157 +#  else /* !__cplusplus */
   1.158 +#    define NULL        ((void*) 0)
   1.159 +#  endif /* !__cplusplus */
   1.160 +#endif
   1.161 +
   1.162 +#ifndef	FALSE
   1.163 +#define	FALSE	(0)
   1.164 +#endif
   1.165 +
   1.166 +#ifndef	TRUE
   1.167 +#define	TRUE	(!FALSE)
   1.168 +#endif
   1.169 +
   1.170 +#undef	MAX
   1.171 +#define MAX(a, b)  (((a) > (b)) ? (a) : (b))
   1.172 +
   1.173 +#undef	MIN
   1.174 +#define MIN(a, b)  (((a) < (b)) ? (a) : (b))
   1.175 +
   1.176 +#undef	ABS
   1.177 +#define ABS(a)	   (((a) < 0) ? -(a) : (a))
   1.178 +
   1.179 +#undef	CLAMP
   1.180 +#define CLAMP(x, low, high)  (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x)))
   1.181 +
   1.182 +/* Count the number of elements in an array. The array must be defined
   1.183 + * as such; using this with a dynamically allocated array will give
   1.184 + * incorrect results.
   1.185 + */
   1.186 +#define G_N_ELEMENTS(arr)		(sizeof (arr) / sizeof ((arr)[0]))
   1.187 +
   1.188 +/* Macros by analogy to GINT_TO_POINTER, GPOINTER_TO_INT
   1.189 + */
   1.190 +#define GPOINTER_TO_SIZE(p)	((gsize) (p))
   1.191 +#define GSIZE_TO_POINTER(s)	((gpointer) (gsize) (s))
   1.192 +
   1.193 +/* Provide convenience macros for handling structure
   1.194 + * fields through their offsets.
   1.195 + */
   1.196 +#define G_STRUCT_OFFSET(struct_type, member)	\
   1.197 +    ((glong) ((guint8*) &((struct_type*) 0)->member))
   1.198 +#define G_STRUCT_MEMBER_P(struct_p, struct_offset)   \
   1.199 +    ((gpointer) ((guint8*) (struct_p) + (glong) (struct_offset)))
   1.200 +#define G_STRUCT_MEMBER(member_type, struct_p, struct_offset)   \
   1.201 +    (*(member_type*) G_STRUCT_MEMBER_P ((struct_p), (struct_offset)))
   1.202 +
   1.203 +/* Provide simple macro statement wrappers (adapted from Perl):
   1.204 + *  G_STMT_START { statements; } G_STMT_END;
   1.205 + *  can be used as a single statement, as in
   1.206 + *  if (x) G_STMT_START { ... } G_STMT_END; else ...
   1.207 + *
   1.208 + *  When GCC is compiling C code in non-ANSI mode, it will use the
   1.209 + *  compiler __extension__ to wrap the statements wihin `({' and '})' braces.
   1.210 + *  When compiling on platforms where configure has defined
   1.211 + *  HAVE_DOWHILE_MACROS, statements will be wrapped with `do' and `while (0)'.
   1.212 + *  For any other platforms (SunOS4 is known to have this issue), wrap the
   1.213 + *  statements with `if (1)' and `else (void) 0'.
   1.214 + */
   1.215 +#if !(defined (G_STMT_START) && defined (G_STMT_END))
   1.216 +# if defined (__GNUC__) && !defined (__STRICT_ANSI__) && !defined (__cplusplus)
   1.217 +#  define G_STMT_START (void) __extension__ (
   1.218 +#  define G_STMT_END )
   1.219 +# else /* !(__GNUC__ && !__STRICT_ANSI__ && !__cplusplus) */
   1.220 +#  if defined (HAVE_DOWHILE_MACROS)
   1.221 +#   define G_STMT_START do
   1.222 +#   define G_STMT_END while (0)
   1.223 +#  else /* !HAVE_DOWHILE_MACROS */
   1.224 +#   define G_STMT_START if (1)
   1.225 +#   define G_STMT_END else (void) 0
   1.226 +#  endif /* !HAVE_DOWHILE_MACROS */
   1.227 +# endif /* !(__GNUC__ && !__STRICT_ANSI__ && !__cplusplus) */
   1.228 +#endif
   1.229 +
   1.230 +/* Allow the app programmer to select whether or not return values
   1.231 + * (usually char*) are const or not.  Don't try using this feature for
   1.232 + * functions with C++ linkage.
   1.233 + */
   1.234 +#ifdef G_DISABLE_CONST_RETURNS
   1.235 +#define G_CONST_RETURN
   1.236 +#else
   1.237 +#define G_CONST_RETURN const
   1.238 +#endif
   1.239 +
   1.240 +/*
   1.241 + * The G_LIKELY and G_UNLIKELY macros let the programmer give hints to 
   1.242 + * the compiler about the expected result of an expression. Some compilers
   1.243 + * can use this information for optimizations.
   1.244 + *
   1.245 + * The _G_BOOLEAN_EXPR macro is intended to trigger a gcc warning when
   1.246 + * putting assignments in g_return_if_fail ().  
   1.247 + */
   1.248 +#if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__)
   1.249 +#define _G_BOOLEAN_EXPR(expr)                   \
   1.250 + __extension__ ({                               \
   1.251 +   int _g_boolean_var_;                         \
   1.252 +   if (expr)                                    \
   1.253 +      _g_boolean_var_ = 1;                      \
   1.254 +   else                                         \
   1.255 +      _g_boolean_var_ = 0;                      \
   1.256 +   _g_boolean_var_;                             \
   1.257 +})
   1.258 +#define G_LIKELY(expr) (__builtin_expect (_G_BOOLEAN_EXPR(expr), 1))
   1.259 +#define G_UNLIKELY(expr) (__builtin_expect (_G_BOOLEAN_EXPR(expr), 0))
   1.260 +#else
   1.261 +#define G_LIKELY(expr) (expr)
   1.262 +#define G_UNLIKELY(expr) (expr)
   1.263 +#endif
   1.264 +
   1.265 +#endif /* __G_MACROS_H__ */