X-Git-Url: http://nsz.repo.hu/git/?p=musl;a=blobdiff_plain;f=arch%2Fi386%2Fatomic.h;h=77b0b3b73759721c9a1ccc7668ba356cde92100e;hp=e74e45352574859ed06fbfea614750068846c623;hb=075fdb909b7692df7f3c440331114a754267a167;hpb=a5bf06c035168122725ec32537f99ab1e6c8432c diff --git a/arch/i386/atomic.h b/arch/i386/atomic.h index e74e4535..77b0b3b7 100644 --- a/arch/i386/atomic.h +++ b/arch/i386/atomic.h @@ -1,5 +1,5 @@ -#ifndef _INTERNAA_ATOMIC_H -#define _INTERNAA_ATOMIC_H +#ifndef _INTERNAL_ATOMIC_H +#define _INTERNAL_ATOMIC_H #include @@ -11,6 +11,12 @@ static inline int a_ctz_64(uint64_t x) return r; } +static inline int a_ctz_l(unsigned long x) +{ + long r; + __asm__( "bsf %1,%0" : "=r"(r) : "r"(x) ); + return r; +} static inline void a_and_64(volatile uint64_t *p, uint64_t v) { @@ -49,6 +55,13 @@ static inline long a_cas_l(volatile void *p, long t, long s) return t; } +static inline int a_cas(volatile int *p, int t, int s) +{ + __asm__( "lock ; cmpxchg %3, %1" + : "=a"(t), "=m"(*p) : "a"(t), "r"(s) : "memory" ); + return t; +} + static inline void *a_swap_p(void *volatile *x, void *v) { __asm__( "xchg %0, %1" : "=r"(v), "=m"(*(void **)x) : "0"(v) : "memory" ); @@ -106,5 +119,10 @@ static inline void a_spin() __asm__ __volatile__( "pause" : : : "memory" ); } +static inline void a_crash() +{ + __asm__ __volatile__( "hlt" : : : "memory" ); +} + #endif