From: Austin Clements Date: Thu, 30 Oct 2014 15:17:26 +0000 (-0400) Subject: [dev.power64] runtime: test CAS on large unsigned 32-bit numbers X-Git-Tag: go1.5beta1~2684^2~11^2~25 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=36d417c0e380b8ea762812b415796cf4b0af72de;p=gostls13.git [dev.power64] runtime: test CAS on large unsigned 32-bit numbers 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 --- diff --git a/src/runtime/runtime.c b/src/runtime/runtime.c index f19f8e4be3..a684142848 100644 --- a/src/runtime/runtime.c +++ b/src/runtime/runtime.c @@ -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);