Back to index

glibc  2.9
cdefs.h
Go to the documentation of this file.
00001 /* Copyright (C) 1992-2001, 2002, 2004, 2005, 2006, 2007
00002    Free Software Foundation, Inc.
00003    This file is part of the GNU C Library.
00004 
00005    The GNU C Library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Lesser General Public
00007    License as published by the Free Software Foundation; either
00008    version 2.1 of the License, or (at your option) any later version.
00009 
00010    The GNU C Library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Lesser General Public License for more details.
00014 
00015    You should have received a copy of the GNU Lesser General Public
00016    License along with the GNU C Library; if not, write to the Free
00017    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00018    02111-1307 USA.  */
00019 
00020 #ifndef       _SYS_CDEFS_H
00021 #define       _SYS_CDEFS_H  1
00022 
00023 /* We are almost always included from features.h. */
00024 #ifndef _FEATURES_H
00025 # include <features.h>
00026 #endif
00027 
00028 /* The GNU libc does not support any K&R compilers or the traditional mode
00029    of ISO C compilers anymore.  Check for some of the combinations not
00030    anymore supported.  */
00031 #if defined __GNUC__ && !defined __STDC__
00032 # error "You need a ISO C conforming compiler to use the glibc headers"
00033 #endif
00034 
00035 /* Some user header file might have defined this before.  */
00036 #undef __P
00037 #undef __PMT
00038 
00039 #ifdef __GNUC__
00040 
00041 /* GCC can always grok prototypes.  For C++ programs we add throw()
00042    to help it optimize the function calls.  But this works only with
00043    gcc 2.8.x and egcs.  For gcc 3.2 and up we even mark C functions
00044    as non-throwing using a function attribute since programs can use
00045    the -fexceptions options for C code as well.  */
00046 # if !defined __cplusplus && __GNUC_PREREQ (3, 3)
00047 #  define __THROW    __attribute__ ((__nothrow__))
00048 #  define __NTH(fct) __attribute__ ((__nothrow__)) fct
00049 # else
00050 #  if defined __cplusplus && __GNUC_PREREQ (2,8)
00051 #   define __THROW   throw ()
00052 #   define __NTH(fct)       fct throw ()
00053 #  else
00054 #   define __THROW
00055 #   define __NTH(fct)       fct
00056 #  endif
00057 # endif
00058 
00059 #else  /* Not GCC.  */
00060 
00061 # define __inline           /* No inline functions.  */
00062 
00063 # define __THROW
00064 # define __NTH(fct)  fct
00065 
00066 # define __const     const
00067 # define __signed    signed
00068 # define __volatile  volatile
00069 
00070 #endif /* GCC.  */
00071 
00072 /* These two macros are not used in glibc anymore.  They are kept here
00073    only because some other projects expect the macros to be defined.  */
00074 #define __P(args)    args
00075 #define __PMT(args)  args
00076 
00077 /* For these things, GCC behaves the ANSI way normally,
00078    and the non-ANSI way under -traditional.  */
00079 
00080 #define __CONCAT(x,y)       x ## y
00081 #define __STRING(x)  #x
00082 
00083 /* This is not a typedef so `const __ptr_t' does the right thing.  */
00084 #define __ptr_t void *
00085 #define __long_double_t  long double
00086 
00087 
00088 /* C++ needs to know that types and declarations are C, not C++.  */
00089 #ifdef __cplusplus
00090 # define __BEGIN_DECLS      extern "C" {
00091 # define __END_DECLS }
00092 #else
00093 # define __BEGIN_DECLS
00094 # define __END_DECLS
00095 #endif
00096 
00097 
00098 /* The standard library needs the functions from the ISO C90 standard
00099    in the std namespace.  At the same time we want to be safe for
00100    future changes and we include the ISO C99 code in the non-standard
00101    namespace __c99.  The C++ wrapper header take case of adding the
00102    definitions to the global namespace.  */
00103 #if defined __cplusplus && defined _GLIBCPP_USE_NAMESPACES
00104 # define __BEGIN_NAMESPACE_STD     namespace std {
00105 # define __END_NAMESPACE_STD       }
00106 # define __USING_NAMESPACE_STD(name) using std::name;
00107 # define __BEGIN_NAMESPACE_C99     namespace __c99 {
00108 # define __END_NAMESPACE_C99       }
00109 # define __USING_NAMESPACE_C99(name) using __c99::name;
00110 #else
00111 /* For compatibility we do not add the declarations into any
00112    namespace.  They will end up in the global namespace which is what
00113    old code expects.  */
00114 # define __BEGIN_NAMESPACE_STD
00115 # define __END_NAMESPACE_STD
00116 # define __USING_NAMESPACE_STD(name)
00117 # define __BEGIN_NAMESPACE_C99
00118 # define __END_NAMESPACE_C99
00119 # define __USING_NAMESPACE_C99(name)
00120 #endif
00121 
00122 
00123 /* Support for bounded pointers.  */
00124 #ifndef __BOUNDED_POINTERS__
00125 # define __bounded   /* nothing */
00126 # define __unbounded /* nothing */
00127 # define __ptrvalue  /* nothing */
00128 #endif
00129 
00130 
00131 /* Fortify support.  */
00132 #define __bos(ptr) __builtin_object_size (ptr, __USE_FORTIFY_LEVEL > 1)
00133 #define __bos0(ptr) __builtin_object_size (ptr, 0)
00134 
00135 #if __GNUC_PREREQ (4,3)
00136 # define __warndecl(name, msg) \
00137   extern void name (void) __attribute__((__warning__ (msg)))
00138 # define __warnattr(msg) __attribute__((__warning__ (msg)))
00139 # define __errordecl(name, msg) \
00140   extern void name (void) __attribute__((__error__ (msg)))
00141 #else
00142 # define __warndecl(name, msg) extern void name (void)
00143 # define __warnattr(msg)
00144 # define __errordecl(name, msg) extern void name (void)
00145 #endif
00146 
00147 /* Support for flexible arrays.  */
00148 #if __GNUC_PREREQ (2,97)
00149 /* GCC 2.97 supports C99 flexible array members.  */
00150 # define __flexarr   []
00151 #else
00152 # ifdef __GNUC__
00153 #  define __flexarr  [0]
00154 # else
00155 #  if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
00156 #   define __flexarr []
00157 #  else
00158 /* Some other non-C99 compiler.  Approximate with [1].  */
00159 #   define __flexarr [1]
00160 #  endif
00161 # endif
00162 #endif
00163 
00164 
00165 /* __asm__ ("xyz") is used throughout the headers to rename functions
00166    at the assembly language level.  This is wrapped by the __REDIRECT
00167    macro, in order to support compilers that can do this some other
00168    way.  When compilers don't support asm-names at all, we have to do
00169    preprocessor tricks instead (which don't have exactly the right
00170    semantics, but it's the best we can do).
00171 
00172    Example:
00173    int __REDIRECT(setpgrp, (__pid_t pid, __pid_t pgrp), setpgid); */
00174 
00175 #if defined __GNUC__ && __GNUC__ >= 2
00176 
00177 # define __REDIRECT(name, proto, alias) name proto __asm__ (__ASMNAME (#alias))
00178 # ifdef __cplusplus
00179 #  define __REDIRECT_NTH(name, proto, alias) \
00180      name proto __THROW __asm__ (__ASMNAME (#alias))
00181 # else
00182 #  define __REDIRECT_NTH(name, proto, alias) \
00183      name proto __asm__ (__ASMNAME (#alias)) __THROW
00184 # endif
00185 # define __ASMNAME(cname)  __ASMNAME2 (__USER_LABEL_PREFIX__, cname)
00186 # define __ASMNAME2(prefix, cname) __STRING (prefix) cname
00187 
00188 /*
00189 #elif __SOME_OTHER_COMPILER__
00190 
00191 # define __REDIRECT(name, proto, alias) name proto; \
00192        _Pragma("let " #name " = " #alias)
00193 */
00194 #endif
00195 
00196 /* GCC has various useful declarations that can be made with the
00197    `__attribute__' syntax.  All of the ways we use this do fine if
00198    they are omitted for compilers that don't understand it. */
00199 #if !defined __GNUC__ || __GNUC__ < 2
00200 # define __attribute__(xyz) /* Ignore */
00201 #endif
00202 
00203 /* At some point during the gcc 2.96 development the `malloc' attribute
00204    for functions was introduced.  We don't want to use it unconditionally
00205    (although this would be possible) since it generates warnings.  */
00206 #if __GNUC_PREREQ (2,96)
00207 # define __attribute_malloc__ __attribute__ ((__malloc__))
00208 #else
00209 # define __attribute_malloc__ /* Ignore */
00210 #endif
00211 
00212 /* At some point during the gcc 2.96 development the `pure' attribute
00213    for functions was introduced.  We don't want to use it unconditionally
00214    (although this would be possible) since it generates warnings.  */
00215 #if __GNUC_PREREQ (2,96)
00216 # define __attribute_pure__ __attribute__ ((__pure__))
00217 #else
00218 # define __attribute_pure__ /* Ignore */
00219 #endif
00220 
00221 /* At some point during the gcc 3.1 development the `used' attribute
00222    for functions was introduced.  We don't want to use it unconditionally
00223    (although this would be possible) since it generates warnings.  */
00224 #if __GNUC_PREREQ (3,1)
00225 # define __attribute_used__ __attribute__ ((__used__))
00226 # define __attribute_noinline__ __attribute__ ((__noinline__))
00227 #else
00228 # define __attribute_used__ __attribute__ ((__unused__))
00229 # define __attribute_noinline__ /* Ignore */
00230 #endif
00231 
00232 /* gcc allows marking deprecated functions.  */
00233 #if __GNUC_PREREQ (3,2)
00234 # define __attribute_deprecated__ __attribute__ ((__deprecated__))
00235 #else
00236 # define __attribute_deprecated__ /* Ignore */
00237 #endif
00238 
00239 /* At some point during the gcc 2.8 development the `format_arg' attribute
00240    for functions was introduced.  We don't want to use it unconditionally
00241    (although this would be possible) since it generates warnings.
00242    If several `format_arg' attributes are given for the same function, in
00243    gcc-3.0 and older, all but the last one are ignored.  In newer gccs,
00244    all designated arguments are considered.  */
00245 #if __GNUC_PREREQ (2,8)
00246 # define __attribute_format_arg__(x) __attribute__ ((__format_arg__ (x)))
00247 #else
00248 # define __attribute_format_arg__(x) /* Ignore */
00249 #endif
00250 
00251 /* At some point during the gcc 2.97 development the `strfmon' format
00252    attribute for functions was introduced.  We don't want to use it
00253    unconditionally (although this would be possible) since it
00254    generates warnings.  */
00255 #if __GNUC_PREREQ (2,97)
00256 # define __attribute_format_strfmon__(a,b) \
00257   __attribute__ ((__format__ (__strfmon__, a, b)))
00258 #else
00259 # define __attribute_format_strfmon__(a,b) /* Ignore */
00260 #endif
00261 
00262 /* The nonull function attribute allows to mark pointer parameters which
00263    must not be NULL.  */
00264 #if __GNUC_PREREQ (3,3)
00265 # define __nonnull(params) __attribute__ ((__nonnull__ params))
00266 #else
00267 # define __nonnull(params)
00268 #endif
00269 
00270 /* If fortification mode, we warn about unused results of certain
00271    function calls which can lead to problems.  */
00272 #if __GNUC_PREREQ (3,4)
00273 # define __attribute_warn_unused_result__ \
00274    __attribute__ ((__warn_unused_result__))
00275 # if __USE_FORTIFY_LEVEL > 0
00276 #  define __wur __attribute_warn_unused_result__
00277 # endif
00278 #else
00279 # define __attribute_warn_unused_result__ /* empty */
00280 #endif
00281 #ifndef __wur
00282 # define __wur /* Ignore */
00283 #endif
00284 
00285 /* Forces a function to be always inlined.  */
00286 #if __GNUC_PREREQ (3,2)
00287 # define __always_inline __inline __attribute__ ((__always_inline__))
00288 #else
00289 # define __always_inline __inline
00290 #endif
00291 
00292 /* GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99
00293    inline semantics, unless -fgnu89-inline is used.  */
00294 #if !defined __cplusplus || __GNUC_PREREQ (4,3)
00295 # if defined __GNUC_STDC_INLINE__ || defined __cplusplus
00296 #  define __extern_inline extern __inline __attribute__ ((__gnu_inline__))
00297 #  if __GNUC_PREREQ (4,3)
00298 #   define __extern_always_inline \
00299   extern __always_inline __attribute__ ((__gnu_inline__, __artificial__))
00300 #  else
00301 #   define __extern_always_inline \
00302   extern __always_inline __attribute__ ((__gnu_inline__))
00303 #  endif
00304 # else
00305 #  define __extern_inline extern __inline
00306 #  define __extern_always_inline extern __always_inline
00307 # endif
00308 #endif
00309 
00310 /* GCC 4.3 and above allow passing all anonymous arguments of an
00311    __extern_always_inline function to some other vararg function.  */
00312 #if __GNUC_PREREQ (4,3)
00313 # define __va_arg_pack() __builtin_va_arg_pack ()
00314 # define __va_arg_pack_len() __builtin_va_arg_pack_len ()
00315 #endif
00316 
00317 /* It is possible to compile containing GCC extensions even if GCC is
00318    run in pedantic mode if the uses are carefully marked using the
00319    `__extension__' keyword.  But this is not generally available before
00320    version 2.8.  */
00321 #if !__GNUC_PREREQ (2,8)
00322 # define __extension__             /* Ignore */
00323 #endif
00324 
00325 /* __restrict is known in EGCS 1.2 and above. */
00326 #if !__GNUC_PREREQ (2,92)
00327 # define __restrict  /* Ignore */
00328 #endif
00329 
00330 /* ISO C99 also allows to declare arrays as non-overlapping.  The syntax is
00331      array_name[restrict]
00332    GCC 3.1 supports this.  */
00333 #if __GNUC_PREREQ (3,1) && !defined __GNUG__
00334 # define __restrict_arr     __restrict
00335 #else
00336 # ifdef __GNUC__
00337 #  define __restrict_arr    /* Not supported in old GCC.  */
00338 # else
00339 #  if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
00340 #   define __restrict_arr   restrict
00341 #  else
00342 /* Some other non-C99 compiler.  */
00343 #   define __restrict_arr   /* Not supported.  */
00344 #  endif
00345 # endif
00346 #endif
00347 
00348 #include <bits/wordsize.h>
00349 
00350 #if defined __LONG_DOUBLE_MATH_OPTIONAL && defined __NO_LONG_DOUBLE_MATH
00351 # define __LDBL_COMPAT 1
00352 # ifdef __REDIRECT
00353 #  define __LDBL_REDIR1(name, proto, alias) __REDIRECT (name, proto, alias)
00354 #  define __LDBL_REDIR(name, proto) \
00355   __LDBL_REDIR1 (name, proto, __nldbl_##name)
00356 #  define __LDBL_REDIR1_NTH(name, proto, alias) __REDIRECT_NTH (name, proto, alias)
00357 #  define __LDBL_REDIR_NTH(name, proto) \
00358   __LDBL_REDIR1_NTH (name, proto, __nldbl_##name)
00359 #  define __LDBL_REDIR1_DECL(name, alias) \
00360   extern __typeof (name) name __asm (__ASMNAME (#alias));
00361 #  define __LDBL_REDIR_DECL(name) \
00362   extern __typeof (name) name __asm (__ASMNAME ("__nldbl_" #name));
00363 #  define __REDIRECT_LDBL(name, proto, alias) \
00364   __LDBL_REDIR1 (name, proto, __nldbl_##alias)
00365 #  define __REDIRECT_NTH_LDBL(name, proto, alias) \
00366   __LDBL_REDIR1_NTH (name, proto, __nldbl_##alias)
00367 # endif
00368 #endif
00369 #if !defined __LDBL_COMPAT || !defined __REDIRECT
00370 # define __LDBL_REDIR1(name, proto, alias) name proto
00371 # define __LDBL_REDIR(name, proto) name proto
00372 # define __LDBL_REDIR1_NTH(name, proto, alias) name proto __THROW
00373 # define __LDBL_REDIR_NTH(name, proto) name proto __THROW
00374 # define __LDBL_REDIR_DECL(name)
00375 # ifdef __REDIRECT
00376 #  define __REDIRECT_LDBL(name, proto, alias) __REDIRECT (name, proto, alias)
00377 #  define __REDIRECT_NTH_LDBL(name, proto, alias) \
00378   __REDIRECT_NTH (name, proto, alias)
00379 # endif
00380 #endif
00381 
00382 #endif  /* sys/cdefs.h */