-
Notifications
You must be signed in to change notification settings - Fork 265
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
Compat: pthread.h shim for FreeRTOS #978
base: master
Are you sure you want to change the base?
Conversation
addd6f4
to
7c75b1e
Compare
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.
I made a first pass over your diff and it looks pretty good. Most of my comments are very nitpicky and stylistic. The main points:
- Please make the
libressl_
prefixing completely straightforward, so we change things this usingsed
, as far as possible. - The pthread API is special in that it returns an
errno
value, not-1
(there's also a bug in the windows shim). - I am fine with using the
NO_SYSLOG
logic, but it needs fixing for WIN32 on the autotools level.
xSemaphoreHandle x = mutex->handle; | ||
if (x) { | ||
if ( xSemaphoreGive(x) == pdTRUE ) { | ||
return 0; | ||
} | ||
else { | ||
return -1; | ||
} | ||
} | ||
|
||
return 0; |
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.
xSemaphoreHandle x = mutex->handle; | |
if (x) { | |
if ( xSemaphoreGive(x) == pdTRUE ) { | |
return 0; | |
} | |
else { | |
return -1; | |
} | |
} | |
return 0; | |
if (mutex->handle == NULL) | |
return 0; | |
if (xSemaphoreGive(mutex->handle) == pdTRUE) | |
return 0; | |
return -1; |
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.
In mutex_lock
we:
- Return -1 if the mutex handle is NULL, here we return 0. Should we be consistent here and return -1 as well?
- We compare
!= pdTRUE
and final return is the happy path. Here, we compare== pdTRUE
and the final return is a non-happy path. Should we be consistent and!= pdTRUE
with happy path the final return?
@@ -14,7 +18,7 @@ | |||
|
|||
#include <stdarg.h> | |||
|
|||
#ifdef _WIN32 | |||
#ifdef NO_SYSLOG |
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 seems fine if we fix autotools.
pthread_once(pthread_once_t *once, void (*cb) (void)) | ||
{ | ||
if (!once->is_initialized) { | ||
return -1; |
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.
I think all return -1
should actually be an errno
, such as EINVAL
. This seems also incorrect in the windows pthread shim. I have not corrected that in my suggestions below.
Hi @projectgoav do you have build / test instructions for this branch? |
As discussed in #960.
Assumes that anyone wishing to build for FreeRTOS will define
FREERTOS
and ensure that the FreeRTOS headers are added to the include path atFreeRTOS/___
pthread_once
I wasn't sure if this has to be thread-safe. Can easily adjust this if required.
Syslog Support
I had to adjust the
compat/syslog.h
slighty to account for more than just Windows not providing syslog. Please let me know if there is a better/cleaner/more LibreSSLy way of doing things like this.I liked making sure of the already defined
NO_SYSLOG
which is used as part ofcrypto/compat/r_syslog.c
hence why this was picked.Sockets / Networking
We currently use the LWIP networking stack. My plan was to submit another PR with a compatibility shim for that. As a result, I don't know the status of building for the built-in FreeRTOS stack. It's my understanding it follows the standard socket API so might just work (TM)...