On Jul 20 2010, Jeff Squyres wrote:
>The change was to add casting:
> } while (!OPAL_ATOMIC_CMPSET_32((int32_t*)&ep->eager_rdma_remote.seq,
> (int32_t)ftr->seq, (int32_t)ftr->seq+1));
>Is it safe to simply cast a (uint32_t*) to (int32_t*) in the first param?
Pretty safe. While there ARE circumstances under which it might fail,
I am almost certain that there are no current systems that will expose
them, and that none will appear in the near future. Furthermore, it is
almost, but not quite, specified to be legal by the C99 standard.
> Also, it seems like the 3rd parameter could be problematic if it ever
> goes larger than 2B -- it'll increment in the wrong direction, won't it?
Not on most systems. While this is more clearly illegal, similar remarks
apply to its safety. If there were any debugging C compilers around, it
might well get trapped, but those are about as common as unicorns.
It's a horrible coding style, but this is a case of damned if you do, and
damned if you don't.