atomic.c
304 Bytes
#include "os.h"
#include "os_internal.h"
/* Atomically decrement the integer */
/* Return 1: success, 0: fail */
int __osAtomicDec(unsigned int *p)
{
u32 mask;
int result;
mask = __osDisableInt();
if (*p > 0) {
(*p)--;
result = 1;
} else
result = 0;
__osRestoreInt(mask);
return result;
}