Home | History | Annotate | Download | only in common
      1 //  2016 and later: Unicode, Inc. and others.
      2 // License & terms of use: http://www.unicode.org/copyright.html
      3 /*
      4 ******************************************************************************
      5 * Copyright (C) 2001-2015, International Business Machines
      6 *                Corporation and others. All Rights Reserved.
      7 ******************************************************************************
      8 *   file name:  uinit.cpp
      9 *   encoding:   UTF-8
     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/icuplug.h"
     19 #include "unicode/uclean.h"
     20 #include "cmemory.h"
     21 #include "icuplugimp.h"
     22 #include "ucln_cmn.h"
     23 #include "ucnv_io.h"
     24 #include "umutex.h"
     25 #include "utracimp.h"
     26 
     27 U_NAMESPACE_BEGIN
     28 
     29 static UInitOnce gICUInitOnce = U_INITONCE_INITIALIZER;
     30 
     31 static UBool U_CALLCONV uinit_cleanup() {
     32     gICUInitOnce.reset();
     33     return TRUE;
     34 }
     35 
     36 static void U_CALLCONV
     37 initData(UErrorCode &status)
     38 {
     39 #if UCONFIG_ENABLE_PLUGINS
     40     /* initialize plugins */
     41     uplug_init(&status);
     42 #endif
     43 
     44 #if !UCONFIG_NO_CONVERSION
     45     /*
     46      * 2005-may-02
     47      *
     48      * ICU4C 3.4 (jitterbug 4497) hardcodes the data for Unicode character
     49      * properties for APIs that want to be fast.
     50      * Therefore, we need not load them here nor check for errors.
     51      * Instead, we load the converter alias table to see if any ICU data
     52      * is available.
     53      * Users should really open the service objects they need and check
     54      * for errors there, to make sure that the actual items they need are
     55      * available.
     56      */
     57     ucnv_io_countKnownConverters(&status);
     58 #endif
     59     ucln_common_registerCleanup(UCLN_COMMON_UINIT, uinit_cleanup);
     60 }
     61 
     62 U_NAMESPACE_END
     63 
     64 U_NAMESPACE_USE
     65 
     66 /*
     67  * ICU Initialization Function. Need not be called.
     68  */
     69 U_CAPI void U_EXPORT2
     70 u_init(UErrorCode *status) {
     71     UTRACE_ENTRY_OC(UTRACE_U_INIT);
     72     umtx_initOnce(gICUInitOnce, &initData, *status);
     73     UTRACE_EXIT_STATUS(*status);
     74 }
     75