]> git.feebdaed.xyz Git - 0xmirror/mongoose.git/commitdiff
Zephyr nits
authorcpq <sergey.lyubka@cesanta.com>
Tue, 23 Dec 2025 12:23:23 +0000 (12:23 +0000)
committerSergio R. Caprile <scaprile@cesanta.com>
Tue, 23 Dec 2025 16:12:56 +0000 (13:12 -0300)
.github/workflows/zephyr.yml
mongoose.c
mongoose.h
src/arch_zephyr.h
src/util.c

index cd4e8c6e105813500c4a6e7c2b4c6d67024a3684..ca56b41b9962320c40f0728815b546f0a6776a0d 100644 (file)
@@ -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
index d41b5fc7af8043b03c7726eca5c89cc3ce3cd9a0..1c58fa9eb77ab56fd875b9e37bee44ce3da8945a 100644 (file)
@@ -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;
index b4492bff7abe235884f6bd40e3dd49903afb2fc9..8843814df941175c01202bc8fd6a28657927d929 100644 (file)
@@ -723,12 +723,15 @@ typedef int socklen_t;
 
 #include <zephyr/kernel.h>
 #include <zephyr/version.h>
-
-#include <ctype.h>
-#include <errno.h>
 #include <zephyr/net/socket.h>
+//#include <zephyr/posix/dirent.h>
 #include <zephyr/posix/fcntl.h>
 #include <zephyr/posix/sys/select.h>
+#include <zephyr/random/random.h>
+
+
+#include <ctype.h>
+#include <errno.h>
 #include <stdarg.h>
 #include <stdbool.h>
 #include <stdint.h>
index 321a83dddc880bb0b87324108a91d1c808ff7495..7865133f4b7cab64a05faf480f975096d1daadc2 100644 (file)
@@ -4,12 +4,15 @@
 
 #include <zephyr/kernel.h>
 #include <zephyr/version.h>
-
-#include <ctype.h>
-#include <errno.h>
 #include <zephyr/net/socket.h>
+//#include <zephyr/posix/dirent.h>
 #include <zephyr/posix/fcntl.h>
 #include <zephyr/posix/sys/select.h>
+#include <zephyr/random/random.h>
+
+
+#include <ctype.h>
+#include <errno.h>
 #include <stdarg.h>
 #include <stdbool.h>
 #include <stdint.h>
index a99d7efaeaa724a9e399f52d568129a93042d34b..3df83065def67f70f9b3d4d83ba05961414e3998 100644 (file)
@@ -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;