Date: Wed, 31 Jan 2001 21:06:25 -0500 From: "Matthew Emmerton" <matt@gsicomp.on.ca> To: "John Baldwin" <jhb@FreeBSD.org> Cc: <freebsd-hackers@FreeBSD.org> Subject: Re: Atomic bit operations Message-ID: <015401c08bf3$95294ec0$1200a8c0@gsicomp.on.ca> References: <XFMail.010131172705.jhb@FreeBSD.org>
next in thread | previous in thread | raw e-mail | index | archive | help
> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?015401c08bf3$95294ec0$1200a8c0>