[commit: ghc] master: Cleanup PosixSource.h (cac3fb0)

git at git.haskell.org git at git.haskell.org
Wed Jul 20 13:18:08 UTC 2016


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/cac3fb06f4b282eee21159c364c4d08e8fdedce9/ghc

>---------------------------------------------------------------

commit cac3fb06f4b282eee21159c364c4d08e8fdedce9
Author: Moritz Angermann <moritz.angermann at gmail.com>
Date:   Wed Jul 20 09:53:45 2016 +0200

    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: rwbarton, erikd, austin, hvr, simonmar, bgamari
    
    Reviewed By: simonmar, bgamari
    
    Subscribers: thomie
    
    Differential Revision: https://phabricator.haskell.org/D2375


>---------------------------------------------------------------

cac3fb06f4b282eee21159c364c4d08e8fdedce9
 rts/PosixSource.h     | 25 ++-----------------------
 rts/posix/OSThreads.c |  5 +++++
 2 files changed, 7 insertions(+), 23 deletions(-)

diff --git a/rts/PosixSource.h b/rts/PosixSource.h
index f4b880e..c4e328c 100644
--- a/rts/PosixSource.h
+++ b/rts/PosixSource.h
@@ -11,28 +11,7 @@
 
 #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.
-*/
-#define _POSIX_C_SOURCE 200112L
-#define _XOPEN_SOURCE   600
-
-#define __USE_MINGW_ANSI_STDIO 1
-
-#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
-#endif
+#define _POSIX_C_SOURCE 200809L
+#define _XOPEN_SOURCE   700
 
 #endif /* POSIXSOURCE_H */
diff --git a/rts/posix/OSThreads.c b/rts/posix/OSThreads.c
index 112a311..4010c5d 100644
--- a/rts/posix/OSThreads.c
+++ b/rts/posix/OSThreads.c
@@ -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"
 



More information about the ghc-commits mailing list