Re: [AD] ALLEGRO_USE_C vs ALLEGRO_NO_ASM

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


On Sat, 2006-03-25 at 16:32 +0000, Peter Hull wrote:
> As far as I can tell, ALLEGRO_USE_C is something that we set in the
> makefile (either statically for OSX/PowerPC or  via a ./configure
> option on Linux) whereas ALLEGRO_NO_ASM is set by the compiler at
> build time.  There are certain 'valid' combinations of compiler and
> processor for which assembly code exists, and if it's a different
> combination, ALLEGRO_NO_ASM is set. This happens in asm.inl.
> 
> This relates to Juvinious's problem with his Intel OSX compile.
> (http://sourceforge.net/mailarchive/forum.php?thread_id=9929081&forum_id=34598)
> 
> The problem we found is that OSX/Intel is a 'valid' combination (i86 +
> gcc) but we don't want asm.inl to include any assembly code. Some
> functions (_stub_bank_switch was one of them) have both asm and C
> implementations, but the C version is only defined if ALLEGRO_NO_ASM
> is set. Since the asm version is in a file which isn't part of the OSX
> build, these functions are never defined. 
> 
> What needs to happen is that ALLEGRO_USE_C should override the
> compiler's decision to use asm or not. As far as we could see in our
> discussion on #allegro, ALLEGRO_USE_C and ALLEGRO_NO_ASM as synonymous
> - there are no cases where you'd want one set, but not the other.
> Therefore they should be merged in my opinion. 
> 
> Another thing is that alconfig.h independently checks for gcc/i386 and
> defines a little bit of inline assembly. This needs to be overridden
> by ALLEGRO_USE_C as well.
> 

Ok, so basically, the makefile can simply set ALLEGRO_NO_ASM instead of
ALLEGRO_USE_C - and the ALLEGRO_USE_C define can go. Could maybe try to
trace back when it was introduced, but it seems clear that it never can
be right that one is set and not the other - unless we are
mis-understanding something.

Anyway, the attached patch replaces all occurences of ALLEGRO_USE_C
(except the makefile define mentioned in the docs) with ALLEGRO_NO_ASM.

And I also just noticed again in the test program that the non-asm
version is between 10% and 100% (!) faster in the draw_sprite tests for
my old pentium 4 here, so I propose to change the default ./configure
result to always disable asm, and give Allegro some speed up under unix
that way, the X11 port can need it :)

-- 
Elias Pschernig
Index: makefile.qnx
===================================================================
--- makefile.qnx	(revision 5763)
+++ makefile.qnx	(working copy)
@@ -99,7 +99,7 @@
 
 VPATH += src/c
 MY_OBJECTS = $(C_OBJECTS) cmiscs
-CFLAGS += -DALLEGRO_USE_C
+CFLAGS += -DALLEGRO_NO_ASM
 
 else
 
Index: src/poly3d.c
===================================================================
--- src/poly3d.c	(revision 5763)
+++ src/poly3d.c	(working copy)
@@ -32,7 +32,7 @@
    #include ALLEGRO_ASMCAPA_HEADER
 #endif
 
-#ifdef ALLEGRO_USE_C
+#ifdef ALLEGRO_NO_ASM
    #undef ALLEGRO_MMX
 #endif
 
Index: src/math.c
===================================================================
--- src/math.c	(revision 5763)
+++ src/math.c	(working copy)
@@ -289,7 +289,7 @@
 
 
 
-#if (defined ALLEGRO_I386) && (!defined ALLEGRO_USE_C)
+#if (defined ALLEGRO_I386) && (!defined ALLEGRO_NO_ASM)
 
 
 
Index: src/i386/asmdef.c
===================================================================
--- src/i386/asmdef.c	(revision 5763)
+++ src/i386/asmdef.c	(working copy)
@@ -118,7 +118,7 @@
   {"BMP_ID_MASK",     BMP_ID_MASK},
   {"#endif", 0 },
   {"NEWLINE", 0},
-#if !defined ALLEGRO_USE_C && defined ALLEGRO_I386
+#if !defined ALLEGRO_NO_ASM && defined ALLEGRO_I386
   {"CMP_PLANAR",      (int)offsetof(COMPILED_SPRITE, planar)},
   {"CMP_COLOR_DEPTH", (int)offsetof(COMPILED_SPRITE, color_depth)},
   {"CMP_DRAW",        (int)offsetof(COMPILED_SPRITE, proc)},
Index: src/misc/ccolconv.c
===================================================================
--- src/misc/ccolconv.c	(revision 5763)
+++ src/misc/ccolconv.c	(working copy)
@@ -26,7 +26,7 @@
 extern unsigned char *_colorconv_rgb_map;  /* for conversion from 8/12-bit to 8-bit */
 
 
-#if (defined ALLEGRO_USE_C || defined ALLEGRO_NO_ASM)
+#ifdef ALLEGRO_NO_ASM
 
 #ifdef ALLEGRO_COLOR8
 
Index: src/misc/modex.c
===================================================================
--- src/misc/modex.c	(revision 5763)
+++ src/misc/modex.c	(working copy)
@@ -665,7 +665,7 @@
     * The bank switchers assume asm-mode calling conventions, but the
     * library would try to call them with C calling conventions.
     */
