Use GCC builtins instead of inline asm
This commit is contained in:
parent
8ce7d7ea47
commit
308768c5b1
1 changed files with 1 additions and 10 deletions
|
@ -7,16 +7,7 @@ StgInt* hs_counter_new(void) {
|
|||
return counter;
|
||||
}
|
||||
void hs_counter_add(volatile StgInt* counter, StgInt n) {
|
||||
StgInt temp = n;
|
||||
#if SIZEOF_VOID_P == 8
|
||||
__asm__ __volatile__("lock; xaddq %0,%1"
|
||||
#elif SIZEOF_VOID_P == 4
|
||||
__asm__ __volatile__("lock; xaddl %0,%1"
|
||||
#else
|
||||
# error GHC untested on this architecture: sizeof(void *) != 4 or 8
|
||||
#endif
|
||||
: "+r" (temp), "+m" (*counter)
|
||||
: : "cc", "memory");
|
||||
__sync_fetch_and_add(counter, n);
|
||||
}
|
||||
|
||||
StgInt hs_counter_read(volatile const StgInt* counter) {
|
||||
|
|
Loading…
Reference in a new issue