1 | // © 2016 and later: Unicode, Inc. and others. |
2 | // License & terms of use: http://www.unicode.org/copyright.html |
3 | /* |
4 | ******************************************************************************* |
5 | * Copyright (C) 2011-2015, International Business Machines |
6 | * Corporation and others. All Rights Reserved. |
7 | ******************************************************************************* |
8 | * file name: uposixdefs.h |
9 | * encoding: UTF-8 |
10 | * tab size: 8 (not used) |
11 | * indentation:4 |
12 | * |
13 | * created on: 2011jul25 |
14 | * created by: Markus W. Scherer |
15 | * |
16 | * Common definitions for implementation files working with POSIX functions. |
17 | * *Important*: #include this file before any other header files! |
18 | */ |
19 | |
20 | #ifndef __UPOSIXDEFS_H__ |
21 | #define __UPOSIXDEFS_H__ |
22 | |
23 | /* |
24 | * Define _XOPEN_SOURCE for access to POSIX functions. |
25 | * |
26 | * We cannot use U_PLATFORM from platform.h/utypes.h because |
27 | * "The Open Group Base Specifications" |
28 | * chapter "2.2 The Compilation Environment" says: |
29 | * "In the compilation of an application that #defines a feature test macro |
30 | * specified by IEEE Std 1003.1-2001, |
31 | * no header defined by IEEE Std 1003.1-2001 shall be included prior to |
32 | * the definition of the feature test macro." |
33 | */ |
34 | #ifdef _XOPEN_SOURCE |
35 | /* Use the predefined value. */ |
36 | #else |
37 | /* |
38 | * Version 6.0: |
39 | * The Open Group Base Specifications Issue 6 (IEEE Std 1003.1, 2004 Edition) |
40 | * also known as |
41 | * SUSv3 = Open Group Single UNIX Specification, Version 3 (UNIX03) |
42 | * |
43 | * Note: This definition used to be in C source code (e.g., putil.c) |
44 | * and define _XOPEN_SOURCE to different values depending on __STDC_VERSION__. |
45 | * In C++ source code (e.g., putil.cpp), __STDC_VERSION__ is not defined at all. |
46 | */ |
47 | # define _XOPEN_SOURCE 600 |
48 | #endif |
49 | |
50 | /* |
51 | * Make sure things like realpath and such functions work. |
52 | * Poorly upgraded Solaris machines can't have this defined. |
53 | * Cleanly installed Solaris can use this #define. |
54 | * |
55 | * z/OS needs this definition for timeval and to get usleep. |
56 | */ |
57 | #if !defined(_XOPEN_SOURCE_EXTENDED) && defined(__TOS_MVS__) |
58 | # define _XOPEN_SOURCE_EXTENDED 1 |
59 | #endif |
60 | |
61 | /** |
62 | * Solaris says: |
63 | * "...it is invalid to compile an XPG6 or a POSIX.1-2001 application with anything other |
64 | * than a c99 or later compiler." |
65 | * Apparently C++11 is not "or later". Work around this. |
66 | */ |
67 | #if defined(__cplusplus) && (defined(sun) || defined(__sun)) && !defined (_STDC_C99) |
68 | # define _STDC_C99 |
69 | #endif |
70 | |
71 | #if !defined _POSIX_C_SOURCE && \ |
72 | defined(__APPLE__) && defined(__MACH__) && !defined(__clang__) |
73 | // Needed to prevent EOWNERDEAD issues with GCC on Mac |
74 | #define _POSIX_C_SOURCE 200809L |
75 | #endif |
76 | |
77 | #endif /* __UPOSIXDEFS_H__ */ |
78 | |