Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions ext/digest/blake3/blake3_dispatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,16 @@
#endif

#if !defined(BLAKE3_ATOMICS)
#if defined(__has_include)
#if defined(__has_include) && defined(__STDC_VERSION__) && \
__STDC_VERSION__ >= 201112L
Comment on lines +22 to +23

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

#if __has_include(<stdatomic.h>) && !defined(_MSC_VER)
#define BLAKE3_ATOMICS 1
#else
#define BLAKE3_ATOMICS 0
#endif /* __has_include(<stdatomic.h>) && !defined(_MSC_VER) */
#else
#define BLAKE3_ATOMICS 0
#endif /* defined(__has_include) */
#endif /* defined(__has_include) && C11 */
#endif /* BLAKE3_ATOMICS */

#if BLAKE3_ATOMICS
Expand Down
16 changes: 10 additions & 6 deletions ext/digest/blake3/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
# Extra per-object compiler flags, keyed by object basename.
simd_cflags = {}

def blake3_disable(macro)
$CPPFLAGS << " -D#{macro}"
end

# Probe used to confirm the compiler both accepts +flag+ and can compile the
# intrinsics the backend relies on.
def blake3_have_isa?(name, flag, snippet)
Expand Down Expand Up @@ -55,7 +59,7 @@ def blake3_have_isa?(name, flag, snippet)
objs << obj
simd_cflags[obj] = flag
else
$defs << "-D#{no_macro}"
blake3_disable(no_macro)
end
end
when /\A(aarch64|arm64)\z/i
Expand All @@ -67,11 +71,11 @@ def blake3_have_isa?(name, flag, snippet)
# No optimized backend wired up for this architecture (e.g. 32-bit x86,
# ppc): build portable-only. Disabling every x86 ISA keeps the dispatcher
# from referencing backends we didn't compile, and NEON is forced off.
$defs << "-DBLAKE3_NO_SSE2"
$defs << "-DBLAKE3_NO_SSE41"
$defs << "-DBLAKE3_NO_AVX2"
$defs << "-DBLAKE3_NO_AVX512"
$defs << "-DBLAKE3_USE_NEON=0"
blake3_disable("BLAKE3_NO_SSE2")
blake3_disable("BLAKE3_NO_SSE41")
blake3_disable("BLAKE3_NO_AVX2")
blake3_disable("BLAKE3_NO_AVX512")
blake3_disable("BLAKE3_USE_NEON=0")
end

$objs = objs.map { |o| "#{o}.#{$OBJEXT}" }
Expand Down