ICU-9010 remove --disable-threads, move ICU_USE_THREADS out of uconfig.h into test code

X-SVN-Rev: 31911
This commit is contained in:
Markus Scherer 2012-06-06 04:13:28 +00:00
parent 34e31825e5
commit 00dc45723c
10 changed files with 51 additions and 127 deletions

View 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 -->
@ -221,6 +221,15 @@
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>
@ -940,9 +949,6 @@
<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>

View 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.
*
******************************************************************************
@ -36,10 +36,10 @@
# 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
@ -85,18 +85,7 @@
*/
#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);

View 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. */

View 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.

View File

@ -81,25 +81,6 @@
#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.

View File

@ -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"

View 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"

View File

@ -15,6 +15,23 @@
#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

View 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>

View 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). */
@ -93,10 +95,6 @@
#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");}}