diff options
author | Eric Anholt <anholt@freebsd.org> | 2003-04-26 06:53:22 +0000 |
---|---|---|
committer | Eric Anholt <anholt@freebsd.org> | 2003-04-26 06:53:22 +0000 |
commit | e60eb69bc029c04b39ef0de620002d5ba2433d04 (patch) | |
tree | 6bc74a6823692eaba30bf92665fb6fcf916c490b | |
parent | acb5d6b2732cccfa3734b25dc808ecdc5a6c556c (diff) |
Replace the C atomic_cmpset_int compatibility function for -stable with the
real i386 atomic_cmpset_int from -current. FreeBSD-stable won't ever
have DRM support for non-i386.
-rw-r--r-- | bsd-core/drm_os_freebsd.h | 25 | ||||
-rw-r--r-- | bsd/drm_os_freebsd.h | 25 |
2 files changed, 32 insertions, 18 deletions
diff --git a/bsd-core/drm_os_freebsd.h b/bsd-core/drm_os_freebsd.h index 461a26ce..acbd7cf3 100644 --- a/bsd-core/drm_os_freebsd.h +++ b/bsd-core/drm_os_freebsd.h @@ -249,16 +249,23 @@ typedef u_int8_t u8; #if __FreeBSD_version < 500000 /* The extra atomic functions from 5.0 haven't been merged to 4.x */ static __inline int -atomic_cmpset_int(volatile int *dst, int old, int new) +atomic_cmpset_int(volatile u_int *dst, u_int exp, u_int src) { - int s = splhigh(); - if (*dst==old) { - *dst = new; - splx(s); - return 1; - } - splx(s); - return 0; + int res = exp; + + __asm __volatile ( + " lock ; " + " cmpxchgl %1,%2 ; " + " setz %%al ; " + " movzbl %%al,%0 ; " + "1: " + "# atomic_cmpset_int" + : "+a" (res) /* 0 (result) */ + : "r" (src), /* 1 */ + "m" (*(dst)) /* 2 */ + : "memory"); + + return (res); } #endif diff --git a/bsd/drm_os_freebsd.h b/bsd/drm_os_freebsd.h index 461a26ce..acbd7cf3 100644 --- a/bsd/drm_os_freebsd.h +++ b/bsd/drm_os_freebsd.h @@ -249,16 +249,23 @@ typedef u_int8_t u8; #if __FreeBSD_version < 500000 /* The extra atomic functions from 5.0 haven't been merged to 4.x */ static __inline int -atomic_cmpset_int(volatile int *dst, int old, int new) +atomic_cmpset_int(volatile u_int *dst, u_int exp, u_int src) { - int s = splhigh(); - if (*dst==old) { - *dst = new; - splx(s); - return 1; - } - splx(s); - return 0; + int res = exp; + + __asm __volatile ( + " lock ; " + " cmpxchgl %1,%2 ; " + " setz %%al ; " + " movzbl %%al,%0 ; " + "1: " + "# atomic_cmpset_int" + : "+a" (res) /* 0 (result) */ + : "r" (src), /* 1 */ + "m" (*(dst)) /* 2 */ + : "memory"); + + return (res); } #endif |