Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure XXH_INLINE_ALL fully inlines all XXH32_ and XXH64_ symbols #903

Merged
merged 3 commits into from
Dec 5, 2024
Merged
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
19 changes: 16 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,8 @@ cxxtest: clean
@echo ---- test C++ compilation ----
CC="$(CXX) -Wno-deprecated" $(MAKE) all CFLAGS="-O3 -Wall -Wextra -Wundef -Wshadow -Wcast-align -Werror -fPIC"

# In strict C90 mode, there is no `long long` type support,
# consequently, only XXH32 can be compiled.
.PHONY: c90test
ifeq ($(NO_C90_TEST),true)
c90test:
Expand Down Expand Up @@ -453,10 +455,20 @@ preview-man: man
test: DEBUGFLAGS += -DXXH_DEBUGLEVEL=1
test: all namespaceTest check test-xxhsum-c c90test test-tools noxxh3test nostdlibtest

.PHONY: test-inline
test-inline:
# this test checks that including "xxhash.h" multiple times and with different directives still compiles properly
.PHONY: test-multiInclude
test-multiInclude:
$(MAKE) -C tests test_multiInclude

.PHONY: test-inline-notexposed
test-inline-notexposed: xxhsum_inlinedXXH
$(NM) xxhsum_inlinedXXH | $(GREP) "t _XXH32_" ; test $$? -eq 1 # no XXH32 symbol should be left
$(NM) xxhsum_inlinedXXH | $(GREP) "t _XXH64_" ; test $$? -eq 1 # no XXH64 symbol should be left

.PHONY: test-inline
test-inline: test-inline-notexposed test-multiInclude


.PHONY: test-all
test-all: CFLAGS += -Werror
test-all: test test32 test-unicode clangtest gcc-og-test cxxtest usan test-inline listL120 trailingWhitespace test-xxh-nnn-sums
Expand Down Expand Up @@ -640,7 +652,8 @@ install_man:
$(Q)ln -sf xxhsum.1 $(DESTDIR)$(MANDIR)/xxh3sum.1

.PHONY: install
install: install_libxxhash.a install_libxxhash install_libxxhash.includes install_libxxhash.pc install_xxhsum install_man ## install libraries, CLI, links and man page
## install libraries, CLI, links and man pages
install: install_libxxhash.a install_libxxhash install_libxxhash.includes install_libxxhash.pc install_xxhsum install_man
@echo xxhash installation completed

.PHONY: uninstall
Expand Down
8 changes: 7 additions & 1 deletion xxhash.h
Original file line number Diff line number Diff line change
Expand Up @@ -2418,6 +2418,12 @@ static void* XXH_memcpy(void* dest, const void* src, size_t size)
# define XXH_NO_INLINE static
#endif

#if defined(XXH_INLINE_ALL)
# define XXH_STATIC XXH_FORCE_INLINE
#else
# define XXH_STATIC static
#endif

#if XXH3_INLINE_SECRET
# define XXH3_WITH_SECRET_INLINE XXH_FORCE_INLINE
#else
Expand Down Expand Up @@ -3458,7 +3464,7 @@ static xxh_u64 XXH64_avalanche(xxh_u64 hash)
* @return The finalized hash
* @see XXH32_finalize().
*/
static XXH_PUREF xxh_u64
XXH_STATIC XXH_PUREF xxh_u64
XXH64_finalize(xxh_u64 hash, const xxh_u8* ptr, size_t len, XXH_alignment align)
{
if (ptr==NULL) XXH_ASSERT(len == 0);
Expand Down
Loading