From owner-cvs-all Tue Oct 9 4:50:21 2001 Delivered-To: cvs-all@freebsd.org Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by hub.freebsd.org (Postfix) with ESMTP id 53C8237B406; Tue, 9 Oct 2001 04:50:13 -0700 (PDT) Received: from bde.zeta.org.au (bde.zeta.org.au [203.2.228.102]) by mailman.zeta.org.au (8.9.3/8.8.7) with ESMTP id VAA00274; Tue, 9 Oct 2001 21:50:08 +1000 Date: Tue, 9 Oct 2001 21:49:24 +1000 (EST) From: Bruce Evans X-X-Sender: To: John Baldwin Cc: , Subject: Re: cvs commit: src/sys/i386/include atomic.h In-Reply-To: Message-ID: <20011009204225.O24682-100000@delplex.bde.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Mon, 8 Oct 2001, John Baldwin wrote: > On 09-Oct-01 Bruce Evans wrote: > > On Mon, 8 Oct 2001, John Baldwin wrote: > >> [atomic ops...] > > > > I don't want the current bad interface exported to userland where it is > > harder to fix. The interface should by type-generic. E.g., > > atomic_add(lvalue, rvalue) instead of: > > So use the gcc-specific typeof()? :) The code calling atomic_* knows what type Nah, just use sizeof() ... > it is using. Why make the compiler guess what that type is so it can call the > proper primitive? Just like at the x86 PCPU macros to see how gross this can ... as in the x86 PCPU macros :-), except for not using so many casts. I can't see much use of typeof() here except to to generate better error messages. It could be used if %L worked: #define atomic_add(var, val) \ __asm __volatile("lock; add%L0 %1,%0" \ : "=m" (var) \ : "ir" ((typeof(var))val)); but %L apparently only works in .md files. Maybe this will be fixed to support type-generic macros in C99. > get. Now repeat that for each atomic operation with variations for the acquire > and release memory barriers. Ugh. It's better to have the complications in the implementation than the callers. I prefer the implementation complications for the x86 PCPU() to the current ones for the x86 atomic operations anyway. The macros aren't layered as deep. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message