]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/test/intltest/simplethread.cpp
ICU-491.11.1.tar.gz
[apple/icu.git] / icuSources / test / intltest / simplethread.cpp
index 323de8569274c76f543e8b1b5fdb7dba9a65c51c..b903173e170a4ff7ffe8fce561f22fd41c49b97d 100644 (file)
@@ -1,6 +1,6 @@
 /********************************************************************
  * COPYRIGHT: 
- * Copyright (c) 1999-2009, International Business Machines Corporation and
+ * Copyright (c) 1999-2011, International Business Machines Corporation and
  * others. All Rights Reserved.
  ********************************************************************/
 
 # endif
 #endif
 
+/* Define __EXTENSIONS__ for Solaris and old friends in strict mode. */
+#ifndef __EXTENSIONS__
+#define __EXTENSIONS__
+#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"
 #include <string.h>
 #include <ctype.h>    // tolower, toupper
 
-#if !defined(U_WINDOWS) && !defined(XP_MAC) && !defined(U_RHAPSODY)
-#define POSIX 1
+#if U_PLATFORM_USES_ONLY_WIN32_API
+    /* Prefer native Windows APIs even if POSIX is implemented (i.e., on Cygwin). */
+#   undef POSIX
+#elif U_PLATFORM_IMPLEMENTS_POSIX
+#   define POSIX
+#else
+#   undef POSIX
 #endif
 
 /* Needed by z/OS to get usleep */
-#if defined(OS390)
+#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) || defined(U_SOLARIS) || defined(U_AIX) || defined(U_HPUX)
+#if defined(POSIX)
 #define HAVE_IMP
 
 #if (ICU_USE_THREADS == 1)
 # endif
 #endif
 
-/* Define __EXTENSIONS__ for Solaris and old friends in strict mode. */
-#ifndef __EXTENSIONS__
-#define __EXTENSIONS__
-#endif
-
-#if defined(OS390)
+#if U_PLATFORM == U_PF_OS390
 #include <sys/types.h>
 #endif
 
-#if !defined(OS390)
+#if U_PLATFORM != U_PF_OS390
 #include <signal.h>
 #endif
 
 #include "unicode/calendar.h"
 #include "ucaconf.h"
 
-#ifdef U_WINDOWS
+#if U_PLATFORM_USES_ONLY_WIN32_API
 #define HAVE_IMP
 
 #   define VC_EXTRALEAN
@@ -255,7 +262,7 @@ void SimpleThread::sleep(int32_t millis)
 //   class SimpleThread   NULL  Implementation
 //
 //-----------------------------------------------------------------------------------
-#elif defined XP_MAC
+#elif U_PLATFORM == U_PF_CLASSIC_MACOS
 
 // since the Mac has no preemptive threading (at least on MacOS 8), only
 // cooperative threading, threads are a no-op.  We have no yield() calls
@@ -310,7 +317,7 @@ SimpleThread::isRunning() {
 //        system level cleanup has happened.
 //
 //-----------------------------------------------------------------------------------
-#if defined(POSIX)||defined(U_SOLARIS)||defined(U_AIX)||defined(U_HPUX)
+#if defined(POSIX)
 #define HAVE_IMP
 
 struct PosixThreadImplementation
@@ -373,7 +380,7 @@ int32_t SimpleThread::start()
 #else
     if (attrIsInitialized == FALSE) {
         rc = pthread_attr_init(&attr);
-#if defined(OS390)
+#if U_PLATFORM == U_PF_OS390
         {
             int detachstate = 0;  // jdc30: detach state of zero causes
                                   //threads created with this attr to be in
@@ -417,13 +424,13 @@ SimpleThread::isRunning() {
 
 void SimpleThread::sleep(int32_t millis)
 {
-#ifdef U_SOLARIS
+#if U_PLATFORM == U_PF_SOLARIS
     sigignore(SIGALRM);
 #endif
 
 #ifdef HPUX_CMA
     cma_sleep(millis/100);
-#elif defined(U_HPUX) || defined(OS390)
+#elif U_PLATFORM == U_PF_HPUX || U_PLATFORM == U_PF_OS390
     millis *= 1000;
     while(millis >= 1000000) {
         usleep(999999);