edf16b5b1a42bed109db771875fb2d30248566e7
[ghc.git] / rts / PosixSource.h
1 /* -----------------------------------------------------------------------------
2 *
3 * (c) The GHC Team, 1998-2005
4 *
5 * Include this file into sources which should not need any non-Posix services.
6 * That includes most RTS C sources.
7 * ---------------------------------------------------------------------------*/
8
9 #ifndef POSIXSOURCE_H
10 #define POSIXSOURCE_H
11
12 #include <ghcplatform.h>
13
14 /* We aim for C99 so we need to define following two defines in a consistent way
15 with what POSIX/XOPEN provide for C99. Some OSes are particularly picky about
16 the right versions defined here, e.g. Solaris
17 We also settle on lowest version of POSIX/XOPEN needed for proper C99 support
18 here which is POSIX.1-2001 compilation and Open Group Technical Standard,
19 Issue 6 (XPG6). XPG6 itself is a result of the merge of X/Open and POSIX
20 specification. It is also referred as IEEE Std. 1003.1-2001 or ISO/IEC
21 9945:2002 or UNIX 03 and SUSv3.
22 Please also see trac ticket #11757 for more information about switch
23 to C99/C11.
24
25 However, the use of `strnlen`, which is strictly speaking only available in
26 IEEE Std 1003.1-2008 (XPG7), requires lifting the bounds, to be able to
27 compile ghc on systems that are strict about enforcing the standard, e.g.
28 Apples mobile platforms.
29
30 Oracle's Solaris 11 supports only up to XPG6, hence the ifdef.
31 */
32
33 #if defined(solaris2_HOST_OS)
34 #define _POSIX_C_SOURCE 200112L
35 #define _XOPEN_SOURCE 600
36 #else
37 #define _POSIX_C_SOURCE 200809L
38 #define _XOPEN_SOURCE 700
39 #endif
40
41 #if defined(mingw32_HOST_OS)
42 /* Without this gcc will warn about %ull and the like since some msvcrt versions
43 do not support them. See
44 https://sourceforge.net/p/mingw-w64/mailman/message/28557333/
45
46 Note that this is implied by _POSIX_C_SOURCE in the msys2 toolchain that we
47 now use. However, we retain this explicit #define to preserve the ability to
48 bootstrap GHC with compilers still using msys (e.g. GHC 7.10.1 and 7.10.2).
49 This can be removed in for GHC 8.4. See #12951.
50 */
51 #define __USE_MINGW_ANSI_STDIO 1
52 #endif
53
54 #endif /* POSIXSOURCE_H */