This is the mail archive of the cygwin-patches mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Re: 1.7 winbase.h (ilockcmpexch) compile error


Brian Ford wrote:
> I'm trying to build Cygwin 1.7 from CVS to debug an ImageMagick problem on
> server 2008 that causes an access violation in cygwin1.dll.  Doe anyone
> know the work around for this issue?
> 
> g++ (GCC) 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)
> 
> winsup/cygwin/winbase.h: In
> member function `int pthread_mutex::_trylock(pthread*)':
> winsup/cygwin/winbase.h:59:
> warning: volatile register variables don't work as you might wish
> winsup/cygwin/winbase.h:63:
> error: can't find a register in class `AREG' while reloading `asm'

  The attached patch fixes the warning about volatile register variables, by
explicitly specifying the type, instead of using typeof() the input parameter
(which inherits the volatility), and which I also saw using gcc HEAD the other
day.

  It doesn't do anything about the reload failure, which is a bug in GCC-3,
since the usage is a standard usage supported by the documentation.  It's
possible that it may disappear as a side-effect, in which case all the better.
 (I experimented briefly with removing the register asm from the source and
building it with gcc-4.3.2, and the results were disappointing; we actually
got worse register allocation, resulting in some functions having larger stack
frames and more registers saved/restored, so I guess the RA can still benefit
from the extra hint.)

  Tested by building thread.o and shared.o with CFLAGS="-g -O2 --save-temps"
before and after and comparing the generated .s file; no differences except in
debug info, where (naturally) a bunch of bits changed in the flag words
encoding the datatypes of variables.

winsup/cygwin/ChangeLog:

	* winbase.h (ilockexch):  Avoid making 'ret' volatile.
	(ilockcmpexch):  Likewise.

  Ok?

    cheers,
      DaveK
Index: winsup/cygwin/winbase.h
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/winbase.h,v
retrieving revision 1.15
diff -p -u -r1.15 winbase.h
--- winsup/cygwin/winbase.h	5 Jun 2009 13:53:01 -0000	1.15
+++ winsup/cygwin/winbase.h	7 Jul 2009 20:53:12 -0000
@@ -40,7 +40,7 @@ ilockexch (volatile long *t, long v)
 {
   return
   ({
-    register __typeof (*t) ret __asm ("%eax");
+    register long ret __asm ("%eax");
     __asm __volatile ("\n"
 	"1:	lock cmpxchgl %2, %1\n"
 	"	jne  1b\n"
@@ -56,7 +56,7 @@ ilockcmpexch (volatile long *t, long v, 
 {
   return
   ({
-    register __typeof (*t) ret __asm ("%eax");
+    register long ret __asm ("%eax");
     __asm __volatile ("lock cmpxchgl %2, %1"
 	: "=a" (ret), "=m" (*t)
 	: "r" (v), "m" (*t), "0" (c)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]