mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-15 17:43:51 +01:00
cpu/native: move syscalls into separate header
This commit is contained in:
parent
54d51b448c
commit
cf54187b7c
@ -68,6 +68,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "syscalls.h"
|
||||
/**
|
||||
* Prototype for native's internal callbacks
|
||||
*/
|
||||
@ -89,77 +90,6 @@ void _native_syscall_enter(void);
|
||||
void _native_init_syscalls(void);
|
||||
|
||||
/**
|
||||
* external functions regularly wrapped in native for direct use
|
||||
*/
|
||||
extern ssize_t (*real_read)(int fd, void *buf, size_t count);
|
||||
extern ssize_t (*real_write)(int fd, const void *buf, size_t count);
|
||||
extern off_t (*real_lseek)(int fd, off_t offset, int whence);
|
||||
extern off_t (*real_fstat)(int fd, struct stat *statbuf);
|
||||
extern int (*real_statvfs)(const char *restrict path, struct statvfs *restrict buf);
|
||||
extern int (*real_fsync)(int fd);
|
||||
extern size_t (*real_fread)(void *ptr, size_t size, size_t nmemb, FILE *stream);
|
||||
extern void (*real_clearerr)(FILE *stream);
|
||||
extern __attribute__((noreturn)) void (*real_exit)(int status);
|
||||
extern void (*real_free)(void *ptr);
|
||||
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);
|
||||
extern void (*real_freeaddrinfo)(struct addrinfo *res);
|
||||
extern void (*real_freeifaddrs)(struct ifaddrs *ifa);
|
||||
extern void (*real_srandom)(unsigned int seed);
|
||||
/* 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, ...);
|
||||
extern int (*real_connect)(int socket, ...);
|
||||
extern ssize_t (*real_recv)(int sockfd, void *buf, size_t len, int flags);
|
||||
extern int (*real_chdir)(const char *path);
|
||||
extern int (*real_close)(int);
|
||||
extern int (*real_fcntl)(int, int, ...);
|
||||
/* The ... is a hack to save includes: */
|
||||
extern int (*real_creat)(const char *path, ...);
|
||||
extern int (*real_dup2)(int, int);
|
||||
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_getifaddrs)(struct ifaddrs **ifap);
|
||||
extern int (*real_getpid)(void);
|
||||
extern int (*real_gettimeofday)(struct timeval *t, ...);
|
||||
extern int (*real_ioctl)(int fildes, unsigned long request, ...);
|
||||
extern int (*real_listen)(int socket, int backlog);
|
||||
extern int (*real_open)(const char *path, int oflag, ...);
|
||||
extern int (*real_mkdir)(const char *pathname, mode_t mode);
|
||||
extern int (*real_rmdir)(const char *pathname);
|
||||
extern DIR *(*real_opendir)(const char *name);
|
||||
extern struct dirent *(*real_readdir)(DIR *dirp);
|
||||
extern int (*real_closedir)(DIR *dirp);
|
||||
extern int (*real_pause)(void);
|
||||
extern int (*real_pipe)(int[2]);
|
||||
/* The ... is a hack to save includes: */
|
||||
extern int (*real_select)(int nfds, ...);
|
||||
extern int (*real_poll)(struct pollfd *nfds, ...);
|
||||
extern int (*real_setitimer)(int which, const struct itimerval
|
||||
*__restrict value, struct itimerval *__restrict ovalue);
|
||||
extern int (*real_setsid)(void);
|
||||
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 int (*real_rename)(const char *, const char *);
|
||||
extern long int (*real_random)(void);
|
||||
extern const char* (*real_gai_strerror)(int errcode);
|
||||
extern FILE* (*real_fopen)(const char *path, const char *mode);
|
||||
extern int (*real_fclose)(FILE *stream);
|
||||
extern int (*real_fseek)(FILE *stream, long offset, int whence);
|
||||
extern long (*real_ftell)(FILE *stream);
|
||||
extern int (*real_fputc)(int c, FILE *stream);
|
||||
extern int (*real_fgetc)(FILE *stream);
|
||||
extern mode_t (*real_umask)(mode_t cmask);
|
||||
extern ssize_t (*real_writev)(int fildes, const struct iovec *iov, int iovcnt);
|
||||
extern ssize_t (*real_send)(int sockfd, const void *buf, size_t len, int flags);
|
||||
|
||||
/**
|
||||
* data structures
|
||||
|
||||
118
cpu/native/include/syscalls.h
Normal file
118
cpu/native/include/syscalls.h
Normal file
@ -0,0 +1,118 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Ludwig Knüpfer <ludwig.knuepfer@fu-berlin.de>
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU Lesser
|
||||
* General Public License v2.1. See the file LICENSE in the top level
|
||||
* directory for more details.
|
||||
*/
|
||||
|
||||
#ifndef SYSCALLS_H
|
||||
#define SYSCALLS_H
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <stdint.h>
|
||||
#include <ifaddrs.h>
|
||||
#include <stdio.h>
|
||||
|
||||
/**
|
||||
* @addtogroup cpu_native
|
||||
* @{
|
||||
*/
|
||||
|
||||
#ifndef DOXYGEN
|
||||
# if NATIVE_SYSCALLS_DEFINITION
|
||||
# define __SPECIFIER
|
||||
# else
|
||||
# define __SPECIFIER extern
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* MARK: - System call wrappers */
|
||||
/** @cond */
|
||||
/**
|
||||
* @name System call wrappers
|
||||
*
|
||||
* Internally, these function pointers are assigned their implementation in the standard library.
|
||||
* We wrap system calls and syscall-invoking library calls to ensure **no context switches occur during a system call**.
|
||||
* @{
|
||||
*/
|
||||
__SPECIFIER ssize_t (*real_read)(int fd, void *buf, size_t count);
|
||||
__SPECIFIER ssize_t (*real_write)(int fd, const void *buf, size_t count);
|
||||
__SPECIFIER size_t (*real_fread)(void *ptr, size_t size, size_t nmemb, FILE *stream);
|
||||
__SPECIFIER ssize_t (*real_recv)(int sockfd, void *buf, size_t len, int flags);
|
||||
__SPECIFIER void (*real_clearerr)(FILE *stream);
|
||||
__SPECIFIER __attribute__((noreturn)) void (*real_exit)(int status);
|
||||
__SPECIFIER void (*real_free)(void *ptr);
|
||||
__SPECIFIER void* (*real_malloc)(size_t size);
|
||||
__SPECIFIER void* (*real_calloc)(size_t nmemb, size_t size);
|
||||
__SPECIFIER void* (*real_realloc)(void *ptr, size_t size);
|
||||
__SPECIFIER void (*real_freeaddrinfo)(struct addrinfo *res);
|
||||
__SPECIFIER void (*real_freeifaddrs)(struct ifaddrs *ifa);
|
||||
__SPECIFIER void (*real_srandom)(unsigned int seed);
|
||||
__SPECIFIER int (*real_accept)(int socket, ...);
|
||||
__SPECIFIER int (*real_bind)(int socket, ...);
|
||||
__SPECIFIER int (*real_connect)(int socket, ...);
|
||||
__SPECIFIER int (*real_printf)(const char *format, ...);
|
||||
__SPECIFIER int (*real_getaddrinfo)(const char *node, ...);
|
||||
__SPECIFIER int (*real_getifaddrs)(struct ifaddrs **ifap);
|
||||
__SPECIFIER int (*real_gettimeofday)(struct timeval *t, ...);
|
||||
__SPECIFIER int (*real_getpid)(void);
|
||||
__SPECIFIER int (*real_chdir)(const char *path);
|
||||
__SPECIFIER int (*real_close)(int);
|
||||
__SPECIFIER int (*real_fcntl)(int, int, ...);
|
||||
__SPECIFIER int (*real_creat)(const char *path, ...);
|
||||
__SPECIFIER int (*real_dup2)(int, int);
|
||||
__SPECIFIER int (*real_execve)(const char *, char *const[], char *const[]);
|
||||
__SPECIFIER int (*real_fork)(void);
|
||||
__SPECIFIER int (*real_feof)(FILE *stream);
|
||||
__SPECIFIER int (*real_ferror)(FILE *stream);
|
||||
__SPECIFIER int (*real_listen)(int socket, int backlog);
|
||||
__SPECIFIER int (*real_ioctl)(int fildes, unsigned long request, ...);
|
||||
__SPECIFIER int (*real_open)(const char *path, int oflag, ...);
|
||||
__SPECIFIER int (*real_pause)(void);
|
||||
__SPECIFIER int (*real_pipe)(int[2]);
|
||||
__SPECIFIER int (*real_select)(int nfds, ...);
|
||||
__SPECIFIER int (*real_poll)(struct pollfd *fds, ...);
|
||||
__SPECIFIER int (*real_setsid)(void);
|
||||
__SPECIFIER int (*real_setsockopt)(int socket, ...);
|
||||
__SPECIFIER int (*real_socket)(int domain, int type, int protocol);
|
||||
__SPECIFIER int (*real_unlink)(const char *);
|
||||
__SPECIFIER long int (*real_random)(void);
|
||||
__SPECIFIER const char* (*real_gai_strerror)(int errcode);
|
||||
__SPECIFIER FILE* (*real_fopen)(const char *path, const char *mode);
|
||||
__SPECIFIER int (*real_fclose)(FILE *stream);
|
||||
__SPECIFIER int (*real_fseek)(FILE *stream, long offset, int whence);
|
||||
__SPECIFIER long (*real_ftell)(FILE *stream);
|
||||
__SPECIFIER int (*real_fputc)(int c, FILE *stream);
|
||||
__SPECIFIER int (*real_fgetc)(FILE *stream);
|
||||
__SPECIFIER mode_t (*real_umask)(mode_t cmask);
|
||||
__SPECIFIER ssize_t (*real_writev)(int fildes, const struct iovec *iov, int iovcnt);
|
||||
__SPECIFIER ssize_t (*real_send)(int sockfd, const void *buf, size_t len, int flags);
|
||||
__SPECIFIER off_t (*real_lseek)(int fd, off_t offset, int whence);
|
||||
__SPECIFIER off_t (*real_fstat)(int fd, struct stat *statbuf);
|
||||
__SPECIFIER int (*real_fsync)(int fd);
|
||||
__SPECIFIER int (*real_mkdir)(const char *pathname, mode_t mode);
|
||||
__SPECIFIER int (*real_rmdir)(const char *pathname);
|
||||
__SPECIFIER DIR *(*real_opendir)(const char *name);
|
||||
__SPECIFIER struct dirent *(*real_readdir)(DIR *dirp);
|
||||
__SPECIFIER int (*real_closedir)(DIR *dirp);
|
||||
__SPECIFIER int (*real_rename)(const char *, const char *);
|
||||
__SPECIFIER int (*real_statvfs)(const char *restrict path, struct statvfs *restrict buf);
|
||||
/** @}*/
|
||||
/** @endcond */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(DOXYGEN)
|
||||
# undef __SPECIFIER
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
||||
#endif /* SYSCALLS_H */
|
||||
@ -46,73 +46,13 @@
|
||||
#include "stdio_base.h"
|
||||
|
||||
#include "kernel_defines.h"
|
||||
/* This header defines the system call function pointers */
|
||||
#define NATIVE_SYSCALLS_DEFINITION 1
|
||||
#include "native_internal.h"
|
||||
|
||||
#define ENABLE_DEBUG 0
|
||||
#include "debug.h"
|
||||
|
||||
ssize_t (*real_read)(int fd, void *buf, size_t count);
|
||||
ssize_t (*real_write)(int fd, const void *buf, size_t count);
|
||||
size_t (*real_fread)(void *ptr, size_t size, size_t nmemb, FILE *stream);
|
||||
ssize_t (*real_recv)(int sockfd, void *buf, size_t len, int flags);
|
||||
void (*real_clearerr)(FILE *stream);
|
||||
__attribute__((noreturn)) void (*real_exit)(int status);
|
||||
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);
|
||||
void (*real_freeifaddrs)(struct ifaddrs *ifa);
|
||||
void (*real_srandom)(unsigned int seed);
|
||||
int (*real_accept)(int socket, ...);
|
||||
int (*real_bind)(int socket, ...);
|
||||
int (*real_connect)(int socket, ...);
|
||||
int (*real_printf)(const char *format, ...);
|
||||
int (*real_getaddrinfo)(const char *node, ...);
|
||||
int (*real_getifaddrs)(struct ifaddrs **ifap);
|
||||
int (*real_gettimeofday)(struct timeval *t, ...);
|
||||
int (*real_getpid)(void);
|
||||
int (*real_chdir)(const char *path);
|
||||
int (*real_close)(int);
|
||||
int (*real_fcntl)(int, int, ...);
|
||||
int (*real_creat)(const char *path, ...);
|
||||
int (*real_dup2)(int, int);
|
||||
int (*real_execve)(const char *, char *const[], char *const[]);
|
||||
int (*real_fork)(void);
|
||||
int (*real_feof)(FILE *stream);
|
||||
int (*real_ferror)(FILE *stream);
|
||||
int (*real_listen)(int socket, int backlog);
|
||||
int (*real_ioctl)(int fildes, unsigned long request, ...);
|
||||
int (*real_open)(const char *path, int oflag, ...);
|
||||
int (*real_pause)(void);
|
||||
int (*real_pipe)(int[2]);
|
||||
int (*real_select)(int nfds, ...);
|
||||
int (*real_poll)(struct pollfd *fds, ...);
|
||||
int (*real_setsid)(void);
|
||||
int (*real_setsockopt)(int socket, ...);
|
||||
int (*real_socket)(int domain, int type, int protocol);
|
||||
int (*real_unlink)(const char *);
|
||||
long int (*real_random)(void);
|
||||
const char* (*real_gai_strerror)(int errcode);
|
||||
FILE* (*real_fopen)(const char *path, const char *mode);
|
||||
int (*real_fclose)(FILE *stream);
|
||||
int (*real_fseek)(FILE *stream, long offset, int whence);
|
||||
long (*real_ftell)(FILE *stream);
|
||||
int (*real_fputc)(int c, FILE *stream);
|
||||
int (*real_fgetc)(FILE *stream);
|
||||
mode_t (*real_umask)(mode_t cmask);
|
||||
ssize_t (*real_writev)(int fildes, const struct iovec *iov, int iovcnt);
|
||||
ssize_t (*real_send)(int sockfd, const void *buf, size_t len, int flags);
|
||||
off_t (*real_lseek)(int fd, off_t offset, int whence);
|
||||
off_t (*real_fstat)(int fd, struct stat *statbuf);
|
||||
int (*real_fsync)(int fd);
|
||||
int (*real_mkdir)(const char *pathname, mode_t mode);
|
||||
int (*real_rmdir)(const char *pathname);
|
||||
DIR *(*real_opendir)(const char *name);
|
||||
struct dirent *(*real_readdir)(DIR *dirp);
|
||||
int (*real_closedir)(DIR *dirp);
|
||||
int (*real_rename)(const char *, const char *);
|
||||
int (*real_statvfs)(const char *restrict path, struct statvfs *restrict buf);
|
||||
|
||||
void _native_syscall_enter(void)
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user