]> granicus.if.org Git - icu/commitdiff
ICU-8452 consolidate definition of _XOPEN_SOURCE for access to POSIX functions; do...
authorMarkus Scherer <markus.icu@gmail.com>
Mon, 25 Jul 2011 21:02:32 +0000 (21:02 +0000)
committerMarkus Scherer <markus.icu@gmail.com>
Mon, 25 Jul 2011 21:02:32 +0000 (21:02 +0000)
X-SVN-Rev: 30418

icu4c/source/common/common.vcxproj
icu4c/source/common/common.vcxproj.filters
icu4c/source/common/putil.cpp
icu4c/source/common/uposixdefs.h [new file with mode: 0644]
icu4c/source/io/ufile.c
icu4c/source/test/intltest/simplethread.cpp
icu4c/source/test/intltest/tsmthred.cpp
icu4c/source/tools/ctestfw/uperf.cpp
icu4c/source/tools/pkgdata/pkgdata.cpp
icu4c/source/tools/toolutil/platform_xopen_source_extended.h [deleted file]
icu4c/source/tools/toolutil/toolutil.vcxproj

index ec679931911bc35077503443d56bf6564f7e9644..2ccddef0062f6cf1335471a16465287c5e767afd 100644 (file)
 </Command>\r
       <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">..\..\include\unicode\%(Filename)%(Extension);%(Outputs)</Outputs>\r
     </CustomBuild>\r
+    <ClInclude Include="uposixdefs.h" />\r
     <CustomBuild Include="unicode\urename.h">\r
       <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">copy "%(FullPath)" ..\..\include\unicode\r
 </Command>\r
index 1e4ae39601fbf54003c53bfc89fd0be1102cde26..1a6e6f4d04cb9accc24328cef829c5f4658af589 100644 (file)
     <ClInclude Include="umutex.h">\r
       <Filter>configuration</Filter>\r
     </ClInclude>\r
+    <ClInclude Include="uposixdefs.h">\r
+      <Filter>configuration</Filter>\r
+    </ClInclude>\r
     <ClInclude Include="utracimp.h">\r
       <Filter>configuration</Filter>\r
     </ClInclude>\r
index 10eeb0b89d78250467af24df0e46fb678243ea8c..82a397df4dcd4af6f2c1e178cbc54d29d94ec509 100644 (file)
 ******************************************************************************
 */
 
-/* Define _XOPEN_SOURCE for Solaris and friends. */
-/* NetBSD needs it to be >= 4 */
-#if !defined(_XOPEN_SOURCE)
-#if __STDC_VERSION__ >= 199901L
-/* It is invalid to compile an XPG3, XPG4, XPG4v2 or XPG5 application using c99 on Solaris */
-#define _XOPEN_SOURCE 600
-#else
-#define _XOPEN_SOURCE 4
-#endif
-#endif
-
-/* Make sure things like readlink and such functions work.
-Poorly upgraded Solaris machines can't have this defined.
-Cleanly installed Solaris can use this #define.
-*/
-#if !defined(_XOPEN_SOURCE_EXTENDED) && ((!defined(__STDC_VERSION__) || __STDC_VERSION__ >= 199901L) || defined(__xlc__))
-#define _XOPEN_SOURCE_EXTENDED 1
-#endif
+// Defines _XOPEN_SOURCE for access to POSIX functions.
+// Must be before any other #includes.
+#include "uposixdefs.h"
 
 /* include ICU headers */
 #include "unicode/utypes.h"
