From: Christopher F. <cg...@al...> - 2004-05-25 23:50:19
|
On Tue, May 25, 2004 at 05:14:00AM +0100, Danny Smith wrote: > >----- Original Message ----- >From: "Christopher Faylor" >| On Mon, May 24, 2004 at 02:55:34PM +0800, Wu Yongwei wrote: >| >Ah. I did not know but the reason is quite simple: they lack the >| >"memory" clobber (which both your code and mine has). Should we CC to >| >Chris reporting this? >| >| I don't understand why a memory clobber was needed in this case. Shouldn't >| it be something like this: >| >| __inline__ long >| ilockincr (long *m) >| { >| register int __res; >| __asm__ __volatile__ ("\n\ >| movl $1,%0\n\ >| lock xadd %0,%1\n\ >| inc %0\n\ >| ": "=a" (__res), "+m" (m)); >| return __res; >| } >| > >Have a look at config/i486/atomicity.h in 3.4.0 or trunk libstdc++ sources.. > >(m) is input and output. > >/* From libstdc++ i486/atomicity.h */ > >Atomically add __val to *__mem. Return intial value of *__mem. > >static __inline__ long >__gthr_i486__exchange_and_add (volatile long * __mem, const int __val) >{ > register long __sav_val; > __asm__ __volatile__ ("lock; xadd{l} {%0,%1|%1,%0}" > : "=r" (__save_val), "=m" (*__mem) ^ There's the clue. Pretty obvious when you think about it. Making that change seems to fix the problem with cygwin's versions of these routines. cgf |