xref: /OK3568_Linux_fs/buildroot/package/libfreeimage/0002-fix-cpuid-x86.patch (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1Fix build issue caused by invalid register usage on x86
2
3Patch taken from https://github.com/openexr/openexr/issues/128.
4
5Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
6
7Index: b/Source/OpenEXR/IlmImf/ImfSystemSpecific.cpp
8===================================================================
9--- a/Source/OpenEXR/IlmImf/ImfSystemSpecific.cpp
10+++ b/Source/OpenEXR/IlmImf/ImfSystemSpecific.cpp
11@@ -40,21 +40,19 @@
12
13 namespace {
14 #if defined(IMF_HAVE_SSE2) &&  defined(__GNUC__)
15-
16+#include <cpuid.h>
17     // Helper functions for gcc + SSE enabled
18-    void cpuid(int n, int &eax, int &ebx, int &ecx, int &edx)
19+    void cpuid(unsigned int n, unsigned int &eax, unsigned int &ebx,
20+					unsigned int &ecx, unsigned int &edx)
21     {
22-        __asm__ __volatile__ (
23-            "cpuid"
24-            : /* Output  */ "=a"(eax), "=b"(ebx), "=c"(ecx), "=d"(edx)
25-            : /* Input   */ "a"(n)
26-            : /* Clobber */);
27+		__get_cpuid(n, &eax, &ebx, &ecx, &edx);
28     }
29
30 #else // IMF_HAVE_SSE2 && __GNUC__
31
32     // Helper functions for generic compiler - all disabled
33-    void cpuid(int n, int &eax, int &ebx, int &ecx, int &edx)
34+    void cpuid(unsigned int n, unsigned int &eax, unsigned int &ebx,
35+					unsigned int &ecx, unsigned int &edx)
36     {
37         eax = ebx = ecx = edx = 0;
38     }
39@@ -64,7 +62,7 @@
40
41 #ifdef OPENEXR_IMF_HAVE_GCC_INLINE_ASM_AVX
42
43-    void xgetbv(int n, int &eax, int &edx)
44+    void xgetbv(unsigned int n, unsigned int &eax, unsigned int &edx)
45     {
46         __asm__ __volatile__ (
47             "xgetbv"
48@@ -75,7 +73,7 @@
49
50 #else //  OPENEXR_IMF_HAVE_GCC_INLINE_ASM_AVX
51
52-    void xgetbv(int n, int &eax, int &edx)
53+    void xgetbv(unsigned int n, unsigned int &eax, unsigned int &edx)
54     {
55         eax = edx = 0;
56     }
57@@ -94,8 +92,8 @@
58     f16c(false)
59 {
60     bool osxsave = false;
61-    int  max     = 0;
62-    int  eax, ebx, ecx, edx;
63+    unsigned int  max     = 0;
64+    unsigned int  eax, ebx, ecx, edx;
65
66     cpuid(0, max, ebx, ecx, edx);
67     if (max > 0)
68