home *** CD-ROM | disk | FTP | other *** search
/ RISCWORLD 7 / RISCWORLD_VOL7.iso / Software / Issue4 / SDL / gcc346 / !gcc / include / unixlib / sys / h / cdefs < prev    next >
Encoding:
Text File  |  2006-09-17  |  11.5 KB  |  352 lines

  1. /* Generic system definitions to improve compiler/source compatibility.  */
  2.  
  3. /* Copyright (C) 1992,93,94,95,96,97,98,99,
  4.    2000,2001 Free Software Foundation, Inc.
  5.    This file is part of the GNU C Library.
  6.  
  7.    The GNU C Library is free software; you can redistribute it and/or
  8.    modify it under the terms of the GNU Lesser General Public
  9.    License as published by the Free Software Foundation; either
  10.    version 2.1 of the License, or (at your option) any later version.
  11.  
  12.    The GNU C Library is distributed in the hope that it will be useful,
  13.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  15.    Lesser General Public License for more details.
  16.  
  17.    You should have received a copy of the GNU Lesser General Public
  18.    License along with the GNU C Library; if not, write to the Free
  19.    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  20.    02111-1307 USA.  */
  21.  
  22. #ifndef    __SYS_CDEFS_H
  23. #define    __SYS_CDEFS_H    1
  24.  
  25. /* We are almost always included from features.h. */
  26. #ifndef __UNIXLIB_FEATURES_H
  27. # include <features.h>
  28. #endif
  29.  
  30. #ifdef __GNUC__
  31.  
  32. /* GCC can always grok prototypes.  For C++ programs we add throw()
  33.    to help it optimize the function calls.  But this works only with
  34.    gcc 2.8.x and egcs.  For gcc 3.2 and up we even mark C functions
  35.    as non-throwing using a function attribute since programs can use
  36.    the -fexceptions options for C code as well.
  37.  
  38.    If compiling UnixLib with a C++ compiler, we disable the option
  39.    as it breaks compatibility between function prototype and definition.
  40.    UnixLib generally isn't compiled with a C++ compiler but the additional
  41.    type checking can be useful in finding small errors.  */
  42. # if !defined __cplusplus && __GNUC_PREREQ (3, 3)
  43. #  define __THROW       __attribute__ ((__nothrow__))
  44. #  define __NTH(fct)    __attribute__ ((__nothrow__)) fct
  45. # else
  46. #  if defined __cplusplus && ! defined (__UNIXLIB_INTERNALS)
  47. #   define __THROW      throw ()
  48. #   define __NTH(fct)   fct throw ()
  49. #  else
  50. #   define __THROW
  51. #   define __NTH(fct)   fct
  52. #  endif
  53. # endif
  54.  
  55. #elif defined(__CC_NORCROFT)
  56. /* The Norcroft compiler supports the __inline keyword.  Allow it
  57.    to support the GCC variant.  */
  58. # define __inline__ __inline
  59.  
  60. # define __const const
  61. # define __signed signed
  62. # define __volatile volatile
  63. # define __THROW
  64. # define __NTH(fct) fct
  65.  
  66. # define __UNIXLIB_NO_COMPLEX 1
  67.  
  68. #elif defined(__LCC__)
  69. # define __inline__        /* No inline functions.  */
  70. # define __inline               /* No inline functions.  */
  71. # define __THROW
  72. # define __NTH(fct)    fct
  73. # define __const        const
  74. # define __signed       signed
  75. # define __volatile     volatile
  76. # define __UNIXLIB_NO_COMPLEX 1
  77.  
  78. #else /* Unknown compiler.  */
  79. #error "Unrecognised/unsupported system compiler."
  80. #endif
  81.  
  82. /* Some user header file might have defined this before.  */
  83. #undef    __P
  84. #undef    __PMT
  85. #define __P(args)      args
  86. #define __PMT(args)    args
  87.  
  88. /* For these things, GCC behaves the ANSI way normally,
  89.    and the non-ANSI way under -traditional.  */
  90. #define __CONCAT(x,y)    x ## y
  91. #define __STRING(x)    #x
  92.  
  93. /* This is not a typedef so `const __ptr_t' does the right thing.  */
  94. #define __ptr_t void *
  95. #define __long_double_t  long double
  96.  
  97.  
  98. /* C++ needs to know that types and declarations are C, not C++.  */
  99. #ifdef    __cplusplus
  100. # define __BEGIN_DECLS    extern "C" {
  101. # define __END_DECLS    }
  102. #else
  103. # define __BEGIN_DECLS
  104. # define __END_DECLS
  105. #endif
  106.  
  107.  
  108. /* The standard library needs the functions from the ISO C90 standard
  109.    in the std namespace.  At the same time we want to be safe for
  110.    future changes and we include the ISO C99 code in the non-standard
  111.    namespace __c99.  The C++ wrapper header take case of adding the
  112.    definitions to the global namespace.  */
  113. #if defined __cplusplus && defined _GLIBCPP_USE_NAMESPACES
  114. # define __BEGIN_NAMESPACE_STD    namespace std {
  115. # define __END_NAMESPACE_STD    }
  116. # define __USING_NAMESPACE_STD(name) using std::name;
  117. # define __BEGIN_NAMESPACE_C99    namespace __c99 {
  118. # define __END_NAMESPACE_C99    }
  119. # define __USING_NAMESPACE_C99(name) using __c99::name;
  120. #else
  121. /* For compatibility we do not add the declarations into any
  122.    namespace.  They will end up in the global namespace which is what
  123.    old code expects.  */
  124. # define __BEGIN_NAMESPACE_STD
  125. # define __END_NAMESPACE_STD
  126. # define __USING_NAMESPACE_STD(name)
  127. # define __BEGIN_NAMESPACE_C99
  128. # define __END_NAMESPACE_C99
  129. # define __USING_NAMESPACE_C99(name)
  130. #endif
  131.  
  132.  
  133. /* Support for bounded pointers.  */
  134. #ifndef __BOUNDED_POINTERS__
  135. # define __bounded    /* nothing */
  136. # define __unbounded    /* nothing */
  137. # define __ptrvalue    /* nothing */
  138. #endif
  139.  
  140.  
  141. /* Support for flexible arrays.  */
  142. #if __GNUC__
  143. # define __flexarr    []
  144. #else /* ! __GNUC__ */
  145. # if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
  146. #  define __flexarr    []
  147. # else
  148. /* Some other non-C99 compiler.  Approximate with [1].  */
  149. #  define __flexarr    [1]
  150. # endif
  151. #endif /* __GNUC__ */
  152.  
  153. /* GCC has various useful declarations that can be made with the
  154.    `__attribute__' syntax.  All of the ways we use this do fine if
  155.    they are omitted for compilers that don't understand it. */
  156. #ifndef __GNUC__
  157. #define __attribute__(xyz)    /* Ignore */
  158. #endif
  159.  
  160. /* At some point during the gcc 2.96 development the `malloc' attribute
  161.    for functions was introduced.  We don't want to use it unconditionally
  162.    (although this would be possible) since it generates warnings.  */
  163. #if __GNUC_PREREQ (2,96)
  164. # define __attribute_malloc__ __attribute__ ((__malloc__))
  165. #else
  166. # define __attribute_malloc__ /* Ignore */
  167. #endif
  168.  
  169. /* At some point during the gcc 2.96 development the `pure' attribute
  170.    for functions was introduced.  We don't want to use it unconditionally
  171.    (although this would be possible) since it generates warnings.  */
  172. #if __GNUC_PREREQ (2,96)
  173. # define __attribute_pure__ __attribute__ ((__pure__))
  174. #else
  175. # define __attribute_pure__ /* Ignore */
  176. #endif
  177.  
  178. /* At some point during the gcc 3.1 development the `used' attribute
  179.    for functions was introduced.  We don't want to use it unconditionally
  180.    (although this would be possible) since it generates warnings.  */
  181. #if __GNUC_PREREQ (3,1)
  182. # define __attribute_used__ __attribute__ ((__used__))
  183. # define __attribute_noinline__ __attribute__ ((__noinline__))
  184. #else
  185. # define __attribute_used__ __attribute__ ((__unused__))
  186. # define __attribute_noinline__ /* Ignore */
  187. #endif
  188.  
  189. /* gcc allows marking deprecated functions.  */
  190. #if __GNUC_PREREQ (3,2)
  191. # define __attribute_deprecated__ __attribute__ ((__deprecated__))
  192. #else
  193. # define __attribute_deprecated__ /* Ignore */
  194. #endif
  195.  
  196. /* At some point during the gcc 2.8 development the `format_arg' attribute
  197.    for functions was introduced.  We don't want to use it unconditionally
  198.    (although this would be possible) since it generates warnings.
  199.    If several `format_arg' attributes are given for the same function, in
  200.    gcc-3.0 and older, all but the last one are ignored.  In newer gccs,
  201.    all designated arguments are considered.  */
  202. #if __GNUC_PREREQ (2,8)
  203. # define __attribute_format_arg__(x) __attribute__ ((__format_arg__ (x)))
  204. #else
  205. # define __attribute_format_arg__(x) /* Ignore */
  206. #endif
  207.  
  208. /* At some point during the gcc 2.97 development the `strfmon' format
  209.    attribute for functions was introduced.  We don't want to use it
  210.    unconditionally (although this would be possible) since it
  211.    generates warnings.  */
  212. #if __GNUC_PREREQ (2,97)
  213. # define __attribute_format_strfmon__(a,b) \
  214.   __attribute__ ((__format__ (__strfmon__, a, b)))
  215. #else
  216. # define __attribute_format_strfmon__(a,b) /* Ignore */
  217. #endif
  218.  
  219. /* The nonull function attribute allows to mark pointer parameters which
  220.    must not be NULL.  */
  221. #if __GNUC_PREREQ (3,3)
  222. # define __nonnull(params) __attribute__ ((__nonnull__ params))
  223. #else
  224. # define __nonnull(params)
  225. #endif
  226.  
  227. /* If fortification mode, we warn about unused results of certain
  228.    function calls which can lead to problems.  */
  229. #if __GNUC_PREREQ (3,4)
  230. # define __attribute_warn_unused_result__ \
  231.    __attribute__ ((__warn_unused_result__))
  232. # define __wur __attribute_warn_unused_result__
  233. #else
  234. # define __attribute_warn_unused_result__ /* empty */
  235. #endif
  236. #ifndef __wur
  237. # define __wur /* Ignore */
  238. #endif
  239.  
  240.  
  241. /* It is possible to compile containing GCC extensions even if GCC is
  242.    run in pedantic mode if the uses are carefully marked using the
  243.    `__extension__' keyword.  But this is not generally available before
  244.    version 2.8.  */
  245. #if !__GNUC_PREREQ (2,8)
  246. # define __extension__        /* Ignore */
  247. #endif
  248.  
  249. /* __restrict is known in EGCS 1.2 and above. */
  250. #if !__GNUC_PREREQ (2,92)
  251. # define __restrict    /* Ignore */
  252. #endif
  253.  
  254. /* ISO C99 also allows to declare arrays as non-overlapping.  The syntax is
  255.      array_name[restrict]
  256.    GCC 3.1 supports this.  */
  257. #if __GNUC_PREREQ (3,1) && !defined __GNUG__
  258. # define __restrict_arr    __restrict
  259. #else
  260. # ifdef __GNUC__
  261. #  define __restrict_arr    /* Not supported in old GCC.  */
  262. # else
  263. #  if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
  264. #   define __restrict_arr    restrict
  265. #  else
  266. /* Some other non-C99 compiler.  */
  267. #   define __restrict_arr    /* Not supported.  */
  268. #  endif
  269. # endif
  270. #endif
  271.  
  272. #ifdef __UNIXLIB_INTERNALS
  273.  
  274. #if defined (__CC_NORCROFT) || defined (__LCC__)
  275. /* The Norcroft and LCC compilers do not have support for any of these
  276.    symbol modifiers.  To retain source code compatibility, we just
  277.    define them to evaluate to nothing.  */
  278.  
  279. #define strong_alias(name, aliasname) /**/
  280. #define _strong_alias(name, aliasname) /**/
  281. #define weak_function /**/
  282. #define weak_const_function /**/
  283. #define weak_alias(name, aliasname) /**/
  284. #define _weak_alias(name, aliasname) /**/
  285. #define hidden_def(name) /**/
  286. #define libm_hidden_def(name) /**/
  287. #define INTDEF(name) /**/
  288.  
  289. #endif /* __CC_NORCROFT || __LCC__ */
  290.  
  291. #ifdef __GNUC__
  292. /* The GCC compiler for RISC OS comes in two variants, an AOF compiler
  293.    and an ELF compiler.  */
  294.  
  295. /* Both AOF and ELF variants support the aliasing of symbols.  */
  296. #define strong_alias(name, aliasname) _strong_alias(name, aliasname)
  297. #define _strong_alias(name, aliasname) \
  298.   extern __typeof (name) aliasname __attribute__ ((alias (#name)));
  299.  
  300. #ifdef __ELF__
  301. /* The GCC/ELF compiler has support for everything.  */
  302.  
  303. /* This comes between the return type and function name in
  304.    a function definition to make that definition weak.  */
  305. # define weak_function __attribute__ ((weak))
  306. # define weak_const_function __attribute__ ((weak, __const__))
  307.  
  308. #define weak_alias(name, aliasname) _weak_alias(name, aliasname)
  309. #define _weak_alias(name, aliasname) \
  310.   extern __typeof (name) aliasname __attribute__ ((weak, alias (#name)));
  311.  
  312. /* For the future, we may want to support ELF symbol visibility which will
  313.    help to reduce the symbol tables of dynamic libraries and speed up
  314.    dynamic linking.  */
  315. #define hidden_def(name) /**/
  316. #define libm_hidden_def(name) /**/
  317. #define INTDEF(name) /**/
  318.  
  319. #else /* ! __ELF__ */
  320.  
  321. /* The GCC/AOF compiler does have a concept of weak symbols, but their
  322.    application is a little more restricted and harder to work with
  323.    naturally in the compiler.  We therefore only support weak symbols
  324.    in hand-crafted assembler.  */
  325.  
  326. # define weak_function /**/
  327. # define weak_const_function /**/
  328.  
  329. /* This is more of a compatibility feature for AOF/GCC so that we can build
  330.    the same source files as ELF/GCC.  */
  331. #define weak_alias(name, aliasname) strong_alias(name, aliasname)
  332.  
  333. #define hidden_def(name) /**/
  334. #define libm_hidden_def(name) /**/
  335. #define INTDEF(name) /**/
  336.  
  337. #endif /* ! __ELF__ */
  338.  
  339. #endif /* __GNUC__ */
  340.  
  341. /* On some platforms we can make internal function calls (i.e., calls of
  342.    functions not exported) a bit faster by using a different calling
  343.    convention.  */
  344. #ifndef internal_function
  345. # define internal_function    /* empty */
  346. #endif
  347.  
  348. #endif /* __UNIXLIB_INTERNALS */
  349.  
  350.  
  351. #endif     /* sys/cdefs.h */
  352.