From owner-freebsd-hackers Wed Jan 31 18: 0: 7 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from xena.gsicomp.on.ca (cr677933-a.ktchnr1.on.wave.home.com [24.43.230.149]) by hub.freebsd.org (Postfix) with ESMTP id 07B0837B6AE; Wed, 31 Jan 2001 17:59:43 -0800 (PST) Received: from hermes (hermes.gsicomp.on.ca [192.168.0.18]) by xena.gsicomp.on.ca (8.11.1/8.9.3) with SMTP id f111vwi11488; Wed, 31 Jan 2001 20:57:58 -0500 (EST) (envelope-from matt@gsicomp.on.ca) Message-ID: <015401c08bf3$95294ec0$1200a8c0@gsicomp.on.ca> From: "Matthew Emmerton" To: "John Baldwin" Cc: References: Subject: Re: Atomic bit operations Date: Wed, 31 Jan 2001 21:06:25 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > On 01-Feb-01 Matthew Emmerton wrote: > >> 2) atomic_set_int(&my_int, 4); sets bit _2_ in the integer variable > > my_int. > >> Make sense? You can't address individual bits on a machine. :-P > >> > >> > I presume that I could wrap the char operations with something that > > takes > >> > 0x01 and bit-shifts it appropriately so that atomic_set/clear could be > > used. > >> > >> Hmm, so you mean the API is atomic_set(&foo, x) implies foo |= 1 << x? > >> That means you can't set more than 1 bit atomically, which is a bit > >> limiting. > > > > Yes, but it's the API used by some code I recently inherited. (Recall that > > this API is Linux's asm/bitops.h) I realize that the existing > > atomic_xxx_xxx functions are much more flexible than bit-based ones, but > > wouldn't it make sense to have the full complement of functions available? > > If you don't want to patch the code, then you can use a local wrapper in your > code in the form of a suitable macro. We already have one atomic API, we don't > need to maintain 2. :) Well, I wasn't proposing to implement the entire Linux API, rather add 'bit' to the the existing list of 'char, int, long' that is currently supported. It wouldn't be too difficult, and some people might even find it convenient. -- Matt Emmerton To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message