Add sodium_runtime_has_ssse3() and sodium_runtime_has_sse41()
This commit is contained in:
parent
84695c8d42
commit
26fdfec99b
@ -7,7 +7,7 @@
|
||||
#define SODIUM_VERSION_STRING "1.0.5"
|
||||
|
||||
#define SODIUM_LIBRARY_VERSION_MAJOR 7
|
||||
#define SODIUM_LIBRARY_VERSION_MINOR 6
|
||||
#define SODIUM_LIBRARY_VERSION_MINOR 7
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -17,9 +17,9 @@ ISODATE=`date +%Y-%m-%d`
|
||||
AC_SUBST(ISODATE)
|
||||
|
||||
SODIUM_LIBRARY_VERSION_MAJOR=7
|
||||
SODIUM_LIBRARY_VERSION_MINOR=6
|
||||
SODIUM_LIBRARY_VERSION_MINOR=7
|
||||
DLL_VERSION=6
|
||||
SODIUM_LIBRARY_VERSION=16:0:3
|
||||
SODIUM_LIBRARY_VERSION=17:0:4
|
||||
# | | |
|
||||
# +------+ | +---+
|
||||
# | | |
|
||||
|
@ -1,4 +1,4 @@
|
||||
cscript msvc-scripts/rep.vbs //Nologo s/@VERSION@/1.0.5/ < src\libsodium\include\sodium\version.h.in > tmp
|
||||
cscript msvc-scripts/rep.vbs //Nologo s/@SODIUM_LIBRARY_VERSION_MAJOR@/7/ < tmp > tmp2
|
||||
cscript msvc-scripts/rep.vbs //Nologo s/@SODIUM_LIBRARY_VERSION_MINOR@/6/ < tmp2 > src\libsodium\include\sodium\version.h
|
||||
cscript msvc-scripts/rep.vbs //Nologo s/@SODIUM_LIBRARY_VERSION_MINOR@/7/ < tmp2 > src\libsodium\include\sodium\version.h
|
||||
del tmp tmp2
|
||||
|
@ -20,6 +20,12 @@ int sodium_runtime_has_sse2(void);
|
||||
SODIUM_EXPORT
|
||||
int sodium_runtime_has_sse3(void);
|
||||
|
||||
SODIUM_EXPORT
|
||||
int sodium_runtime_has_ssse3(void);
|
||||
|
||||
SODIUM_EXPORT
|
||||
int sodium_runtime_has_sse41(void);
|
||||
|
||||
SODIUM_EXPORT
|
||||
int sodium_runtime_has_pclmul(void);
|
||||
|
||||
|
@ -10,6 +10,8 @@ typedef struct CPUFeatures_ {
|
||||
int has_neon;
|
||||
int has_sse2;
|
||||
int has_sse3;
|
||||
int has_ssse3;
|
||||
int has_sse41;
|
||||
int has_pclmul;
|
||||
int has_aesni;
|
||||
} CPUFeatures;
|
||||
@ -18,6 +20,8 @@ static CPUFeatures _cpu_features;
|
||||
|
||||
#define CPUID_SSE2 0x04000000
|
||||
#define CPUIDECX_SSE3 0x00000001
|
||||
#define CPUIDECX_SSSE3 0x00000200
|
||||
#define CPUIDECX_SSE41 0x00080000
|
||||
#define CPUIDECX_PCLMUL 0x00000002
|
||||
#define CPUIDECX_AESNI 0x02000000
|
||||
|
||||
@ -108,6 +112,18 @@ _sodium_runtime_intel_cpu_features(CPUFeatures * const cpu_features)
|
||||
cpu_features->has_sse3 = ((cpu_info[2] & CPUIDECX_SSE3) != 0x0);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_TMMINTRIN_H
|
||||
cpu_features->has_ssse3 = 0;
|
||||
#else
|
||||
cpu_features->has_ssse3 = ((cpu_info[2] & CPUIDECX_SSSE3) != 0x0);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_SMMINTRIN_H
|
||||
cpu_features->has_sse41 = 0;
|
||||
#else
|
||||
cpu_features->has_sse41 = ((cpu_info[2] & CPUIDECX_SSE41) != 0x0);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_WMMINTRIN_H
|
||||
cpu_features->has_pclmul = 0;
|
||||
cpu_features->has_aesni = 0;
|
||||
@ -146,6 +162,16 @@ sodium_runtime_has_sse3(void) {
|
||||
return _cpu_features.has_sse3;
|
||||
}
|
||||
|
||||
int
|
||||
sodium_runtime_has_ssse3(void) {
|
||||
return _cpu_features.has_ssse3;
|
||||
}
|
||||
|
||||
int
|
||||
sodium_runtime_has_sse41(void) {
|
||||
return _cpu_features.has_sse41;
|
||||
}
|
||||
|
||||
int
|
||||
sodium_runtime_has_pclmul(void) {
|
||||
return _cpu_features.has_pclmul;
|
||||
|
@ -9,6 +9,8 @@ int main(void)
|
||||
(void)sodium_runtime_has_neon();
|
||||
(void)sodium_runtime_has_sse2();
|
||||
(void)sodium_runtime_has_sse3();
|
||||
(void)sodium_runtime_has_ssse3();
|
||||
(void)sodium_runtime_has_sse41();
|
||||
(void)sodium_runtime_has_pclmul();
|
||||
(void)sodium_runtime_has_aesni();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user