]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
[linux-kernel] Add test that checks the ifdef hardwiring
authorNick Terrell <terrelln@fb.com>
Wed, 9 Sep 2020 19:36:58 +0000 (12:36 -0700)
committerNick Terrell <terrelln@fb.com>
Wed, 9 Sep 2020 21:36:19 +0000 (14:36 -0700)
contrib/linux-kernel/Makefile
contrib/linux-kernel/test/Makefile
contrib/linux-kernel/test/macro-test.sh [new file with mode: 0755]
lib/common/bitstream.h

index 4a85d8af8778a53707d9efb11eeff8fd4d8e6b5a..f3ece48b89f68ab6090751b8783bba31dff4daec 100644 (file)
@@ -33,7 +33,7 @@ libzstd:
                -DXXH_STATIC_LINKING_ONLY \
                -DMEM_FORCE_MEMORY_ACCESS=0 \
                -D__GNUC__ \
-               -USTATIC_BMI2 \
+               -DSTATIC_BMI2=0 \
                -UZSTD_NO_INLINE \
                -UNO_PREFETCH \
                -U__cplusplus \
index f05fbfc0a413d3e1407dc2357737b88ce651a9a2..0aa0f79fb88bcbe93d5978777b7372c4a12a4c46 100644 (file)
@@ -19,6 +19,7 @@ test: test.c liblinuxzstd.a
        $(CC) $(LDFLAGS) $(CPPFLAGS) $(CFLAGS) $^ -o $@
 
 run-test: test
+       ./macro-test.sh
        ./test
 
 .PHONY:
diff --git a/contrib/linux-kernel/test/macro-test.sh b/contrib/linux-kernel/test/macro-test.sh
new file mode 100755 (executable)
index 0000000..c688ac0
--- /dev/null
@@ -0,0 +1,44 @@
+#!/usr/bin/env sh
+
+set -e
+
+SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
+INCLUDE_DIR="$SCRIPT_DIR/../linux/include"
+LIB_DIR="$SCRIPT_DIR/../linux/lib"
+
+
+print() {
+    printf '%b' "${*}"
+}
+
+println() {
+    printf '%b\n' "${*}"
+}
+
+die() {
+    println "$@" 1>&2
+    exit 1
+}
+
+test_not_present() {
+    print "Testing that '$1' is not present... "
+    grep -r $1 "$INCLUDE_DIR" "$LIB_DIR" && die "Fail!"
+    println "Okay"
+}
+
+println "This test checks that the macro removal process worked as expected"
+println "If this test fails, then freestanding.py wasn't able to remove one of these"
+println "macros from the source code completely. You'll either need to rewrite the check"
+println "or improve freestanding.py."
+println ""
+
+test_not_present "ZSTD_NO_INTRINSICS"
+test_not_present "ZSTD_NO_UNUSED_FUNCTIONS"
+test_not_present "ZSTD_LEGACY_SUPPORT"
+test_not_present "STATIC_BMI2"
+test_not_present "ZSTD_NO_INLINE"
+test_not_present "ZSTD_DLL_EXPORT"
+test_not_present "ZSTD_DLL_IMPORT"
+test_not_present "__ICCARM__"
+test_not_present "_MSC_VER"
+test_not_present "_WIN32"
index 168b2245066da318f2bd8dfb4b593397b4a9bb3f..c74918502c5ce15292cc9d372e0d37c3a8b43d91 100644 (file)
@@ -337,7 +337,7 @@ MEM_STATIC FORCE_INLINE_ATTR size_t BIT_getMiddleBits(size_t bitContainer, U32 c
 
 MEM_STATIC FORCE_INLINE_ATTR size_t BIT_getLowerBits(size_t bitContainer, U32 const nbBits)
 {
-#if STATIC_BMI2 
+#if defined(STATIC_BMI2) && STATIC_BMI2 == 1
        return  _bzhi_u64(bitContainer, nbBits);
 #else
     assert(nbBits < BIT_MASK_SIZE);