It seems to me that the size of the result of cmpxchg(ptr,old,new) should depend on the size of *ptr and not the size of old. For example, see the following: #include #define __SMP__ #define CONFIG_SMP #include typedef unsigned long long uint64_t; uint64_t long lock=0xDEADBEEF00000000; uint64_t long result; main() { result = cmpxchg(&lock,0,1); if (result == 0) printf("failed!!\n"); printf("sizeof(0)=%d sizeof(1)=%d\n",sizeof(0),sizeof(1)); result = cmpxchg(&lock,(uint64_t)0,1); if (result != 0) printf("succeeded!!\n"); } If you run this, you get failed!! succeeded!! The problem is that cmpxchg() returns 0xDEADBEEF00000000 but then gcc generates a sxt4 to truncate the result down to an int, which is the size of old. This is incorrect as near as I can tell. Attached is a patch to fix. -- Best Regards, Ray ----------------------------------------------- Ray Bryant SGI 512-453-9679 (work) 512-507-7807 (cell) raybry@sgi.com raybry@austin.rr.com Computers are like air conditioners. They stop working when you open Windows. -----------------------------------------------