mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-10 09:58:01 +00:00
3396c97da9
Now that the new CMake build system is encouraging us to lay out the code like a set of libraries, it seems like a good idea to make them look more _like_ libraries, by putting things into separate modules as far as possible. This fixes several previous annoyances in which you had to link against some object in order to get a function you needed, but that object also contained other functions you didn't need which included link-time symbol references you didn't want to have to deal with. The usual offender was subsidiary supporting programs including misc.c for some innocuous function and then finding they had to deal with the requirements of buildinfo(). This big reorganisation introduces three new subdirectories called 'utils', one at the top level and one in each platform subdir. In each case, the directory contains basically the same files that were previously placed in the 'utils' build-time library, except that the ones that were extremely miscellaneous (misc.c, utils.c, uxmisc.c, winmisc.c, winmiscs.c, winutils.c) have been split up into much smaller pieces.
81 lines
1.9 KiB
C
81 lines
1.9 KiB
C
/*
|
|
* Unix implementation of the OS query functions that detect Arm
|
|
* architecture extensions.
|
|
*/
|
|
|
|
#include "putty.h"
|
|
#include "ssh.h"
|
|
|
|
#include "utils/arm_arch_queries.h"
|
|
|
|
#if defined __arm__ || defined __aarch64__
|
|
|
|
bool platform_aes_hw_available(void)
|
|
{
|
|
#if defined HWCAP_AES
|
|
return getauxval(AT_HWCAP) & HWCAP_AES;
|
|
#elif defined HWCAP2_AES
|
|
return getauxval(AT_HWCAP2) & HWCAP2_AES;
|
|
#elif defined __APPLE__
|
|
/* M1 macOS defines no optional sysctl flag indicating presence of
|
|
* the AES extension, which I assume to be because it's always
|
|
* present */
|
|
return true;
|
|
#else
|
|
return false;
|
|
#endif
|
|
}
|
|
|
|
bool platform_sha256_hw_available(void)
|
|
{
|
|
#if defined HWCAP_SHA2
|
|
return getauxval(AT_HWCAP) & HWCAP_SHA2;
|
|
#elif defined HWCAP2_SHA2
|
|
return getauxval(AT_HWCAP2) & HWCAP2_SHA2;
|
|
#elif defined __APPLE__
|
|
/* Assume always present on M1 macOS, similarly to AES */
|
|
return true;
|
|
#else
|
|
return false;
|
|
#endif
|
|
}
|
|
|
|
bool platform_sha1_hw_available(void)
|
|
{
|
|
#if defined HWCAP_SHA1
|
|
return getauxval(AT_HWCAP) & HWCAP_SHA1;
|
|
#elif defined HWCAP2_SHA1
|
|
return getauxval(AT_HWCAP2) & HWCAP2_SHA1;
|
|
#elif defined __APPLE__
|
|
/* Assume always present on M1 macOS, similarly to AES */
|
|
return true;
|
|
#else
|
|
return false;
|
|
#endif
|
|
}
|
|
|
|
bool platform_sha512_hw_available(void)
|
|
{
|
|
#if defined HWCAP_SHA512
|
|
return getauxval(AT_HWCAP) & HWCAP_SHA512;
|
|
#elif defined HWCAP2_SHA512
|
|
return getauxval(AT_HWCAP2) & HWCAP2_SHA512;
|
|
#elif defined __APPLE__
|
|
return test_sysctl_flag("hw.optional.armv8_2_sha512");
|
|
#else
|
|
return false;
|
|
#endif
|
|
}
|
|
|
|
#else /* defined __arm__ || defined __aarch64__ */
|
|
|
|
/*
|
|
* Include _something_ in this file to prevent an annoying compiler
|
|
* warning, and to avoid having to condition out this file in
|
|
* CMakeLists. It's in a library, so this variable shouldn't end up in
|
|
* any actual program, because nothing will refer to it.
|
|
*/
|
|
const int arm_arch_queries_dummy_variable = 0;
|
|
|
|
#endif /* defined __arm__ || defined __aarch64__ */
|