Index: winsup/cygwin/winbase.h =================================================================== RCS file: /cvs/src/src/winsup/cygwin/winbase.h,v retrieving revision 1.14 diff -p -u -r1.14 winbase.h --- winsup/cygwin/winbase.h 12 Jul 2008 18:09:17 -0000 1.14 +++ winsup/cygwin/winbase.h 3 Jun 2009 22:54:38 -0000 @@ -34,27 +34,31 @@ ilockdecr (volatile long *m) ": "=&r" (__res), "=m" (*m): "m" (*m): "cc"); return __res; } - -extern __inline__ long -ilockexch (volatile long *t, long v) -{ - register int __res; - __asm__ __volatile__ ("\n\ -1: lock cmpxchgl %3,(%1)\n\ - jne 1b\n\ - ": "=a" (__res), "=q" (t): "1" (t), "q" (v), "0" (*t): "cc"); - return __res; -} - -extern __inline__ long -ilockcmpexch (volatile long *t, long v, long c) -{ - register int __res; - __asm__ __volatile__ ("\n\ - lock cmpxchgl %3,(%1)\n\ - ": "=a" (__res), "=q" (t) : "1" (t), "q" (v), "0" (c): "cc"); - return __res; -} + +extern __inline__ long +ilockexch (volatile long *t, long v) +{ + return ({ + __typeof (*t) ret; + __asm __volatile ("1: lock cmpxchgl %2, %1\n" + " jne 1b\n" + : "=a" (ret), "=m" (*t) + : "r" (v), "m" (*t), "0" (*t)); + ret; + }); +} + +extern __inline__ long +ilockcmpexch (volatile long *t, long v, long c) +{ + return ({ + __typeof (*t) ret; + __asm __volatile ("lock cmpxchgl %2, %1" + : "=a" (ret), "=m" (*t) + : "r" (v), "m" (*t), "0" (c)); + ret; + }); +} #undef InterlockedIncrement #define InterlockedIncrement ilockincr