From: nsz Date: Fri, 19 Oct 2012 22:18:26 +0000 (+0200) Subject: api: add stdarg .. sys/uio X-Git-Url: http://nsz.repo.hu/git/?p=libc-test;a=commitdiff_plain;h=f81126942f3b97eec5bdf2fb57a45579946be59d api: add stdarg .. sys/uio --- diff --git a/src/api/netdb.c b/src/api/netdb.c index c8b223c..40675af 100644 --- a/src/api/netdb.c +++ b/src/api/netdb.c @@ -89,3 +89,10 @@ void(*p_setnetent)(int) = setnetent; void(*p_setprotoent)(int) = setprotoent; void(*p_setservent)(int) = setservent; } +#include +static void g() +{ +void(*p_freeaddrinfo)(struct addrinfo*) = freeaddrinfo; +int(*p_getaddrinfo)(const char*restrict,const char*restrict,const struct addrinfo*restrict,struct addrinfo**restrict) = getaddrinfo; +int(*p_getnameinfo)(const struct sockaddr*restrict,socklen_t,char*restrict,socklen_t,char*restrict,socklen_t,int) = getnameinfo; +} diff --git a/src/api/stdarg.c b/src/api/stdarg.c new file mode 100644 index 0000000..7211594 --- /dev/null +++ b/src/api/stdarg.c @@ -0,0 +1,18 @@ +#include +#define T(t) (t*)0; +static void f() +{ +T(va_list) +#ifndef va_start +#error no va_start +#endif +#ifndef va_arg +#error no va_arg +#endif +#ifndef va_end +#error no va_end +#endif +#ifndef va_copy +#error no va_copy +#endif +} diff --git a/src/api/stdio.c b/src/api/stdio.c new file mode 100644 index 0000000..b854540 --- /dev/null +++ b/src/api/stdio.c @@ -0,0 +1,129 @@ +#include +#define T(t) (t*)0; +#define F(t,n) {t *y = &x.n;} +#define C(n) switch(n){case n:;} +static void f() +{ +T(FILE) +T(fpos_t) +T(off_t) +T(size_t) +C(BUFSIZ) +#ifdef _POSIX_C_SOURCE +T(ssize_t) +T(va_list) +C(L_ctermid) +#endif +C(_IOFBF) +C(_IOLBF) +C(_IONBF) +C(SEEK_CUR) +C(SEEK_END) +C(SEEK_SET) +C(FILENAME_MAX) +C(FOPEN_MAX) +C(EOF) +{void *x=NULL;} +{FILE *x=stderr;} +{FILE *x=stdin;} +{FILE *x=stdout;} +void(*p_clearerr)(FILE*) = clearerr; +char*(*p_ctermid)(char*) = ctermid; +int(*p_dprintf)(int,const char*restrict,...) = dprintf; +int(*p_fclose)(FILE*) = fclose; +FILE*(*p_fdopen)(int,const char*) = fdopen; +int(*p_feof)(FILE*) = feof; +int(*p_ferror)(FILE*) = ferror; +int(*p_fflush)(FILE*) = fflush; +int(*p_fgetc)(FILE*) = fgetc; +int(*p_fgetpos)(FILE*restrict,fpos_t*restrict) = fgetpos; +char*(*p_fgets)(char*restrict,int,FILE*restrict) = fgets; +int(*p_fileno)(FILE*) = fileno; +void(*p_flockfile)(FILE*) = flockfile; +FILE*(*p_fmemopen)(void*restrict,size_t,const char*restrict) = fmemopen; +FILE*(*p_fopen)(const char*restrict,const char*restrict) = fopen; +int(*p_fprintf)(FILE*restrict,const char*restrict,...) = fprintf; +int(*p_fputc)(int,FILE*) = fputc; +int(*p_fputs)(const char*restrict,FILE*restrict) = fputs; +size_t(*p_fread)(void*restrict,size_t,size_t,FILE*restrict) = fread; +FILE*(*p_freopen)(const char*restrict,const char*restrict,FILE*restrict) = freopen; +int(*p_fscanf)(FILE*restrict,const char*restrict,...) = fscanf; +int(*p_fseek)(FILE*,long,int) = fseek; +int(*p_fseeko)(FILE*,off_t,int) = fseeko; +int(*p_fsetpos)(FILE*,const fpos_t*) = fsetpos; +long(*p_ftell)(FILE*) = ftell; +off_t(*p_ftello)(FILE*) = ftello; +int(*p_ftrylockfile)(FILE*) = ftrylockfile; +void(*p_funlockfile)(FILE*) = funlockfile; +size_t(*p_fwrite)(const void*restrict,size_t,size_t,FILE*restrict) = fwrite; +int(*p_getc)(FILE*) = getc; +int(*p_getc_unlocked)(FILE*) = getc_unlocked; +int(*p_getchar)(void) = getchar; +int(*p_getchar_unlocked)(void) = getchar_unlocked; +ssize_t(*p_getdelim)(char**restrict,size_t*restrict,int,FILE*restrict) = getdelim; +ssize_t(*p_getline)(char**restrict,size_t*restrict,FILE*restrict) = getline; +char*(*p_gets)(char*) = gets; +FILE*(*p_open_memstream)(char**,size_t*) = open_memstream; +int(*p_pclose)(FILE*) = pclose; +void(*p_perror)(const char*) = perror; +FILE*(*p_popen)(const char*,const char*) = popen; +int(*p_printf)(const char*restrict,...) = printf; +int(*p_putc)(int,FILE*) = putc; +int(*p_putc_unlocked)(int,FILE*) = putc_unlocked; +int(*p_putchar)(int) = putchar; +int(*p_putchar_unlocked)(int) = putchar_unlocked; +int(*p_puts)(const char*) = puts; +int(*p_remove)(const char*) = remove; +int(*p_rename)(const char*,const char*) = rename; +int(*p_renameat)(int,const char*,int,const char*) = renameat; +void(*p_rewind)(FILE*) = rewind; +int(*p_scanf)(const char*restrict,...) = scanf; +void(*p_setbuf)(FILE*restrict,char*restrict) = setbuf; +int(*p_setvbuf)(FILE*restrict,char*restrict,int,size_t) = setvbuf; +int(*p_snprintf)(char*restrict,size_t,const char*restrict,...) = snprintf; +int(*p_sprintf)(char*restrict,const char*restrict,...) = sprintf; +int(*p_sscanf)(const char*restrict,const char*restrict,...) = sscanf; +char*(*p_tempnam)(const char*,const char*) = tempnam; +FILE*(*p_tmpfile)(void) = tmpfile; +char*(*p_tmpnam)(char*) = tmpnam; +int(*p_ungetc)(int,FILE*) = ungetc; +} +#include +static void g() +{ +wint_t(*p_btowc)(int) = btowc; +wint_t(*p_fgetwc)(FILE*) = fgetwc; +wchar_t*(*p_fgetws)(wchar_t*restrict,int,FILE*restrict) = fgetws; +wint_t(*p_fputwc)(wchar_t,FILE*) = fputwc; +int(*p_fputws)(const wchar_t*restrict,FILE*restrict) = fputws; +int(*p_fwide)(FILE*,int) = fwide; +int(*p_fwprintf)(FILE*restrict,const wchar_t*restrict,...) = fwprintf; +int(*p_fwscanf)(FILE*restrict,const wchar_t*restrict,...) = fwscanf; +wint_t(*p_getwc)(FILE*) = getwc; +wint_t(*p_putwc)(wchar_t,FILE*) = putwc; +int(*p_swprintf)(wchar_t*restrict,size_t,const wchar_t*restrict,...) = swprintf; +int(*p_swscanf)(const wchar_t*restrict,const wchar_t*restrict,...) = swscanf; +wint_t(*p_ungetwc)(wint_t,FILE*) = ungetwc; +int(*p_wctob)(wint_t) = wctob; +int(*p_wprintf)(const wchar_t*restrict,...) = wprintf; +int(*p_wscanf)(const wchar_t*restrict,...) = wscanf; +} +#include +static void h() +{ +int(*p_vdprintf)(int,const char*restrict,va_list) = vdprintf; +int(*p_vfprintf)(FILE*restrict,const char*restrict,va_list) = vfprintf; +int(*p_vfscanf)(FILE*restrict,const char*restrict,va_list) = vfscanf; +int(*p_vprintf)(const char*restrict,va_list) = vprintf; +int(*p_vscanf)(const char*restrict,va_list) = vscanf; +int(*p_vsnprintf)(char*restrict,size_t,const char*restrict,va_list) = vsnprintf; +int(*p_vsprintf)(char*restrict,const char*restrict,va_list) = vsprintf; +int(*p_vsscanf)(const char*restrict,const char*restrict,va_list) = vsscanf; + +int(*p_vfwprintf)(FILE*restrict,const wchar_t*restrict,va_list) = vfwprintf; +int(*p_vfwscanf)(FILE*restrict,const wchar_t*restrict,va_list) = vfwscanf; +int(*p_vswprintf)(wchar_t*restrict,size_t,const wchar_t*restrict,va_list) = vswprintf; +int(*p_vswscanf)(const wchar_t*restrict,const wchar_t*restrict,va_list) = vswscanf; +int(*p_vwprintf)(const wchar_t*restrict,va_list) = vwprintf; +int(*p_vwscanf)(const wchar_t*restrict,va_list) = vwscanf; +} diff --git a/src/api/stdlib.c b/src/api/stdlib.c new file mode 100644 index 0000000..ca5337c --- /dev/null +++ b/src/api/stdlib.c @@ -0,0 +1,103 @@ +#include +#define T(t) (t*)0; +#define F(t,n) {t *y = &x.n;} +#define C(n) switch(n){case n:;} +static void f() +{ +C(EXIT_FAILURE) +C(EXIT_SUCCESS) +C(RAND_MAX) +C(MB_CUR_MAX) +{void *x=NULL;} +T(div_t) +T(ldiv_t) +T(lldiv_t) +T(size_t) +T(wchar_t) +#ifdef _POSIX_C_SOURCE +C(WEXITSTATUS(0)) +C(WIFEXITED(0)) +C(WIFSIGNALED(0)) +C(WIFSTOPPED(0)) +C(WNOHANG) +C(WSTOPSIG(0)) +C(WTERMSIG(0)) +C(WUNTRACED) +#endif +void(*p__Exit)(int) = _Exit; +void(*p_abort)(void) = abort; +int(*p_abs)(int) = abs; +int(*p_atexit)(void(*)(void)) = atexit; +double(*p_atof)(const char*) = atof; +int(*p_atoi)(const char*) = atoi; +long(*p_atol)(const char*) = atol; +long long(*p_atoll)(const char*) = atoll; +void*(*p_bsearch)(const void*,const void*,size_t,size_t,int(*)(const void*,const void*)) = bsearch; +void*(*p_calloc)(size_t,size_t) = calloc; +div_t(*p_div)(int,int) = div; +void(*p_exit)(int) = exit; +void(*p_free)(void*) = free; +char*(*p_getenv)(const char*) = getenv; +int(*p_getsubopt)(char**,char*const*,char**) = getsubopt; +long(*p_labs)(long) = labs; +ldiv_t(*p_ldiv)(long,long) = ldiv; +long long(*p_llabs)(long long) = llabs; +lldiv_t(*p_lldiv)(long long,long long) = lldiv; +void*(*p_malloc)(size_t) = malloc; +int(*p_mblen)(const char*,size_t) = mblen; +size_t(*p_mbstowcs)(wchar_t*restrict,const char*restrict,size_t) = mbstowcs; +int(*p_mbtowc)(wchar_t*restrict,const char*restrict,size_t) = mbtowc; +int(*p_posix_memalign)(void**,size_t,size_t) = posix_memalign; +void(*p_qsort)(void*,size_t,size_t,int(*)(const void*,const void*)) = qsort; +int(*p_rand)(void) = rand; +void*(*p_realloc)(void*,size_t) = realloc; +void(*p_srand)(unsigned) = srand; +double(*p_strtod)(const char*restrict,char**restrict) = strtod; +float(*p_strtof)(const char*restrict,char**restrict) = strtof; +long(*p_strtol)(const char*restrict,char**restrict,int) = strtol; +long double(*p_strtold)(const char*restrict,char**restrict) = strtold; +long long(*p_strtoll)(const char*restrict,char**restrict,int) = strtoll; +unsigned long(*p_strtoul)(const char*restrict,char**restrict,int) = strtoul; +unsigned long long(*p_strtoull)(const char*restrict,char**restrict,int) = strtoull; +int(*p_system)(const char*) = system; +size_t(*p_wcstombs)(char*restrict,const wchar_t*restrict,size_t) = wcstombs; +int(*p_wctomb)(char*,wchar_t) = wctomb; +#ifdef _POSIX_C_SOURCE +char*(*p_mkdtemp)(char*) = mkdtemp; +int(*p_mkstemp)(char*) = mkstemp; +int(*p_setenv)(const char*,const char*,int) = setenv; +int(*p_unsetenv)(const char*) = unsetenv; +#endif +#ifdef _XOPEN_SOURCE +long(*p_a64l)(const char*) = a64l; +double(*p_drand48)(void) = drand48; +double(*p_erand48)(unsigned short[]) = erand48; +int(*p_grantpt)(int) = grantpt; +char*(*p_initstate)(unsigned,char*,size_t) = initstate; +long(*p_jrand48)(unsigned short[]) = jrand48; +char*(*p_l64a)(long) = l64a; +void(*p_lcong48)(unsigned short[]) = lcong48; +long(*p_lrand48)(void) = lrand48; +long(*p_mrand48)(void) = mrand48; +long(*p_nrand48)(unsigned short[]) = nrand48; +char*(*p_ptsname)(int) = ptsname; +int(*p_putenv)(char*) = putenv; +long(*p_random)(void) = random; +char*(*p_realpath)(const char*restrict,char*restrict) = realpath; +unsigned short*(*p_seed48)(unsigned short[]) = seed48; +void(*p_setkey)(const char*) = setkey; +char*(*p_setstate)(char*) = setstate; +void(*p_srand48)(long) = srand48; +void(*p_srandom)(unsigned) = srandom; +int(*p_unlockpt)(int) = unlockpt; +#endif +} + +#ifdef _XOPEN_SOURCE +#include +static void g() +{ +int(*p_posix_openpt)(int) = posix_openpt; +} +#endif + diff --git a/src/api/string.c b/src/api/string.c new file mode 100644 index 0000000..60aa768 --- /dev/null +++ b/src/api/string.c @@ -0,0 +1,45 @@ +#include +#define T(t) (t*)0; +static void f() +{ +T(size_t) +void*(*p_memchr)(const void*,int,size_t) = memchr; +int(*p_memcmp)(const void*,const void*,size_t) = memcmp; +void*(*p_memcpy)(void*restrict,const void*restrict,size_t) = memcpy; +void*(*p_memmove)(void*,const void*,size_t) = memmove; +void*(*p_memset)(void*,int,size_t) = memset; +char*(*p_strcat)(char*restrict,const char*restrict) = strcat; +char*(*p_strchr)(const char*,int) = strchr; +int(*p_strcmp)(const char*,const char*) = strcmp; +int(*p_strcoll)(const char*,const char*) = strcoll; +char*(*p_strcpy)(char*restrict,const char*restrict) = strcpy; +size_t(*p_strcspn)(const char*,const char*) = strcspn; +char*(*p_strerror)(int) = strerror; +size_t(*p_strlen)(const char*) = strlen; +char*(*p_strncat)(char*restrict,const char*restrict,size_t) = strncat; +int(*p_strncmp)(const char*,const char*,size_t) = strncmp; +char*(*p_strncpy)(char*restrict,const char*restrict,size_t) = strncpy; +char*(*p_strpbrk)(const char*,const char*) = strpbrk; +char*(*p_strrchr)(const char*,int) = strrchr; +char*(*p_strsignal)(int) = strsignal; +size_t(*p_strspn)(const char*,const char*) = strspn; +char*(*p_strstr)(const char*,const char*) = strstr; +char*(*p_strtok)(char*restrict,const char*restrict) = strtok; +size_t(*p_strxfrm)(char*restrict,const char*restrict,size_t) = strxfrm; +#ifdef _POSIX_C_SOURCE +T(locale_t) +char*(*p_stpcpy)(char*restrict,const char*restrict) = stpcpy; +char*(*p_stpncpy)(char*restrict,const char*restrict,size_t) = stpncpy; +int(*p_strcoll_l)(const char*,const char*,locale_t) = strcoll_l; +char*(*p_strdup)(const char*) = strdup; +char*(*p_strerror_l)(int,locale_t) = strerror_l; +int(*p_strerror_r)(int,char*,size_t) = strerror_r; +char*(*p_strndup)(const char*,size_t) = strndup; +size_t(*p_strnlen)(const char*,size_t) = strnlen; +char*(*p_strtok_r)(char*restrict,const char*restrict,char**restrict) = strtok_r; +size_t(*p_strxfrm_l)(char*restrict,const char*restrict,size_t,locale_t) = strxfrm_l; +#endif +#ifdef _XOPEN_SOURCE +void*(*p_memccpy)(void*restrict,const void*restrict,int,size_t) = memccpy; +#endif +} diff --git a/src/api/strings.c b/src/api/strings.c new file mode 100644 index 0000000..30177cd --- /dev/null +++ b/src/api/strings.c @@ -0,0 +1,14 @@ +#include +#define T(t) (t*)0; +static void f() +{ +T(size_t) +T(locale_t) +#ifdef _XOPEN_SOURCE +int(*p_ffs)(int) = ffs; +#endif +int(*p_strcasecmp)(const char*,const char*) = strcasecmp; +int(*p_strcasecmp_l)(const char*,const char*,locale_t) = strcasecmp_l; +int(*p_strncasecmp)(const char*,const char*,size_t) = strncasecmp; +int(*p_strncasecmp_l)(const char*,const char*,size_t,locale_t) = strncasecmp_l; +} diff --git a/src/api/sys_ipc.c b/src/api/sys_ipc.c new file mode 100644 index 0000000..8995206 --- /dev/null +++ b/src/api/sys_ipc.c @@ -0,0 +1,27 @@ +#include +#define T(t) (t*)0; +#define F(t,n) {t *y = &x.n;} +#define C(n) switch(n){case n:;} +static void f() +{ +T(uid_t) +T(gid_t) +T(mode_t) +T(key_t) +{ +struct ipc_perm x; +F(uid_t,uid) +F(gid_t,gid) +F(uid_t,cuid) +F(gid_t,cgid) +F(mode_t, mode) +} +C(IPC_CREAT) +C(IPC_EXCL) +C(IPC_NOWAIT) +C(IPC_PRIVATE) +C(IPC_RMID) +C(IPC_SET) +C(IPC_STAT) +key_t(*p_ftok)(const char*,int) = ftok; +} diff --git a/src/api/sys_mman.c b/src/api/sys_mman.c new file mode 100644 index 0000000..4217223 --- /dev/null +++ b/src/api/sys_mman.c @@ -0,0 +1,53 @@ +#include +#define T(t) (t*)0; +#define F(t,n) {t *y = &x.n;} +#define C(n) switch(n){case n:;} +static void f() +{ +T(mode_t) +T(off_t) +T(size_t) +C(PROT_EXEC) +C(PROT_NONE) +C(PROT_READ) +C(PROT_WRITE) +C(MAP_FIXED) +C(MAP_PRIVATE) +C(MAP_SHARED) +#ifdef _XOPEN_SOURCE +C(MS_ASYNC) +C(MS_INVALIDATE) +C(MS_SYNC) +#endif +C(MCL_CURRENT) +C(MCL_FUTURE) +{void *x = MAP_FAILED;} +C(POSIX_MADV_DONTNEED) +C(POSIX_MADV_NORMAL) +C(POSIX_MADV_RANDOM) +C(POSIX_MADV_SEQUENTIAL) +C(POSIX_MADV_WILLNEED) +//C(POSIX_TYPED_MEM_ALLOCATE) +//C(POSIX_TYPED_MEM_ALLOCATE_CONTIG) +//C(POSIX_TYPED_MEM_MAP_ALLOCATABLE) +//{ +//struct posix_typed_mem_info x; +//F(size_t,posix_tmi_length) +//} +int(*p_mlock)(const void*,size_t) = mlock; +int(*p_mlockall)(int) = mlockall; +void*(*p_mmap)(void*,size_t,int,int,int,off_t) = mmap; +int(*p_mprotect)(void*,size_t,int) = mprotect; +#ifdef _XOPEN_SOURCE +int(*p_msync)(void*,size_t,int) = msync; +#endif +int(*p_munlock)(const void*,size_t) = munlock; +int(*p_munlockall)(void) = munlockall; +int(*p_munmap)(void*,size_t) = munmap; +int(*p_posix_madvise)(void*,size_t,int) = posix_madvise; +//int(*p_posix_mem_offset)(const void*restrict,size_t,off_t*restrict,size_t*restrict,int*restrict) = posix_mem_offset; +//int(*p_posix_typed_mem_get_info)(int,struct posix_typed_mem_info*) = posix_typed_mem_get_info; +//int(*p_posix_typed_mem_open)(const char*,int,int) = posix_typed_mem_open; +int(*p_shm_open)(const char*,int,mode_t) = shm_open; +int(*p_shm_unlink)(const char*) = shm_unlink; +} diff --git a/src/api/sys_msg.c b/src/api/sys_msg.c new file mode 100644 index 0000000..41c76ec --- /dev/null +++ b/src/api/sys_msg.c @@ -0,0 +1,29 @@ +#include +#define T(t) (t*)0; +#define F(t,n) {t *y = &x.n;} +#define C(n) switch(n){case n:;} +static void f() +{ +T(msgqnum_t) +T(msglen_t) +T(pid_t) +T(size_t) +T(ssize_t) +T(time_t) +C(MSG_NOERROR) +{ +struct msqid_ds x; +F(struct ipc_perm, msg_perm) +F(msgqnum_t, msg_qnum) +F(msglen_t,msg_qbytes) +F(pid_t, msg_lspid) +F(pid_t, msg_lrpid) +F(time_t, msg_stime) +F(time_t, msg_rtime) +F(time_t,msg_ctime) +} +int(*p_msgctl)(int,int,struct msqid_ds*) = msgctl; +int(*p_msgget)(key_t,int) = msgget; +ssize_t(*p_msgrcv)(int,void*,size_t,long,int) = msgrcv; +int(*p_msgsnd)(int,const void*,size_t,int) = msgsnd; +} diff --git a/src/api/sys_resource.c b/src/api/sys_resource.c new file mode 100644 index 0000000..0622a50 --- /dev/null +++ b/src/api/sys_resource.c @@ -0,0 +1,39 @@ +#include +#define T(t) (t*)0; +#define F(t,n) {t *y = &x.n;} +#define C(n) switch(n){case n:;} +static void f() +{ +T(rlim_t) +T(struct timeval) +C(PRIO_PROCESS) +C(PRIO_PGRP) +C(PRIO_USER) +C(RLIM_INFINITY) +C(RLIM_SAVED_MAX) +C(RLIM_SAVED_CUR) +C(RUSAGE_SELF) +C(RUSAGE_CHILDREN) +{ +struct rlimit x; +F(rlim_t, rlim_cur) +F(rlim_t, rlim_max) +} +{ +struct rusage x; +F(struct timeval, ru_utime) +F(struct timeval, ru_stime) +} +C(RLIMIT_CORE) +C(RLIMIT_CPU) +C(RLIMIT_DATA) +C(RLIMIT_FSIZE) +C(RLIMIT_NOFILE) +C(RLIMIT_STACK) +C(RLIMIT_AS) +int(*p_getpriority)(int,id_t) = getpriority; +int(*p_getrlimit)(int,struct rlimit*) = getrlimit; +int(*p_getrusage)(int,struct rusage*) = getrusage; +int(*p_setpriority)(int,id_t,int) = setpriority; +int(*p_setrlimit)(int,const struct rlimit*) = setrlimit; +} diff --git a/src/api/sys_select.c b/src/api/sys_select.c new file mode 100644 index 0000000..d013d96 --- /dev/null +++ b/src/api/sys_select.c @@ -0,0 +1,32 @@ +#include +#define T(t) (t*)0; +#define F(t,n) {t *y = &x.n;} +#define C(n) switch(n){case n:;} +static void f() +{ +T(time_t) +T(suseconds_t) +T(sigset_t) +T(struct timespec) +T(fd_set) +{ +struct timeval x; +F(time_t, tv_sec) +F(suseconds_t, tv_usec) +} +C(FD_SETSIZE) +#ifndef FD_CLR +void(*p_FD_CLR)(int,fd_set*) = FD_CLR; +#endif +#ifndef FD_ISSET +int(*p_FD_ISSET)(int,fd_set*) = FD_ISSET; +#endif +#ifndef FD_SET +void(*p_FD_SET)(int,fd_set*) = FD_SET; +#endif +#ifndef FD_ZERO +void(*p_FD_ZERO)(fd_set*) = FD_ZERO; +#endif +int(*p_pselect)(int,fd_set*restrict,fd_set*restrict,fd_set*restrict,const struct timespec*restrict,const sigset_t*restrict) = pselect; +int(*p_select)(int,fd_set*restrict,fd_set*restrict,fd_set*restrict,struct timeval*restrict) = select; +} diff --git a/src/api/sys_sem.c b/src/api/sys_sem.c new file mode 100644 index 0000000..94dc8e1 --- /dev/null +++ b/src/api/sys_sem.c @@ -0,0 +1,55 @@ +#include +#define T(t) (t*)0; +#define F(t,n) {t *y = &x.n;} +#define C(n) switch(n){case n:;} +static void f() +{ +T(pid_t) +T(size_t) +T(time_t) +C(SEM_UNDO) +C(GETNCNT) +C(GETPID) +C(GETVAL) +C(GETALL) +C(GETZCNT) +C(SETVAL) +C(SETALL) +{ +struct semid_ds x; +F(struct ipc_perm,sem_perm) +F(unsigned short, sem_nsems) +F(time_t, sem_otime) +F(time_t, sem_ctime) +} +{ +struct sembuf x; +F(unsigned short,sem_num) +F(short, sem_op) +F(short, sem_flg) +} +int(*p_semctl)(int,int,int,...) = semctl; +int(*p_semget)(key_t,int,int) = semget; +int(*p_semop)(int,struct sembuf*,size_t) = semop; + +T(uid_t) +T(gid_t) +T(mode_t) +T(key_t) +{ +struct ipc_perm x; +F(uid_t,uid) +F(gid_t,gid) +F(uid_t,cuid) +F(gid_t,cgid) +F(mode_t, mode) +} +C(IPC_CREAT) +C(IPC_EXCL) +C(IPC_NOWAIT) +C(IPC_PRIVATE) +C(IPC_RMID) +C(IPC_SET) +C(IPC_STAT) +key_t(*p_ftok)(const char*,int) = ftok; +} diff --git a/src/api/sys_shm.c b/src/api/sys_shm.c new file mode 100644 index 0000000..128e806 --- /dev/null +++ b/src/api/sys_shm.c @@ -0,0 +1,50 @@ +#include +#define T(t) (t*)0; +#define F(t,n) {t *y = &x.n;} +#define C(n) switch(n){case n:;} +static void f() +{ +T(shmatt_t) +T(pid_t) +T(size_t) +T(time_t) +C(SHM_RDONLY) +C(SHM_RND) +C(SHMLBA) +{ +struct shmid_ds x; +F(struct ipc_perm, shm_perm) +F(size_t,shm_segsz) +F(pid_t, shm_lpid) +F(pid_t, shm_cpid) +F(shmatt_t,shm_nattch) +F(time_t,shm_atime) +F(time_t,shm_dtime) +F(time_t,shm_ctime) +} +void*(*p_shmat)(int,const void*,int) = shmat; +int(*p_shmctl)(int,int,struct shmid_ds*) = shmctl; +int(*p_shmdt)(const void*) = shmdt; +int(*p_shmget)(key_t,size_t,int) = shmget; + +T(uid_t) +T(gid_t) +T(mode_t) +T(key_t) +{ +struct ipc_perm x; +F(uid_t,uid) +F(gid_t,gid) +F(uid_t,cuid) +F(gid_t,cgid) +F(mode_t, mode) +} +C(IPC_CREAT) +C(IPC_EXCL) +C(IPC_NOWAIT) +C(IPC_PRIVATE) +C(IPC_RMID) +C(IPC_SET) +C(IPC_STAT) +key_t(*p_ftok)(const char*,int) = ftok; +} diff --git a/src/api/sys_socket.c b/src/api/sys_socket.c new file mode 100644 index 0000000..d22fe08 --- /dev/null +++ b/src/api/sys_socket.c @@ -0,0 +1,106 @@ +#include +#define T(t) (t*)0; +#define F(t,n) {t *y = &x.n;} +#define C(n) switch(n){case n:;} +static void f() +{ +T(size_t) +T(ssize_t) +T(socklen_t) +T(sa_family_t) +{ +struct sockaddr x; +F(sa_family_t,sa_family) +F(char, sa_data[0]) +} +{ +struct sockaddr_storage x; +F(sa_family_t, ss_family) +} +{ +struct msghdr x; +F(void*,msg_name) +F(socklen_t,msg_namelen) +F(struct iovec*,msg_iov) +F(int,msg_iovlen) +F(void*,msg_control) +F(socklen_t,msg_controllen) +F(int,msg_flags) +} +{ +struct cmsghdr x; +F(socklen_t,cmsg_len) +F(int,cmsg_level) +F(int,cmsg_type) +} +C(SCM_RIGHTS) +#ifndef CMSG_DATA +#error no CMSG_DATA +#endif +#ifndef CMSG_NXTHDR +#error no CMSG_NXTHDR +#endif +#ifndef CMSG_FIRSTHDR +#error CMSG_FIRSTTHDR +#endif +{ +struct linger x; +F(int,l_onoff) +F(int,l_linger) +} +C(SOCK_DGRAM) +C(SOCK_RAW) +C(SOCK_SEQPACKET) +C(SOCK_STREAM) +C(SOL_SOCKET) +C(SO_ACCEPTCONN) +C(SO_BROADCAST) +C(SO_DEBUG) +C(SO_DONTROUTE) +C(SO_ERROR) +C(SO_KEEPALIVE) +C(SO_LINGER) +C(SO_OOBINLINE) +C(SO_RCVBUF) +C(SO_RCVLOWAT) +C(SO_RCVTIMEO) +C(SO_REUSEADDR) +C(SO_SNDBUF) +C(SO_SNDLOWAT) +C(SO_SNDTIMEO) +C(SO_TYPE) +C(SOMAXCONN) +C(MSG_CTRUNC) +C(MSG_DONTROUTE) +C(MSG_EOR) +C(MSG_OOB) +C(MSG_NOSIGNAL) +C(MSG_PEEK) +C(MSG_TRUNC) +C(MSG_WAITALL) +C(AF_INET) +C(AF_INET6) +C(AF_UNIX) +C(AF_UNSPEC) +C(SHUT_RD) +C(SHUT_RDWR) +C(SHUT_WR) +int(*p_accept)(int,struct sockaddr*restrict,socklen_t*restrict) = accept; +int(*p_bind)(int,const struct sockaddr*,socklen_t) = bind; +int(*p_connect)(int,const struct sockaddr*,socklen_t) = connect; +int(*p_getpeername)(int,struct sockaddr*restrict,socklen_t*restrict) = getpeername; +int(*p_getsockname)(int,struct sockaddr*restrict,socklen_t*restrict) = getsockname; +int(*p_getsockopt)(int,int,int,void*restrict,socklen_t*restrict) = getsockopt; +int(*p_listen)(int,int) = listen; +ssize_t(*p_recv)(int,void*,size_t,int) = recv; +ssize_t(*p_recvfrom)(int,void*restrict,size_t,int,struct sockaddr*restrict,socklen_t*restrict) = recvfrom; +ssize_t(*p_recvmsg)(int,struct msghdr*,int) = recvmsg; +ssize_t(*p_send)(int,const void*,size_t,int) = send; +ssize_t(*p_sendmsg)(int,const struct msghdr*,int) = sendmsg; +ssize_t(*p_sendto)(int,const void*,size_t,int,const struct sockaddr*,socklen_t) = sendto; +int(*p_setsockopt)(int,int,int,const void*,socklen_t) = setsockopt; +int(*p_shutdown)(int,int) = shutdown; +int(*p_sockatmark)(int) = sockatmark; +int(*p_socket)(int,int,int) = socket; +int(*p_socketpair)(int,int,int,int[]) = socketpair; +} diff --git a/src/api/sys_stat.c b/src/api/sys_stat.c new file mode 100644 index 0000000..bebf08e --- /dev/null +++ b/src/api/sys_stat.c @@ -0,0 +1,98 @@ +#include +#define T(t) (t*)0; +#define F(t,n) {t *y = &x.n;} +#define C(n) switch(n){case n:;} +static void f() +{ +T(blkcnt_t) +T(blksize_t) +T(dev_t) +T(ino_t) +T(mode_t) +T(nlink_t) +T(uid_t) +T(gid_t) +T(off_t) +T(time_t) +T(struct timespec) + +{ +struct stat x; +F(dev_t, st_dev) +F(ino_t, st_ino) +F(mode_t, st_mode) +F(nlink_t, st_nlink) +F(uid_t, st_uid) +F(gid_t, st_gid) +F(dev_t, st_rdev) +F(off_t, st_size) +F(struct timespec, st_atim) +F(struct timespec, st_mtim) +F(struct timespec, st_ctim) +F(blksize_t, st_blksize) +F(blkcnt_t, st_blocks) + +F(time_t, st_atime) +T(time_t, st_mtime) +T(time_t, st_ctime) +} +C(S_IRWXU) +C(S_IRUSR) +C(S_IWUSR) +C(S_IXUSR) +C(S_IRWXG) +C(S_IRGRP) +C(S_IWGRP) +C(S_IXGRP) +C(S_IRWXO) +C(S_IROTH) +C(S_IWOTH) +C(S_IXOTH) +C(S_ISUID) +C(S_ISGID) +#ifdef _XOPEN_SOURCE +C(S_ISVTX) +C(S_IFMT) +C(S_IFBLK) +C(S_IFCHR) +C(S_IFIFO) +C(S_IFREG) +C(S_IFDIR) +C(S_IFLNK) +C(S_IFSOCK) +#endif +C(S_ISBLK(0)) +C(S_ISCHR(0)) +C(S_ISDIR(0)) +C(S_ISFIFO(0)) +C(S_ISREG(0)) +C(S_ISLNK(0)) +C(S_ISSOCK(0)) +{ +struct stat x = {0}; +{int i = S_TYPEISMQ(&x);} +{int i = S_TYPEISSEM(&x);} +{int i = S_TYPEISSHM(&x);} +{int i = S_TYPEISTMO(&x);} +} +C(UTIME_NOW) +C(UTIME_OMIT) +int(*p_chmod)(const char*,mode_t) = chmod; +int(*p_fchmod)(int,mode_t) = fchmod; +int(*p_fchmodat)(int,const char*,mode_t,int) = fchmodat; +int(*p_fstat)(int,struct stat*) = fstat; +int(*p_fstatat)(int,const char*restrict,struct stat*restrict,int) = fstatat; +int(*p_futimens)(int,const struct timespec[]) = futimens; +int(*p_lstat)(const char*restrict,struct stat*restrict) = lstat; +int(*p_mkdir)(const char*,mode_t) = mkdir; +int(*p_mkdirat)(int,const char*,mode_t) = mkdirat; +int(*p_mkfifo)(const char*,mode_t) = mkfifo; +int(*p_mkfifoat)(int,const char*,mode_t) = mkfifoat; +#ifdef _XOPEN_SOURCE +int(*p_mknod)(const char*,mode_t,dev_t) = mknod; +int(*p_mknodat)(int,const char*,mode_t,dev_t) = mknodat; +#endif +int(*p_stat)(const char*restrict,struct stat*restrict) = stat; +mode_t(*p_umask)(mode_t) = umask; +int(*p_utimensat)(int,const char*,const struct timespec[],int) = utimensat; +} diff --git a/src/api/sys_uio.c b/src/api/sys_uio.c new file mode 100644 index 0000000..5417a72 --- /dev/null +++ b/src/api/sys_uio.c @@ -0,0 +1,15 @@ +#include +#define T(t) (t*)0; +#define F(t,n) {t *y = &x.n;} +static void f() +{ +T(size_t) +T(ssize_t) +{ +struct iovec x; +F(void *,iov_base) +F(size_t,iov_len) +} +ssize_t(*p_readv)(int,const struct iovec*,int) = readv; +ssize_t(*p_writev)(int,const struct iovec*,int) = writev; +}