Don't use gcc-specific cpuid.h, fix the inline asm to properly

save/restore %ebx on i386.
This commit is contained in:
joerg 2014-08-19 13:34:42 +00:00
parent 3299a0eac5
commit e9083c2405
2 changed files with 20 additions and 14 deletions

View file

@ -1,10 +1,10 @@
$NetBSD: distinfo,v 1.25 2014/08/15 18:07:41 richard Exp $
$NetBSD: distinfo,v 1.26 2014/08/19 13:34:42 joerg Exp $
SHA1 (openexr-2.2.0.tar.gz) = d09a68c4443b7a12a0484c073adaef348b44cb92
RMD160 (openexr-2.2.0.tar.gz) = a825ed42e731da3bc39f25ce2a310712a5b0f956
Size (openexr-2.2.0.tar.gz) = 14489661 bytes
SHA1 (patch-IlmImf_ImfFastHuf.cpp) = bf583b5e0efb1af6e00d671b07d4cc154e13ac44
SHA1 (patch-IlmImf_ImfSystemSpecific.cpp) = 774b6498bdce55f24a9ffd6efaee349bfbd82173
SHA1 (patch-IlmImf_ImfSystemSpecific.cpp) = 79bf644181650fa7dc13c04dfeb68142bde6a2b6
SHA1 (patch-IlmImf_ImfSystemSpecific.h) = f36d049085e42beabcf5f7af5354009391a1f9f2
SHA1 (patch-aa) = 08b38d81338fc755c321911a9ffa3cccb53e99f3
SHA1 (patch-ab) = 0efe7155350e1976d1d7bad9da8b1a037fd84572

View file

@ -1,4 +1,4 @@
$NetBSD: patch-IlmImf_ImfSystemSpecific.cpp,v 1.1 2014/08/15 18:07:41 richard Exp $
$NetBSD: patch-IlmImf_ImfSystemSpecific.cpp,v 1.2 2014/08/19 13:34:42 joerg Exp $
Rework cpuid function to use gnuc __get_cpuid (requiring at least gcc 4.3)
This get's over issues such as encountered with PIC builds.
@ -6,23 +6,29 @@ Upstream issue : https://github.com/openexr/openexr/issues/128
--- IlmImf/ImfSystemSpecific.cpp.orig 2014-08-10 04:23:57.000000000 +0000
+++ IlmImf/ImfSystemSpecific.cpp
@@ -40,21 +40,19 @@ OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_EN
@@ -40,21 +40,30 @@ OPENEXR_IMF_INTERNAL_NAMESPACE_SOURCE_EN
namespace {
#if defined(IMF_HAVE_SSE2) && defined(__GNUC__)
-
+#include <cpuid.h>
// Helper functions for gcc + SSE enabled
- void cpuid(int n, int &eax, int &ebx, int &ecx, int &edx)
+ void cpuid(unsigned int n, unsigned int &eax, unsigned int &ebx,
+ unsigned int &ecx, unsigned int &edx)
{
- __asm__ __volatile__ (
- "cpuid"
- : /* Output */ "=a"(eax), "=b"(ebx), "=c"(ecx), "=d"(edx)
- : /* Input */ "a"(n)
- : /* Clobber */);
+ __get_cpuid(n, &eax, &ebx, &ecx, &edx);
+#ifdef __i386__
+ __asm__ __volatile__ (
+ "pushl %%ebx; cpuid; movl %%ebx, %0; popl %%ebx"
+ : /* Output */ "=m"(ebx), "=a"(eax), "=c"(ecx), "=d"(edx)
+ : /* Input */ "a"(n)
+ : /* Clobber */);
+#else
__asm__ __volatile__ (
"cpuid"
: /* Output */ "=a"(eax), "=b"(ebx), "=c"(ecx), "=d"(edx)
: /* Input */ "a"(n)
: /* Clobber */);
+#endif
}
#else // IMF_HAVE_SSE2 && __GNUC__
@ -34,7 +40,7 @@ Upstream issue : https://github.com/openexr/openexr/issues/128
{
eax = ebx = ecx = edx = 0;
}
@@ -64,7 +62,7 @@ namespace {
@@ -64,7 +73,7 @@ namespace {
#ifdef OPENEXR_IMF_HAVE_GCC_INLINE_ASM_AVX
@ -43,7 +49,7 @@ Upstream issue : https://github.com/openexr/openexr/issues/128
{
__asm__ __volatile__ (
"xgetbv"
@@ -75,7 +73,7 @@ namespace {
@@ -75,7 +84,7 @@ namespace {
#else // OPENEXR_IMF_HAVE_GCC_INLINE_ASM_AVX
@ -52,7 +58,7 @@ Upstream issue : https://github.com/openexr/openexr/issues/128
{
eax = edx = 0;
}
@@ -94,8 +92,8 @@ CpuId::CpuId():
@@ -94,8 +103,8 @@ CpuId::CpuId():
f16c(false)
{
bool osxsave = false;