diff src/video/mmx.h @ 1895:c121d94672cb

SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
author Sam Lantinga <slouken@libsdl.org>
date Mon, 10 Jul 2006 21:04:37 +0000
parents 450721ad5436
children f2c2f0ecba5f
line wrap: on
line diff
--- a/src/video/mmx.h	Thu Jul 06 18:01:37 2006 +0000
+++ b/src/video/mmx.h	Mon Jul 10 21:04:37 2006 +0000
@@ -43,17 +43,18 @@
 	 by LL and unsigned long long values by ULL, lest
 	 they be truncated by the compiler)
 */
-typedef	union {
-	long long		q;	/* Quadword (64-bit) value */
-	unsigned long long	uq;	/* Unsigned Quadword */
-	int			d[2];	/* 2 Doubleword (32-bit) values */
-	unsigned int		ud[2];	/* 2 Unsigned Doubleword */
-	short			w[4];	/* 4 Word (16-bit) values */
-	unsigned short		uw[4];	/* 4 Unsigned Word */
-	char			b[8];	/* 8 Byte (8-bit) values */
-	unsigned char		ub[8];	/* 8 Unsigned Byte */
-	float			s[2];	/* Single-precision (32-bit) value */
-} __attribute__ ((aligned (8))) mmx_t;	/* On an 8-byte (64-bit) boundary */
+typedef union
+{
+    long long q;                /* Quadword (64-bit) value */
+    unsigned long long uq;      /* Unsigned Quadword */
+    int d[2];                   /* 2 Doubleword (32-bit) values */
+    unsigned int ud[2];         /* 2 Unsigned Doubleword */
+    short w[4];                 /* 4 Word (16-bit) values */
+    unsigned short uw[4];       /* 4 Unsigned Word */
+    char b[8];                  /* 8 Byte (8-bit) values */
+    unsigned char ub[8];        /* 8 Unsigned Byte */
+    float s[2];                 /* Single-precision (32-bit) value */
+} __attribute__ ((aligned(8))) mmx_t;   /* On an 8-byte (64-bit) boundary */
 
 
 #if 0
@@ -62,158 +63,95 @@
 inline extern int
 mm_support(void)
 {
-	/* Returns 1 if MMX instructions are supported,
-	   3 if Cyrix MMX and Extended MMX instructions are supported
-	   5 if AMD MMX and 3DNow! instructions are supported
-	   0 if hardware does not support any of these
-	*/
-	register int rval = 0;
-
-	__asm__ __volatile__ (
-		/* See if CPUID instruction is supported ... */
-		/* ... Get copies of EFLAGS into eax and ecx */
-		"pushf\n\t"
-		"popl %%eax\n\t"
-		"movl %%eax, %%ecx\n\t"
-
-		/* ... Toggle the ID bit in one copy and store */
-		/*     to the EFLAGS reg */
-		"xorl $0x200000, %%eax\n\t"
-		"push %%eax\n\t"
-		"popf\n\t"
-
-		/* ... Get the (hopefully modified) EFLAGS */
-		"pushf\n\t"
-		"popl %%eax\n\t"
-
-		/* ... Compare and test result */
-		"xorl %%eax, %%ecx\n\t"
-		"testl $0x200000, %%ecx\n\t"
-		"jz NotSupported1\n\t"		/* CPUID not supported */
-
-
-		/* Get standard CPUID information, and
-		       go to a specific vendor section */
-		"movl $0, %%eax\n\t"
-		"cpuid\n\t"
-
-		/* Check for Intel */
-		"cmpl $0x756e6547, %%ebx\n\t"
-		"jne TryAMD\n\t"
-		"cmpl $0x49656e69, %%edx\n\t"
-		"jne TryAMD\n\t"
-		"cmpl $0x6c65746e, %%ecx\n"
-		"jne TryAMD\n\t"
-		"jmp Intel\n\t"
-
-		/* Check for AMD */
-		"\nTryAMD:\n\t"
-		"cmpl $0x68747541, %%ebx\n\t"
-		"jne TryCyrix\n\t"
-		"cmpl $0x69746e65, %%edx\n\t"
-		"jne TryCyrix\n\t"
-		"cmpl $0x444d4163, %%ecx\n"
-		"jne TryCyrix\n\t"
-		"jmp AMD\n\t"
-
-		/* Check for Cyrix */
-		"\nTryCyrix:\n\t"
-		"cmpl $0x69727943, %%ebx\n\t"
-		"jne NotSupported2\n\t"
-		"cmpl $0x736e4978, %%edx\n\t"
-		"jne NotSupported3\n\t"
-		"cmpl $0x64616574, %%ecx\n\t"
-		"jne NotSupported4\n\t"
-		/* Drop through to Cyrix... */
-
+    /* Returns 1 if MMX instructions are supported,
+       3 if Cyrix MMX and Extended MMX instructions are supported
+       5 if AMD MMX and 3DNow! instructions are supported
+       0 if hardware does not support any of these
+     */
+    register int rval = 0;
 
-		/* Cyrix Section */
-		/* See if extended CPUID level 80000001 is supported */
-		/* The value of CPUID/80000001 for the 6x86MX is undefined
-		   according to the Cyrix CPU Detection Guide (Preliminary
-		   Rev. 1.01 table 1), so we'll check the value of eax for
-		   CPUID/0 to see if standard CPUID level 2 is supported.
-		   According to the table, the only CPU which supports level
-		   2 is also the only one which supports extended CPUID levels.
-		*/
-		"cmpl $0x2, %%eax\n\t"
-		"jne MMXtest\n\t"	/* Use standard CPUID instead */
-
-		/* Extended CPUID supported (in theory), so get extended
-		   features */
-		"movl $0x80000001, %%eax\n\t"
-		"cpuid\n\t"
-		"testl $0x00800000, %%eax\n\t"	/* Test for MMX */
-		"jz NotSupported5\n\t"		/* MMX not supported */
-		"testl $0x01000000, %%eax\n\t"	/* Test for Ext'd MMX */
-		"jnz EMMXSupported\n\t"
-		"movl $1, %0:\n\n\t"		/* MMX Supported */
-		"jmp Return\n\n"
-		"EMMXSupported:\n\t"
-		"movl $3, %0:\n\n\t"		/* EMMX and MMX Supported */
-		"jmp Return\n\t"
-
-
-		/* AMD Section */
-		"AMD:\n\t"
-
-		/* See if extended CPUID is supported */
-		"movl $0x80000000, %%eax\n\t"
-		"cpuid\n\t"
-		"cmpl $0x80000000, %%eax\n\t"
-		"jl MMXtest\n\t"	/* Use standard CPUID instead */
+    __asm__ __volatile__(
+                            /* See if CPUID instruction is supported ... */
+                            /* ... Get copies of EFLAGS into eax and ecx */
+                            "pushf\n\t"
+                            "popl %%eax\n\t" "movl %%eax, %%ecx\n\t"
+                            /* ... Toggle the ID bit in one copy and store */
+                            /*     to the EFLAGS reg */
+                            "xorl $0x200000, %%eax\n\t"
+                            "push %%eax\n\t" "popf\n\t"
+                            /* ... Get the (hopefully modified) EFLAGS */
+                            "pushf\n\t" "popl %%eax\n\t"
+                            /* ... Compare and test result */
+                            "xorl %%eax, %%ecx\n\t" "testl $0x200000, %%ecx\n\t" "jz NotSupported1\n\t" /* CPUID not supported */
+                            /* Get standard CPUID information, and
+                               go to a specific vendor section */
+                            "movl $0, %%eax\n\t" "cpuid\n\t"
+                            /* Check for Intel */
+                            "cmpl $0x756e6547, %%ebx\n\t"
+                            "jne TryAMD\n\t"
+                            "cmpl $0x49656e69, %%edx\n\t"
+                            "jne TryAMD\n\t"
+                            "cmpl $0x6c65746e, %%ecx\n"
+                            "jne TryAMD\n\t" "jmp Intel\n\t"
+                            /* Check for AMD */
+                            "\nTryAMD:\n\t"
+                            "cmpl $0x68747541, %%ebx\n\t"
+                            "jne TryCyrix\n\t"
+                            "cmpl $0x69746e65, %%edx\n\t"
+                            "jne TryCyrix\n\t"
+                            "cmpl $0x444d4163, %%ecx\n"
+                            "jne TryCyrix\n\t" "jmp AMD\n\t"
+                            /* Check for Cyrix */
+                            "\nTryCyrix:\n\t"
+                            "cmpl $0x69727943, %%ebx\n\t"
+                            "jne NotSupported2\n\t"
+                            "cmpl $0x736e4978, %%edx\n\t"
+                            "jne NotSupported3\n\t"
+                            "cmpl $0x64616574, %%ecx\n\t"
+                            "jne NotSupported4\n\t"
+                            /* Drop through to Cyrix... */
+                            /* Cyrix Section */
+                            /* See if extended CPUID level 80000001 is supported */
+                            /* The value of CPUID/80000001 for the 6x86MX is undefined
+                               according to the Cyrix CPU Detection Guide (Preliminary
+                               Rev. 1.01 table 1), so we'll check the value of eax for
+                               CPUID/0 to see if standard CPUID level 2 is supported.
+                               According to the table, the only CPU which supports level
+                               2 is also the only one which supports extended CPUID levels.
+                             */
+                            "cmpl $0x2, %%eax\n\t" "jne MMXtest\n\t"    /* Use standard CPUID instead */
+                            /* Extended CPUID supported (in theory), so get extended
+                               features */
+                            "movl $0x80000001, %%eax\n\t" "cpuid\n\t" "testl $0x00800000, %%eax\n\t"    /* Test for MMX */
+                            "jz NotSupported5\n\t"      /* MMX not supported */
+                            "testl $0x01000000, %%eax\n\t"      /* Test for Ext'd MMX */
+                            "jnz EMMXSupported\n\t" "movl $1, %0:\n\n\t"        /* MMX Supported */
+                            "jmp Return\n\n" "EMMXSupported:\n\t" "movl $3, %0:\n\n\t"  /* EMMX and MMX Supported */
+                            "jmp Return\n\t"
+                            /* AMD Section */
+                            "AMD:\n\t"
+                            /* See if extended CPUID is supported */
+                            "movl $0x80000000, %%eax\n\t" "cpuid\n\t" "cmpl $0x80000000, %%eax\n\t" "jl MMXtest\n\t"    /* Use standard CPUID instead */
+                            /* Extended CPUID supported, so get extended features */
+                            "movl $0x80000001, %%eax\n\t" "cpuid\n\t" "testl $0x00800000, %%edx\n\t"    /* Test for MMX */
+                            "jz NotSupported6\n\t"      /* MMX not supported */
+                            "testl $0x80000000, %%edx\n\t"      /* Test for 3DNow! */
+                            "jnz ThreeDNowSupported\n\t" "movl $1, %0:\n\n\t"   /* MMX Supported */
+                            "jmp Return\n\n" "ThreeDNowSupported:\n\t" "movl $5, %0:\n\n\t"     /* 3DNow! and MMX Supported */
+                            "jmp Return\n\t"
+                            /* Intel Section */
+                            "Intel:\n\t"
+                            /* Check for MMX */
+                            "MMXtest:\n\t" "movl $1, %%eax\n\t" "cpuid\n\t" "testl $0x00800000, %%edx\n\t"      /* Test for MMX */
+                            "jz NotSupported7\n\t"      /* MMX Not supported */
+                            "movl $1, %0:\n\n\t"        /* MMX Supported */
+                            "jmp Return\n\t"
+                            /* Nothing supported */
+                            "\nNotSupported1:\n\t" "#movl $101, %0:\n\n\t" "\nNotSupported2:\n\t" "#movl $102, %0:\n\n\t" "\nNotSupported3:\n\t" "#movl $103, %0:\n\n\t" "\nNotSupported4:\n\t" "#movl $104, %0:\n\n\t" "\nNotSupported5:\n\t" "#movl $105, %0:\n\n\t" "\nNotSupported6:\n\t" "#movl $106, %0:\n\n\t" "\nNotSupported7:\n\t" "#movl $107, %0:\n\n\t" "movl $0, %0:\n\n\t" "Return:\n\t":"=a"(rval):     /* no input */
+                            :"eax", "ebx", "ecx", "edx");
 
-		/* Extended CPUID supported, so get extended features */
-		"movl $0x80000001, %%eax\n\t"
-		"cpuid\n\t"
-		"testl $0x00800000, %%edx\n\t"	/* Test for MMX */
-		"jz NotSupported6\n\t"		/* MMX not supported */
-		"testl $0x80000000, %%edx\n\t"	/* Test for 3DNow! */
-		"jnz ThreeDNowSupported\n\t"
-		"movl $1, %0:\n\n\t"		/* MMX Supported */
-		"jmp Return\n\n"
-		"ThreeDNowSupported:\n\t"
-		"movl $5, %0:\n\n\t"		/* 3DNow! and MMX Supported */
-		"jmp Return\n\t"
-
-
-		/* Intel Section */
-		"Intel:\n\t"
-
-		/* Check for MMX */
-		"MMXtest:\n\t"
-		"movl $1, %%eax\n\t"
-		"cpuid\n\t"
-		"testl $0x00800000, %%edx\n\t"	/* Test for MMX */
-		"jz NotSupported7\n\t"		/* MMX Not supported */
-		"movl $1, %0:\n\n\t"		/* MMX Supported */
-		"jmp Return\n\t"
-
-		/* Nothing supported */
-		"\nNotSupported1:\n\t"
-		"#movl $101, %0:\n\n\t"
-		"\nNotSupported2:\n\t"
-		"#movl $102, %0:\n\n\t"
-		"\nNotSupported3:\n\t"
-		"#movl $103, %0:\n\n\t"
-		"\nNotSupported4:\n\t"
-		"#movl $104, %0:\n\n\t"
-		"\nNotSupported5:\n\t"
-		"#movl $105, %0:\n\n\t"
-		"\nNotSupported6:\n\t"
-		"#movl $106, %0:\n\n\t"
-		"\nNotSupported7:\n\t"
-		"#movl $107, %0:\n\n\t"
-		"movl $0, %0:\n\n\t"
-
-		"Return:\n\t"
-		: "=a" (rval)
-		: /* no input */
-		: "eax", "ebx", "ecx", "edx"
-	);
-
-	/* Return */
-	return(rval);
+    /* Return */
+    return (rval);
 }
 
 /*	Function to test if mmx instructions are supported...
@@ -221,8 +159,8 @@
 inline extern int
 mmx_ok(void)
 {
-	/* Returns 1 if MMX instructions are supported, 0 otherwise */
-	return ( mm_support() & 0x1 );
+    /* Returns 1 if MMX instructions are supported, 0 otherwise */
+    return (mm_support() & 0x1);
 }
 #endif
 
@@ -701,4 +639,4 @@
 #endif
 
 #endif
-
+/* vi: set ts=4 sw=4 expandtab: */