mstorsjo added inline comments.

Comment at: lib/Headers/intrin.h:504
@@ +503,3 @@
+_interlockedbittestandset_acq(long volatile *_BitBase, long _BitPos) {
+  long _PrevVal = __atomic_fetch_or(_BitBase, 1l << _BitPos, __ATOMIC_ACQUIRE);
+  return (_PrevVal >> _BitPos) & 1;
compnerd wrote:
> Perhaps we should add static asserts that _BitPos is within limits for the 
> signed shift.
Sure, although I guess that also goes for the existing inline functions as well?

Which kind of assert would be suitable for that here? As far as I see, 
static_assert is C++ only, while this header also can be used from C.

If I try to add _Static_assert, which is usable in C, I get the following error 
when compiling:

intrin.h:499:18: error: 
      static_assert expression is not an integral constant expression
  _Static_assert(_BitPos < 32, "_BitPos out of range");

This even when I don't actually use the inline function anywhere, just 
including intrin.h.

Comment at: lib/Headers/intrin.h:517
@@ -501,1 +516,3 @@
 #ifdef __x86_64__
compnerd wrote:
> Are the names supposed to be all lower case?
Yes, these ones (for some reason) are all lower case:

cfe-commits mailing list

Reply via email to