Skip to content

Commit e47c696

Browse files
committed
Change the inclusion checking, bump heap amount when using native sim, reposition sys/types.h, and add missing macros to tracking list.
Update benchmark app for native sim to use a sleep function for the timer, and remove timer for waiting on server and instead use a share variable both threads can access.
1 parent 00ada28 commit e47c696

10 files changed

Lines changed: 36 additions & 86 deletions

File tree

.wolfssl_known_macro_extras

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ CONFIG_ARCH_TEGRA
5656
CONFIG_ARM
5757
CONFIG_ARM64
5858
CONFIG_BOARD_NATIVE_POSIX
59+
CONFIG_BOARD_NATIVE_SIM
5960
CONFIG_COMPILER_OPTIMIZATION_DEFAULT
6061
CONFIG_COMPILER_OPTIMIZATION_NONE
6162
CONFIG_COMPILER_OPTIMIZATION_PERF
@@ -1098,11 +1099,8 @@ __clang_major__
10981099
__cplusplus
10991100
__ghc__
11001101
__ghs__
1101-
<<<<<<< HEAD
11021102
__has_attribute
1103-
=======
11041103
__has_include
1105-
>>>>>>> 9188ee19b (Add to macro list)
11061104
__hpux__
11071105
__i386
11081106
__i386__

wolfcrypt/benchmark/benchmark.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15934,7 +15934,11 @@ void bench_sphincsKeySign(byte level, byte optim)
1593415934
int64_t t;
1593515935
(void)reset;
1593615936
#if defined(CONFIG_ARCH_POSIX)
15937-
k_cpu_idle();
15937+
#if defined(CONFIG_BOARD_NATIVE_SIM)
15938+
k_msleep(1);
15939+
#else
15940+
k_cpu_idle();
15941+
#endif
1593815942
#endif
1593915943
t = k_uptime_get(); /* returns current uptime in milliseconds */
1594015944
return (double)(t / 1000);

wolfcrypt/src/random.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3457,6 +3457,8 @@ int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
34573457
#include <version.h>
34583458
#endif
34593459

3460+
#include <sys/types.h>
3461+
34603462
#if KERNEL_VERSION_NUMBER >= 0x30500
34613463
#include <zephyr/random/random.h>
34623464
#else
@@ -3467,14 +3469,12 @@ int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)
34673469
#endif
34683470
#endif
34693471

3470-
#ifndef _POSIX_C_SOURCE
3471-
#if KERNEL_VERSION_NUMBER >= 0x30100
3472-
#include <zephyr/posix/time.h>
3473-
#else
3474-
#include <posix/time.h>
3475-
#endif
3476-
#else
3472+
#if KERNEL_VERSION_NUMBER >= 0x40300
34773473
#include <time.h>
3474+
#elif KERNEL_VERSION_NUMBER >= 0x30100
3475+
#include <zephyr/posix/time.h>
3476+
#else
3477+
#include <posix/time.h>
34783478
#endif
34793479

34803480
int wc_GenerateSeed(OS_Seed* os, byte* output, word32 sz)

wolfssl/test.h

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -202,33 +202,10 @@
202202
#if KERNEL_VERSION_NUMBER >= 0x30100
203203
#include <zephyr/net/socket.h>
204204
#ifdef CONFIG_POSIX_API
205-
#ifdef __has_include
206-
#if __has_include(<zephyr/posix/poll.h>)
207-
#include <zephyr/posix/poll.h>
208-
#else
209-
#include <poll.h>
210-
#endif
211-
#if __has_include(<zephyr/posix/netdb.h>)
212-
#include <zephyr/posix/netdb.h>
213-
#else
214-
#include <netdb.h>
215-
#endif
216-
#if __has_include(<zephyr/posix/sys/socket.h>)
217-
#include <zephyr/posix/sys/socket.h>
218-
#else
219-
#include <sys/socket.h>
220-
#endif
221-
#if __has_include(<zephyr/posix/sys/select.h>)
222-
#include <zephyr/posix/sys/select.h>
223-
#else
224-
#include <sys/select.h>
225-
#endif
226-
#else
227-
#include <zephyr/posix/poll.h>
228-
#include <zephyr/posix/netdb.h>
229-
#include <zephyr/posix/sys/socket.h>
230-
#include <zephyr/posix/sys/select.h>
231-
#endif
205+
#include <zephyr/posix/poll.h>
206+
#include <zephyr/posix/netdb.h>
207+
#include <zephyr/posix/sys/socket.h>
208+
#include <zephyr/posix/sys/select.h>
232209
#endif
233210
#else
234211
#include <net/socket.h>

