[gameprogrammer] SDL atomic operations part #2, and many thanks to the QNX maintainer.

Ok, I've rounded up information about atomic operations as provided by GCC,
QNX, Mac OS X, and windows. I've posted it at:
http://thegrumpyprogrammer.com/node/15.

Part #3 will be an attempt at a redesign based on what I have learned. I
want to reduce, as much as possible, the number of emulated ops.

I have a couple of major question that I would like folks to get opinionated
about. The main question is about atomic operations on pointers. I
originally wrote the atomic ops so that they only worked on unsigned ints. I
figured people would deal with pointers by casting them to unsigned of the
right size. Mac OS X, and Windows provide atomic ops on signed ints and
provided operations for pointers. On windows there is very little support
for atomic ops on pointers, but there is a little.

Having looked at what the other guys do I rather like providing separate ops
for ints and pointers. BUT, that would mean casting pointers to signed ints
on some platforms. Casting pointers to signed ints makes me very very
nervous. I spent too much of my youth working on machines where int and
(void *) were not the same size.

The other thing is also a casting question. How do you feel about casting
signed to unsigned, doing doing addition or subtraction, and then casting it
back? Or, the reverse. We have the problem that some of the platforms
provide ops for only signed ints and some for only unsigned ints.

Bob Pendleton

-- 
+-----------------------------------------------------------
+ Bob Pendleton: writer and programmer
+ email: Bob@xxxxxxxxxxxxx
+ web: www.TheGrumpyProgrammer.com

Other related posts: