From 71cc0cfd80b004b3c9b89a7dc62377871f4a4986 Mon Sep 17 00:00:00 2001 From: cpq Date: Tue, 23 Dec 2025 12:23:23 +0000 Subject: [PATCH] Zephyr nits --- .github/workflows/zephyr.yml | 2 +- mongoose.c | 9 +++++++++ mongoose.h | 9 ++++++--- src/arch_zephyr.h | 9 ++++++--- src/util.c | 9 +++++++++ 5 files changed, 31 insertions(+), 7 deletions(-) diff --git a/.github/workflows/zephyr.yml b/.github/workflows/zephyr.yml index cd4e8c6e..ca56b41b 100644 --- a/.github/workflows/zephyr.yml +++ b/.github/workflows/zephyr.yml @@ -10,7 +10,7 @@ jobs: strategy: fail-fast: false matrix: - revno: ["--mr v3.7-branch", "--mr v4.2.0"] # LTS, latest stable + revno: ["--mr v3.7-branch", "--mr v4.2.0", "--mr v4.3.0"] # LTS, latest stable name: Zephyr ${{ matrix.revno }} steps: - uses: actions/checkout@v4 diff --git a/mongoose.c b/mongoose.c index d41b5fc7..1c58fa9e 100644 --- a/mongoose.c +++ b/mongoose.c @@ -21460,6 +21460,15 @@ bool mg_random(void *buf, size_t len) { #elif MG_ARCH == MG_ARCH_PICOSDK while (len--) *p++ = (unsigned char) (get_rand_32() & 255); success = true; +#elif MG_ARCH == MG_ARCH_ZEPHYR +#if MG_TLS == MG_TLS_BUILTIN || \ + (MG_TLS == MG_TLS_MBED && (!defined(MBEDTLS_VERSION_NUMBER) || \ + MBEDTLS_VERSION_NUMBER < 0x04000000)) + return (sys_csrand_get(buf, len) == 0); // do not fallback on reseed error +#else + sys_rand_get(buf, len); + success = true; +#endif #elif MG_ARCH == MG_ARCH_WIN32 #if defined(_MSC_VER) && _MSC_VER < 1700 static bool initialised = false; diff --git a/mongoose.h b/mongoose.h index b4492bff..8843814d 100644 --- a/mongoose.h +++ b/mongoose.h @@ -723,12 +723,15 @@ typedef int socklen_t; #include #include - -#include -#include #include +//#include #include #include +#include + + +#include +#include #include #include #include diff --git a/src/arch_zephyr.h b/src/arch_zephyr.h index 321a83dd..7865133f 100644 --- a/src/arch_zephyr.h +++ b/src/arch_zephyr.h @@ -4,12 +4,15 @@ #include #include - -#include -#include #include +//#include #include #include +#include + + +#include +#include #include #include #include diff --git a/src/util.c b/src/util.c index a99d7efa..3df83065 100644 --- a/src/util.c +++ b/src/util.c @@ -27,6 +27,15 @@ bool mg_random(void *buf, size_t len) { #elif MG_ARCH == MG_ARCH_PICOSDK while (len--) *p++ = (unsigned char) (get_rand_32() & 255); success = true; +#elif MG_ARCH == MG_ARCH_ZEPHYR +#if MG_TLS == MG_TLS_BUILTIN || \ + (MG_TLS == MG_TLS_MBED && (!defined(MBEDTLS_VERSION_NUMBER) || \ + MBEDTLS_VERSION_NUMBER < 0x04000000)) + return (sys_csrand_get(buf, len) == 0); // do not fallback on reseed error +#else + sys_rand_get(buf, len); + success = true; +#endif #elif MG_ARCH == MG_ARCH_WIN32 #if defined(_MSC_VER) && _MSC_VER < 1700 static bool initialised = false; -- 2.43.0