Commit 8dc72f3c authored by Moritz Angermann's avatar Moritz Angermann Committed by Ben Gamari

Cleanup PosixSource.h

When trying to build arm64-apple-iso, the build fell over `strdup`, as
the arm64-apple-ios build did not fall into `darwin_HOST_OS`, and would
need `ios_HOST_OS`.

This diff tries to clean up PosixSource.h, instead of layering another
define on top.

As we use `strnlen` in sources that include PosixSource.h, and `strnlen`
is defined in POSIX.1-2008, the `_POSIX_C_SOURCE` and `_XOPEN_SOURCE`
are increased accordingly.

Furthermore the `_DARWIN_C_SOURCE` (required for `u_char`, etc. used in
sysctl.h) define is moved into `OSThreads.h` alongside a similar ifdef
for freebsd.

Test Plan: Build on all supported platforms.

Reviewers: austin, simonmar, erikd, kgardas, bgamari

Reviewed By: simonmar, erikd, kgardas, bgamari

Subscribers: Phyx, hvr, thomie

Differential Revision: https://phabricator.haskell.org/D2579

GHC Trac Issues: #12624
parent bcd34451
......@@ -21,18 +21,21 @@
9945:2002 or UNIX 03 and SUSv3.
Please also see trac ticket #11757 for more information about switch
to C99/C11.
*/
#define _POSIX_C_SOURCE 200112L
#define _XOPEN_SOURCE 600
#define __USE_MINGW_ANSI_STDIO 1
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(darwin_HOST_OS)
/* If we don't define this the including sysctl breaks with things like
/usr/include/bsm/audit.h:224:0:
error: syntax error before 'u_char'
*/
#define _DARWIN_C_SOURCE 1
#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
#endif /* POSIXSOURCE_H */
......@@ -14,6 +14,11 @@
* because of some specific types, like u_char, u_int, etc. */
#define __BSD_VISIBLE 1
#endif
#if defined(darwin_HOST_OS)
/* Inclusion of system headers usually requires _DARWIN_C_SOURCE on Mac OS X
* because of some specific types like u_char, u_int, etc. */
#define _DARWIN_C_SOURCE 1
#endif
#include "Rts.h"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment