Date: Sat, 25 Jan 2003 21:13:21 -0800 (PST) From: Juli Mallett <jmallett@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 24211 for review Message-ID: <200301260513.h0Q5DLGp063324@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=24211 Change 24211 by jmallett@jmallett_dalek on 2003/01/25 21:12:44 Finish filling in _int/_long functions. Affected files ... .. //depot/projects/mips/sys/mips/include/atomic.h#7 edit Differences ... ==== //depot/projects/mips/sys/mips/include/atomic.h#7 (text+ko) ==== @@ -27,12 +27,50 @@ #ifndef _MACHINE_ATOMIC_H_ #define _MACHINE_ATOMIC_H_ +#include <machine/cpufunc.h> + /* * Atomic operations on the MIPS, keep code abstracted up to the point * that it is no longer clean. Keep operations on each type sorted in * an order relative to eachother. */ +#define ATOMIC_ACQ_OP(type, op) \ +static __inline void \ +atomic_ ## op ## _acq_ ## type(u_ ## type *p, u_ ## type val) \ +{ \ + atomic_ ## op ## _ ## type(p, val); \ + mips_write_membar(); \ +} + +#define ATOMIC_REL_OP(type, op) \ +static __inline void \ +atomic_ ## op ## _rel_ ## type(u_ ## type *p, u_ ## type val) \ +{ \ + mips_read_membar(); \ + atomic_ ## op ## _ ## type(p, val); \ +} + +#define ATOMIC_ACQ_LOAD(type) \ +static __inline u_ ## type \ +atomic_load_ ## type (u_ ## type *p) \ +{ \ + u_ ## type res; \ + \ + res = *p; \ + mips_write_membar(); \ + \ + return res; \ +} + +#define ATOMIC_REL_STORE(type) \ +static __inline void \ +atomic_store_rel_ ## type (u_ ## type *p, u_ ## type val) \ +{ \ + mips_read_membar(); \ + *p = val; \ +} + /* * Integer atomic operations, hardware calls this single. */ @@ -60,7 +98,19 @@ ATOMIC_OP(set, "or %[temp], %[temp], %[val]") ATOMIC_OP(subtract, "subu %[temp], %[temp], %[val]") -static __inline int +ATOMIC_ACQ_OP(int, add) +ATOMIC_REL_OP(int, add) +ATOMIC_ACQ_OP(int, clear) +ATOMIC_REL_OP(int, clear) +ATOMIC_ACQ_OP(int, set) +ATOMIC_REL_OP(int, set) +ATOMIC_ACQ_OP(int, subtract) +ATOMIC_REL_OP(int, subtract) + +ATOMIC_ACQ_LOAD(int) +ATOMIC_REL_STORE(int) + +static __inline u_int atomic_readandclear_int(u_int *p) { u_int temp, res; @@ -72,7 +122,7 @@ "move %[temp], 0\n\t" "sc %[temp], %[p]\n\t" "beqz %[temp], 1b\n\t" - : [val] "=r"(val) + : : [temp] "r"(temp), [p] "r"(p), [res] "r"(res) : "memory" ); @@ -107,8 +157,20 @@ ATOMIC_DOP(set, "or %[temp], %[temp], %[val]") ATOMIC_DOP(subtract, "dsubu %[temp], %[temp], %[val]") -static __inline long -atomic_readandclear_int(u_long *p) +ATOMIC_ACQ_OP(long, add) +ATOMIC_REL_OP(long, add) +ATOMIC_ACQ_OP(long, clear) +ATOMIC_REL_OP(long, clear) +ATOMIC_ACQ_OP(long, set) +ATOMIC_REL_OP(long, set) +ATOMIC_ACQ_OP(long, subtract) +ATOMIC_REL_OP(long, subtract) + +ATOMIC_ACQ_LOAD(long) +ATOMIC_REL_STORE(long) + +static __inline u_long +atomic_readandclear_long(u_long *p) { u_long temp, res; @@ -119,7 +181,7 @@ "move %[temp], 0\n\t" "scd %[temp], %[p]\n\t" "beqz %[temp], 1b\n\t" - : [val] "=r"(val) + : : [temp] "r"(temp), [p] "r"(p), [res] "r"(res) : "memory" ); To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe p4-projects" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200301260513.h0Q5DLGp063324>