Skip to content

Commit

Permalink
attempt to silence a recent ubsan warning with code reorganization
Browse files Browse the repository at this point in the history
apparently, UBSAN uses the prototype of the inner inlined function
instead of the outer shell of the function.
Let's see if one indirection level is enough to fix this.
  • Loading branch information
Cyan4973 committed Jan 21, 2025
1 parent 1bf7bc4 commit e23a135
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions xxhash.h
Original file line number Diff line number Diff line change
Expand Up @@ -6523,8 +6523,9 @@ XXH3_consumeStripes(xxh_u64* XXH_RESTRICT acc,
# define XXH3_STREAM_USE_STACK 1
# endif
#endif
/*
* Both XXH3_64bits_update and XXH3_128bits_update use this routine.
/* This function accepts f_acc and f_scramble as function pointers,
* making it possible to implement multiple variants with different acc & scramble stages.
* This is notably useful to implement multiple vector variants with different intrinsics.
*/
XXH_FORCE_INLINE XXH_errorcode
XXH3_update(XXH3_state_t* XXH_RESTRICT const state,
Expand Down Expand Up @@ -6605,12 +6606,21 @@ XXH3_update(XXH3_state_t* XXH_RESTRICT const state,
return XXH_OK;
}

/*
* Both XXH3_64bits_update and XXH3_128bits_update use this routine.
*/
static XXH_errorcode
XXH3_update_regular(XXH_NOESCAPE XXH3_state_t* state, XXH_NOESCAPE const void* input, size_t len)
{
return XXH3_update(state, (const xxh_u8*)input, len,
XXH3_accumulate, XXH3_scrambleAcc);
}

/*! @ingroup XXH3_family */
XXH_PUBLIC_API XXH_errorcode
XXH3_64bits_update(XXH_NOESCAPE XXH3_state_t* state, XXH_NOESCAPE const void* input, size_t len)
{
return XXH3_update(state, (const xxh_u8*)input, len,
XXH3_accumulate, XXH3_scrambleAcc);
return XXH3_update_regular(state, input, len);
}


Expand Down Expand Up @@ -7146,7 +7156,7 @@ XXH3_128bits_reset_withSecretandSeed(XXH_NOESCAPE XXH3_state_t* statePtr, XXH_NO
XXH_PUBLIC_API XXH_errorcode
XXH3_128bits_update(XXH_NOESCAPE XXH3_state_t* state, XXH_NOESCAPE const void* input, size_t len)
{
return XXH3_64bits_update(state, input, len);
return XXH3_update_regular(state, input, len);
}

/*! @ingroup XXH3_family */
Expand Down

0 comments on commit e23a135

Please sign in to comment.