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 Tue, Jun 27, 2006 at 10:36:27PM +0200, Thomas Klausner wrote:
> I tried compiling allegro-4.2.0 under NetBSD-3.99.21/i386
> with gcc (GCC) 4.1.2 20060603 prerelease (NetBSD nb1 20060602).
> It failed with:
> ./src/math3d.c: In function 'matrix_mul':
> include/allegro/platform/al386gcc.h:209: error: can't find a register in class 'GENERAL_REGS' while reloading 'asm'
> include/allegro/platform/al386gcc.h:209: error: can't find a register in class 'GENERAL_REGS' while reloading 'asm'

Matthew R. Green came up with the attached patch, which fixes
the compilation problem. Is it correct? If not, what would
be a correct patch?
 Thomas
$NetBSD: patch-ae,v 1.3 2006/07/01 09:59:49 wiz Exp $

--- include/allegro/platform/al386gcc.h.orig	2005-03-09 21:49:46.000000000 +0000
+++ include/allegro/platform/al386gcc.h
@@ -208,14 +208,13 @@ AL_INLINE(fixed, fixsub, (fixed x, fixed
  */
 AL_INLINE(fixed, fixmul, (fixed x, fixed y),
 {
-   fixed edx __attribute__ ((__unused__));
    fixed result;
 
    __PRECALCULATE_CONSTANTS(x / 65536.0 * y)
    {
       __asm__ (
-	 "  movl %2, %%eax ; "
-	 "  imull %3 ; "                  /* do the multiply */
+	 "  movl %1, %%eax ; "
+	 "  imull %2 ; "                  /* do the multiply */
 	 "  shrdl $16, %%edx, %%eax ; "
 
 	 "  sarl $15, %%edx ; "           /* check for overflow */
@@ -223,14 +222,14 @@ AL_INLINE(fixed, fixmul, (fixed x, fixed
 	 "  cmpl $-1, %%edx ; "
 	 "  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,8 +237,7 @@ AL_INLINE(fixed, fixmul, (fixed x, fixed
 
 	 " 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),


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