X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/b25be06635768807f8f693286fa73bb2297bb06c..4388f060552cc537e71e957d32f35e9d75a61233:/icuSources/test/intltest/simplethread.cpp?ds=sidebyside diff --git a/icuSources/test/intltest/simplethread.cpp b/icuSources/test/intltest/simplethread.cpp index 323de856..b903173e 100644 --- a/icuSources/test/intltest/simplethread.cpp +++ b/icuSources/test/intltest/simplethread.cpp @@ -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. ********************************************************************/ @@ -10,6 +10,15 @@ # 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" @@ -28,23 +37,26 @@ #include #include // 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 -/*#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) @@ -57,16 +69,11 @@ # 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 #endif -#if !defined(OS390) +#if U_PLATFORM != U_PF_OS390 #include #endif @@ -130,7 +137,7 @@ #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);