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