- support of [Strings.LanguageID]-sections for inf-files added in setupapi
[reactos.git] / reactos / nls / 3rdparty / icu / source / common / uinit.c
1 /*
2 ******************************************************************************
3 * *
4 * Copyright (C) 2001-2007, International Business Machines *
5 * Corporation and others. All Rights Reserved. *
6 * *
7 ******************************************************************************
8 * file name: uinit.c
9 * encoding: US-ASCII
10 * tab size: 8 (not used)
11 * indentation:4
12 *
13 * created on: 2001July05
14 * created by: George Rhoten
15 */
16
17 #include "unicode/utypes.h"
18 #include "unicode/uclean.h"
19 #include "utracimp.h"
20 #include "ustr_imp.h"
21 #include "unormimp.h"
22 #include "ucln_cmn.h"
23 #include "ucnv_io.h"
24 #include "umutex.h"
25 #include "ucln.h"
26 #include "cmemory.h"
27 #include "uassert.h"
28
29 static UBool gICUInitialized = FALSE;
30 static UMTX gICUInitMutex = NULL;
31
32
33 /************************************************
34 The cleanup order is important in this function.
35 Please be sure that you have read ucln.h
36 ************************************************/
37 U_CAPI void U_EXPORT2
38 u_cleanup(void)
39 {
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. */
43
44 ucln_lib_cleanup();
45
46 umtx_destroy(&gICUInitMutex);
47 umtx_cleanup();
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*/
52 utrace_cleanup();
53 /*#endif*/
54 }
55
56 /*
57 *
58 * ICU Initialization Function. Force loading and/or initialization of
59 * any shared data that could potentially be used concurrently
60 * by multiple threads.
61 */
62 U_CAPI void U_EXPORT2
63 u_init(UErrorCode *status) {
64 UTRACE_ENTRY_OC(UTRACE_U_INIT);
65 /* Make sure the global mutexes are initialized. */
66 umtx_init(NULL);
67 umtx_lock(&gICUInitMutex);
68 if (gICUInitialized || U_FAILURE(*status)) {
69 umtx_unlock(&gICUInitMutex);
70 UTRACE_EXIT_STATUS(*status);
71 return;
72 }
73
74 #if 1
75 /*
76 * 2005-may-02
77 *
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
82 * is available.
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
85 * available.
86 */
87 #if !UCONFIG_NO_CONVERSION
88 ucnv_io_countKnownConverters(status);
89 #endif
90 #else
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).
95 */
96
97 /* Char Properties */
98 uprv_haveProperties(status);
99
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 */
103
104 #if !UCONFIG_NO_NORMALIZATION
105 /* Normalization */
106 unorm_haveData(status);
107 #endif
108 #endif
109 gICUInitialized = TRUE; /* TODO: don't set if U_FAILURE? */
110 umtx_unlock(&gICUInitMutex);
111 UTRACE_EXIT_STATUS(*status);
112 }
113