1 /*
2  * Copyright (c) 2023 Nordic Semiconductor ASA
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  *
6  * The native simulator provides a set of trampolines to some of the simplest
7  * host C library symbols.
8  * These are intended to facilitate test embedded code interacting with the host.
9  *
10  * We should never include here symbols which require host headers be exposed
11  * to the embedded side, for example due to non-basic types being used in
12  * function calls, as that would break the include path isolation
13  *
14  * Naming convention: nsi_host_<fun>() where <func> is the name of the equivalent
15  * C library function we call through
16  */
17 
18 #ifndef NSI_COMMON_SRC_INCL_NSI_HOST_TRAMPOLINES_H
19 #define NSI_COMMON_SRC_INCL_NSI_HOST_TRAMPOLINES_H
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
25 void *nsi_host_calloc(unsigned long nmemb, unsigned long size);
26 int nsi_host_close(int fd);
27 /* void nsi_host_exit (int status); Use nsi_exit() instead */
28 void nsi_host_free(void *ptr);
29 char *nsi_host_getcwd(char *buf, unsigned long size);
30 char *nsi_host_getenv(const char *name);
31 int nsi_host_isatty(int fd);
32 void *nsi_host_malloc(unsigned long size);
33 int nsi_host_open(const char *pathname, int flags);
34 /* int nsi_host_printf (const char *fmt, ...); Use the nsi_tracing.h equivalents */
35 long nsi_host_random(void);
36 long nsi_host_read(int fd, void *buffer, unsigned long size);
37 void *nsi_host_realloc(void *ptr, unsigned long size);
38 int nsi_host_setenv(const char *name, const char *value, int overwrite);
39 void nsi_host_srandom(unsigned int seed);
40 char *nsi_host_strdup(const char *s);
41 long nsi_host_write(int fd, const void *buffer, unsigned long size);
42 
43 #ifdef __cplusplus
44 }
45 #endif
46 
47 #endif /* NSI_COMMON_SRC_INCL_NSI_HOST_TRAMPOLINES_H */
48