]> granicus.if.org Git - icu/commitdiff
ICU-9010 remove --disable-threads, move ICU_USE_THREADS out of uconfig.h into test...
authorMarkus Scherer <markus.icu@gmail.com>
Wed, 6 Jun 2012 04:13:28 +0000 (04:13 +0000)
committerMarkus Scherer <markus.icu@gmail.com>
Wed, 6 Jun 2012 04:13:28 +0000 (04:13 +0000)
X-SVN-Rev: 31911

icu4c/readme.html
icu4c/source/common/umutex.c
icu4c/source/common/umutex.h
icu4c/source/common/unicode/uclean.h
icu4c/source/common/unicode/uconfig.h
icu4c/source/configure
icu4c/source/configure.in
icu4c/source/test/intltest/intltest.h
icu4c/source/test/intltest/simplethread.cpp
icu4c/source/test/intltest/tsmthred.cpp

index 5364b75cc1c0242267ac5edf06ab090d0cb9e60e..b85bd028982693177f836200205b5b635d4bf481 100644 (file)
@@ -24,7 +24,7 @@
     It is not recommended for production use.
     </p>
     -->
-    <p>Last updated: 2012-Mar-19<br />
+    <p>Last updated: 2012-Jun-05<br />
      Copyright &copy; 1997-2012 International Business Machines Corporation and
     others. All Rights Reserved.</p>
     <!-- Remember that there is a copyright at the end too -->
     this release, see the <a href="http://site.icu-project.org/download/">ICU
     download page</a>.</p>
 
+    <h3>Threading support cannot be removed</h3>
+    <p>ICU4C 50 drops the --enable-threads/--disable-threads option
+    and the uconfig.h <code>ICU_USE_THREADS</code> switch.
+    ICU4C 50 and higher is always built with multi-threading support.</p>
+
+    <p>If you need to disable multi-threading, then call
+    <code>u_setMutexFunctions()</code> and <code>u_setAtomicIncDecFunctions()</code>
+    with empty implementation functions.</p>
+
     <h3>C++ namespace support required</h3>
     <p>ICU4C 49 requires C++ namespace support.
     As a result, for example, rather than <code>U_NAMESPACE_QUALIFIER UnicodeString</code>
     <ul>
       <li><tt>--disable-renaming</tt></li>
 
