summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2018-08-09 04:14:31 -0400
committermidipix <writeonce@midipix.org>2018-08-09 04:14:31 -0400
commitdc7e61e60fb6957717a978131c3dc2dca58cf44c (patch)
tree3532cec757961d93fa6b7ed97e5a3efb87b5cb6b /src
parent1f72875a9d19a171a32e759e6251bf8d87e5bcbc (diff)
downloadntapi-dc7e61e60fb6957717a978131c3dc2dca58cf44c.tar.bz2
ntapi-dc7e61e60fb6957717a978131c3dc2dca58cf44c.tar.xz
__ntapi_blt_possess(): use an inlined cmpxchg loop.
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);