0002-fix-cpuid-x86.patch 2.0 KB

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