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