wolfssl/wolfcrypt/wc_port.h

Lines changed: 10 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -310,28 +310,18 @@
310310
#else
311311
#include <version.h>
312312
#endif
313+
/* Include sys/types.h early so host libc sets __timer_t_defined
314+
* before Zephyr's posix_types.h can define a conflicting timer_t */
315+
#include <sys/types.h>
313316
#ifndef SINGLE_THREADED
314317
#if !defined(CONFIG_PTHREAD_IPC) && !defined(CONFIG_POSIX_THREADS)
315318
#error "Threading needs CONFIG_PTHREAD_IPC / CONFIG_POSIX_THREADS"
316319
#endif
317320
#if KERNEL_VERSION_NUMBER >= 0x30100
318321
#include <zephyr/kernel.h>
319322
#ifndef CONFIG_ARCH_POSIX
320-
#ifdef __has_include
321-
#if __has_include(<zephyr/posix/posix_types.h>)
322-
#include <zephyr/posix/posix_types.h>
323-
#else
324-
#include <sys/types.h>
325-
#endif
326-
#if __has_include(<zephyr/posix/pthread.h>)
327-
#include <zephyr/posix/pthread.h>
328-
#else
329-
#include <pthread.h>
330-
#endif
331-
#else
332-
#include <zephyr/posix/posix_types.h>
333-
#include <zephyr/posix/pthread.h>
334-
#endif
323+
#include <zephyr/posix/posix_types.h>
324+
#include <zephyr/posix/pthread.h>
335325
#endif
336326
#else
337327
#include <kernel.h>
@@ -1530,31 +1520,12 @@ WOLFSSL_ABI WOLFSSL_API int wolfCrypt_Cleanup(void);
15301520
} /* extern "C" */
15311521
#endif
15321522

1533-
#ifdef __has_include
1534-
#if __has_include(<zephyr/version.h>)
1535-
#include <zephyr/version.h>
1536-
#else
1537-
#include <version.h>
1538-
#endif
1539-
#else
1540-
#include <version.h>
1541-
#endif
1542-
#ifndef _POSIX_C_SOURCE
1543-
#if KERNEL_VERSION_NUMBER >= 0x30100
1544-
#ifdef __has_include
1545-
#if __has_include(<zephyr/posix/time.h>)
1546-
#include <zephyr/posix/time.h>
1547-
#else
1548-
#include <time.h>
1549-
#endif
1550-
#else
1551-
#include <zephyr/posix/time.h>
1552-
#endif
1553-
#else
1554-
#include <posix/time.h>
1555-
#endif
1556-
#else
1523+
#if KERNEL_VERSION_NUMBER >= 0x40300
15571524
#include <time.h>
1525+
#elif KERNEL_VERSION_NUMBER >= 0x30100
1526+
#include <zephyr/posix/time.h>
1527+
#else
1528+
#include <posix/time.h>
15581529
#endif
15591530

15601531
#ifndef CLOCK_REALTIME

wolfssl/wolfio.h

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -192,15 +192,7 @@
192192
#if KERNEL_VERSION_NUMBER >= 0x30100
193193
#include <zephyr/net/socket.h>
194194
#ifdef CONFIG_POSIX_API
195-
#ifdef __has_include
196-
#if __has_include(<zephyr/posix/sys/socket.h>)
197-
#include <zephyr/posix/sys/socket.h>
198-
#else
199-
#include <sys/socket.h>
200-
#endif
201-
#else
202-
#include <zephyr/posix/sys/socket.h>
203-
#endif
195+
#include <zephyr/posix/sys/socket.h>
204196
#endif
205197
#else
206198
#include <net/socket.h>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# native_sim needs a larger malloc arena for thread stack allocation
2+
CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE=131072
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# native_sim needs a larger malloc arena for thread stack allocation
2+
CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE=131072
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# native_sim needs a larger malloc arena for thread stack allocation
2+
CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE=131072
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# native_sim needs a larger malloc arena for thread stack allocation
2+
CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE=131072

0 commit comments

Comments
 (0)