mirror of
https://github.com/jedisct1/libsodium.git
synced 2026-08-25 08:37:13 +09:00
Use clang pragmas to enable features rather than depend on compiler settings
This commit is contained in:
@@ -6,6 +6,135 @@ const mem = std.mem;
|
||||
const Compile = std.Build.Step.Compile;
|
||||
const Target = std.Target;
|
||||
|
||||
fn initLibConfig(target: std.Build.ResolvedTarget, lib: *Compile) void {
|
||||
lib.linkLibC();
|
||||
lib.addIncludePath(.{ .path = "src/libsodium/include/sodium" });
|
||||
lib.defineCMacro("_GNU_SOURCE", "1");
|
||||
lib.defineCMacro("CONFIGURED", "1");
|
||||
lib.defineCMacro("DEV_MODE", "1");
|
||||
lib.defineCMacro("HAVE_ATOMIC_OPS", "1");
|
||||
lib.defineCMacro("HAVE_C11_MEMORY_FENCES", "1");
|
||||
lib.defineCMacro("HAVE_CET_H", "1");
|
||||
lib.defineCMacro("HAVE_GCC_MEMORY_FENCES", "1");
|
||||
lib.defineCMacro("HAVE_INLINE_ASM", "1");
|
||||
lib.defineCMacro("HAVE_INTTYPES_H", "1");
|
||||
lib.defineCMacro("HAVE_STDINT_H", "1");
|
||||
lib.defineCMacro("HAVE_TI_MODE", "1");
|
||||
lib.want_lto = false;
|
||||
|
||||
const endian = target.result.cpu.arch.endian();
|
||||
switch (endian) {
|
||||
.big => lib.defineCMacro("NATIVE_BIG_ENDIAN", "1"),
|
||||
.little => lib.defineCMacro("NATIVE_LITTLE_ENDIAN", "1"),
|
||||
}
|
||||
|
||||
switch (target.result.os.tag) {
|
||||
.linux => {
|
||||
lib.defineCMacro("ASM_HIDE_SYMBOL", ".hidden");
|
||||
lib.defineCMacro("TLS", "_Thread_local");
|
||||
|
||||
lib.defineCMacro("HAVE_CATCHABLE_ABRT", "1");
|
||||
lib.defineCMacro("HAVE_CATCHABLE_SEGV", "1");
|
||||
lib.defineCMacro("HAVE_CLOCK_GETTIME", "1");
|
||||
lib.defineCMacro("HAVE_GETPID", "1");
|
||||
lib.defineCMacro("HAVE_INLINE_ASM", "1");
|
||||
lib.defineCMacro("HAVE_MADVISE", "1");
|
||||
lib.defineCMacro("HAVE_MLOCK", "1");
|
||||
lib.defineCMacro("HAVE_MMAP", "1");
|
||||
lib.defineCMacro("HAVE_MPROTECT", "1");
|
||||
lib.defineCMacro("HAVE_NANOSLEEP", "1");
|
||||
lib.defineCMacro("HAVE_POSIX_MEMALIGN", "1");
|
||||
lib.defineCMacro("HAVE_PTHREAD_PRIO_INHERIT", "1");
|
||||
lib.defineCMacro("HAVE_PTHREAD", "1");
|
||||
lib.defineCMacro("HAVE_RAISE", "1");
|
||||
lib.defineCMacro("HAVE_SYSCONF", "1");
|
||||
lib.defineCMacro("HAVE_SYS_AUXV_H", "1");
|
||||
lib.defineCMacro("HAVE_SYS_MMAN_H", "1");
|
||||
lib.defineCMacro("HAVE_SYS_PARAM_H", "1");
|
||||
lib.defineCMacro("HAVE_SYS_RANDOM_H", "1");
|
||||
lib.defineCMacro("HAVE_WEAK_SYMBOLS", "1");
|
||||
},
|
||||
.windows => {
|
||||
lib.defineCMacro("HAVE_RAISE", "1");
|
||||
lib.defineCMacro("HAVE_SYS_PARAM_H", "1");
|
||||
if (lib.isStaticLibrary()) {
|
||||
lib.defineCMacro("SODIUM_STATIC", "1");
|
||||
}
|
||||
},
|
||||
.macos => {
|
||||
lib.defineCMacro("ASM_HIDE_SYMBOL", ".private_extern");
|
||||
lib.defineCMacro("TLS", "_Thread_local");
|
||||
|
||||
lib.defineCMacro("HAVE_ARC4RANDOM", "1");
|
||||
lib.defineCMacro("HAVE_ARC4RANDOM_BUF", "1");
|
||||
lib.defineCMacro("HAVE_CATCHABLE_ABRT", "1");
|
||||
lib.defineCMacro("HAVE_CATCHABLE_SEGV", "1");
|
||||
lib.defineCMacro("HAVE_CLOCK_GETTIME", "1");
|
||||
lib.defineCMacro("HAVE_GETENTROPY", "1");
|
||||
lib.defineCMacro("HAVE_GETPID", "1");
|
||||
lib.defineCMacro("HAVE_MADVISE", "1");
|
||||
lib.defineCMacro("HAVE_MEMSET_S", "1");
|
||||
lib.defineCMacro("HAVE_MLOCK", "1");
|
||||
lib.defineCMacro("HAVE_MMAP", "1");
|
||||
lib.defineCMacro("HAVE_MPROTECT", "1");
|
||||
lib.defineCMacro("HAVE_NANOSLEEP", "1");
|
||||
lib.defineCMacro("HAVE_POSIX_MEMALIGN", "1");
|
||||
lib.defineCMacro("HAVE_PTHREAD", "1");
|
||||
lib.defineCMacro("HAVE_PTHREAD_PRIO_INHERIT", "1");
|
||||
lib.defineCMacro("HAVE_RAISE", "1");
|
||||
lib.defineCMacro("HAVE_SYSCONF", "1");
|
||||
lib.defineCMacro("HAVE_SYS_MMAN_H", "1");
|
||||
lib.defineCMacro("HAVE_SYS_PARAM_H", "1");
|
||||
lib.defineCMacro("HAVE_SYS_RANDOM_H", "1");
|
||||
lib.defineCMacro("HAVE_WEAK_SYMBOLS", "1");
|
||||
},
|
||||
.wasi => {
|
||||
lib.defineCMacro("HAVE_ARC4RANDOM", "1");
|
||||
lib.defineCMacro("HAVE_ARC4RANDOM_BUF", "1");
|
||||
lib.defineCMacro("HAVE_CLOCK_GETTIME", "1");
|
||||
lib.defineCMacro("HAVE_GETENTROPY", "1");
|
||||
lib.defineCMacro("HAVE_NANOSLEEP", "1");
|
||||
lib.defineCMacro("HAVE_POSIX_MEMALIGN", "1");
|
||||
lib.defineCMacro("HAVE_SYS_AUXV_H", "1");
|
||||
lib.defineCMacro("HAVE_SYS_PARAM_H", "1");
|
||||
lib.defineCMacro("HAVE_SYS_RANDOM_H", "1");
|
||||
},
|
||||
else => {},
|
||||
}
|
||||
|
||||
switch (target.result.cpu.arch) {
|
||||
.x86_64 => {
|
||||
lib.defineCMacro("HAVE_AMD64_ASM", "1");
|
||||
lib.defineCMacro("HAVE_AVX_ASM", "1");
|
||||
lib.defineCMacro("HAVE_CPUID", "1");
|
||||
lib.defineCMacro("HAVE_MMINTRIN_H", "1");
|
||||
lib.defineCMacro("HAVE_EMMINTRIN_H", "1");
|
||||
lib.defineCMacro("HAVE_PMMINTRIN_H", "1");
|
||||
lib.defineCMacro("HAVE_TMMINTRIN_H", "1");
|
||||
lib.defineCMacro("HAVE_SMMINTRIN_H", "1");
|
||||
lib.defineCMacro("HAVE_AVXINTRIN_H", "1");
|
||||
lib.defineCMacro("HAVE_AVX2INTRIN_H", "1");
|
||||
lib.defineCMacro("HAVE_AVX512FINTRIN_H", "1");
|
||||
lib.defineCMacro("HAVE_WMMINTRIN_H", "1");
|
||||
lib.defineCMacro("HAVE_RDRAND", "1");
|
||||
},
|
||||
.aarch64, .aarch64_be => {
|
||||
lib.defineCMacro("HAVE_ARMCRYPTO", "1");
|
||||
},
|
||||
.wasm32, .wasm64 => {
|
||||
lib.defineCMacro("__wasm__", "1");
|
||||
},
|
||||
else => {},
|
||||
}
|
||||
|
||||
switch (target.result.os.tag) {
|
||||
.wasi => {
|
||||
lib.defineCMacro("__wasi__", "1");
|
||||
},
|
||||
else => {},
|
||||
}
|
||||
}
|
||||
|
||||
pub fn build(b: *std.Build) !void {
|
||||
const root_path = b.pathFromRoot(".");
|
||||
var cwd = try fs.openDirAbsolute(root_path, .{});
|
||||
@@ -29,17 +158,8 @@ pub fn build(b: *std.Build) !void {
|
||||
}
|
||||
|
||||
switch (target.result.cpu.arch) {
|
||||
// Features we assume are always available because they won't affect
|
||||
// code generation in files that don't use them.
|
||||
.x86_64 => {
|
||||
target.query.cpu_features_add.addFeature(@intFromEnum(Target.x86.Feature.sse4_1));
|
||||
target.query.cpu_features_add.addFeature(@intFromEnum(Target.x86.Feature.aes));
|
||||
target.query.cpu_features_add.addFeature(@intFromEnum(Target.x86.Feature.pclmul));
|
||||
target.query.cpu_features_add.addFeature(@intFromEnum(Target.x86.Feature.rdrnd));
|
||||
},
|
||||
.aarch64, .aarch64_be => {
|
||||
target.query.cpu_features_add.addFeature(@intFromEnum(Target.aarch64.Feature.crypto));
|
||||
// ARM CPUs supported by Windows also support NEON.
|
||||
.aarch64, .aarch64_be, .aarch64_32 => {
|
||||
// ARM CPUs supported by Windows are assumed to have NEON support
|
||||
if (target.result.isMinGW()) {
|
||||
target.query.cpu_features_add.addFeature(@intFromEnum(Target.aarch64.Feature.neon));
|
||||
}
|
||||
@@ -48,12 +168,12 @@ pub fn build(b: *std.Build) !void {
|
||||
}
|
||||
|
||||
const static_lib = b.addStaticLibrary(.{
|
||||
.name = "sodium",
|
||||
.name = if (target.result.isMinGW()) "libsodium-static" else "sodium",
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
const shared_lib = b.addSharedLibrary(.{
|
||||
.name = if (target.result.isMinGW()) "sodium_shared" else "sodium",
|
||||
.name = if (target.result.isMinGW()) "libsodium" else "sodium",
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.strip = optimize != .Debug and !target.result.isMinGW(),
|
||||
@@ -85,164 +205,29 @@ pub fn build(b: *std.Build) !void {
|
||||
b.installArtifact(lib);
|
||||
lib.installHeader(.{ .path = src_path ++ "/include/sodium.h" }, "sodium.h");
|
||||
lib.installHeadersDirectory(.{ .path = src_path ++ "/include/sodium" }, "sodium", .{});
|
||||
lib.linkLibC();
|
||||
|
||||
lib.addIncludePath(.{ .path = "src/libsodium/include/sodium" });
|
||||
lib.defineCMacro("_GNU_SOURCE", "1");
|
||||
lib.defineCMacro("CONFIGURED", "1");
|
||||
lib.defineCMacro("DEV_MODE", "1");
|
||||
lib.defineCMacro("HAVE_ATOMIC_OPS", "1");
|
||||
lib.defineCMacro("HAVE_C11_MEMORY_FENCES", "1");
|
||||
lib.defineCMacro("HAVE_CET_H", "1");
|
||||
lib.defineCMacro("HAVE_GCC_MEMORY_FENCES", "1");
|
||||
lib.defineCMacro("HAVE_INLINE_ASM", "1");
|
||||
lib.defineCMacro("HAVE_INTTYPES_H", "1");
|
||||
lib.defineCMacro("HAVE_STDINT_H", "1");
|
||||
lib.defineCMacro("HAVE_TI_MODE", "1");
|
||||
initLibConfig(target, lib);
|
||||
|
||||
const endian = target.result.cpu.arch.endian();
|
||||
switch (endian) {
|
||||
.big => lib.defineCMacro("NATIVE_BIG_ENDIAN", "1"),
|
||||
.little => lib.defineCMacro("NATIVE_LITTLE_ENDIAN", "1"),
|
||||
}
|
||||
|
||||
switch (target.result.os.tag) {
|
||||
.linux => {
|
||||
lib.defineCMacro("ASM_HIDE_SYMBOL", ".hidden");
|
||||
lib.defineCMacro("TLS", "_Thread_local");
|
||||
|
||||
lib.defineCMacro("HAVE_CATCHABLE_ABRT", "1");
|
||||
lib.defineCMacro("HAVE_CATCHABLE_SEGV", "1");
|
||||
lib.defineCMacro("HAVE_CLOCK_GETTIME", "1");
|
||||
lib.defineCMacro("HAVE_GETPID", "1");
|
||||
lib.defineCMacro("HAVE_INLINE_ASM", "1");
|
||||
lib.defineCMacro("HAVE_MADVISE", "1");
|
||||
lib.defineCMacro("HAVE_MLOCK", "1");
|
||||
lib.defineCMacro("HAVE_MMAP", "1");
|
||||
lib.defineCMacro("HAVE_MPROTECT", "1");
|
||||
lib.defineCMacro("HAVE_NANOSLEEP", "1");
|
||||
lib.defineCMacro("HAVE_POSIX_MEMALIGN", "1");
|
||||
lib.defineCMacro("HAVE_PTHREAD_PRIO_INHERIT", "1");
|
||||
lib.defineCMacro("HAVE_PTHREAD", "1");
|
||||
lib.defineCMacro("HAVE_RAISE", "1");
|
||||
lib.defineCMacro("HAVE_SYSCONF", "1");
|
||||
lib.defineCMacro("HAVE_SYS_AUXV_H", "1");
|
||||
lib.defineCMacro("HAVE_SYS_MMAN_H", "1");
|
||||
lib.defineCMacro("HAVE_SYS_PARAM_H", "1");
|
||||
lib.defineCMacro("HAVE_SYS_RANDOM_H", "1");
|
||||
lib.defineCMacro("HAVE_WEAK_SYMBOLS", "1");
|
||||
},
|
||||
.windows => {
|
||||
lib.defineCMacro("HAVE_RAISE", "1");
|
||||
lib.defineCMacro("HAVE_SYS_PARAM_H", "1");
|
||||
if (lib.isStaticLibrary()) {
|
||||
lib.defineCMacro("SODIUM_STATIC", "1");
|
||||
}
|
||||
},
|
||||
.macos => {
|
||||
lib.defineCMacro("ASM_HIDE_SYMBOL", ".private_extern");
|
||||
lib.defineCMacro("TLS", "_Thread_local");
|
||||
|
||||
lib.defineCMacro("HAVE_ARC4RANDOM", "1");
|
||||
lib.defineCMacro("HAVE_ARC4RANDOM_BUF", "1");
|
||||
lib.defineCMacro("HAVE_CATCHABLE_ABRT", "1");
|
||||
lib.defineCMacro("HAVE_CATCHABLE_SEGV", "1");
|
||||
lib.defineCMacro("HAVE_CLOCK_GETTIME", "1");
|
||||
lib.defineCMacro("HAVE_GETENTROPY", "1");
|
||||
lib.defineCMacro("HAVE_GETPID", "1");
|
||||
lib.defineCMacro("HAVE_MADVISE", "1");
|
||||
lib.defineCMacro("HAVE_MEMSET_S", "1");
|
||||
lib.defineCMacro("HAVE_MLOCK", "1");
|
||||
lib.defineCMacro("HAVE_MMAP", "1");
|
||||
lib.defineCMacro("HAVE_MPROTECT", "1");
|
||||
lib.defineCMacro("HAVE_NANOSLEEP", "1");
|
||||
lib.defineCMacro("HAVE_POSIX_MEMALIGN", "1");
|
||||
lib.defineCMacro("HAVE_PTHREAD", "1");
|
||||
lib.defineCMacro("HAVE_PTHREAD_PRIO_INHERIT", "1");
|
||||
lib.defineCMacro("HAVE_RAISE", "1");
|
||||
lib.defineCMacro("HAVE_SYSCONF", "1");
|
||||
lib.defineCMacro("HAVE_SYS_MMAN_H", "1");
|
||||
lib.defineCMacro("HAVE_SYS_PARAM_H", "1");
|
||||
lib.defineCMacro("HAVE_SYS_RANDOM_H", "1");
|
||||
lib.defineCMacro("HAVE_WEAK_SYMBOLS", "1");
|
||||
},
|
||||
.wasi => {
|
||||
lib.defineCMacro("HAVE_ARC4RANDOM", "1");
|
||||
lib.defineCMacro("HAVE_ARC4RANDOM_BUF", "1");
|
||||
lib.defineCMacro("HAVE_CLOCK_GETTIME", "1");
|
||||
lib.defineCMacro("HAVE_GETENTROPY", "1");
|
||||
lib.defineCMacro("HAVE_NANOSLEEP", "1");
|
||||
lib.defineCMacro("HAVE_POSIX_MEMALIGN", "1");
|
||||
lib.defineCMacro("HAVE_SYS_AUXV_H", "1");
|
||||
lib.defineCMacro("HAVE_SYS_PARAM_H", "1");
|
||||
lib.defineCMacro("HAVE_SYS_RANDOM_H", "1");
|
||||
},
|
||||
else => {},
|
||||
}
|
||||
|
||||
switch (target.result.cpu.arch) {
|
||||
.x86_64 => {
|
||||
lib.defineCMacro("HAVE_AMD64_ASM", "1");
|
||||
lib.defineCMacro("HAVE_AVX_ASM", "1");
|
||||
lib.defineCMacro("HAVE_CPUID", "1");
|
||||
lib.defineCMacro("HAVE_MMINTRIN_H", "1");
|
||||
lib.defineCMacro("HAVE_EMMINTRIN_H", "1");
|
||||
|
||||
const cpu_features = target.result.cpu.features;
|
||||
const has_sse3 = cpu_features.isEnabled(@intFromEnum(Target.x86.Feature.sse3));
|
||||
const has_ssse3 = cpu_features.isEnabled(@intFromEnum(Target.x86.Feature.ssse3));
|
||||
const has_sse4_1 = cpu_features.isEnabled(@intFromEnum(Target.x86.Feature.sse4_1));
|
||||
const has_avx = cpu_features.isEnabled(@intFromEnum(Target.x86.Feature.avx));
|
||||
const has_avx2 = cpu_features.isEnabled(@intFromEnum(Target.x86.Feature.avx2));
|
||||
const has_avx512f = cpu_features.isEnabled(@intFromEnum(Target.x86.Feature.avx512f));
|
||||
const has_aes = cpu_features.isEnabled(@intFromEnum(Target.x86.Feature.aes));
|
||||
const has_pclmul = cpu_features.isEnabled(@intFromEnum(Target.x86.Feature.pclmul));
|
||||
const has_rdrnd = cpu_features.isEnabled(@intFromEnum(Target.x86.Feature.rdrnd));
|
||||
|
||||
if (has_sse3) lib.defineCMacro("HAVE_PMMINTRIN_H", "1");
|
||||
if (has_ssse3) lib.defineCMacro("HAVE_TMMINTRIN_H", "1");
|
||||
if (has_sse4_1) lib.defineCMacro("HAVE_SMMINTRIN_H", "1");
|
||||
if (has_avx) lib.defineCMacro("HAVE_AVXINTRIN_H", "1");
|
||||
if (has_avx2) lib.defineCMacro("HAVE_AVX2INTRIN_H", "1");
|
||||
if (has_avx512f) lib.defineCMacro("HAVE_AVX512FINTRIN_H", "1");
|
||||
if (has_aes and has_pclmul) lib.defineCMacro("HAVE_WMMINTRIN_H", "1");
|
||||
if (has_rdrnd) lib.defineCMacro("HAVE_RDRAND", "1");
|
||||
},
|
||||
.aarch64, .aarch64_be => {
|
||||
const cpu_features = target.result.cpu.features;
|
||||
const has_neon = cpu_features.isEnabled(@intFromEnum(Target.aarch64.Feature.neon));
|
||||
const has_crypto = cpu_features.isEnabled(@intFromEnum(Target.aarch64.Feature.crypto));
|
||||
if (has_neon and has_crypto) {
|
||||
lib.defineCMacro("HAVE_ARMCRYPTO", "1");
|
||||
}
|
||||
},
|
||||
.wasm32, .wasm64 => {
|
||||
lib.defineCMacro("__wasm__", "1");
|
||||
},
|
||||
else => {},
|
||||
}
|
||||
|
||||
switch (target.result.os.tag) {
|
||||
.wasi => {
|
||||
lib.defineCMacro("__wasi__", "1");
|
||||
},
|
||||
else => {},
|
||||
}
|
||||
const flags = &.{
|
||||
"-fvisibility=hidden",
|
||||
"-fno-strict-aliasing",
|
||||
"-fno-strict-overflow",
|
||||
"-fwrapv",
|
||||
"-flax-vector-conversions",
|
||||
};
|
||||
|
||||
const allocator = heap.page_allocator;
|
||||
|
||||
var walker = try src_dir.walk(allocator);
|
||||
while (try walker.next()) |entry| {
|
||||
const name = entry.basename;
|
||||
if (mem.endsWith(u8, name, ".c")) {
|
||||
const full_path = try fmt.allocPrint(allocator, "{s}/{s}", .{ src_path, entry.path });
|
||||
const flags = &.{
|
||||
"-fvisibility=hidden",
|
||||
"-fno-strict-aliasing",
|
||||
"-fno-strict-overflow",
|
||||
"-fwrapv",
|
||||
"-flax-vector-conversions",
|
||||
};
|
||||
lib.addCSourceFiles(.{ .files = &.{full_path}, .flags = flags });
|
||||
|
||||
lib.addCSourceFiles(.{
|
||||
.files = &.{full_path},
|
||||
.flags = flags,
|
||||
});
|
||||
} else if (mem.endsWith(u8, name, ".S")) {
|
||||
const full_path = try fmt.allocPrint(allocator, "{s}/{s}", .{ src_path, entry.path });
|
||||
lib.addAssemblyFile(.{ .path = full_path });
|
||||
|
||||
@@ -16,9 +16,11 @@
|
||||
|
||||
#if defined(HAVE_TMMINTRIN_H) && defined(HAVE_WMMINTRIN_H)
|
||||
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC target("avx,aes,pclmul")
|
||||
#endif
|
||||
# ifdef __clang__
|
||||
# pragma clang attribute push(__attribute__((target("aes,avx,pclmul"))), apply_to = function)
|
||||
# elif defined(__GNUC__)
|
||||
# pragma GCC target("aes,avx,pclmul")
|
||||
# endif
|
||||
|
||||
#if !defined(_MSC_VER) || _MSC_VER < 1800
|
||||
#define __vectorcall
|
||||
@@ -1006,4 +1008,8 @@ crypto_aead_aes256gcm_is_available(void)
|
||||
return sodium_runtime_has_pclmul() & sodium_runtime_has_aesni() & sodium_runtime_has_avx();
|
||||
}
|
||||
|
||||
#ifdef __clang__
|
||||
# pragma clang attribute pop
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -12,11 +12,10 @@
|
||||
#if defined(HAVE_AVX2INTRIN_H) && defined(HAVE_EMMINTRIN_H) && \
|
||||
defined(HAVE_TMMINTRIN_H) && defined(HAVE_SMMINTRIN_H)
|
||||
|
||||
# ifdef __GNUC__
|
||||
# pragma GCC target("sse2")
|
||||
# pragma GCC target("ssse3")
|
||||
# pragma GCC target("sse4.1")
|
||||
# pragma GCC target("avx2")
|
||||
# ifdef __clang__
|
||||
# pragma clang attribute push(__attribute__((target("sse2,ssse3,sse4.1,avx2"))), apply_to = function)
|
||||
# elif defined(__GNUC__)
|
||||
# pragma GCC target("sse2,ssse3,sse4.1,avx2")
|
||||
# endif
|
||||
|
||||
# include <emmintrin.h>
|
||||
@@ -46,4 +45,8 @@ blake2b_compress_avx2(blake2b_state *S, const uint8_t block[BLAKE2B_BLOCKBYTES])
|
||||
return 0;
|
||||
}
|
||||
|
||||
# ifdef __clang__
|
||||
# pragma clang attribute pop
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -11,10 +11,10 @@
|
||||
#if defined(HAVE_EMMINTRIN_H) && defined(HAVE_TMMINTRIN_H) && \
|
||||
defined(HAVE_SMMINTRIN_H)
|
||||
|
||||
# ifdef __GNUC__
|
||||
# pragma GCC target("sse2")
|
||||
# pragma GCC target("ssse3")
|
||||
# pragma GCC target("sse4.1")
|
||||
# ifdef __clang__
|
||||
# pragma clang attribute push(__attribute__((target("sse2,ssse3,sse4.1"))), apply_to = function)
|
||||
# elif defined(__GNUC__)
|
||||
# pragma GCC target("sse2,ssse3,sse4.1")
|
||||
# endif
|
||||
|
||||
# include <emmintrin.h>
|
||||
@@ -84,4 +84,8 @@ blake2b_compress_sse41(blake2b_state *S,
|
||||
return 0;
|
||||
}
|
||||
|
||||
# ifdef __clang__
|
||||
# pragma clang attribute pop
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -7,9 +7,10 @@
|
||||
|
||||
#if defined(HAVE_EMMINTRIN_H) && defined(HAVE_TMMINTRIN_H)
|
||||
|
||||
# ifdef __GNUC__
|
||||
# pragma GCC target("sse2")
|
||||
# pragma GCC target("ssse3")
|
||||
# ifdef __clang__
|
||||
# pragma clang attribute push(__attribute__((target("sse2,ssse3"))), apply_to = function)
|
||||
# elif defined(__GNUC__)
|
||||
# pragma GCC target("sse2,ssse3")
|
||||
# endif
|
||||
|
||||
# include <emmintrin.h>
|
||||
@@ -87,4 +88,8 @@ blake2b_compress_ssse3(blake2b_state *S,
|
||||
return 0;
|
||||
}
|
||||
|
||||
# ifdef __clang__
|
||||
# pragma clang attribute pop
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -10,7 +10,9 @@
|
||||
|
||||
#if defined(HAVE_TI_MODE) && defined(HAVE_EMMINTRIN_H)
|
||||
|
||||
# ifdef __GNUC__
|
||||
# ifdef __clang__
|
||||
# pragma clang attribute push(__attribute__((target("sse2"))), apply_to = function)
|
||||
# elif defined(__GNUC__)
|
||||
# pragma GCC target("sse2")
|
||||
# endif
|
||||
|
||||
@@ -946,4 +948,8 @@ struct crypto_onetimeauth_poly1305_implementation
|
||||
SODIUM_C99(.onetimeauth_final =) crypto_onetimeauth_poly1305_sse2_final
|
||||
};
|
||||
|
||||
#ifdef __clang__
|
||||
# pragma clang attribute pop
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -22,11 +22,10 @@
|
||||
#if defined(HAVE_AVX2INTRIN_H) && defined(HAVE_EMMINTRIN_H) && \
|
||||
defined(HAVE_TMMINTRIN_H) && defined(HAVE_SMMINTRIN_H)
|
||||
|
||||
# ifdef __GNUC__
|
||||
# pragma GCC target("sse2")
|
||||
# pragma GCC target("ssse3")
|
||||
# pragma GCC target("sse4.1")
|
||||
# pragma GCC target("avx2")
|
||||
# ifdef __clang__
|
||||
# pragma clang attribute push(__attribute__((target("sse2,ssse3,sse4.1,avx2"))), apply_to = function)
|
||||
# elif defined(__GNUC__)
|
||||
# pragma GCC target("sse2,ssse3,sse4.1,avx2")
|
||||
# endif
|
||||
|
||||
# ifdef _MSC_VER
|
||||
@@ -236,4 +235,9 @@ argon2_fill_segment_avx2(const argon2_instance_t *instance,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __clang__
|
||||
# pragma clang attribute pop
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -22,12 +22,10 @@
|
||||
#if defined(HAVE_AVX512FINTRIN_H) && defined(HAVE_AVX2INTRIN_H) && \
|
||||
defined(HAVE_EMMINTRIN_H) && defined(HAVE_TMMINTRIN_H) && defined(HAVE_SMMINTRIN_H)
|
||||
|
||||
# ifdef __GNUC__
|
||||
# pragma GCC target("sse2")
|
||||
# pragma GCC target("ssse3")
|
||||
# pragma GCC target("sse4.1")
|
||||
# pragma GCC target("avx2")
|
||||
# pragma GCC target("avx512f")
|
||||
# ifdef __clang__
|
||||
# pragma clang attribute push(__attribute__((target("sse2,ssse3,sse4.1,avx2,avx512f"))), apply_to = function)
|
||||
# elif defined(__GNUC__)
|
||||
# pragma GCC target("sse2,ssse3,sse4.1,avx2,avx512f")
|
||||
# endif
|
||||
|
||||
# ifdef _MSC_VER
|
||||
@@ -241,4 +239,9 @@ argon2_fill_segment_avx512f(const argon2_instance_t *instance,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __clang__
|
||||
# pragma clang attribute pop
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -21,9 +21,10 @@
|
||||
|
||||
#if defined(HAVE_EMMINTRIN_H) && defined(HAVE_TMMINTRIN_H)
|
||||
|
||||
# ifdef __GNUC__
|
||||
# pragma GCC target("sse2")
|
||||
# pragma GCC target("ssse3")
|
||||
# ifdef __clang__
|
||||
# pragma clang attribute push(__attribute__((target("sse2,ssse3"))), apply_to = function)
|
||||
# elif defined(__GNUC__)
|
||||
# pragma GCC target("sse2,ssse3")
|
||||
# endif
|
||||
|
||||
# ifdef _MSC_VER
|
||||
@@ -235,4 +236,9 @@ argon2_fill_segment_ssse3(const argon2_instance_t *instance,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __clang__
|
||||
# pragma clang attribute pop
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
+10
-4
@@ -38,13 +38,14 @@
|
||||
|
||||
#ifdef HAVE_EMMINTRIN_H
|
||||
|
||||
# ifdef __GNUC__
|
||||
# ifdef __clang__
|
||||
# pragma clang attribute push(__attribute__((target("sse2"))), apply_to = function)
|
||||
# elif defined(__GNUC__)
|
||||
# pragma GCC target("sse2")
|
||||
# endif
|
||||
|
||||
# include <emmintrin.h>
|
||||
# if defined(__XOP__) && defined(DISABLED)
|
||||
# include <x86intrin.h>
|
||||
# endif
|
||||
|
||||
# include "private/sse2_64_32.h"
|
||||
|
||||
# include "../crypto_scrypt.h"
|
||||
@@ -397,4 +398,9 @@ escrypt_kdf_sse(escrypt_local_t *local, const uint8_t *passwd, size_t passwdlen,
|
||||
/* Success! */
|
||||
return 0;
|
||||
}
|
||||
|
||||
# ifdef __clang__
|
||||
# pragma clang attribute pop
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -11,11 +11,10 @@
|
||||
#if defined(HAVE_AVX2INTRIN_H) && defined(HAVE_EMMINTRIN_H) && \
|
||||
defined(HAVE_TMMINTRIN_H) && defined(HAVE_SMMINTRIN_H)
|
||||
|
||||
# ifdef __GNUC__
|
||||
# pragma GCC target("sse2")
|
||||
# pragma GCC target("ssse3")
|
||||
# pragma GCC target("sse4.1")
|
||||
# pragma GCC target("avx2")
|
||||
# ifdef __clang__
|
||||
# pragma clang attribute push(__attribute__((target("sse2,ssse3,sse4.1,avx2"))), apply_to = function)
|
||||
# elif defined(__GNUC__)
|
||||
# pragma GCC target("sse2,ssse3,sse4.1,avx2")
|
||||
# endif
|
||||
|
||||
# include <emmintrin.h>
|
||||
@@ -174,4 +173,8 @@ struct crypto_stream_chacha20_implementation
|
||||
SODIUM_C99(.stream_ietf_ext_xor_ic =) stream_ietf_ext_ref_xor_ic
|
||||
};
|
||||
|
||||
# ifdef __clang__
|
||||
# pragma clang attribute pop
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -10,9 +10,10 @@
|
||||
|
||||
#if defined(HAVE_EMMINTRIN_H) && defined(HAVE_TMMINTRIN_H)
|
||||
|
||||
# ifdef __GNUC__
|
||||
# pragma GCC target("sse2")
|
||||
# pragma GCC target("ssse3")
|
||||
# ifdef __clang__
|
||||
# pragma clang attribute push(__attribute__((target("sse2,ssse3"))), apply_to = function)
|
||||
# elif defined(__GNUC__)
|
||||
# pragma GCC target("sse2,ssse3")
|
||||
# endif
|
||||
|
||||
# include <emmintrin.h>
|
||||
@@ -168,4 +169,8 @@ struct crypto_stream_chacha20_implementation
|
||||
SODIUM_C99(.stream_ietf_ext_xor_ic =) stream_ietf_ext_ref_xor_ic
|
||||
};
|
||||
|
||||
# ifdef __clang__
|
||||
# pragma clang attribute pop
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -10,18 +10,17 @@
|
||||
#if defined(HAVE_AVX2INTRIN_H) && defined(HAVE_EMMINTRIN_H) && \
|
||||
defined(HAVE_TMMINTRIN_H) && defined(HAVE_SMMINTRIN_H)
|
||||
|
||||
# ifdef __GNUC__
|
||||
# pragma GCC target("sse2")
|
||||
# pragma GCC target("ssse3")
|
||||
# pragma GCC target("sse4.1")
|
||||
# pragma GCC target("avx2")
|
||||
# ifdef __clang__
|
||||
# pragma clang attribute push(__attribute__((target("sse2,ssse3,sse4.1,avx2"))), apply_to = function)
|
||||
# elif defined(__GNUC__)
|
||||
# pragma GCC target("sse2,ssse3,sse4.1,avx2")
|
||||
# endif
|
||||
|
||||
#include <emmintrin.h>
|
||||
#include <immintrin.h>
|
||||
#include <smmintrin.h>
|
||||
#include <tmmintrin.h>
|
||||
#include "private/sse2_64_32.h"
|
||||
# include <emmintrin.h>
|
||||
# include <immintrin.h>
|
||||
# include <smmintrin.h>
|
||||
# include <tmmintrin.h>
|
||||
# include "private/sse2_64_32.h"
|
||||
|
||||
# include "../stream_salsa20.h"
|
||||
# include "salsa20_xmm6int-avx2.h"
|
||||
@@ -128,4 +127,8 @@ struct crypto_stream_salsa20_implementation
|
||||
SODIUM_C99(.stream_xor_ic =) stream_avx2_xor_ic
|
||||
};
|
||||
|
||||
#ifdef __clang__
|
||||
# pragma clang attribute pop
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -9,7 +9,9 @@
|
||||
|
||||
#ifdef HAVE_EMMINTRIN_H
|
||||
|
||||
# ifdef __GNUC__
|
||||
# ifdef __clang__
|
||||
# pragma clang attribute push(__attribute__((target("sse2"))), apply_to = function)
|
||||
# elif defined(__GNUC__)
|
||||
# pragma GCC target("sse2")
|
||||
# endif
|
||||
# include <emmintrin.h>
|
||||
@@ -119,4 +121,8 @@ struct crypto_stream_salsa20_implementation
|
||||
SODIUM_C99(.stream_xor_ic =) stream_sse2_xor_ic
|
||||
};
|
||||
|
||||
#ifdef __clang__
|
||||
# pragma clang attribute pop
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -27,9 +27,6 @@ crypto_verify_64_bytes(void)
|
||||
|
||||
#if defined(HAVE_EMMINTRIN_H) && defined(__SSE2__)
|
||||
|
||||
# ifdef __GNUC__
|
||||
# pragma GCC target("sse2")
|
||||
# endif
|
||||
# include <emmintrin.h>
|
||||
|
||||
static inline int
|
||||
|
||||
@@ -50,7 +50,11 @@
|
||||
# include <poll.h>
|
||||
#endif
|
||||
#ifdef HAVE_RDRAND
|
||||
# pragma GCC target("rdrnd")
|
||||
# ifdef __clang__
|
||||
# pragma clang attribute push(__attribute__((target("rdrnd"))), apply_to = function)
|
||||
# elif defined(__GNUC__)
|
||||
# pragma GCC target("rdrnd")
|
||||
# endif
|
||||
# include <immintrin.h>
|
||||
#endif
|
||||
|
||||
@@ -655,3 +659,9 @@ struct randombytes_implementation randombytes_internal_implementation = {
|
||||
SODIUM_C99(.buf =) randombytes_internal_random_buf,
|
||||
SODIUM_C99(.close =) randombytes_internal_random_close
|
||||
};
|
||||
|
||||
#ifdef HAVE_RDRAND
|
||||
# ifdef __clang__
|
||||
# pragma clang attribute pop
|
||||
# endif
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user