blob: 723bdef88add335e4ca5a6ae3afb18e39af4df88 [file] [log] [blame]
#ifndef _IRT_SYSCALLS_H
#define _IRT_SYSCALLS_H
#include <sys/cdefs_elf.h>
#include <machine/cdefs.h>
#include <irt.h>
#include <string.h>
#include <sys/types.h>
#include <sys/epoll.h>
#include <sys/select.h>
#include <poll.h>
#include <stddef.h>
#include <fcntl.h>
#include <time.h>
#include <nacl_stat.h>
#ifdef weak_alias
#undef weak_alias
#endif
#define weak_alias(oldname, newname) \
extern typeof(oldname) newname __attribute__ ((weak, alias (#oldname)));
#ifdef libc_hidden_def
#undef libc_hidden_def
#endif
#define libc_hidden_def(x)
struct dirent;
struct epoll_event;
struct msghdr;
struct nacl_abi_stat;
struct sockaddr;
struct timespec;
struct timeval;
struct NaClMemMappingInfo;
typedef void (*nacl_start_func_t)(void);
#define socklen_t long
__BEGIN_DECLS
typedef struct {
size_t (*nacl_irt_query)(const char* interface_ident, void* table, size_t tablesize);
void (*nacl_irt_exit)(int status);
int (*nacl_irt_gettod)(struct timeval* tv);
int (*nacl_irt_clock)(clock_t* ticks);
int (*nacl_irt_nanosleep)(const struct timespec* req, struct timespec* rem);
int (*nacl_irt_sched_yield)(void);
int (*nacl_irt_sysconf)(int name, int* value);
int (*nacl_irt_mkdir)(const char* pathname, mode_t mode);
int (*nacl_irt_rmdir)(const char* pathname);
int (*nacl_irt_chdir)(const char* pathname);
int (*nacl_irt_getcwd)(char* buf, size_t size, int* len);
int (*nacl_irt_epoll_create)(int size, int* fd);
int (*nacl_irt_epoll_create1)(int flags, int* fd);
int (*nacl_irt_epoll_ctl)(int epfd, int op, int fd, struct epoll_event* event);
int (*nacl_irt_epoll_pwait)(int epfd, struct epoll_event* events, int maxevents, int timeout, const sigset_t* sigmask, size_t sigset_size, int* count);
int (*nacl_irt_epoll_wait)(int epfd, struct epoll_event* events, int maxevents, int timeout, int* count);
int (*nacl_irt_poll)(struct pollfd* fds, nfds_t nfds, int timeout, int* count);
int (*nacl_irt_ppoll)(struct pollfd* fds, nfds_t nfds, const struct timespec* timeout, const sigset_t* sigmask, size_t sigset_size, int* count);
int (*nacl_irt_socket)(int domain, int type, int protocol, int* sd);
int (*nacl_irt_accept)(int sockfd, struct sockaddr* addr, socklen_t* addrlen, int* sd);
int (*nacl_irt_bind)(int sockfd, const struct sockaddr* addr, socklen_t addrlen);
int (*nacl_irt_listen)(int sockfd, int backlog);
int (*nacl_irt_connect)(int sockfd, const struct sockaddr* addr, socklen_t addrlen);
int (*nacl_irt_send)(int sockfd, const void* buf, size_t len, int flags, int* count);
int (*nacl_irt_sendmsg)(int sockfd, const struct msghdr* msg, int flags, int* count);
int (*nacl_irt_sendto)(int sockfd, const void* buf, size_t len, int flags, const struct sockaddr* dest_addr, socklen_t addrlen, int* count);
int (*nacl_irt_recv)(int sockfd, void* buf, size_t len, int flags, int* count);
int (*nacl_irt_recvmsg)(int sockfd, struct msghdr* msg, int flags, int* count);
int (*nacl_irt_recvfrom)(int sockfd, void* buf, size_t len, int flags, struct sockaddr* dest_addr, socklen_t* addrlen, int* count);
int (*nacl_irt_select)(int nfds, fd_set* readfds, fd_set* writefds, fd_set* exceptfds, const struct timeval* timeout, int* count);
int (*nacl_irt_pselect)(int nfds, fd_set* readfds, fd_set* writefds, fd_set* exceptfds, const struct timeval* timeout, void* sigmask, int* count);
int (*nacl_irt_getpeername)(int sockfd, struct sockaddr* addr, socklen_t* addrlen);
int (*nacl_irt_getsockname)(int sockfd, struct sockaddr* addr, socklen_t* addrlen);
int (*nacl_irt_getsockopt)(int sockfd, int level, int optname, void* optval, socklen_t* optlen);
int (*nacl_irt_setsockopt)(int sockfd, int level, int optname, const void* optval, socklen_t optlen);
int (*nacl_irt_socketpair)(int domain, int type, int protocol, int sv[2]);
int (*nacl_irt_shutdown)(int sockfd, int how);
int (*nacl_irt_open)(const char* pathname, int oflag, mode_t cmode, int* newfd);
int (*nacl_irt_close)(int fd);
int (*nacl_irt_read)(int fd, void* buf, size_t count, size_t* nread);
int (*nacl_irt_write)(int fd, const void* buf, size_t count, size_t* nwrote);
int (*nacl_irt_seek)(int fd, nacl_abi_off_t offset, int whence, nacl_abi_off_t* new_offset);
int (*nacl_irt_dup)(int fd, int* newfd);
int (*nacl_irt_dup2)(int fd, int newfd);
int (*nacl_irt_fstat)(int fd, struct nacl_abi_stat* s);
int (*nacl_irt_stat)(const char* pathname, struct nacl_abi_stat* s);
int (*nacl_irt_getdents)(int fd, struct dirent* de, size_t count, size_t* nread);
int (*nacl_irt_sysbrk)(void** newbrk);
int (*nacl_irt_mmap)(void** addr, size_t len, int prot, int flags, int fd, nacl_abi_off_t off);
int (*nacl_irt_munmap)(void* addr, size_t len);
int (*nacl_irt_mprotect)(void* addr, size_t len, int prot);
int (*nacl_irt_dyncode_create)(void* dest, const void* src, size_t size);
int (*nacl_irt_dyncode_modify)(void* dest, const void* src, size_t size);
int (*nacl_irt_dyncode_delete)(void* dest, size_t size);
int (*nacl_irt_thread_create)(nacl_start_func_t start_func, void* stack, void* thread_ptr);
void (*nacl_irt_thread_exit)(int32_t* stack_flag);
int (*nacl_irt_thread_nice)(const int nice);
int (*nacl_irt_mutex_create)(int* mutex_handle);
int (*nacl_irt_mutex_destroy)(int mutex_handle);
int (*nacl_irt_mutex_lock)(int mutex_handle);
int (*nacl_irt_mutex_unlock)(int mutex_handle);
int (*nacl_irt_mutex_trylock)(int mutex_handle);
int (*nacl_irt_cond_create)(int* cond_handle);
int (*nacl_irt_cond_destroy)(int cond_handle);
int (*nacl_irt_cond_signal)(int cond_handle);
int (*nacl_irt_cond_broadcast)(int cond_handle);
int (*nacl_irt_cond_wait)(int cond_handle, int mutex_handle);
int (*nacl_irt_cond_timed_wait_abs)(int cond_handle, int mutex_handle, const struct timespec* abstime);
int (*nacl_irt_tls_init)(void* tdb);
void* (*nacl_irt_tls_get)(void);
int (*nacl_irt_open_resource)(const char* file, int* fd);
int (*nacl_irt_clock_getres)(clockid_t clk_id, struct timespec* res);
int (*nacl_irt_clock_gettime)(clockid_t clk_id, struct timespec* tp);
int (*nacl_irt_list_mappings)(struct NaClMemMappingInfo* regions, size_t count, size_t* result_count);
int (*nacl_irt_futex_wait_abs)(volatile int* addr, int value, const struct timespec* abstime);
int (*nacl_irt_futex_wake)(volatile int* addr, int nwake, int* count);
} _irt_syscalls_t;
// The loader passes _IRT_SYSCALL_PTR to the main program using this
// fixed address. 0x10030000 is reserved in the loaders space using
// the linker script. See linker/arch/nacl/gen_runnable_ld_lds.py.
#define _IRT_SYSCALL_PTR (*((_irt_syscalls_t**) 0x10030000))
#define __nacl_irt_query (_IRT_SYSCALL_PTR->nacl_irt_query)
#define __nacl_irt_exit (_IRT_SYSCALL_PTR->nacl_irt_exit)
#define __nacl_irt_gettod (_IRT_SYSCALL_PTR->nacl_irt_gettod)
#define __nacl_irt_clock (_IRT_SYSCALL_PTR->nacl_irt_clock)
#define __nacl_irt_nanosleep (_IRT_SYSCALL_PTR->nacl_irt_nanosleep)
#define __nacl_irt_sched_yield (_IRT_SYSCALL_PTR->nacl_irt_sched_yield)
#define __nacl_irt_sysconf (_IRT_SYSCALL_PTR->nacl_irt_sysconf)
#define __nacl_irt_mkdir (_IRT_SYSCALL_PTR->nacl_irt_mkdir)
#define __nacl_irt_rmdir (_IRT_SYSCALL_PTR->nacl_irt_rmdir)
#define __nacl_irt_chdir (_IRT_SYSCALL_PTR->nacl_irt_chdir)
#define __nacl_irt_getcwd (_IRT_SYSCALL_PTR->nacl_irt_getcwd)
#define __nacl_irt_epoll_create (_IRT_SYSCALL_PTR->nacl_irt_epoll_create)
#define __nacl_irt_epoll_create1 (_IRT_SYSCALL_PTR->nacl_irt_epoll_create1)
#define __nacl_irt_epoll_ctl (_IRT_SYSCALL_PTR->nacl_irt_epoll_ctl)
#define __nacl_irt_epoll_pwait (_IRT_SYSCALL_PTR->nacl_irt_epoll_pwait)
#define __nacl_irt_epoll_wait (_IRT_SYSCALL_PTR->nacl_irt_epoll_wait)
#define __nacl_irt_poll (_IRT_SYSCALL_PTR->nacl_irt_poll)
#define __nacl_irt_ppoll (_IRT_SYSCALL_PTR->nacl_irt_ppoll)
#define __nacl_irt_socket (_IRT_SYSCALL_PTR->nacl_irt_socket)
#define __nacl_irt_accept (_IRT_SYSCALL_PTR->nacl_irt_accept)
#define __nacl_irt_bind (_IRT_SYSCALL_PTR->nacl_irt_bind)
#define __nacl_irt_listen (_IRT_SYSCALL_PTR->nacl_irt_listen)
#define __nacl_irt_connect (_IRT_SYSCALL_PTR->nacl_irt_connect)
#define __nacl_irt_send (_IRT_SYSCALL_PTR->nacl_irt_send)
#define __nacl_irt_sendmsg (_IRT_SYSCALL_PTR->nacl_irt_sendmsg)
#define __nacl_irt_sendto (_IRT_SYSCALL_PTR->nacl_irt_sendto)
#define __nacl_irt_recv (_IRT_SYSCALL_PTR->nacl_irt_recv)
#define __nacl_irt_recvmsg (_IRT_SYSCALL_PTR->nacl_irt_recvmsg)
#define __nacl_irt_recvfrom (_IRT_SYSCALL_PTR->nacl_irt_recvfrom)
#define __nacl_irt_select (_IRT_SYSCALL_PTR->nacl_irt_select)
#define __nacl_irt_pselect (_IRT_SYSCALL_PTR->nacl_irt_pselect)
#define __nacl_irt_getpeername (_IRT_SYSCALL_PTR->nacl_irt_getpeername)
#define __nacl_irt_getsockname (_IRT_SYSCALL_PTR->nacl_irt_getsockname)
#define __nacl_irt_getsockopt (_IRT_SYSCALL_PTR->nacl_irt_getsockopt)
#define __nacl_irt_setsockopt (_IRT_SYSCALL_PTR->nacl_irt_setsockopt)
#define __nacl_irt_socketpair (_IRT_SYSCALL_PTR->nacl_irt_socketpair)
#define __nacl_irt_shutdown (_IRT_SYSCALL_PTR->nacl_irt_shutdown)
#define __nacl_irt_open (_IRT_SYSCALL_PTR->nacl_irt_open)
#define __nacl_irt_close (_IRT_SYSCALL_PTR->nacl_irt_close)
#define __nacl_irt_read (_IRT_SYSCALL_PTR->nacl_irt_read)
#define __nacl_irt_write (_IRT_SYSCALL_PTR->nacl_irt_write)
#define __nacl_irt_seek (_IRT_SYSCALL_PTR->nacl_irt_seek)
#define __nacl_irt_dup (_IRT_SYSCALL_PTR->nacl_irt_dup)
#define __nacl_irt_dup2 (_IRT_SYSCALL_PTR->nacl_irt_dup2)
#define __nacl_irt_fstat (_IRT_SYSCALL_PTR->nacl_irt_fstat)
#define __nacl_irt_stat (_IRT_SYSCALL_PTR->nacl_irt_stat)
#define __nacl_irt_getdents (_IRT_SYSCALL_PTR->nacl_irt_getdents)
#define __nacl_irt_sysbrk (_IRT_SYSCALL_PTR->nacl_irt_sysbrk)
#define __nacl_irt_mmap (_IRT_SYSCALL_PTR->nacl_irt_mmap)
#define __nacl_irt_munmap (_IRT_SYSCALL_PTR->nacl_irt_munmap)
#define __nacl_irt_mprotect (_IRT_SYSCALL_PTR->nacl_irt_mprotect)
#define __nacl_irt_dyncode_create (_IRT_SYSCALL_PTR->nacl_irt_dyncode_create)
#define __nacl_irt_dyncode_modify (_IRT_SYSCALL_PTR->nacl_irt_dyncode_modify)
#define __nacl_irt_dyncode_delete (_IRT_SYSCALL_PTR->nacl_irt_dyncode_delete)
#define __nacl_irt_thread_create (_IRT_SYSCALL_PTR->nacl_irt_thread_create)
#define __nacl_irt_thread_exit (_IRT_SYSCALL_PTR->nacl_irt_thread_exit)
#define __nacl_irt_thread_nice (_IRT_SYSCALL_PTR->nacl_irt_thread_nice)
#define __nacl_irt_mutex_create (_IRT_SYSCALL_PTR->nacl_irt_mutex_create)
#define __nacl_irt_mutex_destroy (_IRT_SYSCALL_PTR->nacl_irt_mutex_destroy)
#define __nacl_irt_mutex_lock (_IRT_SYSCALL_PTR->nacl_irt_mutex_lock)
#define __nacl_irt_mutex_unlock (_IRT_SYSCALL_PTR->nacl_irt_mutex_unlock)
#define __nacl_irt_mutex_trylock (_IRT_SYSCALL_PTR->nacl_irt_mutex_trylock)
#define __nacl_irt_cond_create (_IRT_SYSCALL_PTR->nacl_irt_cond_create)
#define __nacl_irt_cond_destroy (_IRT_SYSCALL_PTR->nacl_irt_cond_destroy)
#define __nacl_irt_cond_signal (_IRT_SYSCALL_PTR->nacl_irt_cond_signal)
#define __nacl_irt_cond_broadcast (_IRT_SYSCALL_PTR->nacl_irt_cond_broadcast)
#define __nacl_irt_cond_wait (_IRT_SYSCALL_PTR->nacl_irt_cond_wait)
#define __nacl_irt_cond_timed_wait_abs (_IRT_SYSCALL_PTR->nacl_irt_cond_timed_wait_abs)
#define __nacl_irt_tls_init (_IRT_SYSCALL_PTR->nacl_irt_tls_init)
#define __nacl_irt_tls_get (_IRT_SYSCALL_PTR->nacl_irt_tls_get)
#define __nacl_irt_open_resource (_IRT_SYSCALL_PTR->nacl_irt_open_resource)
#define __nacl_irt_clock_getres (_IRT_SYSCALL_PTR->nacl_irt_clock_getres)
#define __nacl_irt_clock_gettime (_IRT_SYSCALL_PTR->nacl_irt_clock_gettime)
#define __nacl_irt_list_mappings (_IRT_SYSCALL_PTR->nacl_irt_list_mappings)
#define __nacl_irt_futex_wait_abs (_IRT_SYSCALL_PTR->nacl_irt_futex_wait_abs)
#define __nacl_irt_futex_wake (_IRT_SYSCALL_PTR->nacl_irt_futex_wake)
__END_DECLS
#endif