Skip to content

Commit

Permalink
Fix incorrect use of clz (#8)
Browse files Browse the repository at this point in the history
* fix incorrect use of clz when input is 0
* don't force use of native arch when building
  • Loading branch information
bignacio authored Apr 16, 2023
1 parent dcecae9 commit 1a83817
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 0 additions & 1 deletion simple_pool/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ add_compile_options(
-Wimplicit-fallthrough
-Wundef
-Wfloat-equal
-march=native
-fPIE
-fno-omit-frame-pointer
)
Expand Down
3 changes: 3 additions & 0 deletions simple_pool/dyn_mem_pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,9 @@ void multipool_free(struct MultiPool* multipool) {
uint32_t find_multipool_index_for_size(uint32_t size) {
static const uint32_t int32bitcount = sizeof(uint32_t) * CHAR_BIT;
uint32_t size_value = (size - 1) >>DynPoolMinMultiPoolMemNodeSizeBits;
if( __builtin_expect(size_value == 0, 0)) {
return 0;
}
return (int32bitcount - (uint32_t)__builtin_clz(size_value));
}

Expand Down

0 comments on commit 1a83817

Please sign in to comment.