native_simulator: Align with upstream latest with more trampolines

Upstream SHA: be3eac6931b49291e51da5d5aa1a99ab58f81541

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
This commit is contained in:
Alberto Escolar Piedras 2023-07-05 16:45:38 +02:00 committed by Carles Cufí
commit e9721db183
4 changed files with 66 additions and 1 deletions

View file

@ -10,6 +10,8 @@
NSI_CONFIG_FILE?=nsi_config NSI_CONFIG_FILE?=nsi_config
-include ${NSI_CONFIG_FILE} -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_PATH?=./
NSI_BUILD_PATH?=$(abspath _build/) NSI_BUILD_PATH?=$(abspath _build/)

View file

@ -22,10 +22,20 @@
extern "C" { extern "C" {
#endif #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_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 */ /* int nsi_host_printf (const char *fmt, ...); Use the nsi_tracing.h equivalents */
long nsi_host_random(void); long nsi_host_random(void);
long nsi_host_read(int fd, void *buffer, unsigned long size);
void nsi_host_srandom(unsigned int seed); 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 #ifdef __cplusplus
} }

View file

@ -7,13 +7,66 @@
*/ */
#include <stdlib.h> #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) long nsi_host_random(void)
{ {
return random(); 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) void nsi_host_srandom(unsigned int seed)
{ {
srandom(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);
}

View file

@ -42,7 +42,7 @@ extern "C" {
* The function must take no parameters and return nothing. * The function must take no parameters and return nothing.
*/ */
#define NSI_TASK(fn, level, prio) \ #define NSI_TASK(fn, level, prio) \
static void (* const NSI_CONCAT(__nsi_task_, fn))() \ static void (* const NSI_CONCAT(__nsi_task_, fn))(void) \
__attribute__((__used__)) \ __attribute__((__used__)) \
__attribute__((__section__(".nsi_" #level NSI_STRINGIFY(prio) "_task")))\ __attribute__((__section__(".nsi_" #level NSI_STRINGIFY(prio) "_task")))\
= fn = fn