/* ****************************************************************************** * * * Copyright (C) 2001-2005, International Business Machines * * Corporation and others. All Rights Reserved. * * * ****************************************************************************** * file name: uinit.c * encoding: US-ASCII * tab size: 8 (not used) * indentation:4 * * created on: 2001July05 * created by: George Rhoten */ #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; } } /************************************************ The cleanup order is important in this function. Please be sure that you have read ucln.h ************************************************/ U_CAPI void U_EXPORT2 u_cleanup(void) { ECleanupLibraryType libType; UTRACE_ENTRY_OC(UTRACE_U_CLEANUP); umtx_lock(NULL); /* Force a memory barrier, so that we are sure to see */ umtx_unlock(NULL); /* all state left around by any other threads. */ for (libType = UCLN_START+1; libType