#include "unicode/utypes.h"
#include "unicode/uclean.h"
#include "utracimp.h"
#include "ustr_imp.h"
#include "unormimp.h"
#include "ucln_cmn.h"
#include "umutex.h"
#include "ucln.h"
#include "cmemory.h"
#include "uassert.h"
static UBool gICUInitialized = FALSE;
static UMTX gICUInitMutex = NULL;
static cleanupFunc *gLibCleanupFunctions[UCLN_COMMON];
U_CAPI void U_EXPORT2
ucln_registerCleanup(ECleanupLibraryType type,
cleanupFunc *func)
{
U_ASSERT(UCLN_START < type && type < UCLN_COMMON);
if (UCLN_START < type && type < UCLN_COMMON)
{
gLibCleanupFunctions[type] = func;
}
}
U_CAPI void U_EXPORT2
u_cleanup(void)
{
ECleanupLibraryType libType;
UTRACE_ENTRY_OC(UTRACE_U_CLEANUP);
umtx_lock(NULL);
umtx_unlock(NULL);
for (libType = UCLN_START+1; libType<UCLN_COMMON; libType++) {
if (gLibCleanupFunctions[libType])
{
gLibCleanupFunctions[libType]();
gLibCleanupFunctions[libType] = NULL;
}
}
ucln_common_lib_cleanup();
umtx_destroy(&gICUInitMutex);
umtx_cleanup();
cmemory_cleanup();
gICUInitialized = FALSE;
UTRACE_EXIT();
utrace_cleanup();
}
U_CAPI void U_EXPORT2
u_init(UErrorCode *status) {
UTRACE_ENTRY_OC(UTRACE_U_INIT);
umtx_init(NULL);
umtx_lock(&gICUInitMutex);
if (gICUInitialized || U_FAILURE(*status)) {
umtx_unlock(&gICUInitMutex);
UTRACE_EXIT_STATUS(*status);
return;
}
uprv_loadPropsData(status);
#if !UCONFIG_NO_NORMALIZATION
unorm_haveData(status);
#endif
gICUInitialized = TRUE;
umtx_unlock(&gICUInitMutex);
UTRACE_EXIT_STATUS(*status);
}