Merge branch 'tor-gitlab/mr/715'

This commit is contained in:
David Goulet 2023-06-13 13:03:11 -04:00
commit d5306e107f
6 changed files with 27 additions and 26 deletions

3
changes/ticket40800 Normal file
View file

@ -0,0 +1,3 @@
o Minor feature (hs):
- Fix compiler warnings in equix and hashx when building with clang.
Closes ticket 40800.

View file

@ -24,13 +24,14 @@ if(NOT CMAKE_BUILD_TYPE)
message(STATUS "Setting default build type: ${CMAKE_BUILD_TYPE}") message(STATUS "Setting default build type: ${CMAKE_BUILD_TYPE}")
endif() endif()
add_library(equix SHARED ${equix_sources}) include_directories(
set_property(TARGET equix PROPERTY POSITION_INDEPENDENT_CODE ON)
set_property(TARGET equix PROPERTY PUBLIC_HEADER include/equix.h)
include_directories(equix
include/ include/
hashx/include/ hashx/include/
hashx/src/) hashx/src/)
add_library(equix SHARED ${equix_sources})
set_property(TARGET equix PROPERTY POSITION_INDEPENDENT_CODE ON)
set_property(TARGET equix PROPERTY PUBLIC_HEADER include/equix.h)
target_compile_definitions(equix PRIVATE HASHX_STATIC) target_compile_definitions(equix PRIVATE HASHX_STATIC)
target_compile_definitions(equix PRIVATE EQUIX_SHARED) target_compile_definitions(equix PRIVATE EQUIX_SHARED)
target_link_libraries(equix target_link_libraries(equix
@ -43,10 +44,6 @@ set_property(TARGET equix_static PROPERTY POSITION_INDEPENDENT_CODE ON)
set_target_properties(equix_static PROPERTIES OUTPUT_NAME equix) set_target_properties(equix_static PROPERTIES OUTPUT_NAME equix)
target_compile_definitions(equix_static PRIVATE HASHX_STATIC) target_compile_definitions(equix_static PRIVATE HASHX_STATIC)
target_compile_definitions(equix_static PRIVATE EQUIX_STATIC) target_compile_definitions(equix_static PRIVATE EQUIX_STATIC)
include_directories(equix_static
include/
hashx/include/
hashx/src/)
target_link_libraries(equix_static target_link_libraries(equix_static
PRIVATE hashx_static) PRIVATE hashx_static)
@ -58,8 +55,6 @@ install(TARGETS equix equix_static
add_executable(equix-tests add_executable(equix-tests
src/tests.c) src/tests.c)
include_directories(equix-tests
include/)
target_compile_definitions(equix-tests PRIVATE EQUIX_STATIC) target_compile_definitions(equix-tests PRIVATE EQUIX_STATIC)
target_link_libraries(equix-tests target_link_libraries(equix-tests
PRIVATE equix_static) PRIVATE equix_static)
@ -73,9 +68,6 @@ add_executable(equix-bench
src/bench.c src/bench.c
hashx/src/hashx_thread.c hashx/src/hashx_thread.c
hashx/src/hashx_time.c) hashx/src/hashx_time.c)
include_directories(equix-bench
include/
hashx/src/)
target_compile_definitions(equix-bench PRIVATE EQUIX_STATIC) target_compile_definitions(equix-bench PRIVATE EQUIX_STATIC)
target_link_libraries(equix-bench target_link_libraries(equix-bench
PRIVATE equix_static PRIVATE equix_static

View file

@ -55,11 +55,11 @@ if(HASHX_SALT)
endif() endif()
endif() endif()
include_directories(include/)
add_library(hashx SHARED ${hashx_sources}) add_library(hashx SHARED ${hashx_sources})
set_property(TARGET hashx PROPERTY POSITION_INDEPENDENT_CODE ON) set_property(TARGET hashx PROPERTY POSITION_INDEPENDENT_CODE ON)
set_property(TARGET hashx PROPERTY PUBLIC_HEADER include/hashx.h) set_property(TARGET hashx PROPERTY PUBLIC_HEADER include/hashx.h)
include_directories(hashx
include/)
target_compile_definitions(hashx PRIVATE HASHX_SHARED) target_compile_definitions(hashx PRIVATE HASHX_SHARED)
set_target_properties(hashx PROPERTIES VERSION ${HASHX_VERSION_STR} set_target_properties(hashx PROPERTIES VERSION ${HASHX_VERSION_STR}
SOVERSION ${HASHX_VERSION}) SOVERSION ${HASHX_VERSION})
@ -76,8 +76,6 @@ install(TARGETS hashx hashx_static
add_executable(hashx-tests add_executable(hashx-tests
src/tests.c) src/tests.c)
include_directories(hashx-tests
include/)
target_compile_definitions(hashx-tests PRIVATE HASHX_STATIC) target_compile_definitions(hashx-tests PRIVATE HASHX_STATIC)
target_link_libraries(hashx-tests target_link_libraries(hashx-tests
PRIVATE hashx_static) PRIVATE hashx_static)
@ -91,8 +89,6 @@ add_executable(hashx-bench
src/bench.c src/bench.c
src/hashx_thread.c src/hashx_thread.c
src/hashx_time.c) src/hashx_time.c)
include_directories(hashx-bench
include/)
target_compile_definitions(hashx-bench PRIVATE HASHX_STATIC) target_compile_definitions(hashx-bench PRIVATE HASHX_STATIC)
target_link_libraries(hashx-bench target_link_libraries(hashx-bench
PRIVATE hashx_static PRIVATE hashx_static

View file

@ -149,7 +149,7 @@ bool hashx_compile_a64(const hashx_program* program, uint8_t* code) {
if (!hashx_vm_rx(code, COMP_CODE_SIZE)) if (!hashx_vm_rx(code, COMP_CODE_SIZE))
return false; return false;
#ifdef __GNUC__ #ifdef __GNUC__
__builtin___clear_cache(code, pos); __builtin___clear_cache((void*)code, (void*)pos);
#endif #endif
return true; return true;
} }

View file

@ -28,9 +28,12 @@ static uint64_t sum_pair(hashx_ctx* hash_func, equix_idx left, equix_idx right)
uint8_t hash_right[HASHX_SIZE]; uint8_t hash_right[HASHX_SIZE];
hashx_result r_left = hashx_exec(hash_func, left, hash_left); hashx_result r_left = hashx_exec(hash_func, left, hash_left);
hashx_result r_right = hashx_exec(hash_func, right, hash_right); hashx_result r_right = hashx_exec(hash_func, right, hash_right);
assert(r_left == HASHX_OK && r_right == HASHX_OK); if (r_left == HASHX_OK && r_right == HASHX_OK) {
return load64(hash_left) + load64(hash_right); return load64(hash_left) + load64(hash_right);
} }
assert(false);
return ~(uint64_t)0;
}
static equix_result verify_internal(hashx_ctx* hash_func, const equix_solution* solution) { static equix_result verify_internal(hashx_ctx* hash_func, const equix_solution* solution) {
uint64_t pair0 = sum_pair(hash_func, solution->idx[0], solution->idx[1]); uint64_t pair0 = sum_pair(hash_func, solution->idx[0], solution->idx[1]);

View file

@ -47,11 +47,16 @@ typedef stage1_idx_item s1_idx;
typedef stage2_idx_item s2_idx; typedef stage2_idx_item s2_idx;
typedef stage3_idx_item s3_idx; typedef stage3_idx_item s3_idx;
static FORCE_INLINE uint64_t hash_value(hashx_ctx* hash_func, equix_idx index) { static FORCE_INLINE bool hash_value(hashx_ctx* hash_func, equix_idx index, uint64_t *value_out) {
char hash[HASHX_SIZE]; char hash[HASHX_SIZE];
hashx_result result = hashx_exec(hash_func, index, hash); hashx_result result = hashx_exec(hash_func, index, hash);
assert(result == HASHX_OK); if (result == HASHX_OK) {
return load64(hash); *value_out = load64(hash);
return true;
} else {
assert(false);
return false;
}
} }
static void build_solution_stage1(equix_idx* output, solver_heap* heap, s2_idx root) { static void build_solution_stage1(equix_idx* output, solver_heap* heap, s2_idx root) {
@ -97,7 +102,9 @@ static void build_solution(equix_solution* solution, solver_heap* heap, s3_idx l
static void solve_stage0(hashx_ctx* hash_func, solver_heap* heap) { static void solve_stage0(hashx_ctx* hash_func, solver_heap* heap) {
CLEAR(heap->stage1_indices.counts); CLEAR(heap->stage1_indices.counts);
for (u32 i = 0; i < INDEX_SPACE; ++i) { for (u32 i = 0; i < INDEX_SPACE; ++i) {
uint64_t value = hash_value(hash_func, i); uint64_t value;
if (!hash_value(hash_func, i, &value))
break;
u32 bucket_idx = value % NUM_COARSE_BUCKETS; u32 bucket_idx = value % NUM_COARSE_BUCKETS;
u32 item_idx = STAGE1_SIZE(bucket_idx); u32 item_idx = STAGE1_SIZE(bucket_idx);
if (item_idx >= COARSE_BUCKET_ITEMS) if (item_idx >= COARSE_BUCKET_ITEMS)