syscalls.h
1 /*
2  * Copyright (C) 2013 Ludwig Knüpfer <ludwig.knuepfer@fu-berlin.de>
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
9 #ifndef SYSCALLS_H
10 #define SYSCALLS_H
11 
12 #include <sys/time.h>
13 #include <stdint.h>
14 #include <ifaddrs.h>
15 #include <stdio.h>
16 
22 #ifndef DOXYGEN
23 # if NATIVE_SYSCALLS_DEFINITION
24 # define __SPECIFIER
25 # else
26 # define __SPECIFIER extern
27 # endif
28 #endif
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 /* MARK: - System call wrappers */
43 __SPECIFIER ssize_t (*real_read)(int fd, void *buf, size_t count);
44 __SPECIFIER ssize_t (*real_write)(int fd, const void *buf, size_t count);
45 __SPECIFIER size_t (*real_fread)(void *ptr, size_t size, size_t nmemb, FILE *stream);
46 __SPECIFIER ssize_t (*real_recv)(int sockfd, void *buf, size_t len, int flags);
47 __SPECIFIER void (*real_clearerr)(FILE *stream);
48 __SPECIFIER __attribute__((noreturn)) void (*real_exit)(int status);
49 __SPECIFIER void (*real_free)(void *ptr);
50 __SPECIFIER void* (*real_malloc)(size_t size);
51 __SPECIFIER void* (*real_calloc)(size_t nmemb, size_t size);
52 __SPECIFIER void* (*real_realloc)(void *ptr, size_t size);
53 __SPECIFIER void (*real_freeaddrinfo)(struct addrinfo *res);
54 __SPECIFIER void (*real_freeifaddrs)(struct ifaddrs *ifa);
55 __SPECIFIER void (*real_srandom)(unsigned int seed);
56 __SPECIFIER int (*real_accept)(int socket, ...);
57 __SPECIFIER int (*real_bind)(int socket, ...);
58 __SPECIFIER int (*real_connect)(int socket, ...);
59 __SPECIFIER int (*real_printf)(const char *format, ...);
60 __SPECIFIER int (*real_getaddrinfo)(const char *node, ...);
61 __SPECIFIER int (*real_getifaddrs)(struct ifaddrs **ifap);
62 __SPECIFIER int (*real_gettimeofday)(struct timeval *t, ...);
63 __SPECIFIER int (*real_getpid)(void);
64 __SPECIFIER int (*real_chdir)(const char *path);
65 __SPECIFIER int (*real_close)(int);
66 __SPECIFIER int (*real_fcntl)(int, int, ...);
67 __SPECIFIER int (*real_creat)(const char *path, ...);
68 __SPECIFIER int (*real_dup2)(int, int);
69 __SPECIFIER int (*real_execve)(const char *, char *const[], char *const[]);
70 __SPECIFIER int (*real_fork)(void);
71 __SPECIFIER int (*real_feof)(FILE *stream);
72 __SPECIFIER int (*real_ferror)(FILE *stream);
73 __SPECIFIER int (*real_listen)(int socket, int backlog);
74 __SPECIFIER int (*real_ioctl)(int fildes, unsigned long request, ...);
75 __SPECIFIER int (*real_open)(const char *path, int oflag, ...);
76 __SPECIFIER int (*real_pause)(void);
77 __SPECIFIER int (*real_pipe)(int[2]);
78 __SPECIFIER int (*real_select)(int nfds, ...);
79 __SPECIFIER int (*real_poll)(struct pollfd *fds, ...);
80 __SPECIFIER int (*real_setsid)(void);
81 __SPECIFIER int (*real_setsockopt)(int socket, ...);
82 __SPECIFIER int (*real_socket)(int domain, int type, int protocol);
83 __SPECIFIER int (*real_unlink)(const char *);
84 __SPECIFIER long int (*real_random)(void);
85 __SPECIFIER const char* (*real_gai_strerror)(int errcode);
86 __SPECIFIER FILE* (*real_fopen)(const char *path, const char *mode);
87 __SPECIFIER int (*real_fclose)(FILE *stream);
88 __SPECIFIER int (*real_fseek)(FILE *stream, long offset, int whence);
89 __SPECIFIER long (*real_ftell)(FILE *stream);
90 __SPECIFIER int (*real_fputc)(int c, FILE *stream);
91 __SPECIFIER int (*real_fgetc)(FILE *stream);
92 __SPECIFIER mode_t (*real_umask)(mode_t cmask);
93 __SPECIFIER ssize_t (*real_writev)(int fildes, const struct iovec *iov, int iovcnt);
94 __SPECIFIER ssize_t (*real_send)(int sockfd, const void *buf, size_t len, int flags);
95 __SPECIFIER off_t (*real_lseek)(int fd, off_t offset, int whence);
96 __SPECIFIER off_t (*real_fstat)(int fd, struct stat *statbuf);
97 __SPECIFIER int (*real_fsync)(int fd);
98 __SPECIFIER int (*real_mkdir)(const char *pathname, mode_t mode);
99 __SPECIFIER int (*real_rmdir)(const char *pathname);
100 __SPECIFIER DIR *(*real_opendir)(const char *name);
101 __SPECIFIER struct dirent *(*real_readdir)(DIR *dirp);
102 __SPECIFIER int (*real_closedir)(DIR *dirp);
103 __SPECIFIER int (*real_rename)(const char *, const char *);
104 __SPECIFIER int (*real_statvfs)(const char *restrict path, struct statvfs *restrict buf);
108 #ifdef __cplusplus
109 }
110 #endif
111 
112 #if !defined(DOXYGEN)
113 # undef __SPECIFIER
114 #endif
115 
118 #endif /* SYSCALLS_H */
int socket(int domain, int type, int protocol)
Create an endpoint for communication.
stdio wrapper to extend the C libs stdio
Structure for scatter/gather I/O.
Definition: uio.h:33
File system information.
Definition: statvfs.h:46
Definition of struct timeval for the atmega.
Definition: time.h:23