summaryrefslogtreecommitdiff
path: root/rts/include/rts/PosixSource.h
blob: bc1be83d87368b54b23124c9d39f95513ad35cdc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/* -----------------------------------------------------------------------------
 *
 * (c) The GHC Team, 1998-2005
 *
 * Include this file into sources which should not need any non-Posix services.
 * That includes most RTS C sources.
 * ---------------------------------------------------------------------------*/

#pragma once

#include <ghcplatform.h>

/* We aim for C99 so we need to define following two defines in a consistent way
   with what POSIX/XOPEN provide for C99. Some OSes are particularly picky about
   the right versions defined here, e.g. Solaris
   We also settle on lowest version of POSIX/XOPEN needed for proper C99 support
   here which is POSIX.1-2001 compilation and Open Group Technical Standard,
   Issue 6 (XPG6). XPG6 itself is a result of the merge of X/Open and POSIX
   specification. It is also referred as IEEE Std. 1003.1-2001 or ISO/IEC
   9945:2002 or UNIX 03 and SUSv3.
   Please also see trac ticket #11757 for more information about switch
   to C99/C11.

   However, the use of `strnlen`, which is strictly speaking only available in
   IEEE Std 1003.1-2008 (XPG7), requires lifting the bounds, to be able to
   compile ghc on systems that are strict about enforcing the standard, e.g.
   Apples mobile platforms.

   Oracle's Solaris 11 supports only up to XPG6, hence the ifdef.
  */

#if defined(solaris2_HOST_OS)
#define _POSIX_C_SOURCE 200112L
#define _XOPEN_SOURCE   600
#else
#define _POSIX_C_SOURCE 200809L
#define _XOPEN_SOURCE   700
#endif

#define _GNU_SOURCE 1

#if defined(mingw32_HOST_OS)
#  if defined(__USE_MINGW_ANSI_STDIO)
#    if __USE_MINGW_ANSI_STDIO != 1
#       warning "Mismatch between __USE_MINGW_ANSI_STDIO definitions. \
If using PosixSource.h make sure it is the first header included."
#    endif
#  else
/* Inform mingw we want the ISO rather than Windows printf format specifiers. */
#    define __USE_MINGW_ANSI_STDIO 1
#endif
#endif