diff options
Diffstat (limited to 'usr/src/common/bignum/bignumimpl.c')
| -rw-r--r-- | usr/src/common/bignum/bignumimpl.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/usr/src/common/bignum/bignumimpl.c b/usr/src/common/bignum/bignumimpl.c index e1cb454665..079dad8dd0 100644 --- a/usr/src/common/bignum/bignumimpl.c +++ b/usr/src/common/bignum/bignumimpl.c @@ -183,17 +183,28 @@ printbignum(char *aname, BIGNUM *a) #ifdef __amd64 /* * Return 1 if executing on Intel, otherwise 0 (e.g., AMD64). + * Cache the result, as the CPU can't change. + * + * Note: the userland version uses getisax() and checks for an AMD-64-only + * feature. The kernel version uses cpuid_getvendor(). */ static int bignum_on_intel(void) { + static int cached_result = -1; + + if (cached_result == -1) { /* first time */ #ifdef _KERNEL - return (cpuid_getvendor(CPU) == X86_VENDOR_Intel); + cached_result = (cpuid_getvendor(CPU) == X86_VENDOR_Intel); #else - uint_t ui; - (void) getisax(&ui, 1); - return ((ui & AV_386_AMD_MMX) == 0); + uint_t ui; + + (void) getisax(&ui, 1); + cached_result = ((ui & AV_386_AMD_MMX) == 0); #endif /* _KERNEL */ + } + + return (cached_result); } #endif /* __amd64 */ |
