mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-30 16:58:40 -04:00
display: fix get_cpuid_max clobbering %rbx (fixes Py 3.8 crash on macOS)
This could cause a crash when constructing a GraphicsPipe() under some conditions (observed in Python 3.8). Credit goes to @CFSworks for tracking this down.
This commit is contained in:
parent
b78f0b0881
commit
bf6dbefdd2
@ -55,25 +55,6 @@ union cpuid_info {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the highest cpuid leaf that is supported by the CPU.
|
|
||||||
*/
|
|
||||||
static inline uint32_t get_cpuid_max(uint32_t leaf) {
|
|
||||||
#if defined(__GNUC__) && !defined(__APPLE__)
|
|
||||||
return __get_cpuid_max(leaf, nullptr);
|
|
||||||
#elif defined(_MSC_VER)
|
|
||||||
uint32_t p[4] = {0};
|
|
||||||
__cpuid((int *)p, leaf);
|
|
||||||
return p[0];
|
|
||||||
#else
|
|
||||||
unsigned int eax = 0;
|
|
||||||
__asm__ ("cpuid\n\t"
|
|
||||||
: "=a" (eax)
|
|
||||||
: "0" (leaf));
|
|
||||||
return eax;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets cpuid info for the given leaf.
|
* Gets cpuid info for the given leaf.
|
||||||
*/
|
*/
|
||||||
@ -88,6 +69,19 @@ static inline void get_cpuid(uint32_t leaf, cpuid_info &info) {
|
|||||||
: "0" (leaf));
|
: "0" (leaf));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the highest cpuid leaf that is supported by the CPU.
|
||||||
|
*/
|
||||||
|
static inline uint32_t get_cpuid_max(uint32_t leaf) {
|
||||||
|
#if defined(__GNUC__) && !defined(__APPLE__)
|
||||||
|
return __get_cpuid_max(leaf, nullptr);
|
||||||
|
#else
|
||||||
|
cpuid_info info;
|
||||||
|
get_cpuid(leaf, info);
|
||||||
|
return info.eax;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef IS_LINUX
|
#ifdef IS_LINUX
|
||||||
|
Loading…
x
Reference in New Issue
Block a user