Fix for gcc -fPIC build.
authorsenorblanco@chromium.org <senorblanco@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>
Mon, 9 Nov 2009 20:02:43 +0000 (20:02 +0000)
committersenorblanco@chromium.org <senorblanco@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>
Mon, 9 Nov 2009 20:02:43 +0000 (20:02 +0000)
http://codereview.appspot.com/150060

git-svn-id: http://skia.googlecode.com/svn/trunk@421 2bbb7eff-a529-9590-31e7-b0007b416f81

src/opts/SkBlitRow_opts_SSE2.cpp

index 68c7519..772c8eb 100644 (file)
@@ -37,10 +37,16 @@ static void getcpuid(int info_type, int info[4])
 #else
 static void getcpuid(int info_type, int info[4])
 {
-    asm("cpuid": "=a" (info[0]), "=b" (info[1]), "=c" (info[2]), "=d" (info[3])
-               : "a"(info_type)
-               :
-       );
+    // We save and restore ebx, so this code can be compatible with -fPIC
+    asm volatile (
+        "pushl %%ebx      \n\t"
+        "cpuid            \n\t"
+        "movl %%ebx, %1   \n\t"
+        "popl %%ebx       \n\t"
+        : "=a"(info[0]), "=r"(info[1]), "=c"(info[2]), "=d"(info[3])
+        : "a"(info_type)
+        :
+    );
 }
 #endif