From 7a5809b7ac4e1bf9327baf3b2fc5f4f5ca4f1b61 Mon Sep 17 00:00:00 2001 From: night1rider Date: Wed, 11 Feb 2026 22:08:14 -0700 Subject: [PATCH 01/11] Add Zephyr 4.1+ build compatibility for wolfssl_tls_sock sample. Replace removed Kconfig options (PTHREAD_IPC, POSIX_CLOCK, NET_SOCKETS_POSIX_NAMES) with version-conditional config fragments and fix min/max macro collision with Zephyr's sys/util.h. --- zephyr/samples/wolfssl_tls_sock/CMakeLists.txt | 18 ++++++++++++++++++ zephyr/samples/wolfssl_tls_sock/prj.conf | 10 ---------- .../wolfssl_tls_sock/zephyr_legacy.conf | 5 +++++ .../samples/wolfssl_tls_sock/zephyr_v4.1.conf | 3 +++ zephyr/user_settings.h | 2 ++ 5 files changed, 28 insertions(+), 10 deletions(-) create mode 100644 zephyr/samples/wolfssl_tls_sock/zephyr_legacy.conf create mode 100644 zephyr/samples/wolfssl_tls_sock/zephyr_v4.1.conf diff --git a/zephyr/samples/wolfssl_tls_sock/CMakeLists.txt b/zephyr/samples/wolfssl_tls_sock/CMakeLists.txt index a1208f50293..f922d0736d6 100644 --- a/zephyr/samples/wolfssl_tls_sock/CMakeLists.txt +++ b/zephyr/samples/wolfssl_tls_sock/CMakeLists.txt @@ -1,4 +1,22 @@ cmake_minimum_required(VERSION 3.13.1) + +# Select version-specific Kconfig fragment before loading Zephyr +if(EXISTS $ENV{ZEPHYR_BASE}/VERSION) + file(READ $ENV{ZEPHYR_BASE}/VERSION zephyr_version_file) + string(REGEX MATCH "VERSION_MAJOR = ([0-9]+)" _ ${zephyr_version_file}) + set(ZEPHYR_VER_MAJOR ${CMAKE_MATCH_1}) + string(REGEX MATCH "VERSION_MINOR = ([0-9]+)" _ ${zephyr_version_file}) + set(ZEPHYR_VER_MINOR ${CMAKE_MATCH_1}) +endif() + +if(ZEPHYR_VER_MAJOR GREATER_EQUAL 5) + set(EXTRA_CONF_FILE ${CMAKE_CURRENT_SOURCE_DIR}/zephyr_v4.1.conf) +elseif(ZEPHYR_VER_MAJOR EQUAL 4 AND ZEPHYR_VER_MINOR GREATER_EQUAL 1) + set(EXTRA_CONF_FILE ${CMAKE_CURRENT_SOURCE_DIR}/zephyr_v4.1.conf) +else() + set(EXTRA_CONF_FILE ${CMAKE_CURRENT_SOURCE_DIR}/zephyr_legacy.conf) +endif() + include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE) project(wolfssl_tls_sock) diff --git a/zephyr/samples/wolfssl_tls_sock/prj.conf b/zephyr/samples/wolfssl_tls_sock/prj.conf index 549bc07ab0b..a51becba375 100644 --- a/zephyr/samples/wolfssl_tls_sock/prj.conf +++ b/zephyr/samples/wolfssl_tls_sock/prj.conf @@ -4,22 +4,12 @@ CONFIG_ENTROPY_GENERATOR=y CONFIG_INIT_STACKS=y CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE=8192 -# General config -CONFIG_NEWLIB_LIBC=y - -# Pthreads -CONFIG_PTHREAD_IPC=y - -# Clock for time() -CONFIG_POSIX_CLOCK=y - # Networking config CONFIG_NETWORKING=y CONFIG_NET_IPV4=y CONFIG_NET_IPV6=n CONFIG_NET_TCP=y CONFIG_NET_SOCKETS=y -CONFIG_NET_SOCKETS_POSIX_NAMES=y CONFIG_NET_TEST=y CONFIG_NET_LOOPBACK=y diff --git a/zephyr/samples/wolfssl_tls_sock/zephyr_legacy.conf b/zephyr/samples/wolfssl_tls_sock/zephyr_legacy.conf new file mode 100644 index 00000000000..d7760060a54 --- /dev/null +++ b/zephyr/samples/wolfssl_tls_sock/zephyr_legacy.conf @@ -0,0 +1,5 @@ +# Zephyr < 4.1 POSIX and libc options +CONFIG_NEWLIB_LIBC=y +CONFIG_PTHREAD_IPC=y +CONFIG_POSIX_CLOCK=y +CONFIG_NET_SOCKETS_POSIX_NAMES=y diff --git a/zephyr/samples/wolfssl_tls_sock/zephyr_v4.1.conf b/zephyr/samples/wolfssl_tls_sock/zephyr_v4.1.conf new file mode 100644 index 00000000000..aad2366e5af --- /dev/null +++ b/zephyr/samples/wolfssl_tls_sock/zephyr_v4.1.conf @@ -0,0 +1,3 @@ +# Zephyr >= 4.1 POSIX and libc options +CONFIG_NEWLIB_LIBC=y +CONFIG_POSIX_API=y diff --git a/zephyr/user_settings.h b/zephyr/user_settings.h index 4d7e2ebd061..a57115ae13a 100644 --- a/zephyr/user_settings.h +++ b/zephyr/user_settings.h @@ -40,6 +40,8 @@ extern "C" { /* ------------------------------------------------------------------------- */ /* Platform */ /* ------------------------------------------------------------------------- */ +#define WOLFSSL_HAVE_MIN /* Zephyr provides min() in sys/util.h */ +#define WOLFSSL_HAVE_MAX /* Zephyr provides max() in sys/util.h */ #define WOLFSSL_GENERAL_ALIGNMENT 4 /* platform requires 32-bit alignment on uint32_t */ #define SIZEOF_LONG_LONG 8 /* long long is 8 bytes / 64-bit */ //#define WOLFSSL_NO_ASM /* optionally disable inline assembly support */ From ed64163d3db8b700812f01bc5474573be3cd5b33 Mon Sep 17 00:00:00 2001 From: night1rider Date: Wed, 11 Feb 2026 23:24:27 -0700 Subject: [PATCH 02/11] Fix issue due to min/max not being avaliable for older builds in CI --- zephyr/CMakeLists.txt | 7 +++++++ zephyr/user_settings.h | 2 ++ 2 files changed, 9 insertions(+) diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt index aeb714b9466..01cb1cdd6a0 100644 --- a/zephyr/CMakeLists.txt +++ b/zephyr/CMakeLists.txt @@ -186,6 +186,13 @@ if(CONFIG_WOLFSSL) target_compile_definitions(wolfSSL INTERFACE WOLFSSL_ZEPHYR) target_compile_definitions(wolfSSL INTERFACE WOLFSSL_USER_SETTINGS) + + # Zephyr >= 4.1 provides min()/max() macros in sys/util.h that collide + # with wolfSSL's static inline definitions in misc.c + if(KERNEL_VERSION_MAJOR GREATER_EQUAL 5 OR + (KERNEL_VERSION_MAJOR EQUAL 4 AND KERNEL_VERSION_MINOR GREATER_EQUAL 1)) + target_compile_definitions(wolfSSL INTERFACE WOLFSSL_HAVE_MIN_MAX) + endif() if(CONFIG_WOLFSSL_DEBUG) target_compile_definitions(wolfSSL INTERFACE DEBUG_WOLFSSL) zephyr_library_compile_options(-g3 -O0) diff --git a/zephyr/user_settings.h b/zephyr/user_settings.h index a57115ae13a..d8ea3e63a46 100644 --- a/zephyr/user_settings.h +++ b/zephyr/user_settings.h @@ -40,8 +40,10 @@ extern "C" { /* ------------------------------------------------------------------------- */ /* Platform */ /* ------------------------------------------------------------------------- */ +#ifdef WOLFSSL_HAVE_MIN_MAX #define WOLFSSL_HAVE_MIN /* Zephyr provides min() in sys/util.h */ #define WOLFSSL_HAVE_MAX /* Zephyr provides max() in sys/util.h */ +#endif #define WOLFSSL_GENERAL_ALIGNMENT 4 /* platform requires 32-bit alignment on uint32_t */ #define SIZEOF_LONG_LONG 8 /* long long is 8 bytes / 64-bit */ //#define WOLFSSL_NO_ASM /* optionally disable inline assembly support */ From e31fb09d6745956ad4d458202cc79c799ddaf35f Mon Sep 17 00:00:00 2001 From: night1rider Date: Thu, 12 Feb 2026 23:31:44 -0700 Subject: [PATCH 03/11] Update some inclusion related items --- wolfssl/test.h | 4 +++- wolfssl/wolfcrypt/wc_port.h | 12 ++++++++---- zephyr/CMakeLists.txt | 12 +++++++----- zephyr/Kconfig | 7 +++++++ zephyr/samples/wolfssl_tls_sock/CMakeLists.txt | 12 +++++++----- zephyr/user_settings.h | 4 ---- 6 files changed, 32 insertions(+), 19 deletions(-) diff --git a/wolfssl/test.h b/wolfssl/test.h index 56dd88aa8fe..e934cc81618 100644 --- a/wolfssl/test.h +++ b/wolfssl/test.h @@ -209,9 +209,10 @@ #endif #endif #define SOCKET_T int - #define SOL_SOCKET 1 #define WOLFSSL_USE_GETADDRINFO + #if !defined(CONFIG_POSIX_API) + #define SOL_SOCKET 1 static unsigned long inet_addr(const char *cp) { unsigned int a[4]; unsigned long ret; @@ -227,6 +228,7 @@ ret = ((a[3]<<24) + (a[2]<<16) + (a[1]<<8) + a[0]) ; return(ret) ; } + #endif #elif defined(NETOS) #include #include diff --git a/wolfssl/wolfcrypt/wc_port.h b/wolfssl/wolfcrypt/wc_port.h index 384edab030f..46b51e358b3 100644 --- a/wolfssl/wolfcrypt/wc_port.h +++ b/wolfssl/wolfcrypt/wc_port.h @@ -294,12 +294,16 @@ #endif #if KERNEL_VERSION_NUMBER >= 0x30100 #include - #include - #include + #ifndef CONFIG_ARCH_POSIX + #include + #include + #endif #else #include - #include - #include + #ifndef CONFIG_ARCH_POSIX + #include + #include + #endif #endif #endif diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt index 01cb1cdd6a0..35b8a765652 100644 --- a/zephyr/CMakeLists.txt +++ b/zephyr/CMakeLists.txt @@ -187,11 +187,13 @@ if(CONFIG_WOLFSSL) target_compile_definitions(wolfSSL INTERFACE WOLFSSL_ZEPHYR) target_compile_definitions(wolfSSL INTERFACE WOLFSSL_USER_SETTINGS) - # Zephyr >= 4.1 provides min()/max() macros in sys/util.h that collide - # with wolfSSL's static inline definitions in misc.c - if(KERNEL_VERSION_MAJOR GREATER_EQUAL 5 OR - (KERNEL_VERSION_MAJOR EQUAL 4 AND KERNEL_VERSION_MINOR GREATER_EQUAL 1)) - target_compile_definitions(wolfSSL INTERFACE WOLFSSL_HAVE_MIN_MAX) + if(NOT CONFIG_WOLFSSL_NO_HAVE_MIN_MAX AND + (KERNEL_VERSION_MAJOR GREATER_EQUAL 5 OR + (KERNEL_VERSION_MAJOR EQUAL 4 AND + KERNEL_VERSION_MINOR GREATER_EQUAL 3))) + target_compile_definitions(wolfSSL INTERFACE + WOLFSSL_HAVE_MIN + WOLFSSL_HAVE_MAX) endif() if(CONFIG_WOLFSSL_DEBUG) target_compile_definitions(wolfSSL INTERFACE DEBUG_WOLFSSL) diff --git a/zephyr/Kconfig b/zephyr/Kconfig index 9863454ffcd..0de97943cb9 100644 --- a/zephyr/Kconfig +++ b/zephyr/Kconfig @@ -112,6 +112,13 @@ config WOLFCRYPT_INTELASM help wolfCrypt Intel Aassembly support (AVX/AVX2/AESNI) +config WOLFSSL_NO_HAVE_MIN_MAX + bool "Force wolfSSL to use its own min/max" + help + Disable this if Zephyr min()/max() macros cause + issues. By default wolfSSL defers to Zephyr's + min/max on >= 4.3. + config WOLFSSL_DEBUG bool "wolfSSL debug activation" depends on WOLFSSL_BUILTIN diff --git a/zephyr/samples/wolfssl_tls_sock/CMakeLists.txt b/zephyr/samples/wolfssl_tls_sock/CMakeLists.txt index f922d0736d6..258d5bf9738 100644 --- a/zephyr/samples/wolfssl_tls_sock/CMakeLists.txt +++ b/zephyr/samples/wolfssl_tls_sock/CMakeLists.txt @@ -9,12 +9,14 @@ if(EXISTS $ENV{ZEPHYR_BASE}/VERSION) set(ZEPHYR_VER_MINOR ${CMAKE_MATCH_1}) endif() -if(ZEPHYR_VER_MAJOR GREATER_EQUAL 5) - set(EXTRA_CONF_FILE ${CMAKE_CURRENT_SOURCE_DIR}/zephyr_v4.1.conf) -elseif(ZEPHYR_VER_MAJOR EQUAL 4 AND ZEPHYR_VER_MINOR GREATER_EQUAL 1) - set(EXTRA_CONF_FILE ${CMAKE_CURRENT_SOURCE_DIR}/zephyr_v4.1.conf) +if(ZEPHYR_VER_MAJOR GREATER_EQUAL 4 OR + (ZEPHYR_VER_MAJOR EQUAL 3 AND + ZEPHYR_VER_MINOR GREATER 5)) + set(EXTRA_CONF_FILE + ${CMAKE_CURRENT_SOURCE_DIR}/zephyr_v4.1.conf) else() - set(EXTRA_CONF_FILE ${CMAKE_CURRENT_SOURCE_DIR}/zephyr_legacy.conf) + set(EXTRA_CONF_FILE + ${CMAKE_CURRENT_SOURCE_DIR}/zephyr_legacy.conf) endif() include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE) diff --git a/zephyr/user_settings.h b/zephyr/user_settings.h index d8ea3e63a46..4d7e2ebd061 100644 --- a/zephyr/user_settings.h +++ b/zephyr/user_settings.h @@ -40,10 +40,6 @@ extern "C" { /* ------------------------------------------------------------------------- */ /* Platform */ /* ------------------------------------------------------------------------- */ -#ifdef WOLFSSL_HAVE_MIN_MAX -#define WOLFSSL_HAVE_MIN /* Zephyr provides min() in sys/util.h */ -#define WOLFSSL_HAVE_MAX /* Zephyr provides max() in sys/util.h */ -#endif #define WOLFSSL_GENERAL_ALIGNMENT 4 /* platform requires 32-bit alignment on uint32_t */ #define SIZEOF_LONG_LONG 8 /* long long is 8 bytes / 64-bit */ //#define WOLFSSL_NO_ASM /* optionally disable inline assembly support */ From 9c4ce02314affd9edd363f66c4576fe250956937 Mon Sep 17 00:00:00 2001 From: night1rider Date: Fri, 13 Feb 2026 00:11:51 -0700 Subject: [PATCH 04/11] Use __has_include() with a fallback to --- wolfcrypt/src/random.c | 10 +++++++++- wolfssl/test.h | 10 +++++++++- wolfssl/wolfcrypt/settings.h | 10 +++++++++- wolfssl/wolfcrypt/wc_port.h | 20 ++++++++++++++++++-- wolfssl/wolfio.h | 10 +++++++++- 5 files changed, 54 insertions(+), 6 deletions(-) diff --git a/wolfcrypt/src/random.c b/wolfcrypt/src/random.c index 37c410b5439..a66f1111084 100644 --- a/wolfcrypt/src/random.c +++ b/wolfcrypt/src/random.c @@ -3447,7 +3447,15 @@ int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz) #elif defined(WOLFSSL_ZEPHYR) - #include + #ifdef __has_include + #if __has_include() + #include + #else + #include + #endif + #else + #include + #endif #if KERNEL_VERSION_NUMBER >= 0x30500 #include diff --git a/wolfssl/test.h b/wolfssl/test.h index e934cc81618..5505ef7b230 100644 --- a/wolfssl/test.h +++ b/wolfssl/test.h @@ -188,7 +188,15 @@ #include #define SOCKET_T int #elif defined(WOLFSSL_ZEPHYR) - #include + #ifdef __has_include + #if __has_include() + #include + #else + #include + #endif + #else + #include + #endif #include #include #if KERNEL_VERSION_NUMBER >= 0x30100 diff --git a/wolfssl/wolfcrypt/settings.h b/wolfssl/wolfcrypt/settings.h index 49301a4d3af..81599011e44 100644 --- a/wolfssl/wolfcrypt/settings.h +++ b/wolfssl/wolfcrypt/settings.h @@ -2614,7 +2614,15 @@ extern void uITRON4_free(void *p) ; } /* extern "C" */ #endif - #include + #ifdef __has_include + #if __has_include() + #include + #else + #include + #endif + #else + #include + #endif #if KERNEL_VERSION_NUMBER >= 0x30100 #include #include diff --git a/wolfssl/wolfcrypt/wc_port.h b/wolfssl/wolfcrypt/wc_port.h index 46b51e358b3..2e8e6dc8297 100644 --- a/wolfssl/wolfcrypt/wc_port.h +++ b/wolfssl/wolfcrypt/wc_port.h @@ -287,7 +287,15 @@ } /* extern "C" */ #endif - #include + #ifdef __has_include + #if __has_include() + #include + #else + #include + #endif + #else + #include + #endif #ifndef SINGLE_THREADED #if !defined(CONFIG_PTHREAD_IPC) && !defined(CONFIG_POSIX_THREADS) #error "Threading needs CONFIG_PTHREAD_IPC / CONFIG_POSIX_THREADS" @@ -1495,7 +1503,15 @@ WOLFSSL_ABI WOLFSSL_API int wolfCrypt_Cleanup(void); } /* extern "C" */ #endif - #include + #ifdef __has_include + #if __has_include() + #include + #else + #include + #endif + #else + #include + #endif #ifndef _POSIX_C_SOURCE #if KERNEL_VERSION_NUMBER >= 0x30100 #include diff --git a/wolfssl/wolfio.h b/wolfssl/wolfio.h index abfdbe55346..ed20c59c17b 100644 --- a/wolfssl/wolfio.h +++ b/wolfssl/wolfio.h @@ -180,7 +180,15 @@ } /* extern "C" */ #endif - #include + #ifdef __has_include + #if __has_include() + #include + #else + #include + #endif + #else + #include + #endif #if KERNEL_VERSION_NUMBER >= 0x30100 #include #ifdef CONFIG_POSIX_API From 62041a2e99c0aad2e61aab196874a56d1717a0a3 Mon Sep 17 00:00:00 2001 From: night1rider Date: Fri, 13 Feb 2026 14:47:17 -0700 Subject: [PATCH 05/11] Add more gating for has include --- wolfssl/test.h | 31 +++++++++++++++++++++++++++---- wolfssl/wolfcrypt/wc_port.h | 27 ++++++++++++++++++++++++--- wolfssl/wolfio.h | 10 +++++++++- 3 files changed, 60 insertions(+), 8 deletions(-) diff --git a/wolfssl/test.h b/wolfssl/test.h index 5505ef7b230..7bb9869f529 100644 --- a/wolfssl/test.h +++ b/wolfssl/test.h @@ -202,10 +202,33 @@ #if KERNEL_VERSION_NUMBER >= 0x30100 #include #ifdef CONFIG_POSIX_API - #include - #include - #include - #include + #ifdef __has_include + #if __has_include() + #include + #else + #include + #endif + #if __has_include() + #include + #else + #include + #endif + #if __has_include() + #include + #else + #include + #endif + #if __has_include() + #include + #else + #include + #endif + #else + #include + #include + #include + #include + #endif #endif #else #include diff --git a/wolfssl/wolfcrypt/wc_port.h b/wolfssl/wolfcrypt/wc_port.h index 2e8e6dc8297..f1e89c43e5b 100644 --- a/wolfssl/wolfcrypt/wc_port.h +++ b/wolfssl/wolfcrypt/wc_port.h @@ -303,8 +303,21 @@ #if KERNEL_VERSION_NUMBER >= 0x30100 #include #ifndef CONFIG_ARCH_POSIX - #include - #include + #ifdef __has_include + #if __has_include() + #include + #else + #include + #endif + #if __has_include() + #include + #else + #include + #endif + #else + #include + #include + #endif #endif #else #include @@ -1514,7 +1527,15 @@ WOLFSSL_ABI WOLFSSL_API int wolfCrypt_Cleanup(void); #endif #ifndef _POSIX_C_SOURCE #if KERNEL_VERSION_NUMBER >= 0x30100 - #include + #ifdef __has_include + #if __has_include() + #include + #else + #include + #endif + #else + #include + #endif #else #include #endif diff --git a/wolfssl/wolfio.h b/wolfssl/wolfio.h index ed20c59c17b..d170e217e38 100644 --- a/wolfssl/wolfio.h +++ b/wolfssl/wolfio.h @@ -192,7 +192,15 @@ #if KERNEL_VERSION_NUMBER >= 0x30100 #include #ifdef CONFIG_POSIX_API - #include + #ifdef __has_include + #if __has_include() + #include + #else + #include + #endif + #else + #include + #endif #endif #else #include From dcb75a2508452044fbf1d7a19f5e37d01b3b0ff5 Mon Sep 17 00:00:00 2001 From: night1rider Date: Fri, 13 Feb 2026 15:03:06 -0700 Subject: [PATCH 06/11] Fix gating for when _POSIX_C_SOURCE is not used --- wolfcrypt/src/wc_port.c | 4 ++++ wolfcrypt/test/test.c | 4 ++++ zephyr/samples/wolfssl_tls_thread/src/tls_threaded.c | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/wolfcrypt/src/wc_port.c b/wolfcrypt/src/wc_port.c index 4bc487e75ff..a27713cd6f7 100644 --- a/wolfcrypt/src/wc_port.c +++ b/wolfcrypt/src/wc_port.c @@ -4000,7 +4000,11 @@ time_t z_time(time_t * timer) /* Fallback to uptime since boot. This works for relative times, but * not for ASN.1 date validation */ +#ifdef _POSIX_C_SOURCE if (clock_gettime(CLOCK_REALTIME, &ts) == 0) +#else + if (sys_clock_gettime(SYS_CLOCK_REALTIME, &ts) == 0) +#endif if (timer != NULL) *timer = ts.tv_sec; diff --git a/wolfcrypt/test/test.c b/wolfcrypt/test/test.c index 8e340899e68..5caf3a2bd42 100644 --- a/wolfcrypt/test/test.c +++ b/wolfcrypt/test/test.c @@ -3061,7 +3061,11 @@ options: [-s max_relative_stack_bytes] [-m max_relative_heap_memory_bytes]\n\ struct timespec utctime; utctime.tv_sec = 1521725159; /* dummy time: 2018-03-22T13:25:59+00:00 */ utctime.tv_nsec = 0; +#ifdef _POSIX_C_SOURCE clock_settime(CLOCK_REALTIME, &utctime); +#else + sys_clock_settime(SYS_CLOCK_REALTIME, &utctime); +#endif #endif #ifdef DEVKITPRO void *framebuffer; diff --git a/zephyr/samples/wolfssl_tls_thread/src/tls_threaded.c b/zephyr/samples/wolfssl_tls_thread/src/tls_threaded.c index 79581e30e42..9901ffeb54c 100644 --- a/zephyr/samples/wolfssl_tls_thread/src/tls_threaded.c +++ b/zephyr/samples/wolfssl_tls_thread/src/tls_threaded.c @@ -587,7 +587,11 @@ int main() struct timespec utctime; utctime.tv_sec = 1658510212; /* Friday, July 22, 2022 5:16:52 PM GMT */ utctime.tv_nsec = 0; +#ifdef _POSIX_C_SOURCE clock_settime(CLOCK_REALTIME, &utctime); +#else + sys_clock_settime(SYS_CLOCK_REALTIME, &utctime); +#endif #ifdef HAVE_FIPS wolfCrypt_SetCb_fips(myFipsCb); From ac5bb752b86e6dc61816751dc37b17815c0b37a1 Mon Sep 17 00:00:00 2001 From: night1rider Date: Fri, 13 Feb 2026 18:03:50 -0700 Subject: [PATCH 07/11] Change clock calls to be redefines --- wolfcrypt/src/wc_port.c | 4 ---- wolfcrypt/test/test.c | 4 ---- wolfssl/wolfcrypt/wc_port.h | 8 ++++++++ zephyr/samples/wolfssl_tls_thread/src/tls_threaded.c | 4 ---- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/wolfcrypt/src/wc_port.c b/wolfcrypt/src/wc_port.c index a27713cd6f7..4bc487e75ff 100644 --- a/wolfcrypt/src/wc_port.c +++ b/wolfcrypt/src/wc_port.c @@ -4000,11 +4000,7 @@ time_t z_time(time_t * timer) /* Fallback to uptime since boot. This works for relative times, but * not for ASN.1 date validation */ -#ifdef _POSIX_C_SOURCE if (clock_gettime(CLOCK_REALTIME, &ts) == 0) -#else - if (sys_clock_gettime(SYS_CLOCK_REALTIME, &ts) == 0) -#endif if (timer != NULL) *timer = ts.tv_sec; diff --git a/wolfcrypt/test/test.c b/wolfcrypt/test/test.c index 5caf3a2bd42..8e340899e68 100644 --- a/wolfcrypt/test/test.c +++ b/wolfcrypt/test/test.c @@ -3061,11 +3061,7 @@ options: [-s max_relative_stack_bytes] [-m max_relative_heap_memory_bytes]\n\ struct timespec utctime; utctime.tv_sec = 1521725159; /* dummy time: 2018-03-22T13:25:59+00:00 */ utctime.tv_nsec = 0; -#ifdef _POSIX_C_SOURCE clock_settime(CLOCK_REALTIME, &utctime); -#else - sys_clock_settime(SYS_CLOCK_REALTIME, &utctime); -#endif #endif #ifdef DEVKITPRO void *framebuffer; diff --git a/wolfssl/wolfcrypt/wc_port.h b/wolfssl/wolfcrypt/wc_port.h index f1e89c43e5b..9984874e563 100644 --- a/wolfssl/wolfcrypt/wc_port.h +++ b/wolfssl/wolfcrypt/wc_port.h @@ -1543,6 +1543,14 @@ WOLFSSL_ABI WOLFSSL_API int wolfCrypt_Cleanup(void); #include #endif + #ifndef CLOCK_REALTIME + #ifdef SYS_CLOCK_REALTIME + #define CLOCK_REALTIME SYS_CLOCK_REALTIME + #define clock_gettime sys_clock_gettime + #define clock_settime sys_clock_settime + #endif + #endif + #if defined(CONFIG_RTC) #if defined(CONFIG_PICOLIBC) || defined(CONFIG_NEWLIB_LIBC) #include diff --git a/zephyr/samples/wolfssl_tls_thread/src/tls_threaded.c b/zephyr/samples/wolfssl_tls_thread/src/tls_threaded.c index 9901ffeb54c..79581e30e42 100644 --- a/zephyr/samples/wolfssl_tls_thread/src/tls_threaded.c +++ b/zephyr/samples/wolfssl_tls_thread/src/tls_threaded.c @@ -587,11 +587,7 @@ int main() struct timespec utctime; utctime.tv_sec = 1658510212; /* Friday, July 22, 2022 5:16:52 PM GMT */ utctime.tv_nsec = 0; -#ifdef _POSIX_C_SOURCE clock_settime(CLOCK_REALTIME, &utctime); -#else - sys_clock_settime(SYS_CLOCK_REALTIME, &utctime); -#endif #ifdef HAVE_FIPS wolfCrypt_SetCb_fips(myFipsCb); From ba7a22b52296f2084c2a123a2d46520777b5a99b Mon Sep 17 00:00:00 2001 From: night1rider Date: Mon, 16 Feb 2026 22:41:33 -0700 Subject: [PATCH 08/11] update to resolve net driver dependancy --- zephyr/samples/wolfssl_tls_sock/zephyr_v4.1.conf | 3 +++ 1 file changed, 3 insertions(+) diff --git a/zephyr/samples/wolfssl_tls_sock/zephyr_v4.1.conf b/zephyr/samples/wolfssl_tls_sock/zephyr_v4.1.conf index aad2366e5af..7ae86450552 100644 --- a/zephyr/samples/wolfssl_tls_sock/zephyr_v4.1.conf +++ b/zephyr/samples/wolfssl_tls_sock/zephyr_v4.1.conf @@ -1,3 +1,6 @@ # Zephyr >= 4.1 POSIX and libc options CONFIG_NEWLIB_LIBC=y CONFIG_POSIX_API=y + +# NET_LOOPBACK depends on NET_DRIVERS in Zephyr >= 4.1 +CONFIG_NET_DRIVERS=y From ae1428f890e67003d20f3268cb38f0339ba59c3d Mon Sep 17 00:00:00 2001 From: night1rider Date: Tue, 17 Feb 2026 00:05:16 -0700 Subject: [PATCH 09/11] Runtime fix for native sim on zephyr along with project updates for other zephyr examples --- wolfssl/wolfcrypt/settings.h | 28 +++++++++++++++++++ .../samples/wolfssl_benchmark/CMakeLists.txt | 20 +++++++++++++ zephyr/samples/wolfssl_benchmark/prj.conf | 6 ---- .../wolfssl_benchmark/zephyr_legacy.conf | 3 ++ .../wolfssl_benchmark/zephyr_v4.1.conf | 2 ++ zephyr/samples/wolfssl_test/CMakeLists.txt | 20 +++++++++++++ .../samples/wolfssl_test/prj-no-malloc.conf | 6 ---- zephyr/samples/wolfssl_test/prj.conf | 6 ---- .../samples/wolfssl_test/zephyr_legacy.conf | 3 ++ zephyr/samples/wolfssl_test/zephyr_v4.1.conf | 2 ++ .../samples/wolfssl_tls_thread/CMakeLists.txt | 20 +++++++++++++ zephyr/samples/wolfssl_tls_thread/prj.conf | 6 ---- .../wolfssl_tls_thread/zephyr_legacy.conf | 3 ++ .../wolfssl_tls_thread/zephyr_v4.1.conf | 2 ++ 14 files changed, 103 insertions(+), 24 deletions(-) create mode 100644 zephyr/samples/wolfssl_benchmark/zephyr_legacy.conf create mode 100644 zephyr/samples/wolfssl_benchmark/zephyr_v4.1.conf create mode 100644 zephyr/samples/wolfssl_test/zephyr_legacy.conf create mode 100644 zephyr/samples/wolfssl_test/zephyr_v4.1.conf create mode 100644 zephyr/samples/wolfssl_tls_thread/zephyr_legacy.conf create mode 100644 zephyr/samples/wolfssl_tls_thread/zephyr_v4.1.conf diff --git a/wolfssl/wolfcrypt/settings.h b/wolfssl/wolfcrypt/settings.h index 81599011e44..dd5aef88f25 100644 --- a/wolfssl/wolfcrypt/settings.h +++ b/wolfssl/wolfcrypt/settings.h @@ -2650,9 +2650,37 @@ extern void uITRON4_free(void *p) ; void *z_realloc(void *ptr, size_t size); #define realloc z_realloc + #if KERNEL_VERSION_NUMBER >= 0x40100 + /* Zephyr >= 4.1 removed CONFIG_NET_SOCKETS_POSIX_NAMES and the + * corresponding macro block in . + * Define our own compile-time remapping to zsock_* so that wolfSSL + * always calls Zephyr's network stack directly, avoiding host-libc + * symbol conflicts on native_sim. */ + #define socket zsock_socket + #define bind zsock_bind + #define connect zsock_connect + #define listen zsock_listen + #define accept zsock_accept + #define send zsock_send + #define recv zsock_recv + #define sendto zsock_sendto + #define recvfrom zsock_recvfrom + #define setsockopt zsock_setsockopt + #define getsockopt zsock_getsockopt + #define shutdown zsock_shutdown + #define close zsock_close + #define poll zsock_poll + #define getpeername zsock_getpeername + #define getsockname zsock_getsockname + #define inet_pton zsock_inet_pton + #define inet_ntop zsock_inet_ntop + #else + /* Zephyr < 4.1: define CONFIG_NET_SOCKETS_POSIX_NAMES so that + * provides the POSIX name remapping macros. */ #if !defined(CONFIG_NET_SOCKETS_POSIX_NAMES) && !defined(CONFIG_POSIX_API) #define CONFIG_NET_SOCKETS_POSIX_NAMES #endif + #endif #endif /* WOLFSSL_ZEPHYR */ #ifdef WOLFSSL_IMX6 diff --git a/zephyr/samples/wolfssl_benchmark/CMakeLists.txt b/zephyr/samples/wolfssl_benchmark/CMakeLists.txt index 1b68e1bfb7c..417295e640f 100644 --- a/zephyr/samples/wolfssl_benchmark/CMakeLists.txt +++ b/zephyr/samples/wolfssl_benchmark/CMakeLists.txt @@ -1,4 +1,24 @@ cmake_minimum_required(VERSION 3.13.1) + +# Select version-specific Kconfig fragment before loading Zephyr +if(EXISTS $ENV{ZEPHYR_BASE}/VERSION) + file(READ $ENV{ZEPHYR_BASE}/VERSION zephyr_version_file) + string(REGEX MATCH "VERSION_MAJOR = ([0-9]+)" _ ${zephyr_version_file}) + set(ZEPHYR_VER_MAJOR ${CMAKE_MATCH_1}) + string(REGEX MATCH "VERSION_MINOR = ([0-9]+)" _ ${zephyr_version_file}) + set(ZEPHYR_VER_MINOR ${CMAKE_MATCH_1}) +endif() + +if(ZEPHYR_VER_MAJOR GREATER_EQUAL 4 OR + (ZEPHYR_VER_MAJOR EQUAL 3 AND + ZEPHYR_VER_MINOR GREATER 5)) + set(EXTRA_CONF_FILE + ${CMAKE_CURRENT_SOURCE_DIR}/zephyr_v4.1.conf) +else() + set(EXTRA_CONF_FILE + ${CMAKE_CURRENT_SOURCE_DIR}/zephyr_legacy.conf) +endif() + find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) project(wolfssl_benchmark) diff --git a/zephyr/samples/wolfssl_benchmark/prj.conf b/zephyr/samples/wolfssl_benchmark/prj.conf index 01798802494..b542c63b63b 100644 --- a/zephyr/samples/wolfssl_benchmark/prj.conf +++ b/zephyr/samples/wolfssl_benchmark/prj.conf @@ -2,12 +2,6 @@ CONFIG_MAIN_STACK_SIZE=32768 CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE=8192 -# Pthreads -CONFIG_PTHREAD_IPC=y - -# Clock for time() -CONFIG_POSIX_CLOCK=y - # TLS configuration CONFIG_WOLFSSL=y CONFIG_WOLFSSL_BUILTIN=y diff --git a/zephyr/samples/wolfssl_benchmark/zephyr_legacy.conf b/zephyr/samples/wolfssl_benchmark/zephyr_legacy.conf new file mode 100644 index 00000000000..ab3026748b6 --- /dev/null +++ b/zephyr/samples/wolfssl_benchmark/zephyr_legacy.conf @@ -0,0 +1,3 @@ +# Zephyr < 4.1 POSIX options +CONFIG_PTHREAD_IPC=y +CONFIG_POSIX_CLOCK=y diff --git a/zephyr/samples/wolfssl_benchmark/zephyr_v4.1.conf b/zephyr/samples/wolfssl_benchmark/zephyr_v4.1.conf new file mode 100644 index 00000000000..23383009c5a --- /dev/null +++ b/zephyr/samples/wolfssl_benchmark/zephyr_v4.1.conf @@ -0,0 +1,2 @@ +# Zephyr >= 4.1 POSIX options +CONFIG_POSIX_API=y diff --git a/zephyr/samples/wolfssl_test/CMakeLists.txt b/zephyr/samples/wolfssl_test/CMakeLists.txt index bae4c165472..7b9d4e9f0cd 100644 --- a/zephyr/samples/wolfssl_test/CMakeLists.txt +++ b/zephyr/samples/wolfssl_test/CMakeLists.txt @@ -1,4 +1,24 @@ cmake_minimum_required(VERSION 3.13.1) + +# Select version-specific Kconfig fragment before loading Zephyr +if(EXISTS $ENV{ZEPHYR_BASE}/VERSION) + file(READ $ENV{ZEPHYR_BASE}/VERSION zephyr_version_file) + string(REGEX MATCH "VERSION_MAJOR = ([0-9]+)" _ ${zephyr_version_file}) + set(ZEPHYR_VER_MAJOR ${CMAKE_MATCH_1}) + string(REGEX MATCH "VERSION_MINOR = ([0-9]+)" _ ${zephyr_version_file}) + set(ZEPHYR_VER_MINOR ${CMAKE_MATCH_1}) +endif() + +if(ZEPHYR_VER_MAJOR GREATER_EQUAL 4 OR + (ZEPHYR_VER_MAJOR EQUAL 3 AND + ZEPHYR_VER_MINOR GREATER 5)) + set(EXTRA_CONF_FILE + ${CMAKE_CURRENT_SOURCE_DIR}/zephyr_v4.1.conf) +else() + set(EXTRA_CONF_FILE + ${CMAKE_CURRENT_SOURCE_DIR}/zephyr_legacy.conf) +endif() + find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) project(wolfssl_test) diff --git a/zephyr/samples/wolfssl_test/prj-no-malloc.conf b/zephyr/samples/wolfssl_test/prj-no-malloc.conf index 42f98d431d6..e9ff7cf801d 100644 --- a/zephyr/samples/wolfssl_test/prj-no-malloc.conf +++ b/zephyr/samples/wolfssl_test/prj-no-malloc.conf @@ -2,12 +2,6 @@ CONFIG_MAIN_STACK_SIZE=655360 #CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE=65536 -# Pthreads -CONFIG_PTHREAD_IPC=y - -# Clock for time() -CONFIG_POSIX_CLOCK=y - # TLS configuration CONFIG_WOLFSSL_SETTINGS_FILE="user_settings-no-malloc.h" CONFIG_WOLFSSL=y diff --git a/zephyr/samples/wolfssl_test/prj.conf b/zephyr/samples/wolfssl_test/prj.conf index 38b1ce49b4f..215a93c49cf 100644 --- a/zephyr/samples/wolfssl_test/prj.conf +++ b/zephyr/samples/wolfssl_test/prj.conf @@ -2,12 +2,6 @@ CONFIG_MAIN_STACK_SIZE=32768 CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE=16384 -# Pthreads -CONFIG_PTHREAD_IPC=y - -# Clock for time() -CONFIG_POSIX_CLOCK=y - # TLS configuration CONFIG_WOLFSSL=y CONFIG_WOLFSSL_BUILTIN=y diff --git a/zephyr/samples/wolfssl_test/zephyr_legacy.conf b/zephyr/samples/wolfssl_test/zephyr_legacy.conf new file mode 100644 index 00000000000..ab3026748b6 --- /dev/null +++ b/zephyr/samples/wolfssl_test/zephyr_legacy.conf @@ -0,0 +1,3 @@ +# Zephyr < 4.1 POSIX options +CONFIG_PTHREAD_IPC=y +CONFIG_POSIX_CLOCK=y diff --git a/zephyr/samples/wolfssl_test/zephyr_v4.1.conf b/zephyr/samples/wolfssl_test/zephyr_v4.1.conf new file mode 100644 index 00000000000..23383009c5a --- /dev/null +++ b/zephyr/samples/wolfssl_test/zephyr_v4.1.conf @@ -0,0 +1,2 @@ +# Zephyr >= 4.1 POSIX options +CONFIG_POSIX_API=y diff --git a/zephyr/samples/wolfssl_tls_thread/CMakeLists.txt b/zephyr/samples/wolfssl_tls_thread/CMakeLists.txt index 55c2199ec56..db4254566ed 100644 --- a/zephyr/samples/wolfssl_tls_thread/CMakeLists.txt +++ b/zephyr/samples/wolfssl_tls_thread/CMakeLists.txt @@ -1,4 +1,24 @@ cmake_minimum_required(VERSION 3.13.1) + +# Select version-specific Kconfig fragment before loading Zephyr +if(EXISTS $ENV{ZEPHYR_BASE}/VERSION) + file(READ $ENV{ZEPHYR_BASE}/VERSION zephyr_version_file) + string(REGEX MATCH "VERSION_MAJOR = ([0-9]+)" _ ${zephyr_version_file}) + set(ZEPHYR_VER_MAJOR ${CMAKE_MATCH_1}) + string(REGEX MATCH "VERSION_MINOR = ([0-9]+)" _ ${zephyr_version_file}) + set(ZEPHYR_VER_MINOR ${CMAKE_MATCH_1}) +endif() + +if(ZEPHYR_VER_MAJOR GREATER_EQUAL 4 OR + (ZEPHYR_VER_MAJOR EQUAL 3 AND + ZEPHYR_VER_MINOR GREATER 5)) + set(EXTRA_CONF_FILE + ${CMAKE_CURRENT_SOURCE_DIR}/zephyr_v4.1.conf) +else() + set(EXTRA_CONF_FILE + ${CMAKE_CURRENT_SOURCE_DIR}/zephyr_legacy.conf) +endif() + find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) project(wolfssl_tls_threaded) diff --git a/zephyr/samples/wolfssl_tls_thread/prj.conf b/zephyr/samples/wolfssl_tls_thread/prj.conf index 185a7b24c07..6fb19d3aa9f 100644 --- a/zephyr/samples/wolfssl_tls_thread/prj.conf +++ b/zephyr/samples/wolfssl_tls_thread/prj.conf @@ -5,12 +5,6 @@ CONFIG_TEST_RANDOM_GENERATOR=y CONFIG_INIT_STACKS=y CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE=131072 -# Pthreads -CONFIG_PTHREAD_IPC=y - -# Clock for time() -CONFIG_POSIX_CLOCK=y - # Networking CONFIG_NETWORKING=y CONFIG_NET_TEST=y diff --git a/zephyr/samples/wolfssl_tls_thread/zephyr_legacy.conf b/zephyr/samples/wolfssl_tls_thread/zephyr_legacy.conf new file mode 100644 index 00000000000..ab3026748b6 --- /dev/null +++ b/zephyr/samples/wolfssl_tls_thread/zephyr_legacy.conf @@ -0,0 +1,3 @@ +# Zephyr < 4.1 POSIX options +CONFIG_PTHREAD_IPC=y +CONFIG_POSIX_CLOCK=y diff --git a/zephyr/samples/wolfssl_tls_thread/zephyr_v4.1.conf b/zephyr/samples/wolfssl_tls_thread/zephyr_v4.1.conf new file mode 100644 index 00000000000..23383009c5a --- /dev/null +++ b/zephyr/samples/wolfssl_tls_thread/zephyr_v4.1.conf @@ -0,0 +1,2 @@ +# Zephyr >= 4.1 POSIX options +CONFIG_POSIX_API=y From 7739266bfab2b5584cc9638714d9370e7bd6aa07 Mon Sep 17 00:00:00 2001 From: night1rider Date: Tue, 17 Feb 2026 00:20:56 -0700 Subject: [PATCH 10/11] Utilize overlay config instead of extra conf file argument in cmakelist files --- zephyr/samples/wolfssl_benchmark/CMakeLists.txt | 4 ++-- zephyr/samples/wolfssl_test/CMakeLists.txt | 4 ++-- zephyr/samples/wolfssl_tls_sock/CMakeLists.txt | 4 ++-- zephyr/samples/wolfssl_tls_thread/CMakeLists.txt | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/zephyr/samples/wolfssl_benchmark/CMakeLists.txt b/zephyr/samples/wolfssl_benchmark/CMakeLists.txt index 417295e640f..7dadb8e37e2 100644 --- a/zephyr/samples/wolfssl_benchmark/CMakeLists.txt +++ b/zephyr/samples/wolfssl_benchmark/CMakeLists.txt @@ -12,10 +12,10 @@ endif() if(ZEPHYR_VER_MAJOR GREATER_EQUAL 4 OR (ZEPHYR_VER_MAJOR EQUAL 3 AND ZEPHYR_VER_MINOR GREATER 5)) - set(EXTRA_CONF_FILE + set(OVERLAY_CONFIG ${CMAKE_CURRENT_SOURCE_DIR}/zephyr_v4.1.conf) else() - set(EXTRA_CONF_FILE + set(OVERLAY_CONFIG ${CMAKE_CURRENT_SOURCE_DIR}/zephyr_legacy.conf) endif() diff --git a/zephyr/samples/wolfssl_test/CMakeLists.txt b/zephyr/samples/wolfssl_test/CMakeLists.txt index 7b9d4e9f0cd..5ddf1b9a87d 100644 --- a/zephyr/samples/wolfssl_test/CMakeLists.txt +++ b/zephyr/samples/wolfssl_test/CMakeLists.txt @@ -12,10 +12,10 @@ endif() if(ZEPHYR_VER_MAJOR GREATER_EQUAL 4 OR (ZEPHYR_VER_MAJOR EQUAL 3 AND ZEPHYR_VER_MINOR GREATER 5)) - set(EXTRA_CONF_FILE + set(OVERLAY_CONFIG ${CMAKE_CURRENT_SOURCE_DIR}/zephyr_v4.1.conf) else() - set(EXTRA_CONF_FILE + set(OVERLAY_CONFIG ${CMAKE_CURRENT_SOURCE_DIR}/zephyr_legacy.conf) endif() diff --git a/zephyr/samples/wolfssl_tls_sock/CMakeLists.txt b/zephyr/samples/wolfssl_tls_sock/CMakeLists.txt index 258d5bf9738..bdd894eda79 100644 --- a/zephyr/samples/wolfssl_tls_sock/CMakeLists.txt +++ b/zephyr/samples/wolfssl_tls_sock/CMakeLists.txt @@ -12,10 +12,10 @@ endif() if(ZEPHYR_VER_MAJOR GREATER_EQUAL 4 OR (ZEPHYR_VER_MAJOR EQUAL 3 AND ZEPHYR_VER_MINOR GREATER 5)) - set(EXTRA_CONF_FILE + set(OVERLAY_CONFIG ${CMAKE_CURRENT_SOURCE_DIR}/zephyr_v4.1.conf) else() - set(EXTRA_CONF_FILE + set(OVERLAY_CONFIG ${CMAKE_CURRENT_SOURCE_DIR}/zephyr_legacy.conf) endif() diff --git a/zephyr/samples/wolfssl_tls_thread/CMakeLists.txt b/zephyr/samples/wolfssl_tls_thread/CMakeLists.txt index db4254566ed..ec2d0a53926 100644 --- a/zephyr/samples/wolfssl_tls_thread/CMakeLists.txt +++ b/zephyr/samples/wolfssl_tls_thread/CMakeLists.txt @@ -12,10 +12,10 @@ endif() if(ZEPHYR_VER_MAJOR GREATER_EQUAL 4 OR (ZEPHYR_VER_MAJOR EQUAL 3 AND ZEPHYR_VER_MINOR GREATER 5)) - set(EXTRA_CONF_FILE + set(OVERLAY_CONFIG ${CMAKE_CURRENT_SOURCE_DIR}/zephyr_v4.1.conf) else() - set(EXTRA_CONF_FILE + set(OVERLAY_CONFIG ${CMAKE_CURRENT_SOURCE_DIR}/zephyr_legacy.conf) endif() From bc392ea79a36889b8d214584502208ab9a56f4e2 Mon Sep 17 00:00:00 2001 From: night1rider Date: Tue, 17 Feb 2026 01:06:27 -0700 Subject: [PATCH 11/11] Remove unneeded remaps --- wolfssl/wolfcrypt/settings.h | 9 +++++---- wolfssl/wolfio.h | 5 +++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/wolfssl/wolfcrypt/settings.h b/wolfssl/wolfcrypt/settings.h index dd5aef88f25..494373f763c 100644 --- a/wolfssl/wolfcrypt/settings.h +++ b/wolfssl/wolfcrypt/settings.h @@ -2668,12 +2668,13 @@ extern void uITRON4_free(void *p) ; #define setsockopt zsock_setsockopt #define getsockopt zsock_getsockopt #define shutdown zsock_shutdown - #define close zsock_close - #define poll zsock_poll #define getpeername zsock_getpeername #define getsockname zsock_getsockname - #define inet_pton zsock_inet_pton - #define inet_ntop zsock_inet_ntop + /* Note: close, poll, inet_pton, inet_ntop are NOT remapped here. + * They are general POSIX functions still declared in Zephyr's POSIX + * headers; redefining them conflicts with __syscall declarations in + * . close is handled via CloseSocket in wolfio.h, + * inet_pton/inet_ntop via XINET_PTON/XINET_NTOP in wolfio.h. */ #else /* Zephyr < 4.1: define CONFIG_NET_SOCKETS_POSIX_NAMES so that * provides the POSIX name remapping macros. */ diff --git a/wolfssl/wolfio.h b/wolfssl/wolfio.h index d170e217e38..4d9e53be382 100644 --- a/wolfssl/wolfio.h +++ b/wolfssl/wolfio.h @@ -639,6 +639,11 @@ WOLFSSL_API int wolfIO_RecvFrom(SOCKET_T sd, WOLFSSL_BIO_ADDR *addr, char *buf, #define CloseSocket(s) closesocket(s) #endif #define StartTCP() WC_DO_NOTHING +#elif defined(WOLFSSL_ZEPHYR) && KERNEL_VERSION_NUMBER >= 0x40100 + #ifndef CloseSocket + #define CloseSocket(s) zsock_close(s) + #endif + #define StartTCP() WC_DO_NOTHING #else #ifndef CloseSocket #define CloseSocket(s) close(s)