Re: [AD] allegro-4.2.0 compilation error with gcc-4.1.2

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On Sat, Jul 01, 2006 at 02:26:34PM +0200, Elias Pschernig wrote:
> Thanks, but I'm still not sure. I read a bit in the gcc docs, and the
> 
> "=&d" (edx) 
> 
> seems to have been put there by the original author so x and y won't be
> put into EDX. After the patch, this can happen. Is this really allowed?

Thanks for the explanation.

The problem is that the assembler code made assumptions
about the allocation of registers, which the patch fixes.
Matthew fixed the patch so it should do the right thing.
Matthew also said:
It probably should have a dummy variable assigned to the usage of %eax as well.

> And why is the same code valid for fixdiv?

Sorry, I don't know.

> Also, I tried with this version of gcc:
> 
> gcc (GCC) 4.1.2 20060613 (prerelease) (Debian 4.1.1-5)
> 
> And it does not complain.

Weird.
gcc (GCC) 4.1.2 20060628 prerelease (NetBSD nb1 20060602)
here.

> So, well, need to wait until someone who knows more about it shows up,
> or provide me with even more info if I should apply it :)

I hope someone shows up :)
 Thomas
$NetBSD$

--- include/allegro/platform/al386gcc.h.orig	2005-03-09 13:49:46.000000000 -0800
+++ include/allegro/platform/al386gcc.h	2006-07-01 05:39:49.000000000 -0700
@@ -208,29 +208,29 @@
  */
 AL_INLINE(fixed, fixmul, (fixed x, fixed y),
 {
-   fixed edx __attribute__ ((__unused__));
+   long edx;
    fixed result;
 
    __PRECALCULATE_CONSTANTS(x / 65536.0 * y)
    {
       __asm__ (
-	 "  movl %2, %%eax ; "
-	 "  imull %3 ; "                  /* do the multiply */
-	 "  shrdl $16, %%edx, %%eax ; "
+	 "  movl %1, %%eax ; "
+	 "  imull %2 ; "                  /* do the multiply */
+	 "  shrdl $16, %5, %%eax ; "
 
-	 "  sarl $15, %%edx ; "           /* check for overflow */
+	 "  sarl $15, %5 ; "           /* check for overflow */
 	 "  jz 0f ; "
-	 "  cmpl $-1, %%edx ; "
+	 "  cmpl $-1, %5 ; "
 	 "  je 0f ; "
 
-	 "  movl %5, %%eax ; "            /* on overflow, set errno */
-	 "  movl %4, (%%eax) ; "
+	 "  movl %4, %%eax ; "            /* on overflow, set errno */
+	 "  movl %3, (%%eax) ; "
 	 "  movl $0x7FFFFFFF, %%eax ; "   /* and return MAXINT */
-	 "  cmpl $0, %2 ; "
+	 "  cmpl $0, %1 ; "
 	 "  jge 1f ; "
 	 "  negl %%eax ; "
 	 " 1: "
-	 "  cmpl $0, %3 ; "
+	 "  cmpl $0, %2 ; "
 	 "  jge 0f ; "
 	 "  negl %%eax ; "
 
@@ -238,13 +238,13 @@
 
 	 " 0: "                           /* finished */
 
-      : "=&a" (result),                   /* the result has to go in eax */
-	"=&d" (edx)                       /* reliably reserve edx */
+      : "=&a" (result)                    /* the result has to go in eax */
 
       : "mr" (x),                         /* x and y can be regs or mem */
 	"mr" (y),
 	"i" (ERANGE),
-	"m" (allegro_errno)
+	"m" (allegro_errno),
+	"d" (edx)
 
       : "%cc", "memory"                   /* clobbers flags and errno */
       );


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/