From: Leon B. <le...@us...> - 2008-02-25 14:07:16
|
Update of /cvsroot/djvu/djvulibre-3.5/libdjvu In directory sc8-pr-cvs12.sourceforge.net:/tmp/cvs-serv30234 Modified Files: atomic.cpp Log Message: simplified asm code. Index: atomic.cpp =================================================================== RCS file: /cvsroot/djvu/djvulibre-3.5/libdjvu/atomic.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** atomic.cpp 25 Feb 2008 02:06:28 -0000 1.4 --- atomic.cpp 25 Feb 2008 14:07:07 -0000 1.5 *************** *** 163,167 **** #if USE_WIN32_INTERLOCKED && !HAVE_SYNC ! # define SYNC_ACQ(l) (! InterlockedCompareExchange((LONG volatile *)(l),1,0)) # if defined(_M_ALPHA) || defined(_M_PPC) || defined(_M_IA64) # define SYNC_REL(l) (InterlockedExchange((LONG volatile *)(l),0)) --- 163,167 ---- #if USE_WIN32_INTERLOCKED && !HAVE_SYNC ! # define SYNC_ACQ(l) (! InterlockedExchange((LONG volatile *)(l),1)) # if defined(_M_ALPHA) || defined(_M_PPC) || defined(_M_IA64) # define SYNC_REL(l) (InterlockedExchange((LONG volatile *)(l),0)) *************** *** 174,186 **** #if USE_GCC_I386_ASM && !HAVE_SYNC ! static int cas_acq(int volatile *atomic, int newval, int cmpval) { int oldval; ! __asm__ __volatile__ ("lock; cmpxchgl %2, %1" ! : "=a" (oldval), "=m" (*atomic) ! : "r" (newval), "m" (*atomic), "0" (cmpval)); return oldval; } ! # define SYNC_ACQ(l) (! cas_acq(l,1,0)) # define SYNC_REL(l) (*(int volatile *)l = 0) # define HAVE_SYNC 1 --- 174,186 ---- #if USE_GCC_I386_ASM && !HAVE_SYNC ! static int xchgl(int volatile *atomic, int newval) { int oldval; ! __asm__ __volatile__ ("xchgl %0, %1" ! : "=r" (oldval), "=m" (*atomic) ! : "0" (newval), "m" (*atomic)); return oldval; } ! # define SYNC_ACQ(l) (! xchgl(l,1)) # define SYNC_REL(l) (*(int volatile *)l = 0) # define HAVE_SYNC 1 *************** *** 189,203 **** #if USE_GCC_PPC_ASM && !HAVE_SYNC ! static int cas_acq(int volatile *atomic, int newval, int cmpval) { int oldval; ! __asm __volatile ("1: lwarx %0,0,%1\n" ! " cmpw %0,%2\n" ! " bne 2f\n" ! " stwcx. %3,0,%1\n" " bne- 1b\n" ! "2: isync" ! : "=&r" (oldval) ! : "b" (atomic), "r" (cmpval), "r" (newval) : "cr0", "memory"); return oldval; --- 189,201 ---- #if USE_GCC_PPC_ASM && !HAVE_SYNC ! static int xchg_acq(int volatile *atomic, int newval) { int oldval; ! __asm __volatile ("1: lwarx %0,0,%2\n" ! " stwcx. %3,0,%2\n" " bne- 1b\n" ! " isync" ! : "=&r" (oldval), "=m" (*atomic) ! : "b" (atomic), "r" (newval), "m" (*atomic) : "cr0", "memory"); return oldval; *************** *** 208,212 **** *atomic = newval; } ! # define SYNC_ACQ(l) (! cas_acq(l,1,0)) # define SYNC_REL(l) st_rel(l,0) # define HAVE_SYNC 1 --- 206,210 ---- *atomic = newval; } ! # define SYNC_ACQ(l) (! xchg_acq(l,1)) # define SYNC_REL(l) st_rel(l,0) # define HAVE_SYNC 1 |