Skip to content

Commit

Permalink
Use CMAKE_USE_PTHREADS_INIT (#1576)
Browse files Browse the repository at this point in the history
  • Loading branch information
zxjtan authored Oct 18, 2023
1 parent b7c623e commit b7f35d7
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
6 changes: 2 additions & 4 deletions .CMake/compiler_opts.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ if(CMAKE_C_COMPILER_ID MATCHES "Clang")

if(NOT ${OQS_BUILD_ONLY_LIB})
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
set(OQS_USE_PTHREADS_IN_TESTS 1)
find_package(Threads)
endif()

if(${OQS_DEBUG_BUILD})
Expand Down Expand Up @@ -168,8 +167,7 @@ elseif(CMAKE_C_COMPILER_ID STREQUAL "GNU")

if(NOT ${OQS_BUILD_ONLY_LIB})
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
set(OQS_USE_PTHREADS_IN_TESTS 1)
find_package(Threads)
endif()

if(${OQS_DEBUG_BUILD})
Expand Down
4 changes: 2 additions & 2 deletions src/oqsconfig.h.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
#cmakedefine USE_SANITIZER "@USE_SANITIZER@"
#cmakedefine CMAKE_BUILD_TYPE "@CMAKE_BUILD_TYPE@"

#cmakedefine CMAKE_USE_PTHREADS_INIT 1

#cmakedefine OQS_USE_OPENSSL 1
#cmakedefine OQS_USE_AES_OPENSSL 1
#cmakedefine OQS_USE_SHA2_OPENSSL 1
#cmakedefine OQS_USE_SHA3_OPENSSL 1

#cmakedefine OQS_USE_PTHREADS_IN_TESTS 1

#cmakedefine OQS_USE_ADX_INSTRUCTIONS 1
#cmakedefine OQS_USE_AES_INSTRUCTIONS 1
#cmakedefine OQS_USE_AVX_INSTRUCTIONS 1
Expand Down
6 changes: 3 additions & 3 deletions tests/test_kem.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include <oqs/oqs.h>

#if OQS_USE_PTHREADS_IN_TESTS
#if CMAKE_USE_PTHREADS_INIT
#include <pthread.h>
#endif

Expand Down Expand Up @@ -197,7 +197,7 @@ static void TEST_KEM_randombytes(uint8_t *random_array, size_t bytes_to_read) {
}
#endif

#if OQS_USE_PTHREADS_IN_TESTS
#if CMAKE_USE_PTHREADS_INIT
struct thread_data {
char *alg_name;
OQS_STATUS rc;
Expand Down Expand Up @@ -245,7 +245,7 @@ int main(int argc, char **argv) {
#endif

OQS_STATUS rc;
#if OQS_USE_PTHREADS_IN_TESTS
#if CMAKE_USE_PTHREADS_INIT
#define MAX_LEN_KEM_NAME_ 64
// don't run Classic McEliece in threads because of large stack usage
char no_thread_kem_patterns[][MAX_LEN_KEM_NAME_] = {"Classic-McEliece", "HQC-256-"};
Expand Down
6 changes: 3 additions & 3 deletions tests/test_sig.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#include <oqs/oqs.h>

#if OQS_USE_PTHREADS_IN_TESTS
#if CMAKE_USE_PTHREADS_INIT
#include <pthread.h>
#endif

Expand Down Expand Up @@ -174,7 +174,7 @@ static void TEST_SIG_randombytes(uint8_t *random_array, size_t bytes_to_read) {
}
#endif

#if OQS_USE_PTHREADS_IN_TESTS
#if CMAKE_USE_PTHREADS_INIT
struct thread_data {
char *alg_name;
OQS_STATUS rc;
Expand Down Expand Up @@ -222,7 +222,7 @@ int main(int argc, char **argv) {
#endif

OQS_STATUS rc;
#if OQS_USE_PTHREADS_IN_TESTS
#if CMAKE_USE_PTHREADS_INIT
#define MAX_LEN_SIG_NAME_ 64
pthread_t thread;
struct thread_data td;
Expand Down

0 comments on commit b7f35d7

Please sign in to comment.