intl/icu/source/common/unicode/uclean.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /*
michael@0 2 ******************************************************************************
michael@0 3 * Copyright (C) 2001-2013, International Business Machines
michael@0 4 * Corporation and others. All Rights Reserved.
michael@0 5 ******************************************************************************
michael@0 6 * file name: uclean.h
michael@0 7 * encoding: US-ASCII
michael@0 8 * tab size: 8 (not used)
michael@0 9 * indentation:4
michael@0 10 *
michael@0 11 * created on: 2001July05
michael@0 12 * created by: George Rhoten
michael@0 13 */
michael@0 14
michael@0 15 #ifndef __UCLEAN_H__
michael@0 16 #define __UCLEAN_H__
michael@0 17
michael@0 18 #include "unicode/utypes.h"
michael@0 19 /**
michael@0 20 * \file
michael@0 21 * \brief C API: Initialize and clean up ICU
michael@0 22 */
michael@0 23
michael@0 24 /**
michael@0 25 * Initialize ICU.
michael@0 26 *
michael@0 27 * Use of this function is optional. It is OK to simply use ICU
michael@0 28 * services and functions without first having initialized
michael@0 29 * ICU by calling u_init().
michael@0 30 *
michael@0 31 * u_init() will attempt to load some part of ICU's data, and is
michael@0 32 * useful as a test for configuration or installation problems that
michael@0 33 * leave the ICU data inaccessible. A successful invocation of u_init()
michael@0 34 * does not, however, guarantee that all ICU data is accessible.
michael@0 35 *
michael@0 36 * Multiple calls to u_init() cause no harm, aside from the small amount
michael@0 37 * of time required.
michael@0 38 *
michael@0 39 * In old versions of ICU, u_init() was required in multi-threaded applications
michael@0 40 * to ensure the thread safety of ICU. u_init() is no longer needed for this purpose.
michael@0 41 *
michael@0 42 * @param status An ICU UErrorCode parameter. It must not be <code>NULL</code>.
michael@0 43 * An Error will be returned if some required part of ICU data can not
michael@0 44 * be loaded or initialized.
michael@0 45 * The function returns immediately if the input error code indicates a
michael@0 46 * failure, as usual.
michael@0 47 *
michael@0 48 * @stable ICU 2.6
michael@0 49 */
michael@0 50 U_STABLE void U_EXPORT2
michael@0 51 u_init(UErrorCode *status);
michael@0 52
michael@0 53 #ifndef U_HIDE_SYSTEM_API
michael@0 54 /**
michael@0 55 * Clean up the system resources, such as allocated memory or open files,
michael@0 56 * used in all ICU libraries. This will free/delete all memory owned by the
michael@0 57 * ICU libraries, and return them to their original load state. All open ICU
michael@0 58 * items (collators, resource bundles, converters, etc.) must be closed before
michael@0 59 * calling this function, otherwise ICU may not free its allocated memory
michael@0 60 * (e.g. close your converters and resource bundles before calling this
michael@0 61 * function). Generally, this function should be called once just before
michael@0 62 * an application exits. For applications that dynamically load and unload
michael@0 63 * the ICU libraries (relatively uncommon), u_cleanup() should be called
michael@0 64 * just before the library unload.
michael@0 65 * <p>
michael@0 66 * u_cleanup() also clears any ICU heap functions, mutex functions or
michael@0 67 * trace functions that may have been set for the process.
michael@0 68 * This has the effect of restoring ICU to its initial condition, before
michael@0 69 * any of these override functions were installed. Refer to
michael@0 70 * u_setMemoryFunctions(), u_setMutexFunctions and
michael@0 71 * utrace_setFunctions(). If ICU is to be reinitialized after after
michael@0 72 * calling u_cleanup(), these runtime override functions will need to
michael@0 73 * be set up again if they are still required.
michael@0 74 * <p>
michael@0 75 * u_cleanup() is not thread safe. All other threads should stop using ICU
michael@0 76 * before calling this function.
michael@0 77 * <p>
michael@0 78 * Any open ICU items will be left in an undefined state by u_cleanup(),
michael@0 79 * and any subsequent attempt to use such an item will give unpredictable
michael@0 80 * results.
michael@0 81 * <p>
michael@0 82 * After calling u_cleanup(), an application may continue to use ICU by
michael@0 83 * calling u_init(). An application must invoke u_init() first from one single
michael@0 84 * thread before allowing other threads call u_init(). All threads existing
michael@0 85 * at the time of the first thread's call to u_init() must also call
michael@0 86 * u_init() themselves before continuing with other ICU operations.
michael@0 87 * <p>
michael@0 88 * The use of u_cleanup() just before an application terminates is optional,
michael@0 89 * but it should be called only once for performance reasons. The primary
michael@0 90 * benefit is to eliminate reports of memory or resource leaks originating
michael@0 91 * in ICU code from the results generated by heap analysis tools.
michael@0 92 * <p>
michael@0 93 * <strong>Use this function with great care!</strong>
michael@0 94 * </p>
michael@0 95 *
michael@0 96 * @stable ICU 2.0
michael@0 97 * @system
michael@0 98 */
michael@0 99 U_STABLE void U_EXPORT2
michael@0 100 u_cleanup(void);
michael@0 101
michael@0 102
michael@0 103 /**
michael@0 104 * Pointer type for a user supplied memory allocation function.
michael@0 105 * @param context user supplied value, obtained from from u_setMemoryFunctions().
michael@0 106 * @param size The number of bytes to be allocated
michael@0 107 * @return Pointer to the newly allocated memory, or NULL if the allocation failed.
michael@0 108 * @stable ICU 2.8
michael@0 109 * @system
michael@0 110 */
michael@0 111 typedef void *U_CALLCONV UMemAllocFn(const void *context, size_t size);
michael@0 112 /**
michael@0 113 * Pointer type for a user supplied memory re-allocation function.
michael@0 114 * @param context user supplied value, obtained from from u_setMemoryFunctions().
michael@0 115 * @param size The number of bytes to be allocated
michael@0 116 * @return Pointer to the newly allocated memory, or NULL if the allocation failed.
michael@0 117 * @stable ICU 2.8
michael@0 118 * @system
michael@0 119 */
michael@0 120 typedef void *U_CALLCONV UMemReallocFn(const void *context, void *mem, size_t size);
michael@0 121 /**
michael@0 122 * Pointer type for a user supplied memory free function. Behavior should be
michael@0 123 * similar the standard C library free().
michael@0 124 * @param context user supplied value, obtained from from u_setMemoryFunctions().
michael@0 125 * @param mem Pointer to the memory block to be resized
michael@0 126 * @param size The new size for the block
michael@0 127 * @return Pointer to the resized memory block, or NULL if the resizing failed.
michael@0 128 * @stable ICU 2.8
michael@0 129 * @system
michael@0 130 */
michael@0 131 typedef void U_CALLCONV UMemFreeFn (const void *context, void *mem);
michael@0 132
michael@0 133 /**
michael@0 134 * Set the functions that ICU will use for memory allocation.
michael@0 135 * Use of this function is optional; by default (without this function), ICU will
michael@0 136 * use the standard C library malloc() and free() functions.
michael@0 137 * This function can only be used when ICU is in an initial, unused state, before
michael@0 138 * u_init() has been called.
michael@0 139 * @param context This pointer value will be saved, and then (later) passed as
michael@0 140 * a parameter to the memory functions each time they
michael@0 141 * are called.
michael@0 142 * @param a Pointer to a user-supplied malloc function.
michael@0 143 * @param r Pointer to a user-supplied realloc function.
michael@0 144 * @param f Pointer to a user-supplied free function.
michael@0 145 * @param status Receives error values.
michael@0 146 * @stable ICU 2.8
michael@0 147 * @system
michael@0 148 */
michael@0 149 U_STABLE void U_EXPORT2
michael@0 150 u_setMemoryFunctions(const void *context, UMemAllocFn *a, UMemReallocFn *r, UMemFreeFn *f,
michael@0 151 UErrorCode *status);
michael@0 152
michael@0 153
michael@0 154 /*********************************************************************************
michael@0 155 *
michael@0 156 * Deprecated Functions
michael@0 157 *
michael@0 158 * The following functions for user supplied mutexes are no longer supported.
michael@0 159 * Any attempt to use them will return a U_UNSUPPORTED_ERROR.
michael@0 160 *
michael@0 161 **********************************************************************************/
michael@0 162
michael@0 163 /**
michael@0 164 * An opaque pointer type that represents an ICU mutex.
michael@0 165 * For user-implemented mutexes, the value will typically point to a
michael@0 166 * struct or object that implements the mutex.
michael@0 167 * @deprecated ICU 52. This type is no longer supported.
michael@0 168 * @system
michael@0 169 */
michael@0 170 typedef void *UMTX;
michael@0 171
michael@0 172 /**
michael@0 173 * Function Pointer type for a user supplied mutex initialization function.
michael@0 174 * The user-supplied function will be called by ICU whenever ICU needs to create a
michael@0 175 * new mutex. The function implementation should create a mutex, and store a pointer
michael@0 176 * to something that uniquely identifies the mutex into the UMTX that is supplied
michael@0 177 * as a paramter.
michael@0 178 * @param context user supplied value, obtained from from u_setMutexFunctions().
michael@0 179 * @param mutex Receives a pointer that identifies the new mutex.
michael@0 180 * The mutex init function must set the UMTX to a non-null value.
michael@0 181 * Subsequent calls by ICU to lock, unlock, or destroy a mutex will
michael@0 182 * identify the mutex by the UMTX value.
michael@0 183 * @param status Error status. Report errors back to ICU by setting this variable
michael@0 184 * with an error code.
michael@0 185 * @deprecated ICU 52. This function is no longer supported.
michael@0 186 * @system
michael@0 187 */
michael@0 188 typedef void U_CALLCONV UMtxInitFn (const void *context, UMTX *mutex, UErrorCode* status);
michael@0 189
michael@0 190
michael@0 191 /**
michael@0 192 * Function Pointer type for a user supplied mutex functions.
michael@0 193 * One of the user-supplied functions with this signature will be called by ICU
michael@0 194 * whenever ICU needs to lock, unlock, or destroy a mutex.
michael@0 195 * @param context user supplied value, obtained from from u_setMutexFunctions().
michael@0 196 * @param mutex specify the mutex on which to operate.
michael@0 197 * @deprecated ICU 52. This function is no longer supported.
michael@0 198 * @system
michael@0 199 */
michael@0 200 typedef void U_CALLCONV UMtxFn (const void *context, UMTX *mutex);
michael@0 201
michael@0 202
michael@0 203 /**
michael@0 204 * Set the functions that ICU will use for mutex operations
michael@0 205 * Use of this function is optional; by default (without this function), ICU will
michael@0 206 * directly access system functions for mutex operations
michael@0 207 * This function can only be used when ICU is in an initial, unused state, before
michael@0 208 * u_init() has been called.
michael@0 209 * @param context This pointer value will be saved, and then (later) passed as
michael@0 210 * a parameter to the user-supplied mutex functions each time they
michael@0 211 * are called.
michael@0 212 * @param init Pointer to a mutex initialization function. Must be non-null.
michael@0 213 * @param destroy Pointer to the mutex destroy function. Must be non-null.
michael@0 214 * @param lock pointer to the mutex lock function. Must be non-null.
michael@0 215 * @param unlock Pointer to the mutex unlock function. Must be non-null.
michael@0 216 * @param status Receives error values.
michael@0 217 * @deprecated ICU 52. This function is no longer supported.
michael@0 218 * @system
michael@0 219 */
michael@0 220 U_DEPRECATED void U_EXPORT2
michael@0 221 u_setMutexFunctions(const void *context, UMtxInitFn *init, UMtxFn *destroy, UMtxFn *lock, UMtxFn *unlock,
michael@0 222 UErrorCode *status);
michael@0 223
michael@0 224
michael@0 225 /**
michael@0 226 * Pointer type for a user supplied atomic increment or decrement function.
michael@0 227 * @param context user supplied value, obtained from from u_setAtomicIncDecFunctions().
michael@0 228 * @param p Pointer to a 32 bit int to be incremented or decremented
michael@0 229 * @return The value of the variable after the inc or dec operation.
michael@0 230 * @deprecated ICU 52. This function is no longer supported.
michael@0 231 * @system
michael@0 232 */
michael@0 233 typedef int32_t U_CALLCONV UMtxAtomicFn(const void *context, int32_t *p);
michael@0 234
michael@0 235 /**
michael@0 236 * Set the functions that ICU will use for atomic increment and decrement of int32_t values.
michael@0 237 * Use of this function is optional; by default (without this function), ICU will
michael@0 238 * use its own internal implementation of atomic increment/decrement.
michael@0 239 * This function can only be used when ICU is in an initial, unused state, before
michael@0 240 * u_init() has been called.
michael@0 241 * @param context This pointer value will be saved, and then (later) passed as
michael@0 242 * a parameter to the increment and decrement functions each time they
michael@0 243 * are called. This function can only be called
michael@0 244 * @param inc Pointer to a function to do an atomic increment operation. Must be non-null.
michael@0 245 * @param dec Pointer to a function to do an atomic decrement operation. Must be non-null.
michael@0 246 * @param status Receives error values.
michael@0 247 * @deprecated ICU 52. This function is no longer supported.
michael@0 248 * @system
michael@0 249 */
michael@0 250 U_DEPRECATED void U_EXPORT2
michael@0 251 u_setAtomicIncDecFunctions(const void *context, UMtxAtomicFn *inc, UMtxAtomicFn *dec,
michael@0 252 UErrorCode *status);
michael@0 253
michael@0 254 #endif /* U_HIDE_SYSTEM_API */
michael@0 255
michael@0 256 #endif

mercurial