]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.power64] runtime: test CAS on large unsigned 32-bit numbers
authorAustin Clements <austin@google.com>
Thu, 30 Oct 2014 15:17:26 +0000 (11:17 -0400)
committerAustin Clements <austin@google.com>
Thu, 30 Oct 2014 15:17:26 +0000 (11:17 -0400)
This adds a test to runtime·check to ensure CAS of large
unsigned 32-bit numbers does not accidentally sign-extend its
arguments.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/162490044

src/runtime/runtime.c

index f19f8e4be3c397aab8da7923d47ea56ef324cbad..a68414284876c38cf822c761a781a91eac75ed88 100644 (file)
@@ -226,6 +226,12 @@ runtime·check(void)
        if(z != 4)
                runtime·throw("cas4");
 
+       z = 0xffffffff;
+       if(!runtime·cas(&z, 0xffffffff, 0xfffffffe))
+               runtime·throw("cas5");
+       if(z != 0xfffffffe)
+               runtime·throw("cas6");
+
        k = (byte*)0xfedcb123;
        if(sizeof(void*) == 8)
                k = (byte*)((uintptr)k<<10);