1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-09 17:38:00 +00:00

Use correct way to detect new instructions in Clang

__clang_major__ and __clang_minor__ macros may be overriden
 in Apple and other compilers. Instead of them, we use
__has_attribute(target) to check whether Clang supports per-function
targeted build and __has_include() to check if there are intrinsic
header files
This commit is contained in:
Pavel I. Kryukov 2018-03-14 13:51:19 +03:00 committed by Simon Tatham
parent a624786333
commit a27f55e819
2 changed files with 2 additions and 18 deletions

10
ssh.h
View File

@ -512,7 +512,7 @@ void SHATransform(word32 * digest, word32 * data);
#ifdef _FORCE_SHA_NI
# define COMPILER_SUPPORTS_SHA_NI
#elif defined(__clang__)
# if (__clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 8)) && (defined(__x86_64__) || defined(__i386))
# if __has_attribute(target) && __has_include(<shaintrin.h>) && (defined(__x86_64__) || defined(__i386))
# define COMPILER_SUPPORTS_SHA_NI
# endif
#elif defined(__GNUC__)
@ -529,14 +529,6 @@ void SHATransform(word32 * digest, word32 * data);
# undef COMPILER_SUPPORTS_SHA_NI
#endif
#if defined(__clang__)
# if !__has_attribute(target)
/* If clang is old enough not to support __attribute__((target(...)))
* as used below, then we can't use this code after all. */
# undef COMPILER_SUPPORTS_SHA_NI
# endif
#endif
int random_byte(void);
void random_add_noise(void *noise, int length);
void random_add_heavynoise(void *noise, int length);

View File

@ -1134,7 +1134,7 @@ const struct ssh2_ciphers ssh2_aes = {
#ifdef _FORCE_AES_NI
# define COMPILER_SUPPORTS_AES_NI
#elif defined(__clang__)
# if (__clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 8)) && (defined(__x86_64__) || defined(__i386))
# if __has_attribute(target) && __has_include(<wmmintrin.h>) && (defined(__x86_64__) || defined(__i386))
# define COMPILER_SUPPORTS_AES_NI
# endif
#elif defined(__GNUC__)
@ -1151,14 +1151,6 @@ const struct ssh2_ciphers ssh2_aes = {
# undef COMPILER_SUPPORTS_AES_NI
#endif
#if defined(__clang__)
# if !__has_attribute(target)
/* If clang is old enough not to support __attribute__((target(...)))
* as used below, then we can't use this code after all. */
# undef COMPILER_SUPPORTS_AES_NI
# endif
#endif
#ifdef COMPILER_SUPPORTS_AES_NI
/*