PowerPC inline versions of the interlocked functions.
This commit is contained in:
parent
5061d3a21d
commit
455c194da2
|
@ -1935,6 +1935,76 @@ extern inline HANDLE WINAPI GetProcessHeap(void)
|
|||
return pdb[0x18 / sizeof(HANDLE)]; /* get dword at offset 0x18 in pdb */
|
||||
}
|
||||
|
||||
#elif defined(__GNUC__) && defined(__powerpc__)
|
||||
extern inline LONG WINAPI InterlockedCompareExchange( PLONG dest, LONG xchg, LONG compare );
|
||||
extern inline LONG WINAPI InterlockedCompareExchange( PLONG dest, LONG xchg, LONG compare )
|
||||
{
|
||||
LONG ret = 0;
|
||||
LONG scratch;
|
||||
__asm__ (
|
||||
"0: lwarx %0,0,%2\n"
|
||||
" xor. %1,%4,%0\n"
|
||||
" bne 1f\n"
|
||||
" stwcx. %3,0,%2\n"
|
||||
" bne- 0b\n"
|
||||
" isync\n"
|
||||
"1: "
|
||||
: "=&r"(ret), "=&r"(scratch)
|
||||
: "r"(dest), "r"(xchg), "r"(compare)
|
||||
: "cr0","memory","r0");
|
||||
return ret;
|
||||
}
|
||||
|
||||
extern inline LONG WINAPI InterlockedExchange( PLONG dest, LONG val );
|
||||
extern inline LONG WINAPI InterlockedExchange( PLONG dest, LONG val )
|
||||
{
|
||||
LONG ret = 0;
|
||||
__asm__(
|
||||
"0: lwarx %0,0,%1\n"
|
||||
" stwcx. %2,0,%1\n"
|
||||
" bne- 0b\n"
|
||||
" isync\n"
|
||||
: "=&r"(ret)
|
||||
: "r"(dest), "r"(val)
|
||||
: "cr0","memory","r0");
|
||||
return ret;
|
||||
}
|
||||
|
||||
extern inline LONG WINAPI InterlockedExchangeAdd( PLONG dest, LONG incr );
|
||||
extern inline LONG WINAPI InterlockedExchangeAdd( PLONG dest, LONG incr )
|
||||
{
|
||||
LONG ret = 0;
|
||||
LONG zero = 0;
|
||||
__asm__(
|
||||
"0: lwarx %0, %3, %1\n"
|
||||
" add %0, %2, %0\n"
|
||||
" stwcx. %0, %3, %1\n"
|
||||
" bne- 0b\n"
|
||||
" isync\n"
|
||||
: "=&r" (ret)
|
||||
: "r"(dest), "r"(incr), "r"(zero)
|
||||
: "cr0", "memory", "r0"
|
||||
);
|
||||
return ret-incr;
|
||||
}
|
||||
|
||||
extern inline LONG WINAPI InterlockedIncrement( PLONG dest );
|
||||
extern inline LONG WINAPI InterlockedIncrement( PLONG dest )
|
||||
{
|
||||
return InterlockedExchangeAdd( dest, 1 ) + 1;
|
||||
}
|
||||
|
||||
extern inline LONG WINAPI InterlockedDecrement( PLONG dest );
|
||||
extern inline LONG WINAPI InterlockedDecrement( PLONG dest )
|
||||
{
|
||||
return InterlockedExchangeAdd( dest, -1 ) - 1;
|
||||
}
|
||||
|
||||
DWORD WINAPI GetLastError(void);
|
||||
DWORD WINAPI GetCurrentProcessId(void);
|
||||
DWORD WINAPI GetCurrentThreadId(void);
|
||||
void WINAPI SetLastError( DWORD err );
|
||||
HANDLE WINAPI GetProcessHeap(void);
|
||||
#else /* __i386__ && __GNUC__ */
|
||||
DWORD WINAPI GetCurrentProcessId(void);
|
||||
DWORD WINAPI GetCurrentThreadId(void);
|
||||
|
|
Loading…
Reference in New Issue