2013/5/20 dw <limegreenso...@yahoo.com>: > There is a bug in the InterlockedOr function (as well as InterlockedAnd, > InterlockedXor, InterlockedOr64, InterlockedAnd64, InterlockedXor64) where > they do not return the "old" value as expected, but instead return (sort of) > the new value. This code illustrates the problem: > > #include <stdio.h> > #include <windows.h> > > #ifndef _AMD64_ > #error Must be compiled for x64 > #endif > > int main() > { > volatile LONG x = 0; > LONG y = InterlockedXor(&x, 3); > > printf("old: %u new: %u\n", y, x); // Should print 0 3, prints 3 3 > } > > The attached patch resolves this issue. > > In summary, this patch: > > 1) Correctly returns the "old" value. > 2) Uses builtin function instead of inline asm. > > dw
Nice catch. Patch is ok. Could you please also prepare patch for crt's intrinsic-implementation files? Thanks, Kai ------------------------------------------------------------------------------ AlienVault Unified Security Management (USM) platform delivers complete security visibility with the essential security capabilities. Easily and efficiently configure, manage, and operate all of your security controls from a single console and one unified framework. Download a free trial. http://p.sf.net/sfu/alienvault_d2d _______________________________________________ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public