From owner-p4-projects Sat Jan 25 19:43:34 2003 Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 5B50C37B405; Sat, 25 Jan 2003 19:43:31 -0800 (PST) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D42E837B40F for ; Sat, 25 Jan 2003 19:43:30 -0800 (PST) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6376543F13 for ; Sat, 25 Jan 2003 19:43:30 -0800 (PST) (envelope-from jmallett@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.6/8.12.6) with ESMTP id h0Q3hUbv031318 for ; Sat, 25 Jan 2003 19:43:30 -0800 (PST) (envelope-from jmallett@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.6/8.12.6/Submit) id h0Q3hTPp031315 for perforce@freebsd.org; Sat, 25 Jan 2003 19:43:29 -0800 (PST) Date: Sat, 25 Jan 2003 19:43:29 -0800 (PST) Message-Id: <200301260343.h0Q3hTPp031315@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to jmallett@freebsd.org using -f From: Juli Mallett Subject: PERFORCE change 24206 for review To: Perforce Change Reviews Sender: owner-p4-projects@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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