diff --git a/icu4c/source/common/brkiter.cpp b/icu4c/source/common/brkiter.cpp index 9e6ee4d545f..3cbfbf9d694 100644 --- a/icu4c/source/common/brkiter.cpp +++ b/icu4c/source/common/brkiter.cpp @@ -1,6 +1,6 @@ /* ******************************************************************************* -* Copyright (C) 1997-2008, International Business Machines Corporation and * +* Copyright (C) 1997-2009, International Business Machines Corporation and * * others. All Rights Reserved. * ******************************************************************************* * @@ -378,7 +378,6 @@ BreakIterator::createInstance(const Locale& loc, int32_t kind, UErrorCode& statu return NULL; } - u_init(&status); #if !UCONFIG_NO_SERVICE if (hasService()) { Locale actualLoc(""); diff --git a/icu4c/source/common/ucase.c b/icu4c/source/common/ucase.c index 8f27a4ce108..88c9d3bccea 100644 --- a/icu4c/source/common/ucase.c +++ b/icu4c/source/common/ucase.c @@ -1523,6 +1523,10 @@ getCaseProps() { * do not have a service object and also do not have an error code parameter. * Other API implementations get the singleton themselves * (with mutexing), store it in the service object, and report errors. + * + * TODO: Remove this support for non-hardcoded data. u_init() is publicly + * advertised as not being required for thread safety, we cannot + * revert to unsafe data loading. */ #if !UCASE_HARDCODE_DATA #define GET_CASE_PROPS() (gCsp!=NULL ? gCsp : getCaseProps()) diff --git a/icu4c/source/common/uinit.c b/icu4c/source/common/uinit.c index 98dc1b9f310..6e3a14827c6 100644 --- a/icu4c/source/common/uinit.c +++ b/icu4c/source/common/uinit.c @@ -92,6 +92,11 @@ u_init(UErrorCode *status) { * initialization had occurred). */ + /* TODO: Completely remove this section. u_init() is now publicly being + * advertised as never being required for thread safety, and we cannot + * bring back this requirement. + */ + /* Char Properties */ uprv_haveProperties(status); diff --git a/icu4c/source/common/umutex.c b/icu4c/source/common/umutex.c index 23eca46a600..4d8079d87d4 100644 --- a/icu4c/source/common/umutex.c +++ b/icu4c/source/common/umutex.c @@ -1,7 +1,7 @@ /* ****************************************************************************** * -* Copyright (C) 1997-2008, International Business Machines +* Copyright (C) 1997-2009, International Business Machines * Corporation and others. All Rights Reserved. * ****************************************************************************** @@ -504,8 +504,8 @@ u_setMutexFunctions(const void *context, UMtxInitFn *i, UMtxFn *d, UMtxFn *l, UM pMutexUnlockFn = u; gMutexContext = context; gGlobalMutex = NULL; /* For POSIX, the global mutex will be pre-initialized */ - /* Undo that, force re-initialization when u_init() */ - /* happens. */ + /* Undo that, force re-initialization on first use */ + /* of the global mutex. */ } diff --git a/icu4c/source/common/unicode/uclean.h b/icu4c/source/common/unicode/uclean.h index a13924a0c3f..de6d73637da 100644 --- a/icu4c/source/common/unicode/uclean.h +++ b/icu4c/source/common/unicode/uclean.h @@ -1,7 +1,7 @@ /* ****************************************************************************** * * -* Copyright (C) 2001-2005, International Business Machines * +* Copyright (C) 2001-2009, International Business Machines * * Corporation and others. All Rights Reserved. * * * ****************************************************************************** @@ -24,38 +24,22 @@ */ /** - * Initialize ICU. The description further below applies to ICU 2.6 to ICU 3.4. - * Starting with ICU 3.4, u_init() needs not be called any more for - * ensuring thread safety, but it can give an indication for whether ICU - * can load its data. In ICU 3.4, it will try to load the converter alias table - * (cnvalias.icu) and give an error code if that fails. - * This may change in the future. - *
- * For ensuring the availability of necessary data, an application should - * open the service objects (converters, collators, etc.) that it will use - * and check for error codes there. - *
- * Documentation for ICU 2.6 to ICU 3.4: - *
- * This function loads and initializes data items - * that are required internally by various ICU functions. Use of this explicit - * initialization is required in multi-threaded applications; in - * single threaded apps, use is optional, but incurs little additional - * cost, and is thus recommended. - *
- * In multi-threaded applications, u_init() should be called in the - * main thread before starting additional threads, or, alternatively - * it can be called in each individual thread once, before other ICU - * functions are called in that thread. In this second scenario, the - * application must guarantee that the first call to u_init() happen - * without contention, in a single thread only. - *
- * If u_setMemoryFunctions()
or
- * u_setMutexFunctions
are needed (uncommon), they must be
- * called _before_ u_init()
.
- *
- * Extra, repeated, or otherwise unneeded calls to u_init() do no harm,
- * other than taking a small amount of time.
+ * Initialize ICU.
+ *
+ * Use of this function is optional. It is OK to simply use ICU
+ * services and functions without first having initialized
+ * ICU by calling u_init().
+ *
+ * u_init() will attempt to load some part of ICU's data, and is
+ * useful as a test for configuration or installation problems that
+ * leave the ICU data inaccessible. A successful invocation of u_init()
+ * does not, however, guarantee that all ICU data is accessible.
+ *
+ * Multiple calls to u_init() cause no harm, aside from the small amount
+ * of time required.
+ *
+ * In old versions of ICU, u_init() was required in multi-threaded applications
+ * to ensure the thread safety of ICU. u_init() is no longer needed for this purpose.
*
* @param status An ICU UErrorCode parameter. It must not be NULL
.
* An Error will be returned if some required part of ICU data can not
diff --git a/icu4c/source/common/unicode/udata.h b/icu4c/source/common/unicode/udata.h
index 84046d5f9cd..69da7ced626 100644
--- a/icu4c/source/common/unicode/udata.h
+++ b/icu4c/source/common/unicode/udata.h
@@ -1,7 +1,7 @@
/*
******************************************************************************
*
-* Copyright (C) 1999-2008, International Business Machines
+* Copyright (C) 1999-2009, International Business Machines
* Corporation and others. All Rights Reserved.
*
******************************************************************************
@@ -373,8 +373,8 @@ typedef enum UDataFileAccess {
/**
* This function may be called to control how ICU loads data. It must be called
- * before any ICU data is loaded, including application data loaded with ures/ResourceBundle or
- * udata APIs. It should be called before u_init. This function is not multithread safe.
+ * before any ICU data is loaded, including application data loaded with
+ * ures/ResourceBundle or udata APIs. This function is not multithread safe.
* The results of calling it while other threads are loading data are undefined.
* @param access The type of file access to be used
* @param status Error code.
diff --git a/icu4c/source/common/unorm.cpp b/icu4c/source/common/unorm.cpp
index 20f81e0b10d..120c3c18c7d 100644
--- a/icu4c/source/common/unorm.cpp
+++ b/icu4c/source/common/unorm.cpp
@@ -1,6 +1,6 @@
/*
******************************************************************************
-* Copyright (c) 1996-2008, International Business Machines
+* Copyright (c) 1996-2009, International Business Machines
* Corporation and others. All Rights Reserved.
******************************************************************************
* File unorm.cpp
@@ -290,6 +290,10 @@ loadNormData(UErrorCode &errorCode) {
* - they are not usually used in execution paths that are
* as performance-sensitive as others
* (e.g., IDNA takes more time than unorm_quickCheck() anyway)
+ *
+ * TODO: Remove code in support for non-hardcoded data. u_init() is now advertised
+ * as not being required for thread safety, and we can't reasonably
+ * revert to requiring it.
*/
if(haveNormData==0) {
UTrie _normTrie={ 0,0,0,0,0,0,0 }, _fcdTrie={ 0,0,0,0,0,0,0 }, _auxTrie={ 0,0,0,0,0,0,0 };
diff --git a/icu4c/source/common/ustr_imp.h b/icu4c/source/common/ustr_imp.h
index 25d93da1d33..7d4d95097df 100644
--- a/icu4c/source/common/ustr_imp.h
+++ b/icu4c/source/common/ustr_imp.h
@@ -1,6 +1,6 @@
/*
**********************************************************************
-* Copyright (C) 1999-2008, International Business Machines
+* Copyright (C) 1999-2009, International Business Machines
* Corporation and others. All Rights Reserved.
**********************************************************************
* file name: ustr_imp.h
@@ -53,8 +53,7 @@ u_strcmpFold(const UChar *s1, int32_t length1,
* Are the Unicode properties loaded?
* This must be used before internal functions are called that do
* not perform this check.
- * Generate a debug assertion failure if data is not loaded, to flag the fact
- * that u_init() wasn't called first, before trying to access character properties.
+ * Generate a debug assertion failure if data is not loaded.
* @internal
*/
U_CFUNC UBool
diff --git a/icu4c/source/i18n/repattrn.cpp b/icu4c/source/i18n/repattrn.cpp
index 49478849cf3..bd4518cfe1e 100644
--- a/icu4c/source/i18n/repattrn.cpp
+++ b/icu4c/source/i18n/repattrn.cpp
@@ -3,7 +3,7 @@
//
/*
***************************************************************************
-* Copyright (C) 2002-2008 International Business Machines Corporation *
+* Copyright (C) 2002-2009 International Business Machines Corporation *
* and others. All rights reserved. *
***************************************************************************
*/
@@ -30,8 +30,8 @@ U_NAMESPACE_BEGIN
//--------------------------------------------------------------------------
RegexPattern::RegexPattern() {
UErrorCode status = U_ZERO_ERROR;
- u_init(&status);
- // Init all of this instances data.
+
+ // Init all of this instance's data.
init();
// Lazy init of all shared global sets.
diff --git a/icu4c/source/i18n/ucol_res.cpp b/icu4c/source/i18n/ucol_res.cpp
index 6b2f677f6a6..4b51039790b 100644
--- a/icu4c/source/i18n/ucol_res.cpp
+++ b/icu4c/source/i18n/ucol_res.cpp
@@ -329,7 +329,6 @@ ucol_open(const char *loc,
UTRACE_DATA1(UTRACE_INFO, "locale = \"%s\"", loc);
UCollator *result = NULL;
- u_init(status);
#if !UCONFIG_NO_SERVICE
result = Collator::createUCollator(loc, status);
if (result == NULL)
@@ -357,11 +356,6 @@ ucol_openRules( const UChar *rules,
return 0;
}
- u_init(status);
- if (U_FAILURE(*status)) {
- return NULL;
- }
-
if(rules == NULL || rulesLength < -1) {
*status = U_ILLEGAL_ARGUMENT_ERROR;
return 0;