Add sodium_runtime_has_ssse3() and sodium_runtime_has_sse41()

This commit is contained in:
Frank Denis 2015-10-31 23:42:44 +01:00
parent 84695c8d42
commit 26fdfec99b
6 changed files with 38 additions and 4 deletions

View File

@ -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" {

View File

@ -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
# | | |
# +------+ | +---+
# | | |

View File

@ -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

View File

@ -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);

View File

@ -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;

View File

@ -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();