cvs commit: src/sys/i386/include atomic.h
John Baldwin
jhb at freebsd.org
Tue Mar 28 18:27:57 UTC 2006
On Tuesday 28 March 2006 11:30, Dag-Erling Smørgrav wrote:
> John Baldwin <jhb at freebsd.org> writes:
> > On Tuesday 28 March 2006 09:34, Dag-Erling Smorgrav wrote:
> > > Log:
> > > Use wrapper macros for atomic pointer operations in order to perform the
> > > correct casts. This should probably be merged to other architectures.
> > It should really be uintptr_t rather than u_int.
>
> I realize that, but I wasn't sure I could safely assume that uintptr_t
> is defined - and by definition, at this point in the code, we know
> that u_int is compatible with a pointer.
Hmm, I think you can assume that because sparc64's atomic.h uses
uintptr_t. I'd prefer it as it would reduce diff's with other archs
as well (I tend to do diff's between files in sys/i386 and sys/amd64).
One reason for not having the casts, btw, is that you lose type checking.
Requiring the caller to add the casts in places that aren't operating
on uintptr_t's (note that the mutex and rwlock code both do operate on
uintptr_t's) should force them to have to think (somewhat) and make sure
they are really operating on a pointer and not an int, etc. Maybe that
level of typechecking isn't needed and perhaps I'm being overly paranoid
due to all the (older) code that assumes sizeof(int) == sizeof(ptr).
--
John Baldwin <jhb at FreeBSD.org> <>< http://www.FreeBSD.org/~jhb/
"Power Users Use the Power to Serve" = http://www.FreeBSD.org
More information about the cvs-src
mailing list