Home | History | Annotate | Download | only in common
      1 /*
      2 *******************************************************************************
      3 *   Copyright (C) 2011-2012, International Business Machines
      4 *   Corporation and others.  All Rights Reserved.
      5 *******************************************************************************
      6 *   file name:  uposixdefs.h
      7 *   encoding:   US-ASCII
      8 *   tab size:   8 (not used)
      9 *   indentation:4
     10 *
     11 *   created on: 2011jul25
     12 *   created by: Markus W. Scherer
     13 *
     14 *   Common definitions for implementation files working with POSIX functions.
     15 *   *Important*: #include this file before any other header files!
     16 */
     17 
     18 #ifndef __UPOSIXDEFS_H__
     19 #define __UPOSIXDEFS_H__
     20 
     21 /*
     22  * Define _XOPEN_SOURCE for access to POSIX functions.
     23  *
     24  * We cannot use U_PLATFORM from platform.h/utypes.h because
     25  * "The Open Group Base Specifications"
     26  * chapter "2.2 The Compilation Environment" says:
     27  * "In the compilation of an application that #defines a feature test macro
     28  * specified by IEEE Std 1003.1-2001,
     29  * no header defined by IEEE Std 1003.1-2001 shall be included prior to
     30  * the definition of the feature test macro."
     31  */
     32 #ifdef _XOPEN_SOURCE
     33     /* Use the predefined value. */
     34 #else
     35     /*
     36      * Version 6.0:
     37      * The Open Group Base Specifications Issue 6 (IEEE Std 1003.1, 2004 Edition)
     38      * also known as
     39      * SUSv3 = Open Group Single UNIX Specification, Version 3 (UNIX03)
     40      *
     41      * Note: This definition used to be in C source code (e.g., putil.c)
     42      * and define _XOPEN_SOURCE to different values depending on __STDC_VERSION__.
     43      * In C++ source code (e.g., putil.cpp), __STDC_VERSION__ is not defined at all.
     44      */
     45 #   define _XOPEN_SOURCE 600
     46 #endif
     47 
     48 /*
     49  * Make sure things like readlink and such functions work.
     50  * Poorly upgraded Solaris machines can't have this defined.
     51  * Cleanly installed Solaris can use this #define.
     52  *
     53  * z/OS needs this definition for timeval and to get usleep.
     54  */
     55 #if !defined(_XOPEN_SOURCE_EXTENDED)
     56 #   define _XOPEN_SOURCE_EXTENDED 1
     57 #endif
     58 
     59 /*
     60  * There is an issue with turning on _XOPEN_SOURCE_EXTENDED on certain platforms.
     61  * A compatibility issue exists between turning on _XOPEN_SOURCE_EXTENDED and using
     62  * standard C++ string class. As a result, standard C++ string class needs to be
     63  * turned off for the follwing platforms:
     64  *  -AIX/VACPP
     65  *  -Solaris/GCC
     66  */
     67 #if (U_PLATFORM == U_PF_AIX && !defined(__GNUC__)) || (U_PLATFORM == U_PF_SOLARIS && defined(__GNUC__))
     68 #   if _XOPEN_SOURCE_EXTENDED && !defined(U_HAVE_STD_STRING)
     69 #   define U_HAVE_STD_STRING 0
     70 #   endif
     71 #endif
     72 
     73 #endif  /* __UPOSIXDEFS_H__ */
     74