From owner-freebsd-hackers Tue Oct 3 11:25: 9 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from wall.polstra.com (rtrwan160.accessone.com [206.213.115.74]) by hub.freebsd.org (Postfix) with ESMTP id 8228037B66E for ; Tue, 3 Oct 2000 11:25:04 -0700 (PDT) Received: from vashon.polstra.com (vashon.polstra.com [206.213.73.13]) by wall.polstra.com (8.9.3/8.9.3) with ESMTP id LAA00832; Tue, 3 Oct 2000 11:24:15 -0700 (PDT) (envelope-from jdp@wall.polstra.com) Received: (from jdp@localhost) by vashon.polstra.com (8.11.0/8.11.0) id e93IOEQ16876; Tue, 3 Oct 2000 11:24:14 -0700 (PDT) (envelope-from jdp) Date: Tue, 3 Oct 2000 11:24:14 -0700 (PDT) From: jdp@polstra.com Message-Id: <200010031824.e93IOEQ16876@vashon.polstra.com> To: hackers@freebsd.org Reply-To: hackers@freebsd.org Cc: bright@wintelcom.net Subject: Re: atomic operations In-Reply-To: <20001003012240.G27736@fw.wintelcom.net> References: <00b701c0273b$39f7aaa0$0901a8c0@haym.transactionsite.com> <20001003012240.G27736@fw.wintelcom.net> Organization: Polstra & Co., Seattle, WA Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG In article <20001003012240.G27736@fw.wintelcom.net>, Alfred Perlstein wrote: > > +typedef struct { volatile int a; } atomic_t; > + > +#define atomic_init(p, v) do { p->a = v; } while(0) > +#define atomic_destroy(p) do { ; } while(0) I don't see the need for the do ... while(0) construct here. Why not something simpler? #define atomic_init(p, v) ((p)->a = (v)) #define atomic_destroy(p) ((void)0) Likewise for atomic_set(), which seems to do the same thing as atomic_init(). John -- John Polstra jdp@polstra.com John D. Polstra & Co., Inc. Seattle, Washington USA "Disappointment is a good sign of basic intelligence." -- Chögyam Trungpa To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message