mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-10 17:01:24 +12:00
add primitive InterlockedOr64 implementation
use non msvc specific type for int64_t add umul for gcc
This commit is contained in:
parent
b05bd51216
commit
96e229abfa
2 changed files with 20 additions and 2 deletions
|
@ -20,6 +20,25 @@
|
|||
#define InterlockedCompareExchange(ptr,new_val,old_val) __sync_val_compare_and_swap(ptr,old_val,new_val)
|
||||
#define InterlockedCompareExchange64(ptr,new_val,old_val) __sync_val_compare_and_swap(ptr,old_val,new_val)
|
||||
|
||||
int64_t InterlockedOr64(volatile int64_t *dest, int64_t val)
|
||||
{
|
||||
int64_t olderval;
|
||||
int64_t oldval = *dest;
|
||||
do
|
||||
{
|
||||
olderval = oldval;
|
||||
oldval = InterlockedCompareExchange64(dest, olderval | val, olderval);
|
||||
} while (olderval != oldval);
|
||||
return oldval;
|
||||
}
|
||||
|
||||
uint64_t __umulh(uint64_t a, uint64_t b)
|
||||
{
|
||||
uint64_t result;
|
||||
__asm__("mulq %[b]" : "=d" (result) : [a] "a" (a), [b] "rm" (b));
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifndef __APPLE__
|
||||
#define _aligned_malloc(size,alignment) memalign(alignment,size)
|
||||
#else
|
||||
|
@ -37,4 +56,3 @@ int clock_gettime(int foo, struct timespec *ts);
|
|||
|
||||
#define DWORD int32_t
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue