Bug #336 ยป atomic.h.patch
| atomic.h 2006-09-30 12:34:02.000000000 -0700 | ||
|---|---|---|
|
/*
|
||
|
* Atomic compare and set
|
||
|
*
|
||
|
* if (*dst == old) *dst = new (all 32 bit words)
|
||
|
* if (*dst == old) *dst = src (all 32 bit words)
|
||
|
*
|
||
|
* Returns 0 on failure, non-zero on success
|
||
|
*
|
||
| ... | ... | |
|
* version may be used by the dynamic linker
|
||
|
*/
|
||
|
#if defined(KLD_MODULE)
|
||
|
extern int atomic_cmpset_int(volatile u_int *dst, u_int old, u_int new);
|
||
|
extern int atomic_cmpset_int(volatile u_int *dst, u_int old, u_int src);
|
||
|
#else
|
||
|
static __inline int
|
||
|
atomic_cmpset_int(volatile u_int *dst, u_int old, u_int new)
|
||
|
atomic_cmpset_int(volatile u_int *dst, u_int old, u_int src)
|
||
|
{
|
||
|
int res = old;
|
||
| ... | ... | |
|
"setz %%al; " \
|
||
|
"movzbl %%al,%0; " \
|
||
|
: "+a" (res), "=m" (*dst) \
|
||
|
: "r" (new), "m" (*dst) \
|
||
|
: "r" (src), "m" (*dst) \
|
||
|
: "memory");
|
||
|
return res;
|
||
|
}
|
||