mirror of
https://github.com/devkitPro/wut.git
synced 2026-04-24 23:46:56 -05:00
wutnewlib: Use OSCompareAndSwapAtomicEx for sbrk
This commit is contained in:
parent
e81c3a159f
commit
42292fadc6
|
|
@ -6,7 +6,7 @@
|
|||
#define MAX_LOCKS 16
|
||||
|
||||
static OSMutex sLibcLocks[MAX_LOCKS];
|
||||
static uint32_t sLibcLockUsedMask = 0;
|
||||
static volatile uint32_t sLibcLockUsedMask = 0;
|
||||
|
||||
static inline bool
|
||||
__wut_is_lock_valid(int *lock)
|
||||
|
|
|
|||
|
|
@ -14,17 +14,17 @@ void *
|
|||
__wut_sbrk_r(struct _reent *r,
|
||||
ptrdiff_t incr)
|
||||
{
|
||||
uint32_t oldSize, newSize;
|
||||
uint32_t newSize;
|
||||
uint32_t oldSize = sHeapSize;
|
||||
|
||||
do {
|
||||
oldSize = sHeapSize;
|
||||
newSize = oldSize + incr;
|
||||
|
||||
if (newSize > sHeapMaxSize) {
|
||||
r->_errno = ENOMEM;
|
||||
return (void *)-1;
|
||||
}
|
||||
} while (!OSCompareAndSwapAtomic(&sHeapSize, oldSize, newSize));
|
||||
} while (!OSCompareAndSwapAtomicEx(&sHeapSize, oldSize, newSize, &oldSize));
|
||||
|
||||
return ((uint8_t *)sHeapBase) + oldSize;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user