-
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
Compilation for platforms without pthreads #960
Comments
The libraries require the API, but there already is compat glue for pthreads on Windows. If you can fill this in appropriately for FreeRTOS, it should work fine. |
Thanks! Annoyingly the compiler we use defines a number of the required pthread structures in the Would the project be willing to accept a patch that abstracts |
Ideally, this would be transparent from our side, so that our code can keep using the standard names. In #961 I have started moving our compat glue into its own I think the same technique should work here: above each compat type or symbol declaration #define foo libressl_foo in the compat |
That all makes sense to me. It sounds similar to what I had thought of but in a much cleaner implementation. Just to confirm I've understood you correctly, in the case of // pthread.h
#ifdef WIN32
#define INIT_ONCE libressl_once
// ...
#else
#define pthread_once libressl_once
// ...
#endif Then in calling code we'd use |
The point of doing this is that the code in our libcrypto/libssl/libtls can remain unmodified and keep using So in the compat header you'd do // pthread.h
#ifdef WIN32
...
/*
* Once definitions.
*/
#define pthread_once libressl_pthread_once
struct pthread_once {
INIT_ONCE once;
};
#define pthread_once_t libressl_pthread_once_t
typedef struct pthread_once pthread_once_t; If I understand correctly, The replacement code should keep using the standard names. The preprocessor already takes care of the renaming. |
Ok, I'm with you now! However, in our case I don't think this will work. We're using the RTEMs compiler which provides a ...
typedef struct {
int is_initialized; /* is this structure initialized? */
int init_executed; /* has the initialization routine been run? */
} pthread_once_t; /* dynamic package initialization */
... Taking your suggestion above, I've added the code above in
The same also happens for typedef unsigned int pthread_t; /* identify a thread */
typedef unsigned int pthread_mutex_t; /* identify a mutex */ |
I will need to play with it a bit. Some toy examples seem to work here with clang. |
Not a problem, let me know if there is anything I can do to help or test. As an aside, I totally understand if this is out with the realm and goals of the LibreSSL project. I know it's great for things to be portable across platforms but there comes a point where certian (niche) setups can't be maintaned! |
I think the problem you run into simply is that Could you try adding Regarding support, if it is only about having some compat shims, there should be no issue to help you with that and carrying it in our portable layer. That's what it is for. The line will be crossed when we need to do modify our code in the openbsd repo in an intrusive way. If/when we get it working, we should think about how we ensure we don't break you. If we can set up some CI on github, that would be ideal. Or maybe you have some test environment where you can regularly pull portable HEAD and notify us when we break something. |
Adding the Quick question about It seems the Windows compat shim checks for an uninitilaised case, initialises then locks. I had to do the same for my FreeRTOS shim otherwise we'd crash. This feels wrong that there are some places the code where this occurs but it might be my misunderstanding of the POSIX/pthread spec. |
This is the way static mutexes are ininitialized/implemented (which are used in the code):
Now the spec (reasonably) says that calling |
I should have said: that you got it working is great news. Do the regress tests pass? I would be happy to merge support into this repository, so feel free to open a PR with what you have. It would be great to figure out a way to test it. Also try to avoid to get this far behind again. There are numerous really bad issues that have been fixed since 2.6. This may or may not be relevant to you: there is some undefined behavior in the windows |
I am unable to confirm that at the moment. Honestly, I'm not really sure how to deploy them to our hardware... I only really know how to deploy our entire app! At least doing that allows us to boot, run and pass our own set of nightly tests without issue. I'll investigate how we could deploy and run the provided tests.
Certainly can do. I'll tidy it up a bit as it's got some other specifics in there for our hardware. I don't currently know how to implement |
I am currently upgrading our LibreSSL version from 2.6. It now seems that v3.0+ requires some pthread related functions -
pthread_once
&pthread_mutex_lock|unlock
.We run FreeRTOS which does not support pthreads. Is there any way for us to define / configure SSL to not require these functions or should be we be providing a FreeRTOS implementation going forward?
The text was updated successfully, but these errors were encountered: