diff src/cpuinfo/SDL_cpuinfo.c @ 1229:1430f5fe092a

Patch from Michael Bonfils to add CPUID support for x86 Solaris.
author Ryan C. Gordon <icculus@icculus.org>
date Thu, 05 Jan 2006 08:17:35 +0000
parents b616ac4f39d1
children c9b51268668f
line wrap: on
line diff
--- a/src/cpuinfo/SDL_cpuinfo.c	Thu Jan 05 07:20:12 2006 +0000
+++ b/src/cpuinfo/SDL_cpuinfo.c	Thu Jan 05 08:17:35 2006 +0000
@@ -116,6 +116,36 @@
         mov     has_CPUID,1         ; We have CPUID support
 done:
 	}
+#elif defined(__sun) && defined(__x86)
+	    __asm (
+"       pushfl                 \n"
+"	    popl    %eax           \n"
+"	    movl    %eax,%ecx      \n"
+"	    xorl    $0x200000,%eax \n"
+"	    pushl   %eax           \n"
+"	    popfl                  \n"
+"	    pushfl                 \n"
+"	    popl    %eax           \n"
+"	    xorl    %ecx,%eax      \n"
+"	    jz      1f             \n"
+"	    movl    $1,-8(%ebp)    \n"
+"1:                            \n"
+	);
+#elif defined(__sun) && defined(__amd64)
+	__asm (
+"       pushfq                 \n"
+"       popq    %rax           \n"
+"       movq    %rax,%rcx      \n"
+"       xorl    $0x200000,%eax \n"
+"       pushq   %rax           \n"
+"       popfq                  \n"
+"       pushfq                 \n"
+"       popq    %rax           \n"
+"       xorl    %ecx,%eax      \n"
+"       jz      1f             \n"
+"       movl    $1,-8(%rbp)    \n"
+"1:                            \n"
+	);
 #endif
 	return has_CPUID;
 }
@@ -152,6 +182,23 @@
         mov     features, edx
 done:
 	}
+#elif defined(__sun) && (defined(__x86) || defined(__amd64))
+	    __asm(
+"        movl    %ebx,%edi\n"
+"        xorl    %eax,%eax         \n"
+"        cpuid                     \n"
+"        cmpl    $1,%eax           \n"
+"        jl      1f                \n"
+"        xorl    %eax,%eax         \n"
+"        incl    %eax              \n"
+"        cpuid                     \n"
+#ifdef __i386
+"        movl    %edx,-8(%ebp)     \n"
+#else
+"        movl    %edx,-8(%rbp)     \n"
+#endif
+"1:                                \n"
+"        movl    %edi,%ebx\n" );
 #endif
 	return features;
 }
@@ -186,6 +233,23 @@
         mov     features,edx
 done:
 	}
+#elif defined(__sun) && ( defined(__i386) || defined(__amd64) )
+	    __asm (
+"        movl    %ebx,%edi\n"
+"        movl    $0x80000000,%eax \n"
+"        cpuid                    \n"
+"        cmpl    $0x80000001,%eax \n"
+"        jl      1f               \n"
+"        movl    $0x80000001,%eax \n"
+"        cpuid                    \n"
+#ifdef __i386
+"        movl    %edx,-8(%ebp)   \n"
+#else
+"        movl    %edx,-8(%rbp)   \n"
+#endif
+"1:                               \n"
+"        movl    %edi,%ebx\n"
+	    );
 #endif
 	return features;
 }