Bug 1835591 - Part 1. Add the detection of ARM crypto extension for arm 32bit. r=glandium

Differential Revision: https://phabricator.services.mozilla.com/D180646
This commit is contained in:
Makoto Kato 2023-06-15 02:48:44 +00:00
Родитель f6e81de754
Коммит f724b1a01b
2 изменённых файлов: 29 добавлений и 1 удалений

Просмотреть файл

@ -22,7 +22,8 @@ enum {
MOZILLA_HAS_EDSP_FLAG = 1,
MOZILLA_HAS_ARMV6_FLAG = 2,
MOZILLA_HAS_ARMV7_FLAG = 4,
MOZILLA_HAS_NEON_FLAG = 8
MOZILLA_HAS_NEON_FLAG = 8,
MOZILLA_HAS_AES_FLAG = 16
};
static unsigned get_arm_cpu_flags(void) {
@ -49,6 +50,10 @@ static unsigned get_arm_cpu_flags(void) {
p = strstr(buf, " neon");
if (p != nullptr && (p[5] == ' ' || p[5] == '\n'))
flags |= MOZILLA_HAS_NEON_FLAG;
p = strstr(buf, " aes");
if (p != nullptr && (p[4] == ' ' || p[4] == '\n')) {
flags |= MOZILLA_HAS_AES_FLAG;
}
}
if (memcmp(buf, "CPU architecture:", 17) == 0) {
int version;
@ -109,6 +114,12 @@ static bool check_neon(void) {
}
# endif
# if !defined(MOZILLA_PRESUME_ARM_AES)
static bool check_aes(void) {
return (arm_cpu_flags & MOZILLA_HAS_AES_FLAG) != 0;
}
# endif
# endif // defined(__linux__) || defined(ANDROID)
namespace mozilla {
@ -125,6 +136,9 @@ bool armv7_enabled = check_armv7();
# if !defined(MOZILLA_PRESUME_NEON)
bool neon_enabled = check_neon();
# endif
# if !defined(MOZILLA_PRESUME_ARM_AES)
bool aes_enabled = check_aes();
# endif
} // namespace arm_private
} // namespace mozilla

Просмотреть файл

@ -81,6 +81,10 @@
# define MOZILLA_PRESUME_NEON 1
#endif
#if defined(__ARM_FEATURE_CRYPTO)
# define MOZILLA_PRESUME_ARM_AES 1
#endif
namespace mozilla {
namespace arm_private {
@ -97,6 +101,9 @@ extern bool MFBT_DATA armv7_enabled;
# if !defined(MOZILLA_PRESUME_NEON)
extern bool MFBT_DATA neon_enabled;
# endif
# if !defined(MOZILLA_PRESUME_ARM_AES)
extern bool MFBT_DATA aes_enabled;
# endif
#endif
} // namespace arm_private
@ -139,6 +146,13 @@ inline bool supports_neon() { return arm_private::neon_enabled; }
#else
inline bool supports_neon() { return false; }
#endif
#if defined(MOZILLA_PRESUME_ARM_AES)
inline bool supports_arm_aes() { return true; }
#elif defined(MOZILLA_ARM_HAVE_CPUID_DETECTION)
inline bool supports_arm_aes() { return arm_private::aes_enabled; }
#else
inline bool supports_arm_aes() { return false; }
#endif
} // namespace mozilla