home *** CD-ROM | disk | FTP | other *** search
/ RISCWORLD 7 / RISCWORLD_VOL7.iso / Software / Issue2 / SDL.ARC / !unixlib / source / clib / sys / h / cdefs < prev    next >
Encoding:
Text File  |  2004-09-05  |  9.7 KB  |  300 lines

  1. /****************************************************************************
  2.  *
  3.  * $Source: /usr/local/cvsroot/gccsdk/unixlib/source/clib/sys/cdefs.h,v $
  4.  * $Date: 2004/03/17 20:00:50 $
  5.  * $Revision: 1.5 $
  6.  * $State: Exp $
  7.  * $Author: joty $
  8.  *
  9.  ***************************************************************************/
  10.  
  11. /*
  12.  * File taken from glibc 2.2.5.
  13.  * Following changes were made:
  14.  *  - Changed _FEATURES_H & #include <features.h> into __UNIXLIB_FEATURES_H
  15.  *    & #include <unixlib/features.h>
  16.  *  - Changed test "__GNUC__ >= (or <) 2" into __GNUC_PREREQ() construction
  17.  *    in order to avoid Norcroft C compiler warnings
  18.  *  - Added weak_(const)_function, internal_function definitions from
  19.  *    include/libc-symbols.h
  20.  */
  21.  
  22. /* Copyright (C) 1992,93,94,95,96,97,98,99,2000,2001 Free Software Foundation, Inc.
  23.    This file is part of the GNU C Library.
  24.  
  25.    The GNU C Library is free software; you can redistribute it and/or
  26.    modify it under the terms of the GNU Lesser General Public
  27.    License as published by the Free Software Foundation; either
  28.    version 2.1 of the License, or (at your option) any later version.
  29.  
  30.    The GNU C Library is distributed in the hope that it will be useful,
  31.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  32.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  33.    Lesser General Public License for more details.
  34.  
  35.    You should have received a copy of the GNU Lesser General Public
  36.    License along with the GNU C Library; if not, write to the Free
  37.    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  38.    02111-1307 USA.  */
  39.  
  40. #ifndef    _SYS_CDEFS_H
  41. #define    _SYS_CDEFS_H    1
  42.  
  43. /* We are almost always included from features.h. */
  44. #ifndef __UNIXLIB_FEATURES_H
  45. # include <unixlib/features.h>
  46. #endif
  47.  
  48. /* The GNU libc does not support any K&R compilers or the traditional mode
  49.    of ISO C compilers anymore.  Check for some of the combinations not
  50.    anymore supported.  */
  51. #if defined __GNUC__ && !defined __STDC__
  52. # error "You need a ISO C conforming compiler to use the glibc headers"
  53. #endif
  54.  
  55. /* Some user header file might have defined this before.  */
  56. #undef    __P
  57. #undef    __PMT
  58.  
  59. #ifdef __GNUC__
  60.  
  61. /* GCC can always grok prototypes.  For C++ programs we add throw()
  62.    to help it optimize the function calls.  But this works only with
  63.    gcc 2.8.x and egcs.  */
  64. # if defined __cplusplus && __GNUC_PREREQ (2,8)
  65. #  define __THROW    throw ()
  66. # else
  67. #  define __THROW
  68. # endif
  69. # define __P(args)    args __THROW
  70. /* This macro will be used for functions which might take C++ callback
  71.    functions.  */
  72. # define __PMT(args)    args
  73.  
  74. #else    /* Not GCC.  */
  75.  
  76. # define __inline        /* No inline functions.  */
  77.  
  78. # define __THROW
  79. # define __P(args)    args
  80. # define __PMT(args)    args
  81.  
  82. # define __const    const
  83. # define __signed    signed
  84. # define __volatile    volatile
  85.  
  86. #endif    /* GCC.  */
  87.  
  88. /* For these things, GCC behaves the ANSI way normally,
  89.    and the non-ANSI way under -traditional.  */
  90.  
  91. #define __CONCAT(x,y)    x ## y
  92. #define __STRING(x)    #x
  93.  
  94. /* This is not a typedef so `const __ptr_t' does the right thing.  */
  95. #define __ptr_t void *
  96. #define __long_double_t  long double
  97.  
  98.  
  99. /* C++ needs to know that types and declarations are C, not C++.  */
  100. #ifdef    __cplusplus
  101. # define __BEGIN_DECLS    extern "C" {
  102. # define __END_DECLS    }
  103. #else
  104. # define __BEGIN_DECLS
  105. # define __END_DECLS
  106. #endif
  107.  
  108.  
  109. /* The standard library needs the functions from the ISO C90 standard
  110.    in the std namespace.  At the same time we want to be safe for
  111.    future changes and we include the ISO C99 code in the non-standard
  112.    namespace __c99.  The C++ wrapper header take case of adding the
  113.    definitions to the global namespace.  */
  114. #if defined __cplusplus && defined _GLIBCPP_USE_NAMESPACES
  115. # define __BEGIN_NAMESPACE_STD    namespace std {
  116. # define __END_NAMESPACE_STD    }
  117. # define __USING_NAMESPACE_STD(name) using std::name;
  118. # define __BEGIN_NAMESPACE_C99    namespace __c99 {
  119. # define __END_NAMESPACE_C99    }
  120. # define __USING_NAMESPACE_C99(name) using __c99::name;
  121. #else
  122. /* For compatibility we do not add the declarations into any
  123.    namespace.  They will end up in the global namespace which is what
  124.    old code expects.  */
  125. # define __BEGIN_NAMESPACE_STD
  126. # define __END_NAMESPACE_STD
  127. # define __USING_NAMESPACE_STD(name)
  128. # define __BEGIN_NAMESPACE_C99
  129. # define __END_NAMESPACE_C99
  130. # define __USING_NAMESPACE_C99(name)
  131. #endif
  132.  
  133.  
  134. /* Support for bounded pointers.  */
  135. #ifndef __BOUNDED_POINTERS__
  136. # define __bounded    /* nothing */
  137. # define __unbounded    /* nothing */
  138. # define __ptrvalue    /* nothing */
  139. #endif
  140.  
  141.  
  142. /* Support for flexible arrays.  */
  143. #if __GNUC_PREREQ (2,97)
  144. /* GCC 2.97 supports C99 flexible array members.  */
  145. # define __flexarr    []
  146. #else
  147. # ifdef __GNUC__
  148. #  define __flexarr    [0]
  149. # else
  150. #  if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
  151. #   define __flexarr    []
  152. #  else
  153. /* Some other non-C99 compiler.  Approximate with [1].  */
  154. #   define __flexarr    [1]
  155. #  endif
  156. # endif
  157. #endif
  158.  
  159.  
  160. /* __asm__ ("xyz") is used throughout the headers to rename functions
  161.    at the assembly language level.  This is wrapped by the __REDIRECT
  162.    macro, in order to support compilers that can do this some other
  163.    way.  When compilers don't support asm-names at all, we have to do
  164.    preprocessor tricks instead (which don't have exactly the right
  165.    semantics, but it's the best we can do).
  166.  
  167.    Example:
  168.    int __REDIRECT(setpgrp, (__pid_t pid, __pid_t pgrp), setpgid); */
  169.  
  170. #if defined __GNUC__ && __GNUC_PREREQ(2,0)
  171.  
  172. # define __REDIRECT(name, proto, alias) name proto __asm__ (__ASMNAME (#alias))
  173. # define __ASMNAME(cname)  __ASMNAME2 (__USER_LABEL_PREFIX__, cname)
  174. # define __ASMNAME2(prefix, cname) __STRING (prefix) cname
  175.  
  176. /*
  177. #elif __SOME_OTHER_COMPILER__
  178.  
  179. # define __REDIRECT(name, proto, alias) name proto; \
  180.     _Pragma("let " #name " = " #alias)
  181. */
  182. #endif
  183.  
  184. /* GCC has various useful declarations that can be made with the
  185.    `__attribute__' syntax.  All of the ways we use this do fine if
  186.    they are omitted for compilers that don't understand it. */
  187. #if !defined __GNUC__
  188. # define __attribute__(xyz)    /* Ignore */
  189. #elif __GNUC__ < 2
  190. # define __attribute__(xyz)    /* Ignore */
  191. #endif
  192.  
  193. /* At some point during the gcc 2.96 development the `malloc' attribute
  194.    for functions was introduced.  We don't want to use it unconditionally
  195.    (although this would be possible) since it generates warnings.  */
  196. #if __GNUC_PREREQ (2,96)
  197. # define __attribute_malloc__ __attribute__ ((__malloc__))
  198. #else
  199. # define __attribute_malloc__ /* Ignore */
  200. #endif
  201.  
  202. /* At some point during the gcc 2.96 development the `pure' attribute
  203.    for functions was introduced.  We don't want to use it unconditionally
  204.    (although this would be possible) since it generates warnings.  */
  205. #if __GNUC_PREREQ (2,96)
  206. # define __attribute_pure__ __attribute__ ((__pure__))
  207. #else
  208. # define __attribute_pure__ /* Ignore */
  209. #endif
  210.  
  211. /* At some point during the gcc 3.1 development the `used' attribute
  212.    for functions was introduced.  We don't want to use it unconditionally
  213.    (although this would be possible) since it generates warnings.  */
  214. #if __GNUC_PREREQ (3,1)
  215. # define __attribute_used__ __attribute__ ((__used__))
  216. # define __attribute_noinline__ __attribute__ ((__noinline__))
  217. #else
  218. # define __attribute_used__ __attribute__ ((__unused__))
  219. # define __attribute_noinline__ /* Ignore */
  220. #endif
  221.  
  222. /* gcc allows marking deprecated functions.  */
  223. #if __GNUC_PREREQ (3,2)
  224. # define __attribute_deprecated__ __attribute__ ((__deprecated__))
  225. #else
  226. # define __attribute_deprecated__ /* Ignore */
  227. #endif
  228.  
  229. /* At some point during the gcc 2.8 development the `format_arg' attribute
  230.    for functions was introduced.  We don't want to use it unconditionally
  231.    (although this would be possible) since it generates warnings.
  232.    If several `format_arg' attributes are given for the same function, in
  233.    gcc-3.0 and older, all but the last one are ignored.  In newer gccs,
  234.    all designated arguments are considered.  */
  235. #if __GNUC_PREREQ (2,8)
  236. # define __attribute_format_arg__(x) __attribute__ ((__format_arg__ (x)))
  237. #else
  238. # define __attribute_format_arg__(x) /* Ignore */
  239. #endif
  240.  
  241. /* At some point during the gcc 2.97 development the `strfmon' format
  242.    attribute for functions was introduced.  We don't want to use it
  243.    unconditionally (although this would be possible) since it
  244.    generates warnings.  */
  245. #if __GNUC_PREREQ (2,97)
  246. # define __attribute_format_strfmon__(a,b) \
  247.   __attribute__ ((__format__ (__strfmon__, a, b)))
  248. #else
  249. # define __attribute_format_strfmon__(a,b) /* Ignore */
  250. #endif
  251.  
  252. /* It is possible to compile containing GCC extensions even if GCC is
  253.    run in pedantic mode if the uses are carefully marked using the
  254.    `__extension__' keyword.  But this is not generally available before
  255.    version 2.8.  */
  256. #if !__GNUC_PREREQ (2,8)
  257. # define __extension__        /* Ignore */
  258. #endif
  259.  
  260. /* __restrict is known in EGCS 1.2 and above. */
  261. #if !__GNUC_PREREQ (2,92)
  262. # define __restrict    /* Ignore */
  263. #endif
  264.  
  265. /* ISO C99 also allows to declare arrays as non-overlapping.  The syntax is
  266.      array_name[restrict]
  267.    GCC 3.1 supports this.  */
  268. #if __GNUC_PREREQ (3,1) && !defined __GNUG__
  269. # define __restrict_arr    __restrict
  270. #else
  271. # ifdef __GNUC__
  272. #  define __restrict_arr    /* Not supported in old GCC.  */
  273. # else
  274. #  if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
  275. #   define __restrict_arr    restrict
  276. #  else
  277. /* Some other non-C99 compiler.  */
  278. #   define __restrict_arr    /* Not supported.  */
  279. #  endif
  280. # endif
  281. #endif
  282.  
  283. #ifdef __UNIXLIB_INTERNALS
  284. /* This comes between the return type and function name in
  285.    a function definition to make that definition weak.  */
  286. # define weak_function __attribute__ ((weak))
  287. # define weak_const_function __attribute__ ((weak, __const__))
  288.  
  289. /* On some platforms we can make internal function calls (i.e., calls of
  290.    functions not exported) a bit faster by using a different calling
  291.    convention.  */
  292. #ifndef internal_function
  293. # define internal_function    /* empty */
  294. #endif
  295.  
  296. #endif
  297.  
  298.  
  299. #endif     /* sys/cdefs.h */
  300.