Re: [AD] 64bit CPU detection patch

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


On Sunday 02 January 2005 01:37, aj wrote:
> im a patch newbie, sorry..  can someone add these 2 lines to
> /allegro/src/i386/icpu.c
> and also add the defines to the list in /include/allegro/system.h  

Proper patch (including docs) attached.
My only `problem' with it is that Allegro actually doesn't use SSE3, or any 
64 bit code. Maybe that's not much of a concern though.

Evert
? src/fontbios.c
? src/fontbmp.c
? src/fontdat.c
? src/fontgrx.c
? src/readfont.c
? src/i386/~icpu.c
? include/allegro/font.h
Index: docs/src/allegro._tx
===================================================================
RCS file: /cvsroot/alleg/allegro/docs/src/allegro._tx,v
retrieving revision 1.286
diff -u -r1.286 allegro._tx
--- docs/src/allegro._tx	4 Jan 2005 17:09:10 -0000	1.286
+++ docs/src/allegro._tx	5 Jan 2005 22:25:59 -0000
@@ -414,10 +414,13 @@
 		     variables are 100% reliable, otherwise there
 		     may be some mistakes.
       CPU_FPU      - An x87 FPU is available.
+      CPU_IA64     - Running on Intel 64 bit CPU
+      CPU_AMD64    - Running on AMD 64 bit CPU
       CPU_MMX      - Intel MMX  instruction set is available.
       CPU_MMXPLUS  - Intel MMX+ instruction set is available.
       CPU_SSE      - Intel SSE  instruction set is available.
       CPU_SSE2     - Intel SSE2 instruction set is available.
+      CPU_SSE3     - Intel SSE3 instruction set is available.
       CPU_3DNOW    - AMD 3DNow! instruction set is available.
       CPU_ENH3DNOW - AMD Enhanced 3DNow! instruction set is
 		     available.
Index: include/allegro/system.h
===================================================================
RCS file: /cvsroot/alleg/allegro/include/allegro/system.h,v
retrieving revision 1.13
diff -u -r1.13 system.h
--- include/allegro/system.h	4 Dec 2004 12:59:50 -0000	1.13
+++ include/allegro/system.h	5 Jan 2005 22:26:01 -0000
@@ -108,6 +108,9 @@
 #define CPU_3DNOW    0x0040
 #define CPU_ENH3DNOW 0x0080
 #define CPU_CMOV     0x0100
+#define CPU_AMD64    0x0200
+#define CPU_IA64     0x0400
+#define CPU_SSE3     0x0800
 
 AL_ARRAY(char, cpu_vendor);
 AL_VAR(int, cpu_family);
? src/fontbios.c
? src/fontbmp.c
? src/fontdat.c
? src/fontgrx.c
? src/readfont.c
Index: src/i386/icpu.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/i386/icpu.c,v
retrieving revision 1.6
diff -u -r1.6 icpu.c
--- src/i386/icpu.c	12 Aug 2003 17:49:23 -0000	1.6
+++ src/i386/icpu.c	5 Jan 2005 22:29:11 -0000
@@ -120,9 +120,11 @@
 	 cpu_capabilities |= (reg[3] & 0x800000 ? CPU_MMX : 0);
 
 	 /* SSE has MMX+ included */
-	 cpu_capabilities |= (reg[3] & 0x2000000 ? CPU_SSE | CPU_MMXPLUS : 0);
-	 cpu_capabilities |= (reg[3] & 0x4000000 ? CPU_SSE2 : 0);
-	 cpu_capabilities |= (reg[3] & 0x8000 ? CPU_CMOV : 0);
+	 cpu_capabilities |= (reg[3] & 0x02000000 ? CPU_SSE | CPU_MMXPLUS : 0);
+	 cpu_capabilities |= (reg[3] & 0x04000000 ? CPU_SSE2 : 0);
+         cpu_capabilities |= (reg[2] & 0x00000001 ? CPU_SSE3 : 0);
+	 cpu_capabilities |= (reg[3] & 0x00008000 ? CPU_CMOV : 0);
+         cpu_capabilities |= (reg[3] & 0x40000000 ? CPU_IA64 : 0);
       }
 
       _i_get_cpuid_info(0x80000000, reg);
@@ -130,7 +132,8 @@
 	 _i_get_cpuid_info(0x80000001, reg);
 
 	 cpu_capabilities |= (reg[3] & 0x80000000 ? CPU_3DNOW : 0);
-	 
+	 cpu_capabilities |= (reg[3] & 0x20000000 ? CPU_AMD64 : 0);
+	 
 	 /* Enhanced 3DNow! has MMX+ included */	 
 	 cpu_capabilities |= (reg[3] & 0x40000000 ? CPU_ENH3DNOW | CPU_MMXPLUS : 0);
       }


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