-
Notifications
You must be signed in to change notification settings - Fork 833
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
Refactor HAVE_PTHREAD and _POSIX_THREADS #6536
Conversation
After seeing the PRB failures, it seems there was some logic missing from a few of the examples. In particular, when the threading capability exists but is explicitly turned off with I sprinkled some There may be an argument to combine all that logic into a single global definition. |
wolfssl/wolfcrypt/settings.h
Outdated
@@ -52,6 +52,12 @@ | |||
extern "C" { | |||
#endif | |||
|
|||
/* pick up compiler def; may need to turn on HAVE_PTHREAD for some configs */ | |||
#ifdef _POSIX_THREADS | |||
#undef HAVE_PTHREAD |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me. Now that this is in settings.h I think it best to change the _POSIX_THREADS
elsewhere to use HAVE_PTHREAD
. I also think you should add && !defined(SINGLE_THREADED)
and remove it from the refactor you did.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool. I've applied your suggested changes and changed the PR description & title to reflect the global nature of this change
@dgarske - After completing the desired changes for If you agree, changes to (or more specifically: removal of) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice cleanup!
Revert #6536 types.h one line HAVE_PTHREAD
See also #6545 |
Description
This started as a corner case of cross-compiling testwolfcrypt, in my case for the Xtensa ESP32-S3 Linux kernel.
I didn't have a
pthread.h
and noticed that several other places (but not all?) are gated withHAVE_PTHREAD
.This PR refactors the
HAVE_PTHREAD
to not only thetest.h
that I encountered, but also all other places that the conditional#if defined(_POSIX_THREADS)
was used.Upon merging there will be only one check of
_POSIX_THREADS
insettings.h
and all other code shall be usingHAVE_PTHREAD
to determine if POSIX threading code should be gated in.Note that MINGW is not POSIX and is part of the global logic that will disable
HAVE_PTHREAD
.The key part of this update is this compiler directive code segment added to
wolfssl/wolfcrypt/setthings.h
to determine if we have POSIX Threads enabled (akaHAVE_PTHREAD
is defined):Fixes zd# n/a/
Testing
How did you test?
Ran the test app in cross-compiled app as well as Linux & ESP-IDF for ESP32.
Default config, threading enabled:
Forced single-thread. This was observed to have failed during PRB with prior changes:
Checklist