zos: implement cmpxchgi() using assembly (#3543)

Use hand-rolled assembly to resolve a runtime bug related to the codegen
from builtin __plo_CSST.

Co-authored-by: ccw <ccw.280231@ca.ibm.com>
This commit is contained in:
Wayne Zhang 2022-03-13 17:50:09 -04:00 committed by GitHub
parent bc9cd56345
commit 442e471cfc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -37,12 +37,11 @@ UV_UNUSED(static int cmpxchgi(int* ptr, int oldval, int newval)) {
: "memory");
return out;
#elif defined(__MVS__)
unsigned int op4;
if (__plo_CSST(ptr, (unsigned int*) &oldval, newval,
(unsigned int*) ptr, *ptr, &op4))
return oldval;
else
return op4;
/* Use hand-rolled assembly because codegen from builtin __plo_CSST results in
* a runtime bug.
*/
__asm(" cs %0,%2,%1 \n " : "+r"(oldval), "+m"(*ptr) : "r"(newval) :);
return oldval;
#elif defined(__SUNPRO_C) || defined(__SUNPRO_CC)
return atomic_cas_uint((uint_t *)ptr, (uint_t)oldval, (uint_t)newval);
#else