]> git.saurik.com Git - apple/icu.git/blame - icuSources/io/ucln_io.cpp
ICU-66108.tar.gz
[apple/icu.git] / icuSources / io / ucln_io.cpp
CommitLineData
f3c0d7a5
A
1// © 2016 and later: Unicode, Inc. and others.
2// License & terms of use: http://www.unicode.org/copyright.html
73c04bcf
A
3/*
4******************************************************************************
5* *
57a6839d 6* Copyright (C) 2001-2014, International Business Machines *
73c04bcf
A
7* Corporation and others. All Rights Reserved. *
8* *
9******************************************************************************
b331163b 10* file name: ucln_io.cpp
f3c0d7a5 11* encoding: UTF-8
73c04bcf
A
12* tab size: 8 (not used)
13* indentation:4
14*
15* created on: 2006August11
16* created by: George Rhoten
17*/
18
340931cb 19#include "unicode/utypes.h"
b331163b 20#include "mutex.h"
73c04bcf
A
21#include "ucln.h"
22#include "ucln_io.h"
73c04bcf
A
23#include "uassert.h"
24
4388f060
A
25#ifndef U_IO_IMPLEMENTATION
26#error U_IO_IMPLEMENTATION not set - must be set for all ICU source files in io/ - see http://userguide.icu-project.org/howtouseicu
27#endif
28
29
729e4ab9
A
30/** Auto-client */
31#define UCLN_TYPE UCLN_IO
32#include "ucln_imp.h"
33
73c04bcf
A
34/* Leave this copyright notice here! It needs to go somewhere in this library. */
35static const char copyright[] = U_COPYRIGHT_STRING;
36
37static cleanupFunc *gCleanupFunctions[UCLN_IO_COUNT];
38
f3c0d7a5 39static UBool U_CALLCONV io_cleanup(void)
73c04bcf 40{
b331163b 41 int32_t libType = UCLN_IO_START;
73c04bcf 42
57a6839d 43 (void)copyright; // Suppress unused variable warning.
73c04bcf
A
44 while (++libType<UCLN_IO_COUNT) {
45 if (gCleanupFunctions[libType])
46 {
47 gCleanupFunctions[libType]();
48 gCleanupFunctions[libType] = NULL;
49 }
50 }
729e4ab9
A
51#if !UCLN_NO_AUTO_CLEANUP && (defined(UCLN_AUTO_ATEXIT) || defined(UCLN_AUTO_LOCAL))
52 ucln_unRegisterAutomaticCleanup();
53#endif
73c04bcf
A
54 return TRUE;
55}
56
57void ucln_io_registerCleanup(ECleanupIOType type,
b331163b 58 cleanupFunc *func) {
73c04bcf 59 U_ASSERT(UCLN_IO_START < type && type < UCLN_IO_COUNT);
73c04bcf 60 {
b331163b
A
61 icu::Mutex m; // See ticket 10295 for discussion.
62 ucln_registerCleanup(UCLN_IO, io_cleanup);
63 if (UCLN_IO_START < type && type < UCLN_IO_COUNT) {
64 gCleanupFunctions[type] = func;
65 }
73c04bcf 66 }
729e4ab9
A
67
68#if !UCLN_NO_AUTO_CLEANUP && (defined(UCLN_AUTO_ATEXIT) || defined(UCLN_AUTO_LOCAL))
69 ucln_registerAutomaticCleanup();
70#endif
73c04bcf
A
71}
72