Conversation
… Windows, macOS, and iOS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description:
This PR replaces the stub
// TODOimplementations inTArmSimdFeatureswith real, cross-platform ARM hardware capability detection. It mirrors the equivalent work done in HashLib4Pascal, adapted to CryptoLib4Pascal's naming conventions and project structure.New Units
ClpArmHwCapProvider— Platform-abstracted ARM HWCAP provider:getauxvalviadlsymto queryAT_HWCAP/AT_HWCAP2elf_aux_info/_elf_aux_infoviadlsymIsProcessorFeaturePresentforPF_ARM_V8_*constantsClpDarwinSysCtl— Darwin-specific (macOS/iOS) feature detection viasysctlbyname, resolved dynamically throughdlsym. Supports modernFEAT_*sysctl keys (macOS 12+) with automatic fallback to legacy keys (macOS 11).Changes to Existing Units
ClpArmSimdFeatures— AllCPUHas*methods now contain real detection logic for NEON, AES, SHA1, SHA256, SHA512, SHA3, PMULL, SVE, and SVE2. AddedCPUHasCRC32/HasCRC32for CRC32 instruction detection. RenamedFSimdLevel→FActiveSimdLevelandGetSimdLevel()→GetActiveSimdLevel().ClpX86SimdFeatures— RenamedFSimdLevel→FActiveSimdLevelandGetSimdLevel()→GetActiveSimdLevel()for consistency with the ARM side.ClpCpuFeatures—TCpuFeatures.X86andTCpuFeatures.Armproperties (and their backing types/getters) are now conditionally compiled underCRYPTOLIB_X86/CRYPTOLIB_ARM, so only the relevant architecture code is included per build target.Include files (
CryptoLib.inc,CryptoLibFPC.inc):CRYPTOLIB_ARM(previously ARM32-specific) toCRYPTOLIB_ARM32andCRYPTOLIB_ARM_ASMtoCRYPTOLIB_ARM32_ASMto eliminate ambiguityCRYPTOLIB_X86(= I386 or X86_64) andCRYPTOLIB_ARM(= ARM32 or AArch64) as architecture-family definesCRYPTOLIB_HAS_GETRANDOM,CRYPTOLIB_HAS_SECRANDOMCOPYBYTES,CRYPTOLIB_HAS_ARC4RANDOM_BUF,CRYPTOLIB_HAS_DEVRANDOM) out of the Delphi/FPC-specific blocks into a shared "Common Feature Detection" section, eliminating duplication between compilersCRYPTOLIB_HAS_ARC4RANDOM_BUFfor BSD andCRYPTOLIB_SOLARISto theCRYPTOLIB_HAS_GETRANDOMgroup (Delphi side was previously missing these)Design Notes
dlopen(nil)+dlsymat runtime, avoiding hard static imports and gracefully degrading when symbols are unavailable.HWCAP2while AArch64 usesHWCAP) are handled via conditional compilation.PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLEbundles AES, PMULL, SHA1, and SHA256 together per Microsoft's documentation. SHA3/SHA512 use the newerPF_ARM_V82_*constants (defined locally to avoid SDK version dependency).