diff --git a/icu4c/source/common/uposixdefs.h b/icu4c/source/common/uposixdefs.h
new file mode 100644 (file)
index 0000000..c1ab899
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+*******************************************************************************
+*   Copyright (C) 2011, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+*******************************************************************************
+*   file name:  uposixdefs.h
+*   encoding:   US-ASCII
+*   tab size:   8 (not used)
+*   indentation:4
+*
+*   created on: 2011jul25
+*   created by: Markus W. Scherer
+*
+*   Common definitions for implementation files working with POSIX functions.
+*   *Important*: #include this file before any other header files!
+*/
+
+#ifndef __UPOSIXDEFS_H__
+#define __UPOSIXDEFS_H__
+
+/*
+ * Define _XOPEN_SOURCE for access to POSIX functions.
+ *
+ * We cannot use U_PLATFORM from platform.h/utypes.h because
+ * "The Open Group Base Specifications"
+ * chapter "2.2 The Compilation Environment" says:
+ * "In the compilation of an application that #defines a feature test macro
+ * specified by IEEE Std 1003.1-2001,
+ * no header defined by IEEE Std 1003.1-2001 shall be included prior to
+ * the definition of the feature test macro."
+ */
+#ifdef _XOPEN_SOURCE
+    /* Use the predefined value. */
+#else
+    /*
+     * Version 6.0:
+     * The Open Group Base Specifications Issue 6 (IEEE Std 1003.1, 2004 Edition)
+     * also known as
+     * SUSv3 = Open Group Single UNIX Specification, Version 3 (UNIX03)
+     *
+     * Note: This definition used to be in C source code (e.g., putil.c)
+     * and define _XOPEN_SOURCE to different values depending on __STDC_VERSION__.
+     * In C++ source code (e.g., putil.cpp), __STDC_VERSION__ is not defined at all.
+     */
+#   define _XOPEN_SOURCE 600
+#endif
+
+/*
+ * Make sure things like readlink and such functions work.
+ * Poorly upgraded Solaris machines can't have this defined.
+ * Cleanly installed Solaris can use this #define.
+ *
+ * z/OS needs this definition for timeval and to get usleep.
+ */
+#if !defined(_XOPEN_SOURCE_EXTENDED)
+#   define _XOPEN_SOURCE_EXTENDED 1
+#endif
+
+/*
+ * There is an issue with turning on _XOPEN_SOURCE_EXTENDED on certain platforms.
+ * A compatibility issue exists between turning on _XOPEN_SOURCE_EXTENDED and using
+ * standard C++ string class. As a result, standard C++ string class needs to be
+ * turned off for the follwing platforms:
+ *  -AIX/VACPP
+ *  -Solaris/GCC
+ */
+#if (U_PLATFORM == U_PF_AIX && !defined(__GNUC__)) || (U_PLATFORM == U_PF_SOLARIS && defined(__GNUC__))
+#   if _XOPEN_SOURCE_EXTENDED && !defined(U_HAVE_STD_STRING)
+#   define U_HAVE_STD_STRING 0
+#   endif
+#endif
+
+#endif  /* __UPOSIXDEFS_H__ */
index 125bbfe4c6223b763a669fc297b121d57df4a73a..62d9551234c51f16349e606f1194065c66590fef 100644 (file)
 ******************************************************************************
 */
 
-/* define for fileno.  */
-#ifndef _XOPEN_SOURCE
-#if __STDC_VERSION__ >= 199901L
-/* It is invalid to compile an XPG3, XPG4, XPG4v2 or XPG5 application using c99 */
-#define _XOPEN_SOURCE 600
-#else
-#define _XOPEN_SOURCE 4
-#endif
-#endif
+/*
+ * Defines _XOPEN_SOURCE for access to POSIX functions.
+ * Must be before any other #includes.
+ */
+#include "uposixdefs.h"
 
 #include "locmap.h"
 #include "unicode/ustdio.h"
index 2817ab2cf856aaa7d12ff9e9e26ae7bc10c7a19d..380b34047740261bca112383a6445cf81e34cd66 100644 (file)
 # endif
 #endif
 
+// Defines _XOPEN_SOURCE for access to POSIX functions.
+// Must be before any other #includes.
+#include "uposixdefs.h"
+
 #include "simplethread.h"
 
 #include "unicode/utypes.h"
 #if U_PLATFORM == U_PF_OS390
 #define __DOT1 1
 #define __UU
-#define _XOPEN_SOURCE_EXTENDED 1
 #ifndef _XPG4_2
 #define _XPG4_2
 #endif
 #include <unistd.h>
-/*#include "platform_xopen_source_extended.h"*/
 #endif
 
 #if defined(POSIX)
index 4074bcaee81ea7e18bf172dfba9cb4be6e628c6e..8edeafd853e5502a7057f73873600759794e5d1b 100644 (file)
 #if U_PLATFORM == U_PF_OS390
 #define __DOT1 1
 #define __UU
-#define _XOPEN_SOURCE_EXTENDED 1
 #ifndef _XPG4_2
 #define _XPG4_2
 #endif
 #include <unistd.h>
-/*#include "platform_xopen_source_extended.h"*/
 #endif
 #if defined(POSIX)
 
index 5fb25b15514199eb23863088c45af4763ee1e2d0..31dd8e7990a2ee04c99670e5e8cf581892eae68f 100644 (file)
@@ -4,8 +4,9 @@
  * others. All Rights Reserved.
  ********************************************************************/
 
-/* z/OS needs this definition for timeval */
-#include "platform_xopen_source_extended.h"
+// Defines _XOPEN_SOURCE for access to POSIX functions.
+// Must be before any other #includes.
+#include "uposixdefs.h"
 
 #include "unicode/uperf.h"
 #include "uoptions.h"
index 444248d925c8f9bccb1d250dbe3cb5cb4f2291e4..3cb8c92124b2e7b1a1f65317b9f1f7cf2d47ce9b 100644 (file)
@@ -2,7 +2,7 @@
  *   Copyright (C) 2000-2011, International Business Machines
  *   Corporation and others.  All Rights Reserved.
  *******************************************************************************
- *   file name:  pkgdata.c
+ *   file name:  pkgdata.cpp
  *   encoding:   ANSI X3.4 (1968)
  *   tab size:   8 (not used)
  *   indentation:4
  *   (DLL, common data, etc.)
  */
 
-/*
- * We define _XOPEN_SOURCE so that we can get popen and pclose.
- */
-#if !defined(_XOPEN_SOURCE)
-#if __STDC_VERSION__ >= 199901L
-/* It is invalid to compile an XPG3, XPG4, XPG4v2 or XPG5 application using c99 on Solaris */
-#define _XOPEN_SOURCE 600
-#else
-#define _XOPEN_SOURCE 4
-#endif
-#endif
-
+// Defines _XOPEN_SOURCE for access to POSIX functions.
+// Must be before any other #includes.
+#include "uposixdefs.h"
 
 #include "unicode/utypes.h"
 
diff --git a/icu4c/source/tools/toolutil/platform_xopen_source_extended.h b/icu4c/source/tools/toolutil/platform_xopen_source_extended.h
deleted file mode 100644 (file)
index 711d7e6..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
-**********************************************************************
-* Copyright (c) 2009-2011, International Business Machines
-* Corporation and others.  All Rights Reserved.
-**********************************************************************
-*/
-#ifndef _PLATFORM_XOPEN_SOURCE_EXTENDED_H
-#define _PLATFORM_XOPEN_SOURCE_EXTENDED_H
-
-#include "unicode/utypes.h"
-
-/*
- * z/OS needs this definition for timeval and to get usleep.
- * We move this definition out of the various source files because
- * there might be some platform issues when this is defined. 
- * See below.
- */
-#if !defined(_XOPEN_SOURCE_EXTENDED)
-#define _XOPEN_SOURCE_EXTENDED 1
-#endif
-
-/*
- * There is an issue with turning on _XOPEN_SOURCE_EXTENDED on certain platforms.
- * A compatibility issue exists between turning on _XOPEN_SOURCE_EXTENDED and using
- * standard C++ string class. As a result, standard C++ string class needs to be
- * turned off for the follwing platforms:
- *  -AIX/VACPP
- *  -Solaris/GCC
- */
-#if (U_PLATFORM == U_PF_AIX && !defined(__GNUC__)) || (U_PLATFORM == U_PF_SOLARIS && defined(__GNUC__))
-#   if _XOPEN_SOURCE_EXTENDED && !defined(U_HAVE_STD_STRING)
-#   define U_HAVE_STD_STRING 0
-#   endif
-#endif
-
-#endif /* _PLATFORM_XOPEN_SOURCE_EXTENDED_H */
index e565bdfb76b03f6493c2ca1311f1c001539ec38d..ffb8c790f3da10223056c148f1df917ffa79b530 100644 (file)
     <ClInclude Include="pkg_gencmn.h" />\r
     <ClInclude Include="pkg_icu.h" />\r
     <ClInclude Include="pkg_imp.h" />\r
-    <ClInclude Include="platform_xopen_source_extended.h" />\r
     <ClInclude Include="swapimpl.h" />\r
     <ClInclude Include="toolutil.h" />\r
     <ClInclude Include="ucbuf.h" />\r