diff --git a/icu4c/source/common/ucln_cmn.c b/icu4c/source/common/ucln_cmn.c index 61c9986fe2..c2057e475e 100644 --- a/icu4c/source/common/ucln_cmn.c +++ b/icu4c/source/common/ucln_cmn.c @@ -137,8 +137,6 @@ U_CFUNC UBool u_ICUStaticInitFunc() { UErrorCode status = U_ZERO_ERROR; -#if (ICU_USE_THREADS == 1) -/* Initialize mutexes only if threading is supported */ UBool heapInUse = cmemory_inUse(); umtx_init(NULL); ucnv_init(&status); @@ -149,7 +147,6 @@ U_CFUNC UBool u_ICUStaticInitFunc() * have done some heap allocation. */ cmemory_clearInUse(); } -#endif /* ICU_USE_THREADS==1 */ return TRUE; } diff --git a/icu4c/source/common/umutex.c b/icu4c/source/common/umutex.c index a3253bbff7..fb3fcebd43 100644 --- a/icu4c/source/common/umutex.c +++ b/icu4c/source/common/umutex.c @@ -277,14 +277,13 @@ umtx_destroy(UMTX *mutex) { #if (ICU_USE_THREADS == 1) #if defined (WIN32) DeleteCriticalSection((CRITICAL_SECTION*)*mutex); - + uprv_free(*mutex); #elif defined (POSIX) pthread_mutex_destroy((pthread_mutex_t*)*mutex); - + uprv_free(*mutex); #endif #endif /* ICU_USE_THREADS==1 */ - uprv_free(*mutex); } *mutex = NULL; diff --git a/icu4c/source/common/unicode/uclean.h b/icu4c/source/common/unicode/uclean.h index d9eb936bd6..284b2ebaf6 100644 --- a/icu4c/source/common/unicode/uclean.h +++ b/icu4c/source/common/unicode/uclean.h @@ -136,7 +136,7 @@ typedef void U_CALLCONV UMtxFunc (const void *context, UMTX *mutex); * This function can only be used when ICU is in an initial, unused state, before * u_init() has been called. * This function may be used even when ICU has been built without multi-threaded - * support (see ICU_USE_THREADS pre-processor variable) + * support (see ICU_USE_THREADS pre-processor variable, umutex.h) * @param context This pointer value will be saved, and then (later) passed as * a parameter to the increment and decrement functions each time they * are called. This function can only be called diff --git a/icu4c/source/test/intltest/tsmthred.cpp b/icu4c/source/test/intltest/tsmthred.cpp index 8f33caba79..3763c9c2d2 100644 --- a/icu4c/source/test/intltest/tsmthred.cpp +++ b/icu4c/source/test/intltest/tsmthred.cpp @@ -11,6 +11,9 @@ #endif #include +#include "unicode/utypes.h" +#include "umutex.h" + // Just turn off threads on cygwin, so that we can test // the other stuff. This needs to be investigated further. @@ -66,17 +69,7 @@ #undef sleep #endif -#include "unicode/utypes.h" -/* APP_NO_THREADS is an old symbol. We'll honour it if present. */ -#ifdef APP_NO_THREADS -# define ICU_USE_THREADS 0 -#endif - -/* Default: use threads. */ -#ifndef ICU_USE_THREADS -# define ICU_USE_THREADS 1 -#endif #include "tsmthred.h" @@ -894,6 +887,7 @@ void MultithreadTest::TestThreadedIntl() } umtx_destroy(&ftMutex); return; + } #endif /* #if !UCONFIG_NO_FORMATTING */