First pass at fixing concurrency issue

This is the patch using CAS instead of the load store sequence.  Do you think I should use a packed C struct instead of these macros?

I do think this is equivalent to the other method, except for the fact that in this one the writers (I believe) will have slightly more contention, since they will cause each other to fail the CAS.  This may end up being the same amount of contention as the contention to just increment the value, and in any case it doesn't seem obviously slower.