X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=arch%2Fi386%2Fatomic.h;h=95fecbdcc51eb7faee9fff264388a3f7bc6d8bcd;hb=2a780aa3050b86d888489361f04220bfb58890a1;hp=bf3c336e6e30ceda2aca4d63ee257e0dc9b65f66;hpb=e914f8b7ec79f622fa3b017af434642f61d45ce8;p=musl diff --git a/arch/i386/atomic.h b/arch/i386/atomic.h index bf3c336e..95fecbdc 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) { @@ -24,11 +30,6 @@ static inline void a_or_64(volatile uint64_t *p, uint64_t v) : : "r"((long *)p), "r"((unsigned)v), "r"((unsigned)(v>>32)) : "memory" ); } -static inline void a_store_l(volatile void *p, long x) -{ - __asm__( "movl %1, %0" : "=m"(*(long *)p) : "r"(x) : "memory" ); -} - static inline void a_or_l(volatile void *p, long v) { __asm__( "lock ; orl %1, %0" @@ -42,13 +43,6 @@ static inline void *a_cas_p(volatile void *p, void *t, void *s) return t; } -static inline long a_cas_l(volatile void *p, long t, long s) -{ - __asm__( "lock ; cmpxchg %3, %1" - : "=a"(t), "=m"(*(long *)p) : "a"(t), "r"(s) : "memory" ); - return t; -} - static inline int a_cas(volatile int *p, int t, int s) { __asm__( "lock ; cmpxchg %3, %1" @@ -56,27 +50,16 @@ static inline int a_cas(volatile int *p, int t, int s) 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" ); - return v; -} -static inline long a_swap_l(volatile void *x, long v) -{ - __asm__( "xchg %0, %1" : "=r"(v), "=m"(*(long *)x) : "0"(v) : "memory" ); - return v; -} - -static inline void a_or(volatile void *p, int v) +static inline void a_or(volatile int *p, int v) { __asm__( "lock ; orl %1, %0" - : "=m"(*(int *)p) : "r"(v) : "memory" ); + : "=m"(*p) : "r"(v) : "memory" ); } -static inline void a_and(volatile void *p, int v) +static inline void a_and(volatile int *p, int v) { __asm__( "lock ; andl %1, %0" - : "=m"(*(int *)p) : "r"(v) : "memory" ); + : "=m"(*p) : "r"(v) : "memory" ); } static inline int a_swap(volatile int *x, int v) @@ -113,5 +96,15 @@ static inline void a_spin() __asm__ __volatile__( "pause" : : : "memory" ); } +static inline void a_barrier() +{ + __asm__ __volatile__( "" : : : "memory" ); +} + +static inline void a_crash() +{ + __asm__ __volatile__( "hlt" : : : "memory" ); +} + #endif