ICU-4290 Fix the context handling for increment/decrement functions.

X-SVN-Rev: 17884
This commit is contained in:
George Rhoten 2005-06-14 05:35:06 +00:00
parent 6493207038
commit 9117209a39
2 changed files with 6 additions and 4 deletions

View file

@ -500,7 +500,7 @@ u_setMutexFunctions(const void *context, UMtxInitFn *i, UMtxFn *d, UMtxFn *l, UM
/* Pointers to user-supplied inc/dec functions. Null if no funcs have been set. */
static UMtxAtomicFn *pIncFn = NULL;
static UMtxAtomicFn *pDecFn = NULL;
static void *gIncDecContext = NULL;
static const void *gIncDecContext = NULL;
U_CAPI int32_t U_EXPORT2
@ -569,6 +569,7 @@ u_setAtomicIncDecFunctions(const void *context, UMtxAtomicFn *ip, UMtxAtomicFn *
pIncFn = ip;
pDecFn = dp;
gIncDecContext = context;
testInt = 0;
U_ASSERT(umtx_atomic_inc(&testInt) == 1); /* Sanity Check. Do the functions work at all? */
@ -594,6 +595,7 @@ U_CFUNC UBool umtx_cleanup(void) {
gGlobalMutex = NULL;
pIncFn = NULL;
pDecFn = NULL;
gIncDecContext = NULL;
gIncDecMutex = NULL;
#if (ICU_USE_THREADS == 1)

View file

@ -1,6 +1,6 @@
/********************************************************************
* COPYRIGHT:
* Copyright (c) 200-20043, International Business Machines Corporation and
* Copyright (c) 2003-2005, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
/*
@ -381,7 +381,7 @@ const void *gIncDecContext;
static int32_t U_CALLCONV myIncFunc(const void *context, int32_t *p) {
int32_t retVal;
TEST_ASSERT(context == gIncDecContext);
TEST_ASSERT(context == &gIncDecContext);
gIncCount++;
retVal = ++(*p);
return retVal;
@ -389,7 +389,7 @@ static int32_t U_CALLCONV myIncFunc(const void *context, int32_t *p) {
static int32_t U_CALLCONV myDecFunc(const void *context, int32_t *p) {
int32_t retVal;
TEST_ASSERT(context == gIncDecContext);
TEST_ASSERT(context == &gIncDecContext);
gDecCount++;
retVal = --(*p);
return retVal;