]>
git.saurik.com Git - apple/icu.git/blob - icuSources/common/uinit.c
2 ******************************************************************************
4 * Copyright (C) 2001-2010, 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/icuplug.h"
19 #include "unicode/uclean.h"
21 #include "icuplugimp.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*/
57 * ICU Initialization Function. Need not be called.
60 u_init(UErrorCode
*status
) {
61 UTRACE_ENTRY_OC(UTRACE_U_INIT
);
62 /* initialize plugins */
65 umtx_lock(&gICUInitMutex
);
66 if (gICUInitialized
|| U_FAILURE(*status
)) {
67 umtx_unlock(&gICUInitMutex
);
68 UTRACE_EXIT_STATUS(*status
);
75 * ICU4C 3.4 (jitterbug 4497) hardcodes the data for Unicode character
76 * properties for APIs that want to be fast.
77 * Therefore, we need not load them here nor check for errors.
78 * Instead, we load the converter alias table to see if any ICU data
80 * Users should really open the service objects they need and check
81 * for errors there, to make sure that the actual items they need are
84 #if !UCONFIG_NO_CONVERSION
85 ucnv_io_countKnownConverters(status
);
88 gICUInitialized
= TRUE
; /* TODO: don't set if U_FAILURE? */
89 umtx_unlock(&gICUInitMutex
);
90 UTRACE_EXIT_STATUS(*status
);