Date: Sat, 25 Jan 2003 19:43:29 -0800 (PST) From: Juli Mallett <jmallett@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 24206 for review Message-ID: <200301260343.h0Q3hTPp031315@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=24206 Change 24206 by jmallett@jmallett_dalek on 2003/01/25 19:43:14 Macro hell: Fill out the basic int/long functions using ll[d]/sc[d]. Affected files ... .. //depot/projects/mips/sys/mips/include/atomic.h#5 edit Differences ... ==== //depot/projects/mips/sys/mips/include/atomic.h#5 (text+ko) ==== @@ -27,38 +27,50 @@ #ifndef _MACHINE_ATOMIC_H_ #define _MACHINE_ATOMIC_H_ -static __inline void -atomic_set_int(int *p, int val) -{ - int temp; - - __asm __volatile ( - "1:\n\t" - "ll %[temp], %[p]\n\t" - "or %[temp], %[temp], %[val]\n\t" - "sc %[temp], %[p]\n\t" - "beqz %[temp], 1b\n\t" - : [val] "=r"(val) - : [temp] "r"(temp), [p] "r"(p) - : "memory" - ); +#define ATOMIC_OP(op, asmop) \ +static __inline void \ +atomic_ ## op ## _int(u_int *p, u_int val) \ +{ \ + u_int temp; \ + \ + __asm __volatile ( \ + "1:\n\t" \ + "ll %[temp], %[p]\n\t" \ + asmop "\n\t" \ + "sc %[temp], %[p]\n\t" \ + "beqz %[temp], 1b\n\t" \ + : [val] "=r"(val) \ + : [temp] "r"(temp), [p] "r"(p) \ + : "memory" \ + ); \ } -static __inline void -atomic_set_long(long *p, long val) -{ - long temp; +ATOMIC_OP(add, "addu %[temp], %[temp], %[val]") +ATOMIC_OP(clear, "and %[temp], %[temp], %[val]") +ATOMIC_OP(set, "or %[temp], %[temp], %[val]") +ATOMIC_OP(subtract, "subu %[temp], %[temp], %[val]") - __asm __volatile ( - "1:\n\t" - "lld %[temp], %[p]\n\t" - "or %[temp], %[temp], %[val]\n\t" - "scd %[temp], %[p]\n\t" - "beqz %[temp], 1b\n\t" - : [val] "=r"(val) - : [temp] "r"(temp), [p] "r"(p) - : "memory" - ); +#define ATOMIC_DOP(op, asmop) \ +static __inline void \ +atomic_ ## op ## _long(u_long *p, u_long val) \ +{ \ + u_long temp; \ + \ + __asm __volatile ( \ + "1:\n\t" \ + "lld %[temp], %[p]\n\t" \ + asmop "\n\t" \ + "scd %[temp], %[p]\n\t" \ + "beqz %[temp], 1b\n\t" \ + : [val] "=r"(val) \ + : [temp] "r"(temp), [p] "r"(p) \ + : "memory" \ + ); \ } +ATOMIC_DOP(add, "daddu %[temp], %[temp], %[val]") +ATOMIC_DOP(clear, "and %[temp], %[temp], %[val]") +ATOMIC_DOP(set, "or %[temp], %[temp], %[val]") +ATOMIC_DOP(subtract, "dsubu %[temp], %[temp], %[val]") + #endif /* !_MACHINE_ATOMIC_H_ */ 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?200301260343.h0Q3hTPp031315>