]>
git.saurik.com Git - apple/icu.git/blob - icuSources/common/uinit.c
2 ******************************************************************************
4 * Copyright (C) 2001-2007, International Business Machines *
5 * Corporation and others. All Rights Reserved. *
7 ******************************************************************************
10 * tab size: 8 (not used)
13 * created on: 2001July05
14 * created by: George Rhoten
17 #include "unicode/utypes.h"
18 #include "unicode/uclean.h"
29 static UBool gICUInitialized
= FALSE
;
30 static UMTX gICUInitMutex
= NULL
;
33 /************************************************
34 The cleanup order is important in this function.
35 Please be sure that you have read ucln.h
36 ************************************************/
40 UTRACE_ENTRY_OC(UTRACE_U_CLEANUP
);
41 umtx_lock(NULL
); /* Force a memory barrier, so that we are sure to see */
42 umtx_unlock(NULL
); /* all state left around by any other threads. */
46 umtx_destroy(&gICUInitMutex
);
48 cmemory_cleanup(); /* undo any heap functions set by u_setMemoryFunctions(). */
49 gICUInitialized
= FALSE
;
50 UTRACE_EXIT(); /* Must be before utrace_cleanup(), which turns off tracing. */
51 /*#if U_ENABLE_TRACING*/
58 * ICU Initialization Function. Force loading and/or initialization of
59 * any shared data that could potentially be used concurrently
60 * by multiple threads.
63 u_init(UErrorCode
*status
) {
64 UTRACE_ENTRY_OC(UTRACE_U_INIT
);
65 /* Make sure the global mutexes are initialized. */
67 umtx_lock(&gICUInitMutex
);
68 if (gICUInitialized
|| U_FAILURE(*status
)) {
69 umtx_unlock(&gICUInitMutex
);
70 UTRACE_EXIT_STATUS(*status
);
78 * ICU4C 3.4 (jitterbug 4497) hardcodes the data for Unicode character
79 * properties for APIs that want to be fast.
80 * Therefore, we need not load them here nor check for errors.
81 * Instead, we load the converter alias table to see if any ICU data
83 * Users should really open the service objects they need and check
84 * for errors there, to make sure that the actual items they need are
87 #if !UCONFIG_NO_CONVERSION
88 ucnv_io_countKnownConverters(status
);
91 /* Do any required init for services that don't have open operations
92 * and use "only" the double-check initialization method for performance
93 * reasons (avoiding a mutex lock even for _checking_ whether the
94 * initialization had occurred).
98 uprv_haveProperties(status
);
100 /* load the case and bidi properties but don't fail if they are not available */
101 u_isULowercase(0x61);
102 u_getIntPropertyValue(0x200D, UCHAR_JOINING_TYPE
); /* ZERO WIDTH JOINER: Join_Causing */
104 #if !UCONFIG_NO_NORMALIZATION
106 unorm_haveData(status
);
109 gICUInitialized
= TRUE
; /* TODO: don't set if U_FAILURE? */
110 umtx_unlock(&gICUInitMutex
);
111 UTRACE_EXIT_STATUS(*status
);