1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

native: add more syscall declarations

This commit is contained in:
Ludwig Ortmann 2014-11-14 20:52:17 +01:00
parent a1b530a98d
commit acaa6481cb
3 changed files with 26 additions and 8 deletions

View File

@ -106,24 +106,24 @@ int init_tcp_socket(char *tcpport)
hints.ai_socktype = SOCK_STREAM;
hints.ai_flags = AI_PASSIVE;
if ((i = getaddrinfo(NULL, tcpport, &hints, &info)) != 0) {
if ((i = real_getaddrinfo(NULL, tcpport, &hints, &info)) != 0) {
errx(EXIT_FAILURE,
"init_uart_socket: getaddrinfo: %s", gai_strerror(i));
"init_uart_socket: getaddrinfo: %s", real_gai_strerror(i));
}
for (p = info; p != NULL; p = p->ai_next) {
if ((s = socket(p->ai_family, p->ai_socktype, p->ai_protocol)) == -1) {
if ((s = real_socket(p->ai_family, p->ai_socktype, p->ai_protocol)) == -1) {
warn("init_uart_socket: socket");
continue;
}
i = 1;
if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &i, sizeof(int)) == -1) {
if (real_setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &i, sizeof(int)) == -1) {
err(EXIT_FAILURE, "init_uart_socket: setsockopt");
}
if (real_bind(s, p->ai_addr, p->ai_addrlen) == -1) {
close(s);
real_close(s);
warn("init_uart_socket: bind");
continue;
}
@ -133,7 +133,7 @@ int init_tcp_socket(char *tcpport)
if (p == NULL) {
errx(EXIT_FAILURE, "init_uart_socket: failed to bind\n");
}
freeaddrinfo(info);
real_freeaddrinfo(info);
if (real_listen(s, 1) == -1) {
err(EXIT_FAILURE, "init_uart_socket: listen");
@ -147,7 +147,7 @@ int init_unix_socket(void)
int s;
struct sockaddr_un sa;
if ((s = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) {
if ((s = real_socket(AF_UNIX, SOCK_STREAM, 0)) == -1) {
err(EXIT_FAILURE, "init_unix_socket: socket");
}

View File

@ -43,6 +43,7 @@
#include <ucontext.h>
#endif
#endif // BSD/Linux
#include <netdb.h>
#include "kernel_types.h"
@ -78,6 +79,8 @@ extern void* (*real_calloc)(size_t nmemb, size_t size);
extern void* (*real_malloc)(size_t size);
extern void* (*real_realloc)(void *ptr, size_t size);
/* The ... is a hack to save includes: */
extern void (*real_freeaddrinfo)(struct addrinfo *res);
/* The ... is a hack to save includes: */
extern int (*real_accept)(int socket, ...);
/* The ... is a hack to save includes: */
extern int (*real_bind)(int socket, ...);
@ -87,12 +90,17 @@ extern int (*real_execve)(const char *, char *const[], char *const[]);
extern int (*real_feof)(FILE *stream);
extern int (*real_ferror)(FILE *stream);
extern int (*real_fork)(void);
/* The ... is a hack to save includes: */
extern int (*real_getaddrinfo)(const char *node, ...);
extern int (*real_getpid)(void);
extern int (*real_listen)(int socket, int backlog);
extern int (*real_pause)(void);
extern int (*real_pipe)(int[2]);
extern int (*real_setsockopt)(int socket, ...);
extern int (*real_socket)(int domain, int type, int protocol);
extern int (*real_printf)(const char *format, ...);
extern int (*real_unlink)(const char *);
extern const char* (*real_gai_strerror)(int errcode);
extern FILE* (*real_fopen)(const char *path, const char *mode);
/**

View File

@ -55,11 +55,12 @@ void (*real_free)(void *ptr);
void* (*real_malloc)(size_t size);
void* (*real_calloc)(size_t nmemb, size_t size);
void* (*real_realloc)(void *ptr, size_t size);
void (*real_freeaddrinfo)(struct addrinfo *res);
int (*real_accept)(int socket, ...);
int (*real_bind)(int socket, ...);
int (*real_printf)(const char *format, ...);
int (*real_getaddrinfo)(const char *node, ...);
int (*real_getpid)(void);
int (*real_pipe)(int[2]);
int (*real_close)(int);
int (*real_dup2)(int, int);
int (*real_execve)(const char *, char *const[], char *const[]);
@ -68,7 +69,11 @@ int (*real_feof)(FILE *stream);
int (*real_ferror)(FILE *stream);
int (*real_listen)(int socket, int backlog);
int (*real_pause)(void);
int (*real_pipe)(int[2]);
int (*real_setsockopt)(int socket, ...);
int (*real_socket)(int domain, int type, int protocol);
int (*real_unlink)(const char *);
const char* (*real_gai_strerror)(int errcode);
FILE* (*real_fopen)(const char *path, const char *mode);
void _native_syscall_enter(void)
@ -356,14 +361,19 @@ void _native_init_syscalls(void)
*(void **)(&real_malloc) = dlsym(RTLD_NEXT, "malloc");
*(void **)(&real_realloc) = dlsym(RTLD_NEXT, "realloc");
*(void **)(&real_free) = dlsym(RTLD_NEXT, "free");
*(void **)(&real_freeaddrinfo) = dlsym(RTLD_NEXT, "freeaddrinfo");
*(void **)(&real_accept) = dlsym(RTLD_NEXT, "accept");
*(void **)(&real_bind) = dlsym(RTLD_NEXT, "bind");
*(void **)(&real_printf) = dlsym(RTLD_NEXT, "printf");
*(void **)(&real_gai_strerror) = dlsym(RTLD_NEXT, "gai_strerror");
*(void **)(&real_getaddrinfo) = dlsym(RTLD_NEXT, "getaddrinfo");
*(void **)(&real_getpid) = dlsym(RTLD_NEXT, "getpid");
*(void **)(&real_pipe) = dlsym(RTLD_NEXT, "pipe");
*(void **)(&real_close) = dlsym(RTLD_NEXT, "close");
*(void **)(&real_fork) = dlsym(RTLD_NEXT, "fork");
*(void **)(&real_dup2) = dlsym(RTLD_NEXT, "dup2");
*(void **)(&real_setsockopt) = dlsym(RTLD_NEXT, "setsockopt");
*(void **)(&real_socket) = dlsym(RTLD_NEXT, "socket");
*(void **)(&real_unlink) = dlsym(RTLD_NEXT, "unlink");
*(void **)(&real_execve) = dlsym(RTLD_NEXT, "execve");
*(void **)(&real_listen) = dlsym(RTLD_NEXT, "listen");