mirror of
https://github.com/decompals/wibo.git
synced 2025-08-08 04:59:05 +00:00
Add InterlockedCompareExchange (#85)
This commit is contained in:
parent
8bd112f0e4
commit
78f4d534df
@ -2228,6 +2228,15 @@ namespace kernel32 {
|
|||||||
return initial;
|
return initial;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LONG WIN_FUNC InterlockedCompareExchange(volatile LONG* destination, LONG exchange, LONG comperand){
|
||||||
|
LONG original = *destination;
|
||||||
|
if (original == comperand) {
|
||||||
|
*destination = exchange;
|
||||||
|
}
|
||||||
|
return original;
|
||||||
|
// return __sync_val_compare_and_swap(destination, comperand, exchange); if we want to maintain the atomic behavior
|
||||||
|
}
|
||||||
|
|
||||||
// These are effectively a copy/paste of the Tls* functions
|
// These are effectively a copy/paste of the Tls* functions
|
||||||
enum { MAX_FLS_VALUES = 100 };
|
enum { MAX_FLS_VALUES = 100 };
|
||||||
static bool flsValuesUsed[MAX_FLS_VALUES] = { false };
|
static bool flsValuesUsed[MAX_FLS_VALUES] = { false };
|
||||||
@ -2481,6 +2490,7 @@ static void *resolveByName(const char *name) {
|
|||||||
if (strcmp(name, "InterlockedIncrement") == 0) return (void *) kernel32::InterlockedIncrement;
|
if (strcmp(name, "InterlockedIncrement") == 0) return (void *) kernel32::InterlockedIncrement;
|
||||||
if (strcmp(name, "InterlockedDecrement") == 0) return (void *) kernel32::InterlockedDecrement;
|
if (strcmp(name, "InterlockedDecrement") == 0) return (void *) kernel32::InterlockedDecrement;
|
||||||
if (strcmp(name, "InterlockedExchange") == 0) return (void *) kernel32::InterlockedExchange;
|
if (strcmp(name, "InterlockedExchange") == 0) return (void *) kernel32::InterlockedExchange;
|
||||||
|
if (strcmp(name, "InterlockedCompareExchange") == 0) return (void*) kernel32::InterlockedCompareExchange;
|
||||||
|
|
||||||
// fibersapi.h
|
// fibersapi.h
|
||||||
if (strcmp(name, "FlsAlloc") == 0) return (void *) kernel32::FlsAlloc;
|
if (strcmp(name, "FlsAlloc") == 0) return (void *) kernel32::FlsAlloc;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user