Imported Upstream version 58.1
[platform/upstream/icu.git] / source / common / uposixdefs.h
1 // Copyright (C) 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:   US-ASCII
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 readlink 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)
58 #   define _XOPEN_SOURCE_EXTENDED 1
59 #endif
60
61 /*
62  * There is an issue with turning on _XOPEN_SOURCE_EXTENDED on certain platforms.
63  * A compatibility issue exists between turning on _XOPEN_SOURCE_EXTENDED and using
64  * standard C++ string class. As a result, standard C++ string class needs to be
65  * turned off for the follwing platforms:
66  *  -AIX/VACPP
67  *  -Solaris/GCC
68  */
69 #if (U_PLATFORM == U_PF_AIX && !defined(__GNUC__)) || (U_PLATFORM == U_PF_SOLARIS && defined(__GNUC__))
70 #   if _XOPEN_SOURCE_EXTENDED && !defined(U_HAVE_STD_STRING)
71 #   define U_HAVE_STD_STRING 0
72 #   endif
73 #endif
74
75 #endif  /* __UPOSIXDEFS_H__ */