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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/intl/icu/source/common/unicode/uclean.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,256 @@
     1.4 +/*
     1.5 +******************************************************************************
     1.6 +* Copyright (C) 2001-2013, International Business Machines
     1.7 +*                Corporation and others. All Rights Reserved.
     1.8 +******************************************************************************
     1.9 +*   file name:  uclean.h
    1.10 +*   encoding:   US-ASCII
    1.11 +*   tab size:   8 (not used)
    1.12 +*   indentation:4
    1.13 +*
    1.14 +*   created on: 2001July05
    1.15 +*   created by: George Rhoten
    1.16 +*/
    1.17 +
    1.18 +#ifndef __UCLEAN_H__
    1.19 +#define __UCLEAN_H__
    1.20 +
    1.21 +#include "unicode/utypes.h"
    1.22 +/**
    1.23 + * \file
    1.24 + * \brief C API: Initialize and clean up ICU
    1.25 + */
    1.26 + 
    1.27 +/**
    1.28 + *  Initialize ICU.
    1.29 + *
    1.30 + *  Use of this function is optional.  It is OK to simply use ICU
    1.31 + *  services and functions without first having initialized
    1.32 + *  ICU by calling u_init().
    1.33 + *
    1.34 + *  u_init() will attempt to load some part of ICU's data, and is
    1.35 + *  useful as a test for configuration or installation problems that
    1.36 + *  leave the ICU data inaccessible.  A successful invocation of u_init()
    1.37 + *  does not, however, guarantee that all ICU data is accessible.
    1.38 + *
    1.39 + *  Multiple calls to u_init() cause no harm, aside from the small amount
    1.40 + *  of time required.
    1.41 + *
    1.42 + *  In old versions of ICU, u_init() was required in multi-threaded applications
    1.43 + *  to ensure the thread safety of ICU.  u_init() is no longer needed for this purpose.
    1.44 + *
    1.45 + * @param status An ICU UErrorCode parameter. It must not be <code>NULL</code>.
    1.46 + *    An Error will be returned if some required part of ICU data can not
    1.47 + *    be loaded or initialized.
    1.48 + *    The function returns immediately if the input error code indicates a
    1.49 + *    failure, as usual.
    1.50 + *
    1.51 + * @stable ICU 2.6
    1.52 + */  
    1.53 +U_STABLE void U_EXPORT2 
    1.54 +u_init(UErrorCode *status);
    1.55 +
    1.56 +#ifndef U_HIDE_SYSTEM_API
    1.57 +/**
    1.58 + * Clean up the system resources, such as allocated memory or open files,
    1.59 + * used in all ICU libraries. This will free/delete all memory owned by the
    1.60 + * ICU libraries, and return them to their original load state. All open ICU
    1.61 + * items (collators, resource bundles, converters, etc.) must be closed before
    1.62 + * calling this function, otherwise ICU may not free its allocated memory
    1.63 + * (e.g. close your converters and resource bundles before calling this
    1.64 + * function). Generally, this function should be called once just before
    1.65 + * an application exits. For applications that dynamically load and unload
    1.66 + * the ICU libraries (relatively uncommon), u_cleanup() should be called
    1.67 + * just before the library unload.
    1.68 + * <p>
    1.69 + * u_cleanup() also clears any ICU heap functions, mutex functions or
    1.70 + * trace functions that may have been set for the process.  
    1.71 + * This has the effect of restoring ICU to its initial condition, before
    1.72 + * any of these override functions were installed.  Refer to
    1.73 + * u_setMemoryFunctions(), u_setMutexFunctions and 
    1.74 + * utrace_setFunctions().  If ICU is to be reinitialized after after
    1.75 + * calling u_cleanup(), these runtime override functions will need to
    1.76 + * be set up again if they are still required.
    1.77 + * <p>
    1.78 + * u_cleanup() is not thread safe.  All other threads should stop using ICU
    1.79 + * before calling this function.
    1.80 + * <p>
    1.81 + * Any open ICU items will be left in an undefined state by u_cleanup(),
    1.82 + * and any subsequent attempt to use such an item will give unpredictable
    1.83 + * results.
    1.84 + * <p>
    1.85 + * After calling u_cleanup(), an application may continue to use ICU by
    1.86 + * calling u_init().  An application must invoke u_init() first from one single
    1.87 + * thread before allowing other threads call u_init().  All threads existing
    1.88 + * at the time of the first thread's call to u_init() must also call
    1.89 + * u_init() themselves before continuing with other ICU operations.  
    1.90 + * <p>
    1.91 + * The use of u_cleanup() just before an application terminates is optional,
    1.92 + * but it should be called only once for performance reasons. The primary
    1.93 + * benefit is to eliminate reports of memory or resource leaks originating
    1.94 + * in ICU code from the results generated by heap analysis tools.
    1.95 + * <p>
    1.96 + * <strong>Use this function with great care!</strong>
    1.97 + * </p>
    1.98 + *
    1.99 + * @stable ICU 2.0
   1.100 + * @system
   1.101 + */
   1.102 +U_STABLE void U_EXPORT2 
   1.103 +u_cleanup(void);
   1.104 +
   1.105 +
   1.106 +/**
   1.107 +  *  Pointer type for a user supplied memory allocation function.
   1.108 +  *  @param context user supplied value, obtained from from u_setMemoryFunctions().
   1.109 +  *  @param size    The number of bytes to be allocated
   1.110 +  *  @return        Pointer to the newly allocated memory, or NULL if the allocation failed.
   1.111 +  *  @stable ICU 2.8
   1.112 +  *  @system
   1.113 +  */
   1.114 +typedef void *U_CALLCONV UMemAllocFn(const void *context, size_t size);
   1.115 +/**
   1.116 +  *  Pointer type for a user supplied memory re-allocation function.
   1.117 +  *  @param context user supplied value, obtained from from u_setMemoryFunctions().
   1.118 +  *  @param size    The number of bytes to be allocated
   1.119 +  *  @return        Pointer to the newly allocated memory, or NULL if the allocation failed.
   1.120 +  *  @stable ICU 2.8
   1.121 +  *  @system
   1.122 +  */
   1.123 +typedef void *U_CALLCONV UMemReallocFn(const void *context, void *mem, size_t size);
   1.124 +/**
   1.125 +  *  Pointer type for a user supplied memory free  function.  Behavior should be
   1.126 +  *  similar the standard C library free().
   1.127 +  *  @param context user supplied value, obtained from from u_setMemoryFunctions().
   1.128 +  *  @param mem     Pointer to the memory block to be resized
   1.129 +  *  @param size    The new size for the block
   1.130 +  *  @return        Pointer to the resized memory block, or NULL if the resizing failed.
   1.131 +  *  @stable ICU 2.8
   1.132 +  *  @system
   1.133 +  */
   1.134 +typedef void  U_CALLCONV UMemFreeFn (const void *context, void *mem);
   1.135 +
   1.136 +/**
   1.137 + *  Set the functions that ICU will use for memory allocation.
   1.138 + *  Use of this function is optional; by default (without this function), ICU will
   1.139 + *  use the standard C library malloc() and free() functions.
   1.140 + *  This function can only be used when ICU is in an initial, unused state, before
   1.141 + *  u_init() has been called.
   1.142 + *  @param context This pointer value will be saved, and then (later) passed as
   1.143 + *                 a parameter to the memory functions each time they
   1.144 + *                 are called.
   1.145 + *  @param a       Pointer to a user-supplied malloc function.
   1.146 + *  @param r       Pointer to a user-supplied realloc function.
   1.147 + *  @param f       Pointer to a user-supplied free function.
   1.148 + *  @param status  Receives error values.
   1.149 + *  @stable ICU 2.8
   1.150 + *  @system
   1.151 + */  
   1.152 +U_STABLE void U_EXPORT2 
   1.153 +u_setMemoryFunctions(const void *context, UMemAllocFn *a, UMemReallocFn *r, UMemFreeFn *f, 
   1.154 +                    UErrorCode *status);
   1.155 +
   1.156 +
   1.157 +/*********************************************************************************
   1.158 + *
   1.159 + * Deprecated Functions
   1.160 + *
   1.161 + *    The following functions for user supplied mutexes are no longer supported.
   1.162 + *    Any attempt to use them will return a U_UNSUPPORTED_ERROR.
   1.163 + *
   1.164 + **********************************************************************************/
   1.165 +
   1.166 +/**
   1.167 +  * An opaque pointer type that represents an ICU mutex.
   1.168 +  * For user-implemented mutexes, the value will typically point to a
   1.169 +  *  struct or object that implements the mutex.
   1.170 +  * @deprecated ICU 52. This type is no longer supported.
   1.171 +  * @system
   1.172 +  */
   1.173 +typedef void *UMTX;
   1.174 +
   1.175 +/**
   1.176 +  *  Function Pointer type for a user supplied mutex initialization function.
   1.177 +  *  The user-supplied function will be called by ICU whenever ICU needs to create a
   1.178 +  *  new mutex.  The function implementation should create a mutex, and store a pointer
   1.179 +  *  to something that uniquely identifies the mutex into the UMTX that is supplied
   1.180 +  *  as a paramter.
   1.181 +  *  @param context user supplied value, obtained from from u_setMutexFunctions().
   1.182 +  *  @param mutex   Receives a pointer that identifies the new mutex.
   1.183 +  *                 The mutex init function must set the UMTX to a non-null value.   
   1.184 +  *                 Subsequent calls by ICU to lock, unlock, or destroy a mutex will 
   1.185 +  *                 identify the mutex by the UMTX value.
   1.186 +  *  @param status  Error status.  Report errors back to ICU by setting this variable
   1.187 +  *                 with an error code.
   1.188 +  *  @deprecated ICU 52. This function is no longer supported.
   1.189 +  *  @system
   1.190 +  */
   1.191 +typedef void U_CALLCONV UMtxInitFn (const void *context, UMTX  *mutex, UErrorCode* status);
   1.192 +
   1.193 +
   1.194 +/**
   1.195 +  *  Function Pointer type for a user supplied mutex functions.
   1.196 +  *  One of the  user-supplied functions with this signature will be called by ICU
   1.197 +  *  whenever ICU needs to lock, unlock, or destroy a mutex.
   1.198 +  *  @param context user supplied value, obtained from from u_setMutexFunctions().
   1.199 +  *  @param mutex   specify the mutex on which to operate.
   1.200 +  *  @deprecated ICU 52. This function is no longer supported.
   1.201 +  *  @system
   1.202 +  */
   1.203 +typedef void U_CALLCONV UMtxFn   (const void *context, UMTX  *mutex);
   1.204 +
   1.205 +
   1.206 +/**
   1.207 +  *  Set the functions that ICU will use for mutex operations
   1.208 +  *  Use of this function is optional; by default (without this function), ICU will
   1.209 +  *  directly access system functions for mutex operations
   1.210 +  *  This function can only be used when ICU is in an initial, unused state, before
   1.211 +  *  u_init() has been called.
   1.212 +  *  @param context This pointer value will be saved, and then (later) passed as
   1.213 +  *                 a parameter to the user-supplied mutex functions each time they
   1.214 +  *                 are called. 
   1.215 +  *  @param init    Pointer to a mutex initialization function.  Must be non-null.
   1.216 +  *  @param destroy Pointer to the mutex destroy function.  Must be non-null.
   1.217 +  *  @param lock    pointer to the mutex lock function.  Must be non-null.
   1.218 +  *  @param unlock  Pointer to the mutex unlock function.  Must be non-null.
   1.219 +  *  @param status  Receives error values.
   1.220 +  *  @deprecated ICU 52. This function is no longer supported.
   1.221 +  *  @system
   1.222 +  */  
   1.223 +U_DEPRECATED void U_EXPORT2 
   1.224 +u_setMutexFunctions(const void *context, UMtxInitFn *init, UMtxFn *destroy, UMtxFn *lock, UMtxFn *unlock,
   1.225 +                    UErrorCode *status);
   1.226 +
   1.227 +
   1.228 +/**
   1.229 +  *  Pointer type for a user supplied atomic increment or decrement function.
   1.230 +  *  @param context user supplied value, obtained from from u_setAtomicIncDecFunctions().
   1.231 +  *  @param p   Pointer to a 32 bit int to be incremented or decremented
   1.232 +  *  @return    The value of the variable after the inc or dec operation.
   1.233 +  *  @deprecated ICU 52. This function is no longer supported.
   1.234 +  *  @system
   1.235 +  */
   1.236 +typedef int32_t U_CALLCONV UMtxAtomicFn(const void *context, int32_t *p);
   1.237 +
   1.238 +/**
   1.239 + *  Set the functions that ICU will use for atomic increment and decrement of int32_t values.
   1.240 + *  Use of this function is optional; by default (without this function), ICU will
   1.241 + *  use its own internal implementation of atomic increment/decrement.
   1.242 + *  This function can only be used when ICU is in an initial, unused state, before
   1.243 + *  u_init() has been called.
   1.244 + *  @param context This pointer value will be saved, and then (later) passed as
   1.245 + *                 a parameter to the increment and decrement functions each time they
   1.246 + *                 are called.  This function can only be called 
   1.247 + *  @param inc     Pointer to a function to do an atomic increment operation.  Must be non-null.
   1.248 + *  @param dec     Pointer to a function to do an atomic decrement operation.  Must be non-null.
   1.249 + *  @param status  Receives error values.
   1.250 + *  @deprecated ICU 52. This function is no longer supported.
   1.251 + *  @system
   1.252 + */  
   1.253 +U_DEPRECATED void U_EXPORT2 
   1.254 +u_setAtomicIncDecFunctions(const void *context, UMtxAtomicFn *inc, UMtxAtomicFn *dec,
   1.255 +                    UErrorCode *status);
   1.256 +
   1.257 +#endif  /* U_HIDE_SYSTEM_API */
   1.258 +
   1.259 +#endif

mercurial