atomic.h.patch
| atomic.h 2006-09-30 12:34:02.000000000 -0700 | ||
|---|---|---|
| 346 | 346 |
/* |
| 347 | 347 |
* Atomic compare and set |
| 348 | 348 |
* |
| 349 |
* if (*dst == old) *dst = new (all 32 bit words)
|
|
| 349 |
* if (*dst == old) *dst = src (all 32 bit words)
|
|
| 350 | 350 |
* |
| 351 | 351 |
* Returns 0 on failure, non-zero on success |
| 352 | 352 |
* |
| ... | ... | |
| 355 | 355 |
* version may be used by the dynamic linker |
| 356 | 356 |
*/ |
| 357 | 357 |
#if defined(KLD_MODULE) |
| 358 |
extern int atomic_cmpset_int(volatile u_int *dst, u_int old, u_int new);
|
|
| 358 |
extern int atomic_cmpset_int(volatile u_int *dst, u_int old, u_int src);
|
|
| 359 | 359 |
#else |
| 360 | 360 |
static __inline int |
| 361 |
atomic_cmpset_int(volatile u_int *dst, u_int old, u_int new)
|
|
| 361 |
atomic_cmpset_int(volatile u_int *dst, u_int old, u_int src)
|
|
| 362 | 362 |
{
|
| 363 | 363 |
int res = old; |
| 364 | 364 | |
| ... | ... | |
| 366 | 366 |
"setz %%al; " \ |
| 367 | 367 |
"movzbl %%al,%0; " \ |
| 368 | 368 |
: "+a" (res), "=m" (*dst) \ |
| 369 |
: "r" (new), "m" (*dst) \
|
|
| 369 |
: "r" (src), "m" (*dst) \
|
|
| 370 | 370 |
: "memory"); |
| 371 | 371 |
return res; |
| 372 | 372 |
} |