19 #ifndef NATIVE_INTERNAL_H
20 #define NATIVE_INTERNAL_H
29 #if (defined(__FreeBSD__) || defined(__MACH__))
37 #elif defined(__linux__)
68 void native_cpu_init(
void);
69 void native_interrupt_init(
void);
71 void native_irq_handler(
void);
72 extern void _native_sig_leave_tramp(
void);
73 extern void _native_sig_leave_handler(
void);
75 void _native_syscall_leave(
void);
76 void _native_syscall_enter(
void);
77 void _native_init_syscalls(
void);
82 extern ssize_t (*real_read)(
int fd,
void *buf,
size_t count);
83 extern ssize_t (*real_write)(
int fd,
const void *buf,
size_t count);
84 extern size_t (*real_fread)(
void *ptr,
size_t size,
size_t nmemb, FILE *stream);
85 extern void (*real_clearerr)(FILE *stream);
86 extern __attribute__((noreturn)) void (*real_exit)(
int status);
87 extern void (*real_free)(
void *ptr);
88 extern void* (*real_calloc)(
size_t nmemb,
size_t size);
89 extern void* (*real_malloc)(
size_t size);
90 extern void* (*real_realloc)(
void *ptr,
size_t size);
91 extern void (*real_freeaddrinfo)(
struct addrinfo *res);
92 extern void (*real_freeifaddrs)(
struct ifaddrs *ifa);
93 extern void (*real_srandom)(
unsigned int seed);
95 extern int (*real_accept)(
int socket, ...);
97 extern int (*real_bind)(
int socket, ...);
98 extern int (*real_connect)(
int socket, ...);
99 extern int (*real_chdir)(
const char *path);
100 extern int (*real_close)(int);
101 extern int (*real_fcntl)(int, int, ...);
103 extern int (*real_creat)(
const char *path, ...);
104 extern int (*real_dup2)(int, int);
105 extern int (*real_execve)(
const char *,
char *
const[],
char *
const[]);
106 extern int (*real_feof)(FILE *stream);
107 extern int (*real_ferror)(FILE *stream);
108 extern int (*real_fork)(void);
110 extern int (*real_getaddrinfo)(
const char *node, ...);
111 extern int (*real_getifaddrs)(
struct ifaddrs **ifap);
112 extern int (*real_getpid)(void);
113 extern int (*real_gettimeofday)(
struct timeval *t, ...);
114 extern int (*real_ioctl)(
int fildes,
int request, ...);
115 extern int (*real_listen)(
int socket,
int backlog);
116 extern int (*real_open)(
const char *path,
int oflag, ...);
117 extern int (*real_pause)(void);
118 extern int (*real_pipe)(
int[2]);
120 extern int (*real_select)(
int nfds, ...);
121 extern int (*real_poll)(
struct pollfd *nfds, ...);
122 extern int (*real_setitimer)(
int which,
const struct itimerval
123 *__restrict value,
struct itimerval *__restrict ovalue);
124 extern int (*real_setsid)(void);
125 extern int (*real_setsockopt)(
int socket, ...);
126 extern int (*real_socket)(
int domain,
int type,
int protocol);
127 extern int (*real_printf)(
const char *format, ...);
128 extern int (*real_unlink)(
const char *);
129 extern long int (*real_random)(void);
130 extern const char* (*real_gai_strerror)(
int errcode);
131 extern FILE* (*real_fopen)(
const char *path,
const char *mode);
132 extern int (*real_fclose)(FILE *stream);
133 extern int (*real_fseek)(FILE *stream,
long offset,
int whence);
134 extern int (*real_fputc)(
int c, FILE *stream);
135 extern int (*real_fgetc)(FILE *stream);
136 extern mode_t (*real_umask)(mode_t cmask);
137 extern ssize_t (*real_writev)(
int fildes,
const struct iovec *iov,
int iovcnt);
141 extern int (*real_clock_gettime)(clockid_t clk_id,
struct timespec *tp);
147 extern volatile int native_interrupts_enabled;
148 extern volatile unsigned int _native_saved_eip;
149 extern int _sig_pipefd[2];
150 extern volatile int _native_sigpend;
151 extern volatile int _native_in_isr;
152 extern volatile int _native_in_syscall;
154 extern char __isr_stack[SIGSTKSZ];
155 extern char __end_stack[SIGSTKSZ];
156 extern ucontext_t native_isr_context;
157 extern ucontext_t end_context;
158 extern ucontext_t *_native_cur_ctx, *_native_isr_ctx;
160 extern const char *_progname;
161 extern char **_native_argv;
162 extern pid_t _native_pid;
163 extern pid_t _native_id;
164 extern unsigned _native_rng_seed;
165 extern int _native_rng_mode;
166 extern const char *_native_unix_socket_path;
168 ssize_t _native_read(
int fd,
void *buf,
size_t count);
169 ssize_t _native_write(
int fd,
const void *buf,
size_t count);
170 ssize_t _native_writev(
int fildes,
const struct iovec *iov,
int iovcnt);