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
13 changes: 12 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,18 @@ target_include_directories(

# Helper function used for `stringzilla_shared` and `stringzilla_bare` targets
function (define_stringzilla_shared target)
add_library(${target} SHARED c/stringzilla.c)
add_library(${target} SHARED
c/compare.c
c/memory.c
c/find.c
c/hash.c
c/utf8.c
c/utf8_case.c
c/utf8_word.c
c/sort.c
c/intersect.c
c/stringzilla.c
)
add_library(${PROJECT_NAME}::${target} ALIAS ${target})

set_target_properties(
Expand Down
27 changes: 27 additions & 0 deletions c/compare.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* @file compare.c
* @brief StringZilla compare functions compiled into library
* @author Raul Marin
* @date February 5, 2026
*/

#ifdef SZ_DYNAMIC_DISPATCH
#undef SZ_DYNAMIC_DISPATCH
#endif
#define SZ_DYNAMIC_DISPATCH 0

// Include types.h first to let it define the macros
#include <stringzilla/types.h>

// Use weak symbols to allow multiple definitions (linker will merge them)
#undef SZ_PUBLIC
#undef SZ_C_INLINE
#undef SZ_INTERNAL
#define SZ_C_INLINE __attribute__((weak))
#define SZ_PUBLIC __attribute__((weak))
#define SZ_INTERNAL static inline
#undef SZ_DYNAMIC
#define SZ_DYNAMIC static inline

// Now include compare.h which will use our overridden macros
#include <stringzilla/compare.h>
27 changes: 27 additions & 0 deletions c/find.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* @file find.c
* @brief StringZilla find functions compiled into library
* @author Raul Marin
* @date February 5, 2026
*/

#ifdef SZ_DYNAMIC_DISPATCH
#undef SZ_DYNAMIC_DISPATCH
#endif
#define SZ_DYNAMIC_DISPATCH 0

// Include types.h first to let it define the macros
#include <stringzilla/types.h>

// Now override the macros AFTER types.h has defined them
#undef SZ_PUBLIC
#undef SZ_C_INLINE
#undef SZ_INTERNAL
// Use weak symbols to allow multiple definitions (linker will merge them)
#define SZ_C_INLINE __attribute__((weak))
#define SZ_PUBLIC __attribute__((weak))
#define SZ_INTERNAL static inline
#undef SZ_DYNAMIC
#define SZ_DYNAMIC static inline

#include <stringzilla/find.h>
27 changes: 27 additions & 0 deletions c/hash.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* @file hash.c
* @brief StringZilla hash functions compiled into library
* @author Raul Marin
* @date February 5, 2026
*/

#ifdef SZ_DYNAMIC_DISPATCH
#undef SZ_DYNAMIC_DISPATCH
#endif
#define SZ_DYNAMIC_DISPATCH 0

// Include types.h first to let it define the macros
#include <stringzilla/types.h>

// Use weak symbols to allow multiple definitions (linker will merge them)
#undef SZ_PUBLIC
#undef SZ_C_INLINE
#undef SZ_INTERNAL
#define SZ_C_INLINE __attribute__((weak))
#define SZ_PUBLIC __attribute__((weak))
#define SZ_INTERNAL static inline
#undef SZ_DYNAMIC
#define SZ_DYNAMIC static inline


#include <stringzilla/hash.h>
27 changes: 27 additions & 0 deletions c/intersect.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* @file intersect.c
* @brief StringZilla intersect functions compiled into library
* @author Raul Marin
* @date February 5, 2026
*/

#ifdef SZ_DYNAMIC_DISPATCH
#undef SZ_DYNAMIC_DISPATCH
#endif
#define SZ_DYNAMIC_DISPATCH 0

// Include types.h first to let it define the macros
#include <stringzilla/types.h>

// Use weak symbols to allow multiple definitions (linker will merge them)
#undef SZ_PUBLIC
#undef SZ_C_INLINE
#undef SZ_INTERNAL
#define SZ_C_INLINE __attribute__((weak))
#define SZ_PUBLIC __attribute__((weak))
#define SZ_INTERNAL static inline
#undef SZ_DYNAMIC
#define SZ_DYNAMIC static inline


#include <stringzilla/intersect.h>
27 changes: 27 additions & 0 deletions c/memory.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* @file memory.c
* @brief StringZilla memory functions compiled into library
* @author Raul Marin
* @date February 5, 2026
*/

#ifdef SZ_DYNAMIC_DISPATCH
#undef SZ_DYNAMIC_DISPATCH
#endif
#define SZ_DYNAMIC_DISPATCH 0

// Include types.h first to let it define the macros
#include <stringzilla/types.h>

// Use weak symbols to allow multiple definitions (linker will merge them)
#undef SZ_PUBLIC
#undef SZ_C_INLINE
#undef SZ_INTERNAL
#define SZ_C_INLINE __attribute__((weak))
#define SZ_PUBLIC __attribute__((weak))
#define SZ_INTERNAL static inline
#undef SZ_DYNAMIC
#define SZ_DYNAMIC static inline


#include <stringzilla/memory.h>
27 changes: 27 additions & 0 deletions c/sort.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* @file sort.c
* @brief StringZilla sort functions compiled into library
* @author Raul Marin
* @date February 5, 2026
*/

#ifdef SZ_DYNAMIC_DISPATCH
#undef SZ_DYNAMIC_DISPATCH
#endif
#define SZ_DYNAMIC_DISPATCH 0

// Include types.h first to let it define the macros
#include <stringzilla/types.h>

// Use weak symbols to allow multiple definitions (linker will merge them)
#undef SZ_PUBLIC
#undef SZ_C_INLINE
#undef SZ_INTERNAL
#define SZ_C_INLINE __attribute__((weak))
#define SZ_PUBLIC __attribute__((weak))
#define SZ_INTERNAL static inline
#undef SZ_DYNAMIC
#define SZ_DYNAMIC static inline


#include <stringzilla/sort.h>
27 changes: 27 additions & 0 deletions c/utf8.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* @file utf8.c
* @brief StringZilla UTF-8 functions compiled into library
* @author Raul Marin
* @date February 5, 2026
*/

#ifdef SZ_DYNAMIC_DISPATCH
#undef SZ_DYNAMIC_DISPATCH
#endif
#define SZ_DYNAMIC_DISPATCH 0

// Include types.h first to let it define the macros
#include <stringzilla/types.h>

// Use weak symbols to allow multiple definitions (linker will merge them)
#undef SZ_PUBLIC
#undef SZ_C_INLINE
#undef SZ_INTERNAL
#define SZ_C_INLINE __attribute__((weak))
#define SZ_PUBLIC __attribute__((weak))
#define SZ_INTERNAL static inline
#undef SZ_DYNAMIC
#define SZ_DYNAMIC static inline


#include <stringzilla/utf8.h>
27 changes: 27 additions & 0 deletions c/utf8_case.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* @file utf8_case.c
* @brief StringZilla UTF-8 case functions compiled into library
* @author Raul Marin
* @date February 5, 2026
*/

#ifdef SZ_DYNAMIC_DISPATCH
#undef SZ_DYNAMIC_DISPATCH
#endif
#define SZ_DYNAMIC_DISPATCH 0

// Include types.h first to let it define the macros
#include <stringzilla/types.h>

// Now override the macros AFTER types.h has defined them
#undef SZ_PUBLIC
#undef SZ_C_INLINE
#undef SZ_INTERNAL
// Use weak symbols to allow multiple definitions (linker will merge them)
#define SZ_C_INLINE __attribute__((weak))
#define SZ_PUBLIC __attribute__((weak))
#define SZ_INTERNAL static inline
#undef SZ_DYNAMIC
#define SZ_DYNAMIC static inline

#include <stringzilla/utf8_case.h>
27 changes: 27 additions & 0 deletions c/utf8_word.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* @file utf8_word.c
* @brief StringZilla UTF-8 word functions compiled into library
* @author Raul Marin
* @date February 5, 2026
*/

#ifdef SZ_DYNAMIC_DISPATCH
#undef SZ_DYNAMIC_DISPATCH
#endif
#define SZ_DYNAMIC_DISPATCH 0

// Include types.h first to let it define the macros
#include <stringzilla/types.h>

// Use weak symbols to allow multiple definitions (linker will merge them)
#undef SZ_PUBLIC
#undef SZ_C_INLINE
#undef SZ_INTERNAL
#define SZ_C_INLINE __attribute__((weak))
#define SZ_PUBLIC __attribute__((weak))
#define SZ_INTERNAL static inline
#undef SZ_DYNAMIC
#define SZ_DYNAMIC static inline


#include <stringzilla/utf8_word.h>
6 changes: 4 additions & 2 deletions include/stringzilla/compare.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ SZ_PUBLIC sz_ordering_t sz_order_neon(sz_cptr_t a, sz_size_t a_length, sz_cptr_t

#pragma endregion // Core API

#if !SZ_DYNAMIC_DISPATCH

/* SSE implementation of the string search algorithms for Westmere processors and newer.
* Very minimalistic (compared to AVX-512), but still faster than the serial implementation.
*/
Expand Down Expand Up @@ -516,7 +518,6 @@ SZ_PUBLIC sz_ordering_t sz_order_sve(sz_cptr_t a, sz_size_t a_length, sz_cptr_t
* To override this behavior and precompile all backends - set `SZ_DYNAMIC_DISPATCH` to 1.
*/
#pragma region Compile Time Dispatching
#if !SZ_DYNAMIC_DISPATCH

SZ_DYNAMIC sz_bool_t sz_equal(sz_cptr_t a, sz_cptr_t b, sz_size_t length) {
#if SZ_USE_SKYLAKE
Expand Down Expand Up @@ -546,9 +547,10 @@ SZ_DYNAMIC sz_ordering_t sz_order(sz_cptr_t a, sz_size_t a_length, sz_cptr_t b,
#endif
}

#endif // !SZ_DYNAMIC_DISPATCH
#pragma endregion // Compile Time Dispatching

#endif // !SZ_DYNAMIC_DISPATCH

#ifdef __cplusplus
}
#endif // __cplusplus
Expand Down
6 changes: 4 additions & 2 deletions include/stringzilla/find.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,8 @@ SZ_PUBLIC sz_cptr_t sz_find_delimiters_utf8_ice(sz_cptr_t text, sz_size_t length
SZ_PUBLIC sz_cptr_t sz_find_delimiters_utf8_neon(sz_cptr_t text, sz_size_t length, sz_size_t *matched_length);
#endif

#if !SZ_DYNAMIC_DISPATCH

#pragma endregion // Core API

#pragma region Helper Shortcuts
Expand Down Expand Up @@ -2005,7 +2007,6 @@ SZ_PUBLIC sz_cptr_t sz_find_sve(sz_cptr_t h, sz_size_t h_length, sz_cptr_t n, sz
* To override this behavior and precompile all backends - set `SZ_DYNAMIC_DISPATCH` to 1.
*/
#pragma region Compile Time Dispatching
#if !SZ_DYNAMIC_DISPATCH

#pragma region Core Functionality

Expand Down Expand Up @@ -2096,9 +2097,10 @@ SZ_DYNAMIC sz_cptr_t sz_rfind_byteset(sz_cptr_t text, sz_size_t length, sz_bytes
}

#pragma endregion
#endif // !SZ_DYNAMIC_DISPATCH
#pragma endregion // Compile Time Dispatching

#endif // !SZ_DYNAMIC_DISPATCH

#ifdef __cplusplus
}
#endif // __cplusplus
Expand Down
15 changes: 13 additions & 2 deletions include/stringzilla/hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,15 @@ SZ_PUBLIC void sz_sha256_state_update_goldmont(sz_sha256_state_t *state, sz_cptr
/** @copydoc sz_sha256_state_digest */
SZ_PUBLIC void sz_sha256_state_digest_goldmont(sz_sha256_state_t const *state, sz_u8_t digest[sz_at_least_(32)]);

/** @copydoc sz_sha256_state_init */
SZ_PUBLIC void sz_sha256_state_init_serial(sz_sha256_state_t *state);

/** @copydoc sz_sha256_state_update */
SZ_PUBLIC void sz_sha256_state_update_serial(sz_sha256_state_t *state, sz_cptr_t text, sz_size_t length);

/** @copydoc sz_sha256_state_digest */
SZ_PUBLIC void sz_sha256_state_digest_serial(sz_sha256_state_t const *state, sz_u8_t digest[sz_at_least_(32)]);

#endif

#if SZ_USE_HASWELL
Expand Down Expand Up @@ -459,6 +468,8 @@ SZ_PUBLIC sz_u64_t sz_hash_state_digest_sve2(sz_hash_state_t const *state);

#pragma endregion // Core API

#if !SZ_DYNAMIC_DISPATCH

#pragma region Helper Methods

/**
Expand Down Expand Up @@ -4151,7 +4162,6 @@ SZ_PUBLIC void sz_fill_random_sve2(sz_ptr_t text, sz_size_t length, sz_u64_t non
* To override this behavior and precompile all backends - set `SZ_DYNAMIC_DISPATCH` to 1.
*/
#pragma region Compile Time Dispatching
#if !SZ_DYNAMIC_DISPATCH

SZ_DYNAMIC sz_u64_t sz_bytesum(sz_cptr_t text, sz_size_t length) {
#if SZ_USE_ICE
Expand Down Expand Up @@ -4287,9 +4297,10 @@ SZ_DYNAMIC void sz_sha256_state_digest(sz_sha256_state_t const *state, sz_u8_t d
#endif
}

#endif // !SZ_DYNAMIC_DISPATCH
#pragma endregion // Compile Time Dispatching

#endif // !SZ_DYNAMIC_DISPATCH

#ifdef __cplusplus
}
#endif // __cplusplus
Expand Down
Loading