summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/blitter/ntapi_blt_block.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/blitter/ntapi_blt_block.c b/src/blitter/ntapi_blt_block.c
index 12dc2f7..803e723 100644
--- a/src/blitter/ntapi_blt_block.c
+++ b/src/blitter/ntapi_blt_block.c
@@ -135,14 +135,21 @@ int32_t __fastcall __ntapi_blt_possess(
size_t byte;
uintptr_t test;
uintptr_t mask;
+ uintptr_t cmp;
+ uintptr_t xchg;
bit = *blkid % (8*sizeof(size_t));
byte = *blkid / (8*sizeof(size_t));
+ mask = (uintptr_t)1 << bit;
+
+ do {
+ cmp = blitter->bitmap[byte];
+ xchg = cmp & ~mask;
- mask = ((uintptr_t)1 << bit);
- test = at_locked_and(
- (intptr_t *)&blitter->bitmap[byte],
- ~mask);
+ test = at_locked_cas(
+ (intptr_t *)&blitter->bitmap[byte],
+ cmp,xchg);
+ } while (test != cmp);
if (test & mask) {
at_locked_dec(&blitter->info.blocks_avail);