Skip to content

Commit

Permalink
native_simulator: Align with upstream latest with more trampolines
Browse files Browse the repository at this point in the history
Upstream SHA: 9990deecdaa11f78f7738ba1efa3de15a72d6418

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
  • Loading branch information
aescolar committed Jul 6, 2023
1 parent 235caf2 commit 6e53732
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 0 deletions.
2 changes: 2 additions & 0 deletions scripts/native_simulator/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

NSI_CONFIG_FILE?=nsi_config
-include ${NSI_CONFIG_FILE}
#If the file does not exist, we don't use it as a build dependency
NSI_CONFIG_FILE:=$(wildcard ${NSI_CONFIG_FILE})

NSI_PATH?=./
NSI_BUILD_PATH?=$(abspath _build/)
Expand Down
10 changes: 10 additions & 0 deletions scripts/native_simulator/common/src/include/nsi_host_trampolines.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,20 @@
extern "C" {
#endif

void *nsi_host_calloc(unsigned long nmemb, unsigned long size);
int nsi_host_close(int fd);
/* void nsi_host_exit (int status); Use nsi_exit() instead */
void nsi_host_free(void *ptr);
char *nsi_host_getcwd(char *buf, unsigned long size);
int nsi_host_isatty(int fd);
void *nsi_host_malloc(unsigned long size);
int nsi_host_open(const char *pathname, int flags);
/* int nsi_host_printf (const char *fmt, ...); Use the nsi_tracing.h equivalents */
long nsi_host_random(void);
long nsi_host_read(int fd, void *buffer, unsigned long size);
void nsi_host_srandom(unsigned int seed);
char *nsi_host_strdup(const char *s);
long nsi_host_write(int fd, void *buffer, unsigned long size);

#ifdef __cplusplus
}
Expand Down
53 changes: 53 additions & 0 deletions scripts/native_simulator/common/src/nsi_host_trampolines.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,66 @@
*/

#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

void *nsi_host_calloc(unsigned long nmemb, unsigned long size)
{
return calloc(nmemb, size);
}

int nsi_host_close(int fd)
{
return close(fd);
}

void nsi_host_free(void *ptr)
{
free(ptr);
}

char *nsi_host_getcwd(char *buf, unsigned long size)
{
return getcwd(buf, size);
}

int nsi_host_isatty(int fd)
{
return isatty(fd);
}

void *nsi_host_malloc(unsigned long size)
{
return malloc(size);
}

int nsi_host_open(const char *pathname, int flags)
{
return open(pathname, flags);
}

long nsi_host_random(void)
{
return random();
}

long nsi_host_read(int fd, void *buffer, unsigned long size)
{
return read(fd, buffer, size);
}

void nsi_host_srandom(unsigned int seed)
{
srandom(seed);
}

char *nsi_host_strdup(const char *s)
{
return strdup(s);
}

long nsi_host_write(int fd, void *buffer, unsigned long size)
{
return write(fd, buffer, size);
}

0 comments on commit 6e53732

Please sign in to comment.