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

  1. /* UnixLib declaration of its features.
  2.    Copyright (c) 2004, 2005, 2006 UnixLib Developers.  */
  3.  
  4. /* This file is derived from GNU Libc 2.2.4, features.h  We are attempting
  5.    to closely match the macros defined within it in order to maintain
  6.    a decent level of compatibility.  A desire to do this forces me to
  7.    include the following license:
  8.  
  9.    Copyright (C) 1992,93,94,95,96,97,98,99, 2000 Free Software Foundation, Inc.
  10.    This file is part of the GNU C Library.
  11.  
  12.    The GNU C Library is free software; you can redistribute it and/or
  13.    modify it under the terms of the GNU Library General Public License as
  14.    published by the Free Software Foundation; either version 2 of the
  15.    License, or (at your option) any later version.
  16.  
  17.    The GNU C Library is distributed in the hope that it will be useful,
  18.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  19.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  20.    Library General Public License for more details.
  21.  
  22.    You should have received a copy of the GNU Library General Public
  23.    License along with the GNU C Library; see the file COPYING.LIB.  If not,
  24.    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  25.    Boston, MA 02111-1307, USA.  */
  26.  
  27. #ifndef __UNIXLIB_FEATURES_H
  28. #define __UNIXLIB_FEATURES_H 1
  29.  
  30.  
  31. /* These are defined by the user (or the compiler)
  32.    to specify the desired environment:
  33.  
  34.    __STRICT_ANSI__      ISO Standard C.
  35.    _ISOC99_SOURCE       Extensions to ISO C89 from ISO C99.
  36.    _POSIX_SOURCE        IEEE Std 1003.1.
  37.    _POSIX_C_SOURCE      If ==1, like _POSIX_SOURCE; if >=2 add IEEE Std 1003.2;
  38.                         if >=199309L, add IEEE Std 1003.1b-1993;
  39.                         if >=199506L, add IEEE Std 1003.1c-1995
  40.    _XOPEN_SOURCE        Includes POSIX and XPG things.  Set to 500 if
  41.                         Single Unix conformance is wanted, to 600 for the
  42.                         upcoming sixth revision.
  43.    _XOPEN_SOURCE_EXTENDED XPG things and X/Open Unix extensions.
  44.    _LARGEFILE_SOURCE    Some more functions for correct standard I/O.
  45.    _LARGEFILE64_SOURCE  Additional functionality from LFS for large files.
  46.    _FILE_OFFSET_BITS=N  Select default filesystem interface.
  47.    _BSD_SOURCE          ISO C, POSIX, and 4.3BSD things.
  48.    _SVID_SOURCE         ISO C, POSIX, and SVID things.
  49.    _GNU_SOURCE          All of the above, plus GNU extensions.
  50.    _REENTRANT           Select additionally reentrant object.
  51.    _THREAD_SAFE         Same as _REENTRANT, often used by other systems.
  52.  
  53.    The `-ansi' switch to the GNU C compiler defines __STRICT_ANSI__.
  54.    If none of these are defined, the default is to have _SVID_SOURCE,
  55.    _BSD_SOURCE, and _POSIX_SOURCE set to one and _POSIX_C_SOURCE set to
  56.    199506L.  If more than one of these are defined, they accumulate.
  57.    For example __STRICT_ANSI__, _POSIX_SOURCE and _POSIX_C_SOURCE
  58.    together give you ISO C, 1003.1, and 1003.2, but nothing else.
  59.  
  60.    These are defined by this file and are used by the
  61.    header files to decide what to declare or define:
  62.  
  63.    __USE_ISOC99         Define ISO C99 things.
  64.    __USE_POSIX          Define IEEE Std 1003.1 things.
  65.    __USE_POSIX2         Define IEEE Std 1003.2 things.
  66.    __USE_POSIX199309    Define IEEE Std 1003.1, and .1b things.
  67.    __USE_POSIX199506    Define IEEE Std 1003.1, .1b, .1c and .1i things.
  68.    __USE_XOPEN          Define XPG things.
  69.    __USE_XOPEN_EXTENDED Define X/Open Unix things.
  70.    __USE_UNIX98         Define Single Unix V2 things.
  71.    __USE_XOPEN2K        Define XPG6 things.
  72.    __USE_LARGEFILE      Define correct standard I/O things.
  73.    __USE_LARGEFILE64    Define LFS things with separate names.
  74.    __USE_FILE_OFFSET64  Define 64bit interface as default.
  75.    __USE_BSD            Define 4.3BSD things.
  76.    __USE_SVID           Define SVID things.
  77.    __USE_MISC           Define things common to BSD and System V Unix.
  78.    __USE_GNU            Define GNU extensions.
  79.    __USE_REENTRANT      Define reentrant/thread-safe *_r functions.
  80.    __FAVOR_BSD          Favor 4.3BSD things in cases of conflict.
  81.  
  82.    The macros `__GNU_LIBRARY__', `__GLIBC__', and `__GLIBC_MINOR__' are
  83.    defined by this file unconditionally.  `__GNU_LIBRARY__' is provided
  84.    only for compatibility.  All new code should use the other symbols
  85.    to test for features.
  86.  
  87.    All macros listed above as possibly being defined by this file are
  88.    explicitly undefined if they are not explicitly defined.
  89.    Feature-test macros that are not defined by the user or compiler
  90.    but are implied by the other feature-test macros defined (or by the
  91.    lack of any definitions) are defined by the file.  */
  92.  
  93.  
  94. /* Undefine everything, so we get a clean slate.  */
  95. #undef  __USE_ISOC99
  96. #undef  __USE_POSIX
  97. #undef  __USE_POSIX2
  98. #undef  __USE_POSIX199309
  99. #undef  __USE_POSIX199506
  100. #undef  __USE_XOPEN
  101. #undef  __USE_XOPEN_EXTENDED
  102. #undef  __USE_UNIX98
  103. #undef  __USE_XOPEN2K
  104. #undef  __USE_LARGEFILE
  105. #undef  __USE_LARGEFILE64
  106. #undef  __USE_FILE_OFFSET64
  107. #undef  __USE_BSD
  108. #undef  __USE_SVID
  109. #undef  __USE_MISC
  110. #undef  __USE_GNU
  111. #undef  __USE_REENTRANT
  112. #undef  __FAVOR_BSD
  113. #undef  __KERNEL_STRICT_NAMES
  114.  
  115. /* This will reduce the number of Norcroft compiler warnings "Undefined macro
  116.    'xxx' in #if - treated as 0".  */
  117. #ifdef __CC_NORCROFT
  118. # ifndef __STDC_VERSION__
  119. #  define __STDC_VERSION__       199409L
  120. # endif
  121. # ifndef _ISOC99_SOURCE
  122. #  define _ISOC99_SOURCE         1
  123. # endif
  124. # ifndef _POSIX_SOURCE
  125. #  define _POSIX_SOURCE          1
  126. # endif
  127. # ifndef _POSIX_C_SOURCE
  128. #  define _POSIX_C_SOURCE        199506L
  129. # endif
  130. # ifndef _XOPEN_SOURCE
  131. #  define _XOPEN_SOURCE          500
  132. # endif
  133. # ifndef _XOPEN_SOURCE_EXTENDED
  134. #  define _XOPEN_SOURCE_EXTENDED 1
  135. # endif
  136. # ifndef _LARGEFILE64_SOURCE
  137. #  define _LARGEFILE64_SOURCE    1
  138. # endif
  139. # ifndef _BSD_SOURCE
  140. #  define _BSD_SOURCE            1
  141. # endif
  142. # ifndef _SVID_SOURCE
  143. #  define _SVID_SOURCE           1
  144. # endif
  145. # ifndef _FILE_OFFSET_BITS
  146. #  define _FILE_OFFSET_BITS      32
  147. # endif
  148. #endif
  149.  
  150. #ifdef __UNIXLIB_INTERNALS
  151. # define __GNU_LIBRARY__
  152. #endif
  153.  
  154. /* Always use ISO C things.  */
  155. #define    __USE_ANSI    1
  156.  
  157.  
  158. /* If _BSD_SOURCE was defined by the user, favor BSD over POSIX.  */
  159. #if defined _BSD_SOURCE && \
  160.     !(defined _POSIX_SOURCE || defined _POSIX_C_SOURCE || \
  161.       defined _XOPEN_SOURCE || defined _XOPEN_SOURCE_EXTENDED || \
  162.       defined _GNU_SOURCE || defined _SVID_SOURCE)
  163. # define __FAVOR_BSD    1
  164. #endif
  165.  
  166. /* If _GNU_SOURCE was defined by the user, turn on all the other features.  */
  167. #ifdef _GNU_SOURCE
  168. # undef  _ISOC99_SOURCE
  169. # define _ISOC99_SOURCE 1
  170. # undef  _POSIX_SOURCE
  171. # define _POSIX_SOURCE  1
  172. # undef  _POSIX_C_SOURCE
  173. # define _POSIX_C_SOURCE        199506L
  174. # undef  _XOPEN_SOURCE
  175. # define _XOPEN_SOURCE  600
  176. # undef  _XOPEN_SOURCE_EXTENDED
  177. # define _XOPEN_SOURCE_EXTENDED 1
  178. # undef  _LARGEFILE64_SOURCE
  179. # define _LARGEFILE64_SOURCE    1
  180. # undef  _BSD_SOURCE
  181. # define _BSD_SOURCE    1
  182. # undef  _SVID_SOURCE
  183. # define _SVID_SOURCE   1
  184. #endif
  185.  
  186. /* If nothing (other than _GNU_SOURCE) is defined,
  187.    define _BSD_SOURCE and _SVID_SOURCE.  */
  188. #if (!defined __STRICT_ANSI__ && !defined _ISOC99_SOURCE && \
  189.      !defined _POSIX_SOURCE && !defined _POSIX_C_SOURCE && \
  190.      !defined _XOPEN_SOURCE && !defined _XOPEN_SOURCE_EXTENDED && \
  191.      !defined _BSD_SOURCE && !defined _SVID_SOURCE)
  192. # define _BSD_SOURCE    1
  193. # define _SVID_SOURCE   1
  194. #endif
  195.  
  196. /* This is to enable the ISO C99 extension.  Also recognize the old macro
  197.    which was used prior to the standard acceptance.  This macro will
  198.    eventually go away and the features enabled by default once the ISO C99
  199.    standard is widely adopted.  */
  200. #if (defined _ISOC99_SOURCE || defined _ISOC9X_SOURCE \
  201.      || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L))
  202. # define __USE_ISOC99   1
  203. #endif
  204.  
  205. /* If none of the ANSI/POSIX macros are defined, use POSIX.1 and POSIX.2
  206.    (and IEEE Std 1003.1b-1993 unless _XOPEN_SOURCE is defined).  */
  207. #if (!defined __STRICT_ANSI__ && !defined _POSIX_SOURCE && \
  208.      !defined _POSIX_C_SOURCE)
  209. # define _POSIX_SOURCE  1
  210. # if defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) < 500
  211. #  define _POSIX_C_SOURCE       2
  212. # else
  213. #  define _POSIX_C_SOURCE       199506L
  214. # endif
  215. #endif
  216.  
  217. #if defined _POSIX_SOURCE || _POSIX_C_SOURCE >= 1 || defined _XOPEN_SOURCE
  218. # define __USE_POSIX    1
  219. #endif
  220.  
  221. #if defined _POSIX_C_SOURCE && _POSIX_C_SOURCE >= 2 || defined _XOPEN_SOURCE
  222. # define __USE_POSIX2    1
  223. #endif
  224.  
  225. #if (_POSIX_C_SOURCE - 0) >= 199309L
  226. # define __USE_POSIX199309    1
  227. #endif
  228.  
  229. #if (_POSIX_C_SOURCE - 0) >= 199506L
  230. # define __USE_POSIX199506    1
  231. #endif
  232.  
  233. #if (_POSIX_C_SOURCE - 0) >= 200112L
  234. # define __USE_XOPEN2K        1
  235. #endif
  236.  
  237. #ifdef  _XOPEN_SOURCE
  238. # define __USE_XOPEN    1
  239. # if (_XOPEN_SOURCE - 0) >= 500
  240. #  define __USE_XOPEN_EXTENDED  1
  241. #  define __USE_UNIX98  1
  242. #  undef _LARGEFILE_SOURCE
  243. #  define _LARGEFILE_SOURCE     1
  244. #  if (_XOPEN_SOURCE - 0) >= 600
  245. #   define __USE_XOPEN2K        1
  246. #   undef __USE_ISOC99
  247. #   define __USE_ISOC99         1
  248. #  endif
  249. # else
  250. #  ifdef _XOPEN_SOURCE_EXTENDED
  251. #   define __USE_XOPEN_EXTENDED 1
  252. #  endif
  253. # endif
  254. #endif
  255.  
  256. #ifdef _LARGEFILE_SOURCE
  257. # define __USE_LARGEFILE        1
  258. #endif
  259.  
  260. #ifdef _LARGEFILE64_SOURCE
  261. # define __USE_LARGEFILE64      1
  262. #endif
  263.  
  264. #if defined _FILE_OFFSET_BITS && _FILE_OFFSET_BITS == 64
  265. # define __USE_FILE_OFFSET64    1
  266. #endif
  267.  
  268. #if defined _BSD_SOURCE || defined _SVID_SOURCE
  269. # define __USE_MISC     1
  270. #endif
  271.  
  272. #ifdef  _BSD_SOURCE
  273. # define __USE_BSD      1
  274. #endif
  275.  
  276. #ifdef  _SVID_SOURCE
  277. # define __USE_SVID     1
  278. #endif
  279.  
  280. #ifdef  _GNU_SOURCE
  281. # define __USE_GNU      1
  282. #endif
  283.  
  284. #if defined _REENTRANT || defined _THREAD_SAFE
  285. # define __USE_REENTRANT        1
  286. #endif
  287.  
  288. /* We do support the IEC 559 math functionality, real and complex.  */
  289. #define __STDC_IEC_559__                1
  290. #define __STDC_IEC_559_COMPLEX__        1
  291.  
  292. #if 0
  293. /* wchar_t uses ISO 10646-1 (2nd ed., published 2000-09-15) / Unicode 3.0.  */
  294. //#define __STDC_ISO_10646__              200009L
  295. #endif
  296.  
  297. /* Major and minor version number of the UnixLib C library package.  Use
  298.    these macros to test for features in specific releases.  */
  299. #define __ULIBC__       4
  300. #define __ULIBC_MINOR__ 5
  301.  
  302. /* Convenience macros to test the versions of glibc and gcc.
  303.    Use them like this:
  304.    #if __GNUC_PREREQ (2,8)
  305.    ... code requiring gcc 2.8 or later ...
  306.    #endif
  307.    Note - they won't work for gcc1 or glibc1, since the _MINOR macros
  308.    were not defined then.  */
  309. #if defined __GNUC__ && defined __GNUC_MINOR__
  310. # define __GNUC_PREREQ(maj, min) \
  311.     ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
  312. #else
  313. # define __GNUC_PREREQ(maj, min) 0
  314. #endif
  315.  
  316. #define __ULIBC_PREREQ(maj, min) \
  317.     ((__ULIBC__ << 16) + __ULIBC_MINOR__ >= ((maj) << 16) + (min))
  318.  
  319. /* Decide whether a compiler supports the long long datatypes.  */
  320. #if defined __GNUC__
  321. # define __GLIBC_HAVE_LONG_LONG    1
  322. #endif
  323.  
  324. /* This is here only because every header file already includes this one.  */
  325. #ifndef __ASSEMBLER__
  326. # ifndef __SYS_CDEFS_H
  327. #  include <sys/cdefs.h>
  328. # endif
  329.  
  330. /* If we don't have __REDIRECT, prototypes will be missing if
  331.    __USE_FILE_OFFSET64 but not __USE_LARGEFILE[64]. */
  332. # if defined __USE_FILE_OFFSET64 && !defined __REDIRECT
  333. #  define __USE_LARGEFILE    1
  334. #  define __USE_LARGEFILE64    1
  335. # endif
  336.  
  337. #endif    /* !ASSEMBLER */
  338.  
  339. /* Decide whether we can define 'extern inline' functions in headers.  */
  340. #if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ \
  341.     && !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__
  342. # define __USE_EXTERN_INLINES    1
  343. #endif
  344.  
  345.  
  346. /* This is here only because every header file already includes this one.
  347.    Get the definitions of all the appropriate `__stub_FUNCTION' symbols.
  348.    <gnu/stubs.h> contains `#define __stub_FUNCTION' when FUNCTION is a stub
  349.    that will always return failure (and set errno to ENOSYS).  */
  350. #include <unixlib/stubs.h>
  351.  
  352. /* Default to recognising Image filesystems as directories.  Some programs
  353.    may wish to expose them as files for the purpose of compression
  354.    or direct manipulation of the contents.  Set to one in this case.  */
  355. extern int __feature_imagefs_is_file; /* Note: this is a weak symbol.  */
  356.  
  357. #include <unixlib/buildoptions.h>
  358.  
  359. /* Include the UnixLib build options.  */
  360. #ifdef __UNIXLIB_INTERNALS
  361.  
  362. /* Amount to align the wimpslot or dynamic area. */
  363. #define __DA_WIMPSLOT_ALIGNMENT (32*1024-1)
  364.  
  365. #ifndef __GNUC__
  366. #define __builtin_expect(exp, c)  (exp)
  367. #endif
  368.  
  369. /* Gets the __feature_imagefs_is_file value which can be defined by
  370.    the global variable __feature_imagefs_is_file in the user program.
  371.    Returns a copy of __feature_imagefs_is_file_internal (its default
  372.    value is 0) when __feature_imagefs_is_file is not defined.  */
  373. extern int __get_feature_imagefs_is_file (void);
  374. #if 0
  375. /* Currently the code __set_feature_imagefs_is_file commented out because
  376.    we don't need it in UnixLib internally.  */
  377.  
  378. /* Sets the __feature_imagefs_is_file value when it's defined.
  379.    Otherwise __feature_imagefs_is_file_internal gets written.  */
  380. extern void __set_feature_imagefs_is_file (int __value);
  381. #endif
  382.  
  383. #ifndef __ELF__
  384.  
  385. /* NULL if user didn't specify __program_name; non-NULL otherwise and then
  386.    its value equals __program_name.
  387.  
  388.    These symbols are only required for compatibility with Norcroft CC
  389.    and AOF/GCC.  */
  390. extern const char * const * const ___program_name;
  391. extern const char * const * const ___dynamic_da_name;
  392. #endif
  393.  
  394. #endif  /* __UNIXLIB_INTERNALS */
  395.  
  396. /* Note that AOF/GCC and Norcroft CC will ignore the WEAK attribute
  397.    here.  ELF/GCC will correctly handle it and do the right thing.  */
  398. #ifdef __ELF__
  399. #define __attribute_weak__ __attribute__ ((__weak__))
  400. #else
  401. #define __attribute_weak__ /**/
  402. #endif
  403.  
  404. #ifdef __STRICT_ANSI__
  405. #define inline __inline__
  406. #endif
  407.  
  408. /* When defined, specifies the <program name> part of the UnixLib OS
  409.    variables.  Otherwise, the leaf filename part of argv[0] is used.
  410.  
  411.    Note: this is a weak symbol.  */
  412. extern const char * const __program_name __attribute_weak__;
  413.  
  414. /* When defined, the memory pool will be created in the WimpSlot area
  415.    instead of a dynamic area (on RISC OS versions supporting dynamic
  416.    areas). Its value is unimportant.
  417.  
  418.    Note: this is a weak symbol.  */
  419. extern int __dynamic_no_da __attribute_weak__;
  420.  
  421. /* When a dynamic area is created as memory pool, __dynamic_da_name can
  422.    be used to specify its name.  When this variable is not defined, the
  423.    dynamic area name will be <program name> + "$Heap".
  424.  
  425.    Note: this is a weak symbol.  */
  426. extern const char * const __dynamic_da_name __attribute_weak__;
  427.  
  428. /* When defined, indicates the maximum size in bytes of the dynamic area
  429.    used for the heap. If undefined, UnixLib defaults to 32MB.
  430.  
  431.    Note: this is a weak symbol.  */
  432. extern int __dynamic_da_max_size __attribute_weak__;
  433.  
  434. #undef __attribute_weak__
  435.  
  436. #ifndef __SYS_CDEFS_H
  437. # include <sys/cdefs.h>
  438. #endif
  439.  
  440. #endif
  441.