-#ifdef ALLEGRO_USE_C
+#ifdef ALLEGRO_NO_ASM
    return NULL;
 #endif
 
@@ -821,7 +821,7 @@
     * The bank switchers assume asm-mode calling conventions, but the
     * library would try to call them with C calling conventions.
     */
-#ifdef ALLEGRO_USE_C
+#ifdef ALLEGRO_NO_ASM
    return NULL;
 #endif
 
Index: src/misc/vbeaf.c
===================================================================
--- src/misc/vbeaf.c	(revision 5763)
+++ src/misc/vbeaf.c	(working copy)
@@ -1183,7 +1183,7 @@
     * The bank switchers assume asm-mode calling conventions, but the
     * library would try to call them with C calling conventions.
     */
-#ifdef ALLEGRO_USE_C
+#ifdef ALLEGRO_NO_ASM
    return NULL;
 #endif
 
Index: src/colblend.c
===================================================================
--- src/colblend.c	(revision 5763)
+++ src/colblend.c	(working copy)
@@ -43,7 +43,7 @@
 
 
 
-#if (defined ALLEGRO_USE_C) || (!defined ALLEGRO_I386) 
+#if (defined ALLEGRO_NO_ASM) || (!defined ALLEGRO_I386) 
 				    /* i386 asm version is in imisc.s */
 
 
Index: makefile.mgw
===================================================================
--- makefile.mgw	(revision 5763)
+++ makefile.mgw	(working copy)
@@ -203,7 +203,7 @@
 
 VPATH += src/c
 MY_OBJECTS = $(C_OBJECTS) cmiscs
-CFLAGS += -DALLEGRO_USE_C
+CFLAGS += -DALLEGRO_NO_ASM
 
 else
 
Index: makefile.in
===================================================================
--- makefile.in	(revision 5765)
+++ makefile.in	(working copy)
@@ -215,7 +215,7 @@
 ifdef CROSSCOMPILE
 
 $(OBJDIR)/asmdef.s: src/i386/asmdef.c include/*.h include/allegro/*.h
-	$(CC) $(INCLUDES) `echo $(CFLAGS) | sed -e "s/.*\(-DALLEGRO_USE_C\).*/\1/"` -S -o $(OBJDIR)/asmdef.s src/i386/asmdef.c
+	$(CC) $(INCLUDES) `echo $(CFLAGS) | sed -e "s/.*\(-DALLEGRO_NO_ASM\).*/\1/"` -S -o $(OBJDIR)/asmdef.s src/i386/asmdef.c
 
 $(obj_unix_asmdef_inc): $(OBJDIR)/asmdef.s
 	@if [ ! -x misc/asmdef.sh ]; then chmod a+x misc/asmdef.sh; fi
Index: include/allegro/compiled.h
===================================================================
--- include/allegro/compiled.h	(revision 5763)
+++ include/allegro/compiled.h	(working copy)
@@ -27,7 +27,7 @@
 
 struct BITMAP;
 
-#if (defined ALLEGRO_I386) && (!defined ALLEGRO_USE_C)
+#if (defined ALLEGRO_I386) && (!defined ALLEGRO_NO_ASM)
 
 /* compiled sprite structure */
 typedef struct COMPILED_SPRITE
Index: makefile.osx
===================================================================
--- makefile.osx	(revision 5763)
+++ makefile.osx	(working copy)
@@ -140,7 +140,7 @@
 # -------- list platform specific objects and programs --------
 
 VPATH = src/macosx src/unix src/misc src/c tools/macosx
-CFLAGS += -DALLEGRO_USE_C
+CFLAGS += -DALLEGRO_NO_ASM
 
 ifdef STATICLINK
 ALLEGRO_SRC_MACOSX_FILES += src/macosx/main.m
Index: configure.in
===================================================================
--- configure.in	(revision 5763)
+++ configure.in	(working copy)
@@ -194,7 +194,7 @@
 
 if test -z "$ALLEGRO_MAYBE_ASM_FILES"; then
   ALLEGRO_MAYBE_ASM_FILES=ALLEGRO_SRC_C_FILES
-  CFLAGS="$CFLAGS -DALLEGRO_USE_C"
+  CFLAGS="$CFLAGS -DALLEGRO_NO_ASM"
   AC_DEFINE(ALLEGRO_NO_ASM,1,
 	    [Define for Unix platforms, to use C convention for bank switching.])
   _code_features="C only"
Index: makefile.be
===================================================================
--- makefile.be	(revision 5763)
+++ makefile.be	(working copy)
@@ -110,7 +110,7 @@
 
 VPATH += src/c
 MY_OBJECTS = $(C_OBJECTS) cmiscs
-CFLAGS += -DALLEGRO_USE_C
+CFLAGS += -DALLEGRO_NO_ASM
 
 else
 
Index: makefile.dj
===================================================================
--- makefile.dj	(revision 5763)
+++ makefile.dj	(working copy)
@@ -228,7 +228,7 @@
 
 VPATH += src/c
 MY_OBJECTS = $(C_OBJECTS) cmiscs
-CFLAGS += -DALLEGRO_USE_C
+CFLAGS += -DALLEGRO_NO_ASM
 
 else
 


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