Use GCC builtins instead of inline asm

This commit is contained in:
Johan Tibell 2014-04-10 15:16:38 +02:00
parent 8ce7d7ea47
commit 308768c5b1

View file

@ -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) {