-      <li><tt>--disable-threading</tt> (This flag does disable threading in ICU,
-      but the resulting ICU library will still be linked with MSVC's multithread DLL)</li>
-
       <li><tt>--enable-tracing</tt></li>
 
       <li><tt>--enable-rpath</tt></li>
index 1c1d1d32be4d01cf59ac3ef60512fcac57bb9e49..e36c241adc6a78fd3cb2076af213d1aaab06cbba 100644 (file)
@@ -1,7 +1,7 @@
 /*
 ******************************************************************************
 *
-*   Copyright (C) 1997-2011, International Business Machines
+*   Copyright (C) 1997-2012, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 *
 ******************************************************************************
 #   undef POSIX
 #endif
 
-#if defined(POSIX) && (ICU_USE_THREADS==1)
+#if defined(POSIX)
 # include <pthread.h> /* must be first, so that we get the multithread versions of things. */
 
-#endif /* POSIX && (ICU_USE_THREADS==1) */
+#endif /* POSIX */
 
 #if U_PLATFORM_HAS_WIN32_API
 # define WIN32_LEAN_AND_MEAN
  */
 
 
-#if (ICU_USE_THREADS == 0)
-#define MUTEX_TYPE void *
-#define PLATFORM_MUTEX_INIT(m) 
-#define PLATFORM_MUTEX_LOCK(m) 
-#define PLATFORM_MUTEX_UNLOCK(m) 
-#define PLATFORM_MUTEX_DESTROY(m) 
-#define PLATFORM_MUTEX_INITIALIZER NULL
-#define SYNC_COMPARE_AND_SWAP(dest, oldval, newval) \
-            mutexed_compare_and_swap(dest, newval, oldval)
-
-
-#elif U_PLATFORM_HAS_WIN32_API
+#if U_PLATFORM_HAS_WIN32_API
 #define MUTEX_TYPE CRITICAL_SECTION
 #define PLATFORM_MUTEX_INIT(m) InitializeCriticalSection(m)
 #define PLATFORM_MUTEX_LOCK(m) EnterCriticalSection(m)
@@ -489,10 +478,7 @@ umtx_atomic_inc(int32_t *p)  {
     if (pIncFn) {
         retVal = (*pIncFn)(gIncDecContext, p);
     } else {
-        #if !ICU_USE_THREADS
-            /* ICU thread support compiled out. */
-            retVal = ++(*p);
-        #elif U_PLATFORM_HAS_WIN32_API
+        #if U_PLATFORM_HAS_WIN32_API
             retVal = InterlockedIncrement((LONG*)p);
         #elif defined(USE_MAC_OS_ATOMIC_INCREMENT)
             retVal = OSAtomicIncrement32Barrier(p);
@@ -516,10 +502,7 @@ umtx_atomic_dec(int32_t *p) {
     if (pDecFn) {
         retVal = (*pDecFn)(gIncDecContext, p);
     } else {
-        #if !ICU_USE_THREADS
-            /* ICU thread support compiled out. */
-            retVal = --(*p);
-        #elif U_PLATFORM_HAS_WIN32_API
+        #if U_PLATFORM_HAS_WIN32_API
             retVal = InterlockedDecrement((LONG*)p);
         #elif defined(USE_MAC_OS_ATOMIC_INCREMENT)
             retVal = OSAtomicDecrement32Barrier(p);
index 78cfc890adfaaf6b7cfdddcf2374c6cc30741ca5..b2ce411d9a1e4994f99f539ef719b72806a93f0f 100644 (file)
@@ -1,6 +1,6 @@
 /*
 **********************************************************************
-*   Copyright (C) 1997-2011, International Business Machines
+*   Copyright (C) 1997-2012, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 **********************************************************************
 *
@@ -51,9 +51,7 @@
 #endif
 
 #ifndef UMTX_FULL_BARRIER
-# if !ICU_USE_THREADS
-#  define UMTX_FULL_BARRIER
-# elif U_HAVE_GCC_ATOMICS
+# if U_HAVE_GCC_ATOMICS
 #  define UMTX_FULL_BARRIER __sync_synchronize();
 # elif defined(_MSC_VER) && _MSC_VER >= 1500
     /* From MSVC intrin.h. Use _ReadWriteBarrier() only on MSVC 9 and higher. */
index 93600b970a69da85440b248f160eba39e8e50ebc..87809f0e687f30b3caafdeee605c8026b23d4d83 100644 (file)
@@ -1,6 +1,6 @@
 /*
 ******************************************************************************
-* Copyright (C) 2001-2011, International Business Machines
+* Copyright (C) 2001-2012, International Business Machines
 *                Corporation and others. All Rights Reserved.
 ******************************************************************************
 *   file name:  uclean.h
@@ -148,8 +148,6 @@ typedef void U_CALLCONV UMtxFn   (const void *context, UMTX  *mutex);
   *  directly access system functions for mutex operations
   *  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, umutex.h)
   *  @param context This pointer value will be saved, and then (later) passed as
   *                 a parameter to the user-supplied mutex functions each time they
   *                 are called. 
index ab03755c2a9d2a8700aa992fb0a96cc3ecd51260..5482cb0bbae1d1825e710591bf5cd6e64e66735d 100644 (file)
 #define UCLN_NO_AUTO_CLEANUP 1
 #endif
 
-/**
- * \def ICU_USE_THREADS
- *
- * Allows thread support (use of mutexes) to be compiled out of ICU.
- * Default: use threads.
- *
- * Even with thread support compiled out, applications may override the
- * (empty) mutex implementation with the u_setMutexFunctions() functions.
- * @internal
- */
-#ifdef ICU_USE_THREADS
-    /* Use the predefined value. */
-#elif defined(APP_NO_THREADS)
-    /* APP_NO_THREADS is an old symbol. We'll honour it if present. */
-#   define ICU_USE_THREADS 0
-#else
-#   define ICU_USE_THREADS 1
-#endif
-
 /**
  * \def U_DISABLE_RENAMING
  * Determines whether to disable renaming or not.
index 4774b48b5ed85d401048e4ea28a54fdf3feb71d8..065a1c19c35deedb3ef00c73f07a0471796c13e6 100755 (executable)
@@ -643,8 +643,6 @@ U_HAVE_INTTYPES_H
 GENCCODE_ASSEMBLY
 HAVE_MMAP
 LIB_THREAD
-ICU_USE_THREADS
-THREADS_TRUE
 U_HAVE_STD_STRING
 ENABLE_RPATH
 U_ENABLE_DYLOAD
@@ -752,7 +750,6 @@ enable_renaming
 enable_tracing
 enable_dyload
 enable_rpath
-enable_threads
 enable_weak_threads
 enable_extras
 enable_icuio
@@ -1399,7 +1396,6 @@ Optional Features:
   --enable-tracing        enable function and data tracing default=no
   --disable-dyload        disable dynamic loading default=no
   --enable-rpath          use rpath when linking default is only if necessary
-  --enable-threads        build ICU with thread safety default=yes
   --enable-weak-threads   weakly reference the threading library default=no
   --enable-extras         build ICU extras default=yes
   --enable-icuio          build ICU's icuio library default=yes
@@ -5813,28 +5809,9 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
+# Always build ICU with multi-threading support.
 threads=true
-
-# Enable/disable threads
-# Check whether --enable-threads was given.
-if test "${enable_threads+set}" = set; then :
-  enableval=$enable_threads; case "${enableval}" in
-               yes) threads=true ;;
-               no)  threads=false ;;
-               *) as_fn_error $? "bad value ${enableval} for --enable-threads" "$LINENO" 5 ;;
-               esac
-else
-  threads=true
-fi
-
-
-if test "$threads" = true; then
-  THREADS_TRUE=
-else
-  THREADS_TRUE='#'
-fi
-
-ICU_USE_THREADS=0
+ICU_USE_THREADS=1
 OLD_LIBS=${LIBS}
 
 if test $threads = true; then
@@ -7493,14 +7470,9 @@ fi
 # Now that we're done using CPPFLAGS etc. for tests, we can change it
 # for build.
 
-if test $ICU_USE_THREADS -ne 0
-then
-    CPPFLAGS="$CPPFLAGS \$(THREADSCPPFLAGS)"
-    CFLAGS="$CFLAGS \$(THREADSCFLAGS)"
-    CXXFLAGS="$CXXFLAGS \$(THREADSCXXFLAGS)"
-else
-    CONFIG_CPPFLAGS="${CONFIG_CPPFLAGS} -DICU_USE_THREADS=0"
-fi
+CPPFLAGS="$CPPFLAGS \$(THREADSCPPFLAGS)"
+CFLAGS="$CFLAGS \$(THREADSCFLAGS)"
+CXXFLAGS="$CXXFLAGS \$(THREADSCXXFLAGS)"
 
 
 
@@ -8759,12 +8731,6 @@ echo
 echo "ICU for C/C++ $VERSION is ready to be built."
 echo "=== Important Notes: ==="
 
-if test $ICU_USE_THREADS = 0; then
-  echo
-  echo  "** ICU was configured without mutex or thread support. Multithread-safe operation will not be tested. If this is unexpected, then run configure with --enable-threads=yes or check the messages above to see why thread support was not found." 1>&6
-  echo
-fi
-
 echo "Data Packaging: $datapackaging"
 echo " This means: $datapackaging_msg"
 echo " To locate data: $datapackaging_howfound"
index 2e9d865e193362517792333a1bb6d3b8e0292c11..897d1c2c0b3e465b82535ec47a8bfaf62b6ace86 100644 (file)
@@ -465,20 +465,9 @@ fi
 AC_SUBST(U_HAVE_STD_STRING)
 AC_LANG_POP([C++])
 
+# Always build ICU with multi-threading support.
 threads=true
-
-# Enable/disable threads
-AC_ARG_ENABLE(threads,
-       [  --enable-threads        build ICU with thread safety [default=yes]],
-       [case "${enableval}" in
-               yes) threads=true ;;
-               no)  threads=false ;;
-               *) AC_MSG_ERROR(bad value ${enableval} for --enable-threads) ;;
-               esac], 
-       threads=true)
-ICU_CONDITIONAL(THREADS, test "$threads" = true)
-
-ICU_USE_THREADS=0
+ICU_USE_THREADS=1
 OLD_LIBS=${LIBS}
 
 if test $threads = true; then
@@ -545,8 +534,6 @@ if test $threads = true; then
   esac
 fi
 
-AC_SUBST(ICU_USE_THREADS)
-
 AC_ARG_ENABLE(weak-threads,
        [  --enable-weak-threads   weakly reference the threading library [default=no]],
        [case "${enableval}" in
@@ -1199,14 +1186,9 @@ fi
 # Now that we're done using CPPFLAGS etc. for tests, we can change it
 # for build.
 
-if test $ICU_USE_THREADS -ne 0
-then
-    CPPFLAGS="$CPPFLAGS \$(THREADSCPPFLAGS)"
-    CFLAGS="$CFLAGS \$(THREADSCFLAGS)"
-    CXXFLAGS="$CXXFLAGS \$(THREADSCXXFLAGS)"
-else
-    CONFIG_CPPFLAGS="${CONFIG_CPPFLAGS} -DICU_USE_THREADS=0"
-fi
+CPPFLAGS="$CPPFLAGS \$(THREADSCPPFLAGS)"
+CFLAGS="$CFLAGS \$(THREADSCFLAGS)"
+CXXFLAGS="$CXXFLAGS \$(THREADSCXXFLAGS)"
 
 AC_SUBST(LIBCFLAGS)
 AC_SUBST(LIBCXXFLAGS)
@@ -1289,12 +1271,6 @@ echo
 echo "ICU for C/C++ $VERSION is ready to be built."
 echo "=== Important Notes: ==="
 
-if test $ICU_USE_THREADS = 0; then
-  echo
-  echo  "** ICU was configured without mutex or thread support. Multithread-safe operation will not be tested. If this is unexpected, then run configure with --enable-threads=yes or check the messages [above] to see why thread support was not found." 1>&6
-  echo
-fi
-
 echo "Data Packaging: $datapackaging"
 echo " This means: $datapackaging_msg"
 echo " To locate data: $datapackaging_howfound"
index 920c5d49926d231db4ebf8b3a30f5d13d1e915c0..3fef2d879179e5005acd255acaad60ca693c06c6 100644 (file)
 #include "unicode/fmtable.h"
 #include "unicode/testlog.h"
 
+/**
+ * \def ICU_USE_THREADS
+ *
+ * Enables multi-threaded testing. Moved here from uconfig.h.
+ * Default: enabled
+ *
+ * This switched used to allow thread support (use of mutexes) to be compiled out of ICU.
+ */
+#ifdef ICU_USE_THREADS
+    /* Use the predefined value. */
+#elif defined(APP_NO_THREADS)
+    /* APP_NO_THREADS is an old symbol. We'll honour it if present. */
+#   define ICU_USE_THREADS 0
+#else
+#   define ICU_USE_THREADS 1
+#endif
+
 U_NAMESPACE_USE
 
 #if U_PLATFORM == U_PF_OS390
index b903173e170a4ff7ffe8fce561f22fd41c49b97d..4d7d0bd5797a910e8261ee166d9df3a46cfa8007 100644 (file)
@@ -1,6 +1,6 @@
 /********************************************************************
  * COPYRIGHT: 
- * Copyright (c) 1999-2011, International Business Machines Corporation and
+ * Copyright (c) 1999-2012, International Business Machines Corporation and
  * others. All Rights Reserved.
  ********************************************************************/
 
@@ -32,6 +32,7 @@
 #include "unicode/uloc.h"
 #include "unicode/locid.h"
 #include "putilimp.h"
+#include "intltest.h"
 
 #include <stdio.h>
 #include <string.h>
index a718fa5ff4efc897dd67dfa3e087774418d6ce87..cf3842431c8b78924c301f9e08e8438e3fb8e931 100644 (file)
@@ -1,6 +1,6 @@
 /********************************************************************
  * COPYRIGHT: 
- * Copyright (c) 1999-2011, International Business Machines Corporation and
+ * Copyright (c) 1999-2012, International Business Machines Corporation and
  * others. All Rights Reserved.
  ********************************************************************/
 
@@ -24,6 +24,8 @@
 #include "unicode/uloc.h"
 #include "unicode/locid.h"
 #include "putilimp.h"
+#include "intltest.h"
+#include "tsmthred.h"
 
 #if U_PLATFORM_USES_ONLY_WIN32_API
     /* Prefer native Windows APIs even if POSIX is implemented (i.e., on Cygwin). */
 #undef sleep
 #endif
 
-
-
-#include "tsmthred.h"
-
 #define TSMTHREAD_FAIL(msg) errln("%s at file %s, line %d", msg, __FILE__, __LINE__)
 #define TSMTHREAD_ASSERT(expr) {if (!(expr)) {TSMTHREAD_FAIL("Fail");}}