uinit.cpp 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. #include "unicode/utypes.h"
  17. #include "unicode/icuplug.h"
  18. #include "unicode/uclean.h"
  19. #include "cmemory.h"
  20. #include "icuplugimp.h"
  21. #include "ucln_cmn.h"
  22. #include "ucnv_io.h"
  23. #include "umutex.h"
  24. #include "utracimp.h"
  25. U_NAMESPACE_BEGIN
  26. static UInitOnce gICUInitOnce {};
  27. static UBool U_CALLCONV uinit_cleanup() {
  28. gICUInitOnce.reset();
  29. return true;
  30. }
  31. static void U_CALLCONV
  32. initData(UErrorCode &status)
  33. {
  34. #if UCONFIG_ENABLE_PLUGINS
  35. /* initialize plugins */
  36. uplug_init(&status);
  37. #endif
  38. #if !UCONFIG_NO_CONVERSION
  39. /*
  40. * 2005-may-02
  41. *
  42. * ICU4C 3.4 (jitterbug 4497) hardcodes the data for Unicode character
  43. * properties for APIs that want to be fast.
  44. * Therefore, we need not load them here nor check for errors.
  45. * Instead, we load the converter alias table to see if any ICU data
  46. * is available.
  47. * Users should really open the service objects they need and check
  48. * for errors there, to make sure that the actual items they need are
  49. * available.
  50. */
  51. ucnv_io_countKnownConverters(&status);
  52. #endif
  53. ucln_common_registerCleanup(UCLN_COMMON_UINIT, uinit_cleanup);
  54. }
  55. U_NAMESPACE_END
  56. U_NAMESPACE_USE
  57. /*
  58. * ICU Initialization Function. Need not be called.
  59. */
  60. U_CAPI void U_EXPORT2
  61. u_init(UErrorCode *status) {
  62. UTRACE_ENTRY_OC(UTRACE_U_INIT);
  63. umtx_initOnce(gICUInitOnce, &initData, *status);
  64. UTRACE_EXIT_STATUS(*status);
  65. }