From a2b0895b354767859c14abb7021b960332730f66 Mon Sep 17 00:00:00 2001 From: Marcus Holland-Moritz Date: Tue, 19 Aug 2025 17:44:22 +0200 Subject: [PATCH] fix: set `NONOPT_FSST` for 32-bit platforms (fixes #37) The optimized code paths for (at least) `count1GetNext()` don't work correctly on 32-bit platforms (at least on ARM, with gcc), presumably due to using `__builtin_ctzl()` on a 64-bit value. This resulted in `buildSymbolTable()` being stuck in an endless loop. This change simply disables the optimized code paths if a 32-bit platform is detected. --- libfsst.cpp | 3 ++- libfsst.hpp | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/libfsst.cpp b/libfsst.cpp index 919cb9c..232ecb8 100644 --- a/libfsst.cpp +++ b/libfsst.cpp @@ -242,6 +242,7 @@ SymbolTable *buildSymbolTable(Counters& counters, vector line, const return bestTable; } +#ifndef NONOPT_FSST static inline size_t compressSIMD(SymbolTable &symbolTable, u8* symbolBase, size_t nlines, const size_t len[], const u8* line[], size_t size, u8* dst, size_t lenOut[], u8* strOut[], int unroll) { size_t curLine = 0, inOff = 0, outOff = 0, batchPos = 0, empty = 0, budget = size; u8 *lim = dst + size, *codeBase = symbolBase + (1<<18); // 512KB temp space for compressing 512 strings @@ -374,7 +375,7 @@ static inline size_t compressSIMD(SymbolTable &symbolTable, u8* symbolBase, size } return curLine; } - +#endif // optimized adaptive *scalar* compression method static inline size_t compressBulk(SymbolTable &symbolTable, size_t nlines, const size_t lenIn[], const u8* strIn[], size_t size, u8* out, size_t lenOut[], u8* strOut[], bool noSuffixOpt, bool avoidBranch) { diff --git a/libfsst.hpp b/libfsst.hpp index a29a4af..ef46214 100644 --- a/libfsst.hpp +++ b/libfsst.hpp @@ -44,6 +44,11 @@ typedef uint32_t u32; typedef uint64_t u64; } // namespace libfsst +#if UINTPTR_MAX == 0xffffffffU +// We're on a 32-bit platform +#define NONOPT_FSST +#endif + #define FSST_ENDIAN_MARKER ((u64) 1) #define FSST_VERSION_20190218 20190218 #define FSST_VERSION ((u64) FSST_VERSION_20190218)