Skip to content

Commit 5098a15

Browse files
committed
Added wrapper for memfd_create
1 parent 0cf60dc commit 5098a15

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

hal/sim.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include <stdio.h>
3030
#include <sys/mman.h>
3131
#include <sys/stat.h>
32+
#include <sys/syscall.h>
3233
#include <fcntl.h>
3334
#include <unistd.h>
3435
#include <errno.h>
@@ -87,6 +88,18 @@ uint32_t hal_sim_get_dualbank_state(void);
8788
char **main_argv;
8889
int main_argc;
8990

91+
static int sim_memfd_create(const char *name, unsigned int flags)
92+
{
93+
#if defined(__linux__) && defined(SYS_memfd_create)
94+
return (int)syscall(SYS_memfd_create, name, flags);
95+
#else
96+
(void)name;
97+
(void)flags;
98+
errno = ENOSYS;
99+
return -1;
100+
#endif
101+
}
102+
90103
#ifdef WOLFBOOT_ENABLE_WOLFHSM_CLIENT
91104

92105
/* Client configuration/contexts */
@@ -559,7 +572,7 @@ void do_boot(const uint32_t *app_offset)
559572
exit(0);
560573
#else
561574
char *envp[1] = {NULL};
562-
int fd = memfd_create("test_app", 0);
575+
int fd = sim_memfd_create("test_app", 0);
563576
size_t wret;
564577
if (fd == -1) {
565578
wolfBoot_printf( "memfd error\n");

0 commit comments

Comments
 (0)