Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix thread start callback prototype for Open Watcom toolchain #8175

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
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
8 changes: 4 additions & 4 deletions examples/benchmark/tls_bench.c
Original file line number Diff line number Diff line change
Expand Up @@ -1229,7 +1229,7 @@ static int bench_tls_client(info_t* info)
}

#if !defined(SINGLE_THREADED) && defined(WOLFSSL_THREAD_NO_JOIN)
static THREAD_RETURN WOLFSSL_THREAD_NO_JOIN client_thread(void* args)
static THREAD_RETURN_NOJOIN WOLFSSL_THREAD_NO_JOIN client_thread(void* args)
{
int ret;
info_t* info = (info_t*)args;
Expand All @@ -1242,7 +1242,7 @@ static THREAD_RETURN WOLFSSL_THREAD_NO_JOIN client_thread(void* args)
THREAD_CHECK_RET(wolfSSL_CondSignal(&info->to_server.cond));
THREAD_CHECK_RET(wolfSSL_CondEnd(&info->to_server.cond));

WOLFSSL_RETURN_FROM_THREAD(0);
RETURN_FROM_THREAD_NOJOIN(0);
}
#endif /* !SINGLE_THREADED */
#endif /* !NO_WOLFSSL_CLIENT */
Expand Down Expand Up @@ -1674,7 +1674,7 @@ static int bench_tls_server(info_t* info)
}

#if !defined(SINGLE_THREADED) && defined(WOLFSSL_THREAD_NO_JOIN)
static THREAD_RETURN WOLFSSL_THREAD_NO_JOIN server_thread(void* args)
static THREAD_RETURN_NOJOIN WOLFSSL_THREAD_NO_JOIN server_thread(void* args)
{
int ret = 0;
info_t* info = (info_t*)args;
Expand Down Expand Up @@ -1702,7 +1702,7 @@ static THREAD_RETURN WOLFSSL_THREAD_NO_JOIN server_thread(void* args)
THREAD_CHECK_RET(wolfSSL_CondSignal(&info->to_client.cond));
THREAD_CHECK_RET(wolfSSL_CondEnd(&info->to_client.cond));

WOLFSSL_RETURN_FROM_THREAD(0);
RETURN_FROM_THREAD_NOJOIN(0);
}
#endif /* !SINGLE_THREADED */
#endif /* !NO_WOLFSSL_SERVER */
Expand Down
7 changes: 4 additions & 3 deletions wolfcrypt/src/random.c
Original file line number Diff line number Diff line change
Expand Up @@ -913,7 +913,8 @@ static WC_INLINE word64 Entropy_TimeHiRes(void)
* @param [in,out] args Entropy data including: counter and stop flag.
* @return NULL always.
*/
static THREAD_RETURN WOLFSSL_THREAD_NO_JOIN Entropy_IncCounter(void* args)
static THREAD_RETURN_NOJOIN WOLFSSL_THREAD_NO_JOIN
Entropy_IncCounter(void* args)
{
(void)args;

Expand All @@ -926,8 +927,8 @@ static THREAD_RETURN WOLFSSL_THREAD_NO_JOIN Entropy_IncCounter(void* args)
#ifdef WOLFSSL_DEBUG_ENTROPY_MEMUSE
fprintf(stderr, "EXITING ENTROPY COUNTER THREAD\n");
#endif
/* Exit from thread. */
WOLFSSL_RETURN_FROM_THREAD(0);

RETURN_FROM_THREAD_NOJOIN(0);
}

/* Start a thread that increments counter if not one already.
Expand Down
31 changes: 25 additions & 6 deletions wolfssl/wolfcrypt/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -1495,7 +1495,11 @@ typedef struct w64wrapper {
#define INVALID_THREAD_VAL ((THREAD_TYPE)(INVALID_HANDLE_VALUE))
#define WOLFSSL_THREAD __stdcall
#if !defined(__MINGW32__)
#define WOLFSSL_THREAD_NO_JOIN __cdecl
#if defined(__WATCOMC__)
#define WOLFSSL_THREAD_NO_JOIN
#else
#define WOLFSSL_THREAD_NO_JOIN __cdecl
#endif
#endif
#else
typedef unsigned int THREAD_RETURN;
Expand Down Expand Up @@ -1525,17 +1529,23 @@ typedef struct w64wrapper {
* to check if the value is an invalid thread
* WOLFSSL_THREAD - attribute that should be used to declare thread
* callbacks
* WOLFSSL_THREAD_NO_JOIN - attribute that should be used to declare
* thread callbacks that don't require cleanup
* WOLFSSL_COND - defined if this system supports signaling
* COND_TYPE - type that should be passed into the signaling API
* WOLFSSL_THREAD_VOID_RETURN - defined if the thread callback has a
* void return
* WOLFSSL_RETURN_FROM_THREAD - define used to correctly return from a
* thread callback
* THREAD_CB - thread callback type for regular threading API
* THREAD_CB_NOJOIN - thread callback type for threading API that don't
*
* WOLFSSL_THREAD_NO_JOIN - attribute used to declare thread callbacks
* that do not require cleanup
* THREAD_CB_NOJOIN - thread callback type for thread APIs that do not
* require cleanup
* THREAD_RETURN_NOJOIN - return type used to declare thread callbacks
* that do not require cleanup
* RETURN_FROM_THREAD_NOJOIN - define used to correctly return from
* a thread callback that do not require
* cleanup
*
* Other defines/types are specific for the threading implementation
*/
Expand All @@ -1558,8 +1568,17 @@ typedef struct w64wrapper {
/* Create a thread that will be automatically cleaned up. We can't
* return a handle/pointer to the new thread because there are no
* guarantees for how long it will be valid. */
typedef THREAD_RETURN (WOLFSSL_THREAD_NO_JOIN *THREAD_CB_NOJOIN)
(void* arg);
#if defined(WOLFSSL_PTHREADS)
#define THREAD_CB_NOJOIN THREAD_CB
#define THREAD_RETURN_NOJOIN THREAD_RETURN
#define RETURN_FROM_THREAD_NOJOIN(x) \
WOLFSSL_RETURN_FROM_THREAD(x)
#else
#define THREAD_RETURN_NOJOIN void
typedef THREAD_RETURN_NOJOIN
(WOLFSSL_THREAD_NO_JOIN *THREAD_CB_NOJOIN)(void* arg);
#define RETURN_FROM_THREAD_NOJOIN(x) return
#endif
WOLFSSL_API int wolfSSL_NewThreadNoJoin(THREAD_CB_NOJOIN cb,
void* arg);
#endif
Expand Down
Loading