Skip to content
Snippets Groups Projects
Commit 5864aab1 authored by Deucе's avatar Deucе :ok_hand_tone4:
Browse files

More patches and fixes and stuff.

parent 71ce5247
No related branches found
No related tags found
No related merge requests found
Pipeline #6787 failed
......@@ -99,6 +99,8 @@ set(PATCHES
cl-mingw64-thread-handles.patch
cl-mingw64-is-really-new.patch
cl-lowercase-versionhelpers.patch
cl-fix-cpuid-order.patch
cl-fix-cbli-incompatible.patch
)
set(SOURCE
......@@ -354,7 +356,6 @@ set(SOURCE
misc/pgp_misc.c
random/random.c
random/rand_x917.c
random/unix.c
misc/user.c
misc/user_attr.c
misc/user_config.c
......@@ -426,6 +427,11 @@ set(SOURCE
zlib/zutil.c
)
if(WIN32)
list(APPEND SOURCE random/win32.c)
else()
list(APPEND SOURCE random/unix.c)
endif()
set(LAST_PATCH "")
# Linux patch -l won't deal with line ending differences. :(
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
......
......@@ -73,6 +73,8 @@ set(PATCHES
${CMAKE_CURRENT_SOURCE_DIR}/cl-mingw64-thread-handles.patch
${CMAKE_CURRENT_SOURCE_DIR}/cl-mingw64-is-really-new.patch
${CMAKE_CURRENT_SOURCE_DIR}/cl-lowercase-versionhelpers.patch
${CMAKE_CURRENT_SOURCE_DIR}/cl-fix-cpuid-order.patch
${CMAKE_CURRENT_SOURCE_DIR}/cl-fix-cbli-incompatible.patch
)
FetchContent_Declare(CryptLib
......
......@@ -107,7 +107,7 @@ $(CRYPT_SRC): | $(3RDPSRCDIR)
$(CRYPT_IDIR): | $(3RDPODIR)
$(QUIET)$(IFNOTEXIST) mkdir $(CRYPT_IDIR)
$(CRYPTLIB_BUILD): $(3RDP_ROOT)/dist/cryptlib.zip $(3RDP_ROOT)/build/cl-fix-test-select.patch $(3RDP_ROOT)/build/cl-terminal-params.patch $(3RDP_ROOT)/build/cl-mingw32-static.patch $(3RDP_ROOT)/build/cl-ranlib.patch $(3RDP_ROOT)/build/cl-win32-noasm.patch $(3RDP_ROOT)/build/cl-zz-country.patch $(3RDP_ROOT)/build/cl-algorithms.patch $(3RDP_ROOT)/build/cl-allow-duplicate-ext.patch $(3RDP_ROOT)/build/cl-macosx-minver.patch $(3RDP_ROOT)/build/cl-posix-me-gently.patch $(3RDP_ROOT)/build/cl-PAM-noprompts.patch $(3RDP_ROOT)/build/cl-zlib.patch $(3RDP_ROOT)/build/cl-Dynamic-linked-static-lib.patch $(3RDP_ROOT)/build/cl-SSL-fix.patch $(3RDP_ROOT)/build/cl-bigger-maxattribute.patch $(3RDP_ROOT)/build/cl-endian.patch $(3RDP_ROOT)/build/cl-vcxproj.patch $(3RDP_ROOT)/build/cl-mingw-vcver.patch $(3RDP_ROOT)/build/cl-win32-build-fix.patch $(3RDP_ROOT)/build/cl-no-odbc.patch $(3RDP_ROOT)/build/cl-noasm-defines.patch $(3RDP_ROOT)/build/cl-bn-noasm64-fix.patch $(3RDP_ROOT)/build/cl-prefer-ECC.patch $(3RDP_ROOT)/build/cl-prefer-ECC-harder.patch $(3RDP_ROOT)/build/cl-clear-GCM-flag.patch $(3RDP_ROOT)/build/cl-use-ssh-ctr.patch $(3RDP_ROOT)/build/cl-ssl-suite-blocksizes.patch $(3RDP_ROOT)/build/cl-no-tpm.patch $(3RDP_ROOT)/build/cl-no-via-aes.patch $(3RDP_ROOT)/build/cl-fix-ssh-ecc-ephemeral.patch $(3RDP_ROOT)/build/cl-just-use-cc.patch $(3RDP_ROOT)/build/cl-no-safe-stack.patch $(3RDP_ROOT)/build/cl-allow-pkcs12.patch $(3RDP_ROOT)/build/cl-openbsd-threads.patch $(3RDP_ROOT)/build/cl-allow-none-auth.patch $(3RDP_ROOT)/build/cl-mingw-add-m32.patch $(3RDP_ROOT)/build/cl-poll-not-select.patch $(3RDP_ROOT)/build/cl-good-sockets.patch $(3RDP_ROOT)/build/cl-moar-objects.patch $(3RDP_ROOT)/build/cl-server-term-support.patch $(3RDP_ROOT)/build/cl-add-pubkey-attribute.patch $(3RDP_ROOT)/build/cl-allow-ssh-auth-retries.patch $(3RDP_ROOT)/build/cl-fix-ssh-channel-close.patch $(3RDP_ROOT)/build/cl-vt-lt-2005-always-defined.patch $(3RDP_ROOT)/build/cl-no-pie.patch $(3RDP_ROOT)/build/cl-no-testobjs.patch $(3RDP_ROOT)/build/cl-win32-lean-and-mean.patch $(3RDP_ROOT)/build/cl-thats-not-asm.patch $(3RDP_ROOT)/build/cl-make-channels-work.patch $(3RDP_ROOT)/build/cl-allow-ssh-2.0-go.patch $(3RDP_ROOT)/build/cl-read-timeout-every-time.patch $(3RDP_ROOT)/build/cl-allow-servercheck-pubkeys.patch $(3RDP_ROOT)/build/cl-pass-after-pubkey.patch $(3RDP_ROOT)/build/cl-ssh-list-ctr-modes.patch $(3RDP_ROOT)/build/cl-double-delete-fine-on-close.patch $(3RDP_ROOT)/build/cl-handle-unsupported-pubkey.patch $(3RDP_ROOT)/build/cl-add-patches-info.patch $(3RDP_ROOT)/build/cl-netbsd-hmac-symbol.patch $(3RDP_ROOT)/build/cl-netbsd-no-getfsstat.patch GNUmakefile $(3RDP_ROOT)/build/cl-remove-march.patch $(3RDP_ROOT)/build/cl-fix-shell-exec-types.patch $(3RDP_ROOT)/build/cl-ssh-eof-half-close.patch $(3RDP_ROOT)/build/cl-add-win64.patch $(3RDP_ROOT)/build/cl-fix-mb-w-conv-warnings.patch $(3RDP_ROOT)/build/cl-fix-ssh-header-read.patch $(3RDP_ROOT)/build/cl-ssh-service-type-for-channel.patch $(3RDP_ROOT)/build/cl-ssh-sbbs-id-string.patch $(3RDP_ROOT)/build/cl-channel-select-both.patch $(3RDP_ROOT)/build/cl-allow-none-auth-svr.patch $(3RDP_ROOT)/build/cl-quote-cc.patch $(3RDP_ROOT)/build/cl-mingw64-thread-handles.patch $(3RDP_ROOT)/build/cl-mingw64-is-really-new.patch $(3RDP_ROOT)/build/cl-lowercase-versionhelpers.patch | $(CRYPT_SRC) $(CRYPT_IDIR)
$(CRYPTLIB_BUILD): $(3RDP_ROOT)/dist/cryptlib.zip $(3RDP_ROOT)/build/cl-fix-test-select.patch $(3RDP_ROOT)/build/cl-terminal-params.patch $(3RDP_ROOT)/build/cl-mingw32-static.patch $(3RDP_ROOT)/build/cl-ranlib.patch $(3RDP_ROOT)/build/cl-win32-noasm.patch $(3RDP_ROOT)/build/cl-zz-country.patch $(3RDP_ROOT)/build/cl-algorithms.patch $(3RDP_ROOT)/build/cl-allow-duplicate-ext.patch $(3RDP_ROOT)/build/cl-macosx-minver.patch $(3RDP_ROOT)/build/cl-posix-me-gently.patch $(3RDP_ROOT)/build/cl-PAM-noprompts.patch $(3RDP_ROOT)/build/cl-zlib.patch $(3RDP_ROOT)/build/cl-Dynamic-linked-static-lib.patch $(3RDP_ROOT)/build/cl-SSL-fix.patch $(3RDP_ROOT)/build/cl-bigger-maxattribute.patch $(3RDP_ROOT)/build/cl-endian.patch $(3RDP_ROOT)/build/cl-vcxproj.patch $(3RDP_ROOT)/build/cl-mingw-vcver.patch $(3RDP_ROOT)/build/cl-win32-build-fix.patch $(3RDP_ROOT)/build/cl-no-odbc.patch $(3RDP_ROOT)/build/cl-noasm-defines.patch $(3RDP_ROOT)/build/cl-bn-noasm64-fix.patch $(3RDP_ROOT)/build/cl-prefer-ECC.patch $(3RDP_ROOT)/build/cl-prefer-ECC-harder.patch $(3RDP_ROOT)/build/cl-clear-GCM-flag.patch $(3RDP_ROOT)/build/cl-use-ssh-ctr.patch $(3RDP_ROOT)/build/cl-ssl-suite-blocksizes.patch $(3RDP_ROOT)/build/cl-no-tpm.patch $(3RDP_ROOT)/build/cl-no-via-aes.patch $(3RDP_ROOT)/build/cl-fix-ssh-ecc-ephemeral.patch $(3RDP_ROOT)/build/cl-just-use-cc.patch $(3RDP_ROOT)/build/cl-no-safe-stack.patch $(3RDP_ROOT)/build/cl-allow-pkcs12.patch $(3RDP_ROOT)/build/cl-openbsd-threads.patch $(3RDP_ROOT)/build/cl-allow-none-auth.patch $(3RDP_ROOT)/build/cl-mingw-add-m32.patch $(3RDP_ROOT)/build/cl-poll-not-select.patch $(3RDP_ROOT)/build/cl-good-sockets.patch $(3RDP_ROOT)/build/cl-moar-objects.patch $(3RDP_ROOT)/build/cl-server-term-support.patch $(3RDP_ROOT)/build/cl-add-pubkey-attribute.patch $(3RDP_ROOT)/build/cl-allow-ssh-auth-retries.patch $(3RDP_ROOT)/build/cl-fix-ssh-channel-close.patch $(3RDP_ROOT)/build/cl-vt-lt-2005-always-defined.patch $(3RDP_ROOT)/build/cl-no-pie.patch $(3RDP_ROOT)/build/cl-no-testobjs.patch $(3RDP_ROOT)/build/cl-win32-lean-and-mean.patch $(3RDP_ROOT)/build/cl-thats-not-asm.patch $(3RDP_ROOT)/build/cl-make-channels-work.patch $(3RDP_ROOT)/build/cl-allow-ssh-2.0-go.patch $(3RDP_ROOT)/build/cl-read-timeout-every-time.patch $(3RDP_ROOT)/build/cl-allow-servercheck-pubkeys.patch $(3RDP_ROOT)/build/cl-pass-after-pubkey.patch $(3RDP_ROOT)/build/cl-ssh-list-ctr-modes.patch $(3RDP_ROOT)/build/cl-double-delete-fine-on-close.patch $(3RDP_ROOT)/build/cl-handle-unsupported-pubkey.patch $(3RDP_ROOT)/build/cl-add-patches-info.patch $(3RDP_ROOT)/build/cl-netbsd-hmac-symbol.patch $(3RDP_ROOT)/build/cl-netbsd-no-getfsstat.patch GNUmakefile $(3RDP_ROOT)/build/cl-remove-march.patch $(3RDP_ROOT)/build/cl-fix-shell-exec-types.patch $(3RDP_ROOT)/build/cl-ssh-eof-half-close.patch $(3RDP_ROOT)/build/cl-add-win64.patch $(3RDP_ROOT)/build/cl-fix-mb-w-conv-warnings.patch $(3RDP_ROOT)/build/cl-fix-ssh-header-read.patch $(3RDP_ROOT)/build/cl-ssh-service-type-for-channel.patch $(3RDP_ROOT)/build/cl-ssh-sbbs-id-string.patch $(3RDP_ROOT)/build/cl-channel-select-both.patch $(3RDP_ROOT)/build/cl-allow-none-auth-svr.patch $(3RDP_ROOT)/build/cl-quote-cc.patch $(3RDP_ROOT)/build/cl-mingw64-thread-handles.patch $(3RDP_ROOT)/build/cl-mingw64-is-really-new.patch $(3RDP_ROOT)/build/cl-lowercase-versionhelpers.patch $(3RDP_ROOT)/build/cl-fix-cpuid-order.patch $(3RDP_ROOT)/build/cl-fix-cbli-incompatible.patch | $(CRYPT_SRC) $(CRYPT_IDIR)
@echo Creating $@ ...
$(QUIET)-rm -rf $(CRYPT_SRC)/*
$(QUIET)unzip -oa $(3RDPDISTDIR)/cryptlib.zip -d $(CRYPT_SRC)
......@@ -185,6 +185,8 @@ $(CRYPTLIB_BUILD): $(3RDP_ROOT)/dist/cryptlib.zip $(3RDP_ROOT)/build/cl-fix-test
$(QUIET)patch -b -p0 -d $(CRYPT_SRC) < cl-mingw64-thread-handles.patch
$(QUIET)patch -b -p0 -d $(CRYPT_SRC) < cl-mingw64-is-really-new.patch
$(QUIET)patch -b -p0 -d $(CRYPT_SRC) < cl-lowercase-versionhelpers.patch
$(QUIET)patch -b -p0 -d $(CRYPT_SRC) < cl-fix-cpuid-order.patch
$(QUIET)patch -b -p0 -d $(CRYPT_SRC) < cl-fix-cbli-incompatible.patch
$(QUIET)perl -pi.bak -e 's/^(#define CRYPTLIB_VERSION.*)$$/"$$1\n#define CRYPTLIB_PATCHES \"" . (chomp($$val = `cat cl-*.patch | if (which md5sum > \/dev\/null 2>&1); then md5sum; else md5; fi`), $$val) . "\""/e' $(CRYPT_SRC)/cryptlib.h
$(QUIET)sed -E -iorig 's/%%MIN_MAC_OSX_VERSION%%/${MIN_MAC_OSX_VERSION}/g' $(CRYPT_SRC)/tools/ccopts.sh
ifdef FIXED_FIXED_SEED
......
--- misc/os_spec.c.orig 2024-10-12 02:22:09.340489000 -0400
+++ misc/os_spec.c 2024-10-12 02:23:00.791733000 -0400
@@ -3357,11 +3357,11 @@
/* Walk down the block list checking whether the page(s) contain another
locked block */
- status = getBlockListInfo( NULL, &currentBlockPtr, &currentBlockSize );
+ status = getBlockListInfo( NULL, (const void **)&currentBlockPtr, &currentBlockSize );
REQUIRES_V( cryptStatusOK( status ) );
LOOP_LARGE_CHECKINC( cryptStatusOK( status ),
status = getBlockListInfo( currentBlockPtr,
- &currentBlockPtr,
+ (const void **)&currentBlockPtr,
&currentBlockSize ) )
{
const PTR_TYPE currentFirstPageAddress = \
--- misc/os_spec.c.orig 2023-02-26 03:33:34.000000000 -0500
+++ misc/os_spec.c 2024-10-12 02:13:21.004004000 -0400
@@ -1203,7 +1203,7 @@
#if VC_GE_2005( _MSC_VER )
#pragma warning( push )
#pragma warning( disable : 4255 ) /* Errors in VersionHelpers.h */
- #include <VersionHelpers.h>
+ #include <versionhelpers.h>
#pragma warning( pop )
#endif /* VC++ >= 2005 */
@@ -2147,37 +2147,76 @@
return( sysCaps );
}
-#elif defined( __WIN32__ ) && defined( _M_X64 )
+#elif ( defined( __clang__ ) || \
+ ( defined( __GNUC__ ) && \
+ ( ( __GNUC__ > 4 ) || \
+ ( __GNUC__ == 4 && __GNUC_MINOR__ >= 4 ) ) ) ) && \
+ ( defined( __i386__ ) || defined( __x86_64__ ) )
-/* 64-bit VC++ doesn't allow inline asm, but does provide the __cpuid()
- builtin to perform the operation above. We don't guard this with the
- NO_ASM check because it's not (technically) done with inline asm,
- although it's a bit unclear whether an intrinsic qualifies as asm or
- C */
+/* clang and newer versions of gcc have cpuid as an intrinsic */
-#pragma intrinsic( __cpuid )
+#if HWINTRINS_FLAG_RDTSC != 0x01
+ #error Need to sync HWINTRINS_FLAG_RDTSC with equivalent asm definition
+#endif /* HWINTRINS_FLAG_RDTSC */
+#include <cpuid.h>
+
typedef struct { unsigned int eax, ebx, ecx, edx; } CPUID_INFO;
-STDC_NONNULL_ARG( ( 1 ) ) \
-static void cpuID( OUT_PTR CPUID_INFO *result, const int type )
+CHECK_RETVAL_BOOL STDC_NONNULL_ARG( ( 1 ) ) \
+static BOOLEAN cpuID_Checked( OUT_PTR CPUID_INFO *result, const int type )
{
- int intResult[ 4 ]; /* That's what the function prototype says */
+ int a, b, c, d; /* That's what the function prototype says */
+ int retVal;
+ assert( isWritePtr( result, sizeof( CPUID_INFO ) ) );
+
/* Clear return value */
memset( result, 0, sizeof( CPUID_INFO ) );
- /* Get the CPUID data and copy it back to the caller. We clear it
- before calling the __cpuid intrinsic because some analysers don't
- know about it and will warn about use of uninitialised memory */
- memset( intResult, 0, sizeof( int ) * 4 );
- __cpuid( intResult, type );
- result->eax = intResult[ 0 ];
- result->ebx = intResult[ 1 ];
- result->ecx = intResult[ 2 ];
- result->edx = intResult[ 3 ];
+ /* Get the CPUID data and copy it back to the caller */
+ retVal = __get_cpuid( type, &a, &b, &c, &d );
+ if( retVal <= 0 )
+ return( FALSE );
+ result->eax = a;
+ result->ebx = b;
+ result->ecx = c;
+ result->edx = d;
+
+ return( TRUE );
}
+STDC_NONNULL_ARG( ( 1 ) ) \
+static void cpuID( OUT_PTR CPUID_INFO *result, const int type )
+ {
+ int a, b, c, d; /* That's what the function prototype says */
+
+ /* The GNU __get_cpuid() is broken, see
+ https://github.com/gcc-mirror/gcc/blob/master/gcc/config/i386/cpuid.h,
+ it's implemented as:
+
+ __get_cpuid (unsigned int __leaf,
+ unsigned int *__eax, unsigned int *__ebx,
+ unsigned int *__ecx, unsigned int *__edx)
+ {
+ unsigned int __ext = __leaf & 0x80000000;
+ unsigned int __maxlevel = __get_cpuid_max (__ext, 0);
+
+ if (__maxlevel == 0 || __maxlevel < __leaf)
+ return 0;
+
+ Since the high bit is masked, it can never work for any query on
+ extended attributes like VIA's 0xC000000x ones since __maxlevel will
+ always be less than the 0xC000000x that we want to query on. To deal
+ with this we call the lower-level __cpuid() directly, bypassing the
+ broken wrapper */
+ __cpuid( type, a, b, c, d );
+ result->eax = a;
+ result->ebx = b;
+ result->ecx = c;
+ result->edx = d;
+ }
+
CHECK_RETVAL_ENUM( HWINTRINS_FLAG ) \
static int getHWIntrins( void )
{
@@ -2185,19 +2224,16 @@
char vendorID[ 12 + 8 ];
int *vendorIDptr = ( int * ) vendorID;
unsigned long processorID, featureFlags, featureFlags2;
- int sysCaps = HWINTRINS_FLAG_RDTSC; /* x86-64 always has RDTSC */
+ int sysCaps = 0;
- /* Get any CPU info that we need. There is an
- IsProcessorFeaturePresent() function, but all that this provides is
- an indication of the availability of rdtsc (alongside some stuff that
- we don't care about, like MMX and 3DNow). Since we still need to
- check for the presence of other features, we do the whole thing
- ourselves */
- cpuID( &cpuidInfo, 0 );
+ /* Get any CPU info that we need */
+ if( !cpuID_Checked( &cpuidInfo, 0 ) ) /* CPUID function 0: Get vendor ID */
+ return( HWINTRINS_FLAG_NONE );
vendorIDptr[ 0 ] = cpuidInfo.ebx;
vendorIDptr[ 1 ] = cpuidInfo.edx;
vendorIDptr[ 2 ] = cpuidInfo.ecx;
- cpuID( &cpuidInfo, 1 );
+ if( !cpuID_Checked( &cpuidInfo, 1 ) ) /* CPUID function 1: Get processor info */
+ return( HWINTRINS_FLAG_NONE );
processorID = cpuidInfo.eax;
featureFlags = cpuidInfo.ecx;
featureFlags2 = cpuidInfo.ebx;
@@ -2206,10 +2242,7 @@
if( !memcmp( vendorID, "CentaurHauls", 12 ) )
{
/* Get the Centaur extended CPUID info and check whether the feature-
- flags read capability is present. VIA only announced their 64-
- bit CPUs in mid-2010 and availability is limited so it's
- uncertain whether this code will ever be exercised, but we provide
- it anyway for compatibility with the 32-bit equivalent */
+ flags read capability is present */
cpuID( &cpuidInfo, 0xC0000000 );
if( cpuidInfo.eax >= 0xC0000001 )
{
@@ -2247,76 +2280,37 @@
return( sysCaps );
}
-#elif ( defined( __clang__ ) || \
- ( defined( __GNUC__ ) && \
- ( ( __GNUC__ > 4 ) || \
- ( __GNUC__ == 4 && __GNUC_MINOR__ >= 4 ) ) ) ) && \
- ( defined( __i386__ ) || defined( __x86_64__ ) )
+#elif defined( __WIN32__ ) && defined( _M_X64 )
-/* clang and newer versions of gcc have cpuid as an intrinsic */
+/* 64-bit VC++ doesn't allow inline asm, but does provide the __cpuid()
+ builtin to perform the operation above. We don't guard this with the
+ NO_ASM check because it's not (technically) done with inline asm,
+ although it's a bit unclear whether an intrinsic qualifies as asm or
+ C */
-#if HWINTRINS_FLAG_RDTSC != 0x01
- #error Need to sync HWINTRINS_FLAG_RDTSC with equivalent asm definition
-#endif /* HWINTRINS_FLAG_RDTSC */
+#pragma intrinsic( __cpuid )
-#include <cpuid.h>
-
typedef struct { unsigned int eax, ebx, ecx, edx; } CPUID_INFO;
-CHECK_RETVAL_BOOL STDC_NONNULL_ARG( ( 1 ) ) \
-static BOOLEAN cpuID_Checked( OUT_PTR CPUID_INFO *result, const int type )
+STDC_NONNULL_ARG( ( 1 ) ) \
+static void cpuID( OUT_PTR CPUID_INFO *result, const int type )
{
- int a, b, c, d; /* That's what the function prototype says */
- int retVal;
+ int intResult[ 4 ]; /* That's what the function prototype says */
- assert( isWritePtr( result, sizeof( CPUID_INFO ) ) );
-
/* Clear return value */
memset( result, 0, sizeof( CPUID_INFO ) );
- /* Get the CPUID data and copy it back to the caller */
- retVal = __get_cpuid( type, &a, &b, &c, &d );
- if( retVal <= 0 )
- return( FALSE );
- result->eax = a;
- result->ebx = b;
- result->ecx = c;
- result->edx = d;
-
- return( TRUE );
+ /* Get the CPUID data and copy it back to the caller. We clear it
+ before calling the __cpuid intrinsic because some analysers don't
+ know about it and will warn about use of uninitialised memory */
+ memset( intResult, 0, sizeof( int ) * 4 );
+ __cpuid( intResult, type );
+ result->eax = intResult[ 0 ];
+ result->ebx = intResult[ 1 ];
+ result->ecx = intResult[ 2 ];
+ result->edx = intResult[ 3 ];
}
-STDC_NONNULL_ARG( ( 1 ) ) \
-static void cpuID( OUT_PTR CPUID_INFO *result, const int type )
- {
- int a, b, c, d; /* That's what the function prototype says */
-
- /* The GNU __get_cpuid() is broken, see
- https://github.com/gcc-mirror/gcc/blob/master/gcc/config/i386/cpuid.h,
- it's implemented as:
-
- __get_cpuid (unsigned int __leaf,
- unsigned int *__eax, unsigned int *__ebx,
- unsigned int *__ecx, unsigned int *__edx)
- {
- unsigned int __ext = __leaf & 0x80000000;
- unsigned int __maxlevel = __get_cpuid_max (__ext, 0);
-
- if (__maxlevel == 0 || __maxlevel < __leaf)
- return 0;
-
- Since the high bit is masked, it can never work for any query on
- extended attributes like VIA's 0xC000000x ones since __maxlevel will
- always be less than the 0xC000000x that we want to query on. To deal
- with this we call the lower-level __cpuid() directly, bypassing the
- broken wrapper */
- __cpuid( type, a, b, c, d );
- result->eax = a;
- result->ebx = b;
- result->ecx = c;
- result->edx = d;
- }
-
CHECK_RETVAL_ENUM( HWINTRINS_FLAG ) \
static int getHWIntrins( void )
{
@@ -2324,16 +2318,19 @@
char vendorID[ 12 + 8 ];
int *vendorIDptr = ( int * ) vendorID;
unsigned long processorID, featureFlags, featureFlags2;
- int sysCaps = 0;
+ int sysCaps = HWINTRINS_FLAG_RDTSC; /* x86-64 always has RDTSC */
- /* Get any CPU info that we need */
- if( !cpuID_Checked( &cpuidInfo, 0 ) ) /* CPUID function 0: Get vendor ID */
- return( HWINTRINS_FLAG_NONE );
+ /* Get any CPU info that we need. There is an
+ IsProcessorFeaturePresent() function, but all that this provides is
+ an indication of the availability of rdtsc (alongside some stuff that
+ we don't care about, like MMX and 3DNow). Since we still need to
+ check for the presence of other features, we do the whole thing
+ ourselves */
+ cpuID( &cpuidInfo, 0 );
vendorIDptr[ 0 ] = cpuidInfo.ebx;
vendorIDptr[ 1 ] = cpuidInfo.edx;
vendorIDptr[ 2 ] = cpuidInfo.ecx;
- if( !cpuID_Checked( &cpuidInfo, 1 ) ) /* CPUID function 1: Get processor info */
- return( HWINTRINS_FLAG_NONE );
+ cpuID( &cpuidInfo, 1 );
processorID = cpuidInfo.eax;
featureFlags = cpuidInfo.ecx;
featureFlags2 = cpuidInfo.ebx;
@@ -2342,7 +2339,10 @@
if( !memcmp( vendorID, "CentaurHauls", 12 ) )
{
/* Get the Centaur extended CPUID info and check whether the feature-
- flags read capability is present */
+ flags read capability is present. VIA only announced their 64-
+ bit CPUs in mid-2010 and availability is limited so it's
+ uncertain whether this code will ever be exercised, but we provide
+ it anyway for compatibility with the 32-bit equivalent */
cpuID( &cpuidInfo, 0xC0000000 );
if( cpuidInfo.eax >= 0xC0000001 )
{
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment