Topic: wolfssl/internal.h includes pthread.h in some configurations

WolfSSL header file wolfssl/internal.h includes pthread.h if none of the following macros is defined

USE_WINDOWS_API
THREADX
WOLFSSL_DEOS
MICRIUM
FREERTOS
FREERTOS_TCP
WOLFSSL_SAFERTOS
EBSNET
FREESCALE_MQX
FREESCALE_KSDK_MQX
FREESCALE_FREE_RTOS
WOLFSSL_uITRON4
WOLFSSL_uTKERNEL2
WOLFSSL_CMSIS_RTOS
WOLFSSL_MDK_ARM
MBED
WOLFSSL_TIRTOS
INTIME_RTOS
WOLFSSL_NUCLEUS_1_2
WOLFSSL_APACHE_MYNEWT
WOLFSSL_ZEPHYR
WOLFSSL_TELIT_M2MB
WOLFSSL_SINGLE_THREADED

Our project uses the Renesas port of uITRON, but we cannot use the WOLFSSL_uITRON4 define because it pulls in declarations and code we do not have.

Our workaround is to create an empty file pthread.h in our project.

Can WolfSSL change the #else clause in the #if/#elif/#elif.../#else/#endif block in wolfssl/internal.h to allow users to not include <pthread.h>?

Share

Re: wolfssl/internal.h includes pthread.h in some configurations

Hi Scoobi_FreeBSD,

You can also build with "SINGLE_THREADED" defined to disable threading / mutex support. What Renesas uiTRON headers are not found when using WOLFSSL_uITRON4?

Thanks,
David Garske, wolfSSL

Share

3 (edited by Scoobi_FreeBSD 2020-09-09 06:23:16)

Re: wolfssl/internal.h includes pthread.h in some configurations

  • wolfcrypt/src/random.c:
    WOLFSSL_uITRON4 forces the definition of USE_TEST_GENSEED unless a custom random number generator is enabled

  • wolfcrypt/src/wc_port.c:
    Defining WOLFSSL_uITRON4 without defining SINGLE_THREADED calls acre_sem(), which constructs a semaphore at runtime, but our uITRON implementation defines all RTOS resources statically (at compile-time).  I've worked around this by defining WOLFSSL_USER_MUTEX and using an atomic XCHG instruction and RTOS sleep calls, but WOLFSSL_USER_MUTEX is tested after testing WOLFSSL_uITRON4, preventing the user from overriding WolfSSL's implementation.

  • wolfssl/wolfcrypt/settings.h:
    WOLFSSL_uITRON4 declares external functions uITRON4_minit(), uITRON4_malloc(), uITRON4_realloc() and uITRON4_free() which our uITRON implementation does not have.  Are we responsible for implementing these functions?

I suppose we could define SINGLE_THREADED to build a single-threaded library, but we are running in a multi-task environment.

Share

Re: wolfssl/internal.h includes pthread.h in some configurations

Hi Scoobi_FreeBSD,

If you define single threaded it just means you will not use the same WOLFSSL_CTX or WOLFSSL object from more than one thread at a time. You could have separate instances of those for multiple threads at the same time.

For the uITRON4 build issues I will have to defer to another engineer.

Thanks,
David Garske, wolfSSL

Share