1
0
Fork 0

Adding upstream version 1.65.7.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-05-19 21:29:57 +02:00
parent 5189956325
commit 32b8eb3fd7
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
4153 changed files with 2487292 additions and 0 deletions

15
testdata/memgrind/badfree.c vendored Normal file
View file

@ -0,0 +1,15 @@
// This program attempts to free a pointer not acquired by malloc/calloc/realloc.
//
// Compile to Go: `$ ccgo -o main.go badfree.c`.
//
// To run the resulting Go code: `$ go run main.go`.
//
// To run the resulting Go code with memgrind: `$ go run -tags=libc.memgrind main.go`.
#include <stdlib.h>
int main() {
int i;
free(&i);
}

16
testdata/memgrind/doublefree.c vendored Normal file
View file

@ -0,0 +1,16 @@
// This program frees allocated memory twice.
//
// Compile to Go: `$ ccgo -o main.go doublefree.c`.
//
// To run the resulting Go code: `$ go run main.go`.
//
// To run the resulting Go code with memgrind: `$ go run -tags=libc.memgrind main.go`.
#include <stdlib.h>
int main() {
void *p = malloc(42);
free(p);
free(p);
}

13
testdata/memgrind/leak.c vendored Normal file
View file

@ -0,0 +1,13 @@
// This program leaks memory.
//
// Compile to Go: `$ ccgo -o main.go leak.c`.
//
// To run the resulting Go code: `$ go run main.go`.
//
// To run the resulting Go code with memgrind: `$ go run -tags=libc.memgrind main.go`.
#include <stdlib.h>
int main() {
malloc(42);
}

View file

@ -0,0 +1,7 @@
*.err
*.o
*.so
*.a
*.exe
config.mak
REPORT

View file

@ -0,0 +1,7 @@
Rich Felker
Szabolcs Nagy
Kirill Ternovsky
John Spencer
Jens Gustedt
Alexander Monakov
Julien Ramseier

View file

@ -0,0 +1,29 @@
libc-test is licensed under the following standard MIT license:
Copyright © 2005-2013 libc-test AUTHORS
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Portions of this software is derived from software authored by
third parties:
math tests use numbers under BSD and GPL licenses see src/math/ucb/*
and src/math/crlibm/* for details

154
testdata/nsz.repo.hu/libc-test/Makefile vendored Normal file
View file

@ -0,0 +1,154 @@
B:=src
SRCS:=$(sort $(wildcard src/*/*.c))
OBJS:=$(SRCS:src/%.c=$(B)/%.o)
LOBJS:=$(SRCS:src/%.c=$(B)/%.lo)
DIRS:=$(patsubst src/%/,%,$(sort $(dir $(SRCS))))
BDIRS:=$(DIRS:%=$(B)/%)
NAMES:=$(SRCS:src/%.c=%)
CFLAGS:=-I$(B)/common -Isrc/common
LDLIBS:=$(B)/common/libtest.a
AR = $(CROSS_COMPILE)ar
RANLIB = $(CROSS_COMPILE)ranlib
RUN_TEST = $(RUN_WRAP) $(B)/common/runtest.exe -w '$(RUN_WRAP)'
all:
%.mk:
# turn off evil implicit rules
.SUFFIXES:
%: %.o
%: %.c
%: %.cc
%: %.C
%: %.cpp
%: %.p
%: %.f
%: %.F
%: %.r
%: %.s
%: %.S
%: %.mod
%: %.sh
%: %,v
%: RCS/%,v
%: RCS/%
%: s.%
%: SCCS/s.%
config.mak:
cp config.mak.def $@
-include config.mak
define default_template
$(1).BINS_TEMPL:=bin.exe bin-static.exe
$(1).NAMES:=$$(filter $(1)/%,$$(NAMES))
$(1).OBJS:=$$($(1).NAMES:%=$(B)/%.o)
endef
$(foreach d,$(DIRS),$(eval $(call default_template,$(d))))
common.BINS_TEMPL:=
api.BINS_TEMPL:=
math.BINS_TEMPL:=bin.exe
define template
D:=$$(patsubst %/,%,$$(dir $(1)))
N:=$(1)
$(1).BINS := $$($$(D).BINS_TEMPL:bin%=$(B)/$(1)%)
-include src/$(1).mk
#$$(warning D $$(D) N $$(N) B $$($(1).BINS))
$(B)/$(1).exe $(B)/$(1)-static.exe: $$($(1).OBJS)
$(B)/$(1).so: $$($(1).LOBJS)
# make sure dynamic and static binaries are not run parallel (matters for some tests eg ipc)
$(B)/$(1)-static.err: $(B)/$(1).err
endef
$(foreach n,$(NAMES),$(eval $(call template,$(n))))
BINS:=$(foreach n,$(NAMES),$($(n).BINS)) $(B)/api/main.exe
LIBS:=$(foreach n,$(NAMES),$($(n).LIBS)) $(B)/common/runtest.exe
ERRS:=$(BINS:%.exe=%.err)
debug:
@echo NAMES $(NAMES)
@echo BINS $(BINS)
@echo LIBS $(LIBS)
@echo ERRS $(ERRS)
@echo DIRS $(DIRS)
define target_template
$(1).ERRS:=$$(filter $(B)/$(1)/%,$$(ERRS))
$(B)/$(1)/all: $(B)/$(1)/REPORT
$(B)/$(1)/run: $(B)/$(1)/cleanerr $(B)/$(1)/REPORT
$(B)/$(1)/cleanerr:
rm -f $$(filter-out $(B)/$(1)/%-static.err,$$($(1).ERRS))
$(B)/$(1)/clean:
rm -f $$(filter $(B)/$(1)/%,$$(OBJS) $$(LOBJS) $$(BINS) $$(LIBS)) $(B)/$(1)/*.err
$(B)/$(1)/REPORT: $$($(1).ERRS)
cat $(B)/$(1)/*.err >$$@
run: $(B)/$(1)/run
$(B)/REPORT: $(B)/$(1)/REPORT
.PHONY: $(B)/$(1)/all $(B)/$(1)/clean
endef
$(foreach d,$(DIRS),$(eval $(call target_template,$(d))))
$(B)/common/libtest.a: $(common.OBJS)
rm -f $@
$(AR) rc $@ $^
$(RANLIB) $@
$(B)/common/all: $(B)/common/runtest.exe
$(ERRS): $(B)/common/runtest.exe | $(BDIRS)
$(BINS) $(LIBS): $(B)/common/libtest.a
$(OBJS): src/common/test.h | $(BDIRS)
$(BDIRS):
mkdir -p $@
$(B)/common/options.h: src/common/options.h.in
$(CC) -E - <$< | awk ' \
/optiongroups_unistd_end/ {s=1; next} \
!s || !NF || /^#/ {next} \
!a {a=$$1; if(NF==1)next} \
{print "#define "a" "$$NF; a=""}' >$@.tmp
mv $@.tmp $@
$(B)/common/mtest.o: src/common/mtest.h
$(math.OBJS): src/common/mtest.h
$(B)/api/main.exe: $(api.OBJS)
api/main.OBJS:=$(api.OBJS)
$(api.OBJS):$(B)/common/options.h
$(api.OBJS):CFLAGS+=-pedantic-errors -Werror -Wno-unused -D_XOPEN_SOURCE=700
all run: $(B)/REPORT
grep FAIL $< || echo PASS
clean:
rm -f $(OBJS) $(BINS) $(LIBS) $(B)/common/libtest.a $(B)/common/runtest.exe $(B)/common/options.h $(B)/*/*.err
cleanall: clean
rm -f $(B)/REPORT $(B)/*/REPORT
$(B)/REPORT:
cat $^ >$@
$(B)/%.o:: src/%.c
$(CC) $(CFLAGS) $($*.CFLAGS) -c -o $@ $< 2>$@.err || echo BUILDERROR $@; cat $@.err
$(B)/%.s:: src/%.c
$(CC) $(CFLAGS) $($*.CFLAGS) -S -o $@ $< || echo BUILDERROR $@; cat $@.err
$(B)/%.lo:: src/%.c
$(CC) $(CFLAGS) $($*.CFLAGS) -fPIC -DSHARED -c -o $@ $< 2>$@.err || echo BUILDERROR $@; cat $@.err
$(B)/%.so: $(B)/%.lo
$(CC) -shared $(LDFLAGS) $($*.so.LDFLAGS) -o $@ $(sort $< $($*.so.LOBJS)) $(LDLIBS) $($*.so.LDLIBS) 2>$@.err || echo BUILDERROR $@; cat $@.err
$(B)/%-static.exe: $(B)/%.o
$(CC) -static $(LDFLAGS) $($*-static.LDFLAGS) -o $@ $(sort $< $($*-static.OBJS)) $(LDLIBS) $($*-static.LDLIBS) 2>$@.ld.err || echo BUILDERROR $@; cat $@.ld.err
$(B)/%.exe: $(B)/%.o
$(CC) $(LDFLAGS) $($*.LDFLAGS) -o $@ $(sort $< $($*.OBJS)) $(LDLIBS) $($*.LDLIBS) 2>$@.ld.err || echo BUILDERROR $@; cat $@.ld.err
%.o.err: %.o
touch $@
%.lo.err: %.lo
touch $@
%.so.err: %.so
touch $@
%.ld.err: %.exe
touch $@
%.err: %.exe
$(RUN_TEST) $< >$@ || true
.PHONY: all run clean cleanall

105
testdata/nsz.repo.hu/libc-test/README vendored Normal file
View file

@ -0,0 +1,105 @@
libc-test is developed as part of the musl project
http://www.musl-libc.org/
configuring:
cp config.mak.def config.mak
edit config.mak
build and run tests:
make
clean up:
make clean
make builds all test binaries and runs them to create
a REPORT file that contains all build and runtime errors
(this means that make does not stop at build failures)
contributing tests:
design goals:
- tests should be easy to run and build even a single test in isolation
(so test should be self contained if possible)
- failure of one test should not interfere with others
(build failure, crash or unexpected results are all failures)
- test output should point to the cause of the failure
- test results should be robust
- the test system should have minimal dependency
(libc, posix sh, gnu make)
- the test system should run on all archs and libcs
- tests should leave the system in a clean state
conventions:
each test is in a separate file at a path like src/directory/file.c with
its own main
the test should return 0 on success and non-0 on failure, on failure it
should print error messages to standard out if possible, on success no
message should be printed
to help with the above test protocol use t_error function for printing
errors and return t_status from main, see src/common/test.h
(t_error allows standard printf formatting, outputs at most 512bytes
in a single write call to fd 1, so there is no buffering, long outputs
are truncated, it sets the global t_status to 1)
it is common to do many similar checks in a test, in such cases macros
may be used to simplify the code like
#define T1(a,b) (check(a,b) || (t_error("check(%s,%s) failed\n", a, b),0))
#define T2(f,w) (result=(f), result==(w) || (t_error("%s failed: got %s, want %s\n", #f, result, w),0))
binaries should be possible to run from arbitrary directory.
the build system runs the tests using the src/common/runtest tool which
kills the test process after a timeout and reports the exit status
in case of failure
directories:
src/api: interface tests, build time include header tests
src/common: common utilities compiled into libtest.a
src/functional: functional tests aiming for large coverage of libc
src/math: tests for each math function with input-output test vectors
src/regression: regression tests aiming for testing particular bugs
initial set of functional tests are derived from the libc-testsuit of
Rich Felker, regression tests should contain reference of the bug
(musl commit hash, glibc bug tracker url, etc)
build system:
the main non-file make targets are all, run, clean and cleanall.
(cleanall removes the reports unlike clean, run reruns the dynamically
linked executables)
make variable can be overridden from config.mak or the make command line,
the variable B sets the build directory which is src by default
for each directory under src there are targets like $(B)/directory/all,
$(B)/directory/run and $(B)/directory/clean to make only the contents
of that directory, each directory has its own Makefile set up so it
invokes the top level make with B=src src/directory/foo for the foo
target, so it is possible to work only under a specific test directory
the build and runtime errors of each target are accumulated into a
target.err file and in the end they are concatenated into a REPORT
each .c file in src/functional and src/regression are built into a
dynamic linked and a static linked executable test binary by default,
this behaviour can be changed by a similarly named .mk file changing
make variables and specifying additional rules:
$(B)/$(N) is the name of the binary target (the file name without the .c)
$(B)/$(N)-static is the name of the static binary target
$(B)/$(D) is the build directory
$(N).CFLAGS are added to the CFLAGS at compilation
$(N).LDFLAGS are added to the LDFLAGS at linking
$(N).LDLIBS are added to the LDLIBS at linking
$(N).BINS are the targets (if empty no binaries are built)
$(N).LIBS are the non-executable targets (shared objects may use it)
if a binary is linked together from several .o files then they
have to be specified as prerequisits for the binary targets and
added to the $(N).LDLIBS as well
if a binary depends on a file at runtime (eg. a .so opened by dlopen)
then the $(N).err target should depend on that file

8
testdata/nsz.repo.hu/libc-test/commit vendored Normal file
View file

@ -0,0 +1,8 @@
fix sscanf test: src must be a string master
author Szabolcs Nagy <nsz@port70.net>
Wed, 3 Aug 2022 17:12:45 +0000 (17:12 +0000)
committer Szabolcs Nagy <nsz@port70.net>
Wed, 3 Aug 2022 17:12:45 +0000 (17:12 +0000)
commit 18e28496adee3d84fefdda6efcb9c5b8996a2398
tree 4a632c2e38f4d3d2e50910db7a62d5a30d25c695
parent b7ec467969a53756258778fa7d9b045f912d1c93

View file

@ -0,0 +1,11 @@
CFLAGS += -pipe -std=c99 -D_POSIX_C_SOURCE=200809L -Wall -Wno-unused-function -Wno-missing-braces -Wno-unused -Wno-overflow
CFLAGS += -Wno-unknown-pragmas -fno-builtin -frounding-math
CFLAGS += -Werror=implicit-function-declaration -Werror=implicit-int -Werror=pointer-sign -Werror=pointer-arith
CFLAGS += -g
LDFLAGS += -g
LDLIBS += -lpthread -lm -lrt
# glibc specific settings
CFLAGS += -D_FILE_OFFSET_BITS=64
LDLIBS += -lcrypt -ldl -lresolv -lutil -lpthread

View file

@ -0,0 +1,5 @@
all:
%: FORCE
$(MAKE) -C ../.. B=src src/api/$@
.SUFFIXES:
FORCE: ;

View file

@ -0,0 +1,41 @@
#include <aio.h>
#define T(t) (t*)0;
#define F(t,n) {t *y = &x.n;}
#define C(n) switch(n){case n:;}
static void f()
{
T(off_t)
T(pthread_attr_t)
T(size_t)
T(ssize_t)
T(struct timespec)
{
struct aiocb x;
F(int, aio_fildes)
F(off_t, aio_offset)
F(volatile void *, aio_buf)
F(size_t, aio_nbytes)
F(int, aio_reqprio)
F(struct sigevent, aio_sigevent)
F(int, aio_lio_opcode)
}
C(AIO_ALLDONE)
C(AIO_CANCELED)
C(AIO_NOTCANCELED)
C(LIO_NOP)
C(LIO_NOWAIT)
C(LIO_READ)
C(LIO_WAIT)
C(LIO_WRITE)
{int(*p)(int,struct aiocb*) = aio_cancel;}
{int(*p)(const struct aiocb*) = aio_error;}
{int(*p)(int,struct aiocb*) = aio_fsync;}
{int(*p)(struct aiocb*) = aio_read;}
{ssize_t(*p)(struct aiocb*) = aio_return;}
{int(*p)(const struct aiocb*const[],int,const struct timespec*) = aio_suspend;}
{int(*p)(struct aiocb*) = aio_write;}
{int(*p)(int,struct aiocb*restrict const[restrict],int,struct sigevent*restrict) = lio_listio;}
}

View file

@ -0,0 +1,41 @@
#include <arpa/inet.h>
#define T(t) (t*)0;
#define C(n) switch(n){case n:;}
#define I(t,e) {t x[sizeof(t)==sizeof(e)] = {e};}
static void f()
{
T(in_port_t)
T(in_addr_t)
T(struct in_addr)
T(uint32_t)
T(uint16_t)
C(INET_ADDRSTRLEN)
C(INET6_ADDRSTRLEN)
#ifdef htonl
I(uint32_t, htonl(0LL))
#else
{uint32_t(*p)(uint32_t) = htonl;}
#endif
#ifdef htons
I(uint16_t, htons(0LL))
#else
{uint16_t(*p)(uint16_t) = htons;}
#endif
#ifdef ntohl
I(uint32_t, ntohl(0LL))
#else
{uint32_t(*p)(uint32_t) = ntohl;}
#endif
#ifdef ntohs
I(uint16_t, ntohs(0LL))
#else
{uint16_t(*p)(uint16_t) = ntohs;}
#endif
{in_addr_t(*p)(const char*) = inet_addr;}
{char*(*p)(struct in_addr) = inet_ntoa;}
{const char*(*p)(int,const void*restrict,char*restrict,socklen_t) = inet_ntop;}
{int(*p)(int,const char*restrict,void*restrict) = inet_pton;}
}

View file

@ -0,0 +1,11 @@
#include <assert.h>
#ifndef assert
#error no assert
#endif
#define NDEBUG 1
#include <assert.h>
#ifndef assert
#error no assert
#endif

View file

@ -0,0 +1,76 @@
#include <complex.h>
#define T(t) (t*)0;
static void f()
{
T(float complex)
{const float complex c = _Complex_I;}
{const float complex c = I;}
{double(*p)(double complex) = cabs;}
{float(*p)(float complex) = cabsf;}
{long double(*p)(long double complex) = cabsl;}
{double complex(*p)(double complex) = cacos;}
{float complex(*p)(float complex) = cacosf;}
{double complex(*p)(double complex) = cacosh;}
{float complex(*p)(float complex) = cacoshf;}
{long double complex(*p)(long double complex) = cacoshl;}
{long double complex(*p)(long double complex) = cacosl;}
{double(*p)(double complex) = carg;}
{float(*p)(float complex) = cargf;}
{long double(*p)(long double complex) = cargl;}
{double complex(*p)(double complex) = casin;}
{float complex(*p)(float complex) = casinf;}
{double complex(*p)(double complex) = casinh;}
{float complex(*p)(float complex) = casinhf;}
{long double complex(*p)(long double complex) = casinhl;}
{long double complex(*p)(long double complex) = casinl;}
{double complex(*p)(double complex) = catan;}
{float complex(*p)(float complex) = catanf;}
{double complex(*p)(double complex) = catanh;}
{float complex(*p)(float complex) = catanhf;}
{long double complex(*p)(long double complex) = catanhl;}
{long double complex(*p)(long double complex) = catanl;}
{double complex(*p)(double complex) = ccos;}
{float complex(*p)(float complex) = ccosf;}
{double complex(*p)(double complex) = ccosh;}
{float complex(*p)(float complex) = ccoshf;}
{long double complex(*p)(long double complex) = ccoshl;}
{long double complex(*p)(long double complex) = ccosl;}
{double complex(*p)(double complex) = cexp;}
{float complex(*p)(float complex) = cexpf;}
{long double complex(*p)(long double complex) = cexpl;}
{double(*p)(double complex) = cimag;}
{float(*p)(float complex) = cimagf;}
{long double(*p)(long double complex) = cimagl;}
{double complex(*p)(double complex) = clog;}
{float complex(*p)(float complex) = clogf;}
{long double complex(*p)(long double complex) = clogl;}
{double complex(*p)(double complex) = conj;}
{float complex(*p)(float complex) = conjf;}
{long double complex(*p)(long double complex) = conjl;}
{double complex(*p)(double complex,double complex) = cpow;}
{float complex(*p)(float complex,float complex) = cpowf;}
{long double complex(*p)(long double complex,long double complex) = cpowl;}
{double complex(*p)(double complex) = cproj;}
{float complex(*p)(float complex) = cprojf;}
{long double complex(*p)(long double complex) = cprojl;}
{double(*p)(double complex) = creal;}
{float(*p)(float complex) = crealf;}
{long double(*p)(long double complex) = creall;}
{double complex(*p)(double complex) = csin;}
{float complex(*p)(float complex) = csinf;}
{double complex(*p)(double complex) = csinh;}
{float complex(*p)(float complex) = csinhf;}
{long double complex(*p)(long double complex) = csinhl;}
{long double complex(*p)(long double complex) = csinl;}
{double complex(*p)(double complex) = csqrt;}
{float complex(*p)(float complex) = csqrtf;}
{long double complex(*p)(long double complex) = csqrtl;}
{double complex(*p)(double complex) = ctan;}
{float complex(*p)(float complex) = ctanf;}
{double complex(*p)(double complex) = ctanh;}
{float complex(*p)(float complex) = ctanhf;}
{long double complex(*p)(long double complex) = ctanhl;}
{long double complex(*p)(long double complex) = ctanl;}
}

View file

@ -0,0 +1,26 @@
#include <cpio.h>
#define C(n) switch(n){case n:;}
static void f(){
C(C_IRUSR)
C(C_IWUSR)
C(C_IXUSR)
C(C_IRGRP)
C(C_IWGRP)
C(C_IXGRP)
C(C_IROTH)
C(C_IWOTH)
C(C_IXOTH)
C(C_ISUID)
C(C_ISGID)
C(C_ISVTX)
C(C_ISDIR)
C(C_ISFIFO)
C(C_ISREG)
C(C_ISBLK)
C(C_ISCHR)
C(C_ISCTG)
C(C_ISLNK)
C(C_ISSOCK)
{char *s = "" MAGIC;}
}

View file

@ -0,0 +1,39 @@
#include <ctype.h>
#define T(t) (t*)0;
static void f()
{
{int(*p)(int) = isalnum;}
{int(*p)(int) = isalpha;}
{int(*p)(int) = isascii;}
{int(*p)(int) = isblank;}
{int(*p)(int) = iscntrl;}
{int(*p)(int) = isdigit;}
{int(*p)(int) = isgraph;}
{int(*p)(int) = islower;}
{int(*p)(int) = isprint;}
{int(*p)(int) = ispunct;}
{int(*p)(int) = isspace;}
{int(*p)(int) = isupper;}
{int(*p)(int) = isxdigit;}
{int(*p)(int) = toascii;}
{int(*p)(int) = tolower;}
{int(*p)(int) = toupper;}
#ifdef _POSIX_C_SOURCE
T(locale_t)
{int(*p)(int,locale_t) = isalnum_l;}
{int(*p)(int,locale_t) = isalpha_l;}
{int(*p)(int,locale_t) = isblank_l;}
{int(*p)(int,locale_t) = iscntrl_l;}
{int(*p)(int,locale_t) = isdigit_l;}
{int(*p)(int,locale_t) = isgraph_l;}
{int(*p)(int,locale_t) = islower_l;}
{int(*p)(int,locale_t) = isprint_l;}
{int(*p)(int,locale_t) = ispunct_l;}
{int(*p)(int,locale_t) = isspace_l;}
{int(*p)(int,locale_t) = isupper_l;}
{int(*p)(int,locale_t) = isxdigit_l;}
{int(*p)(int,locale_t) = tolower_l;}
{int(*p)(int,locale_t) = toupper_l;}
#endif
}

View file

@ -0,0 +1,32 @@
#include <dirent.h>
#define T(t) (t*)0;
#define F(t,n) {t *y = &x.n;}
#define C(n) switch(n){case n:;}
static void f()
{
T(DIR)
T(struct dirent)
#ifdef _XOPEN_SOURCE
T(ino_t)
#endif
{
struct dirent x;
#ifdef _XOPEN_SOURCE
F(ino_t, d_ino)
#endif
F(char, d_name[0])
}
{int(*p)(const struct dirent**,const struct dirent**) = alphasort;}
{int(*p)(DIR*) = closedir;}
{int(*p)(DIR*) = dirfd;}
{DIR*(*p)(int) = fdopendir;}
{DIR*(*p)(const char*) = opendir;}
{struct dirent*(*p)(DIR*) = readdir;}
{int(*p)(DIR*restrict,struct dirent*restrict,struct dirent**restrict) = readdir_r;}
{void(*p)(DIR*) = rewinddir;}
{int(*p)(const char*,struct dirent***,int(*)(const struct dirent*),int(*)(const struct dirent**,const struct dirent**)) = scandir;}
#ifdef _XOPEN_SOURCE
{void(*p)(DIR*,long) = seekdir;}
{long(*p)(DIR*) = telldir;}
#endif
}

View file

@ -0,0 +1,14 @@
#include <dlfcn.h>
#define C(n) switch(n){case n:;}
static void f()
{
C(RTLD_LAZY)
C(RTLD_NOW)
C(RTLD_GLOBAL)
C(RTLD_LOCAL)
{int(*p)(void*) = dlclose;}
{char*(*p)(void) = dlerror;}
{void*(*p)(const char*,int) = dlopen;}
{void*(*p)(void*restrict,const char*restrict) = dlsym;}
}

View file

@ -0,0 +1,89 @@
#include <errno.h>
#define C(n) switch(n){case n:;}
static void f()
{
{int c = errno;}
C(EDOM)
C(EILSEQ)
C(ERANGE)
#ifdef _POSIX_C_SOURCE
C(E2BIG)
C(EACCES)
C(EADDRINUSE)
C(EADDRNOTAVAIL)
C(EAFNOSUPPORT)
C(EAGAIN)
C(EALREADY)
C(EBADF)
C(EBADMSG)
C(EBUSY)
C(ECANCELED)
C(ECHILD)
C(ECONNABORTED)
C(ECONNREFUSED)
C(ECONNRESET)
C(EDEADLK)
C(EDESTADDRREQ)
C(EDQUOT)
C(EEXIST)
C(EFAULT)
C(EFBIG)
C(EHOSTUNREACH)
C(EIDRM)
C(EINPROGRESS)
C(EINTR)
C(EINVAL)
C(EIO)
C(EISCONN)
C(EISDIR)
C(ELOOP)
C(EMFILE)
C(EMLINK)
C(EMSGSIZE)
C(EMULTIHOP)
C(ENAMETOOLONG)
C(ENETDOWN)
C(ENETRESET)
C(ENETUNREACH)
C(ENFILE)
C(ENOBUFS)
C(ENODATA)
C(ENODEV)
C(ENOENT)
C(ENOEXEC)
C(ENOLCK)
C(ENOLINK)
C(ENOMEM)
C(ENOMSG)
C(ENOPROTOOPT)
C(ENOSPC)
C(ENOSR)
C(ENOSTR)
C(ENOSYS)
C(ENOTCONN)
C(ENOTDIR)
C(ENOTEMPTY)
C(ENOTRECOVERABLE)
C(ENOTSOCK)
C(ENOTSUP)
C(ENOTTY)
C(ENXIO)
C(EOPNOTSUPP)
C(EOVERFLOW)
C(EOWNERDEAD)
C(EPERM)
C(EPIPE)
C(EPROTO)
C(EPROTONOSUPPORT)
C(EPROTOTYPE)
C(EROFS)
C(ESPIPE)
C(ESRCH)
C(ESTALE)
C(ETIME)
C(ETIMEDOUT)
C(ETXTBSY)
C(EWOULDBLOCK)
C(EXDEV)
#endif
}

View file

@ -0,0 +1,101 @@
#include <fcntl.h>
#include "options.h"
#define T(t) (t*)0;
#define F(t,n) {t *y = &x.n;}
#define C(n) switch(n){case n:;}
static void f()
{
C(F_DUPFD)
C(F_DUPFD_CLOEXEC)
C(F_GETFD)
C(F_SETFD)
C(F_GETFL)
C(F_SETFL)
C(F_GETLK)
C(F_SETLK)
C(F_SETLKW)
C(F_GETOWN)
C(F_SETOWN)
C(FD_CLOEXEC)
C(F_RDLCK)
C(F_UNLCK)
C(F_WRLCK)
C(SEEK_SET)
C(SEEK_CUR)
C(SEEK_END)
C(O_CREAT)
C(O_EXCL)
C(O_NOCTTY)
C(O_TRUNC)
C(O_TTY_INIT)
C(O_APPEND)
C(O_NONBLOCK)
#ifdef POSIX_SYNCHRONIZED_IO
C(O_DSYNC)
C(O_RSYNC)
#endif
C(O_SYNC)
C(O_ACCMODE)
C(O_EXEC)
C(O_RDONLY)
C(O_RDWR)
C(O_SEARCH)
C(O_WRONLY)
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)
#endif
C(AT_FDCWD)
C(AT_EACCESS)
C(AT_SYMLINK_NOFOLLOW)
C(AT_SYMLINK_FOLLOW)
C(O_CLOEXEC)
C(O_DIRECTORY)
C(O_NOFOLLOW)
C(AT_REMOVEDIR)
C(POSIX_FADV_DONTNEED)
C(POSIX_FADV_NOREUSE)
C(POSIX_FADV_NORMAL)
C(POSIX_FADV_RANDOM)
C(POSIX_FADV_SEQUENTIAL)
C(POSIX_FADV_WILLNEED)
{
struct flock x;
F(short, l_type)
F(short, l_whence)
F(off_t, l_start)
F(off_t, l_len)
F(pid_t, l_pid)
}
T(mode_t)
T(off_t)
T(pid_t)
{int(*p)(int,int,...) = fcntl;}
{int(*p)(int,off_t,off_t,int) = posix_fadvise;}
{int(*p)(int,off_t,off_t) = posix_fallocate;}
}
#ifndef _XOPEN_SOURCE
#include <sys/stat.h>
#endif
static void g()
{
{int(*p)(const char*,mode_t) = creat;}
{int(*p)(const char*,int,...) = open;}
{int(*p)(int,const char*,int,...) = openat;}
}

View file

@ -0,0 +1,31 @@
#include <fenv.h>
#define T(t) (t*)0;
#define F(t,n) {t *y = &x.n;}
#define C(n) switch(n){case n:;}
static void f()
{
T(fenv_t)
T(fexcept_t)
//FE_DIVBYZERO
//FE_INEXACT
//FE_INVALID
//FE_OVERFLOW
//FE_UNDERFLOW
C(FE_ALL_EXCEPT)
//FE_DOWNWARD
//FE_TONEAREST
//FE_TOWARDZERO
//FE_UPWARD
{const fenv_t *c = FE_DFL_ENV;}
{int(*p)(int) = feclearexcept;}
{int(*p)(fenv_t*) = fegetenv;}
{int(*p)(fexcept_t*,int) = fegetexceptflag;}
{int(*p)(void) = fegetround;}
{int(*p)(fenv_t*) = feholdexcept;}
{int(*p)(int) = feraiseexcept;}
{int(*p)(const fenv_t*) = fesetenv;}
{int(*p)(const fexcept_t*,int) = fesetexceptflag;}
{int(*p)(int) = fesetround;}
{int(*p)(int) = fetestexcept;}
{int(*p)(const fenv_t*) = feupdateenv;}
}

View file

@ -0,0 +1,39 @@
#include <float.h>
#define I(t,e) {t x[sizeof(t)==sizeof(e)] = {e};}
#define C(n) switch(n){case n:;}
#define D(n) {long double d = n;}
static void f()
{
I(int,FLT_ROUNDS)
C(FLT_EVAL_METHOD)
C(FLT_RADIX)
C(FLT_MANT_DIG)
C(DBL_MANT_DIG)
C(LDBL_MANT_DIG)
C(DECIMAL_DIG)
C(FLT_DIG)
C(DBL_DIG)
C(LDBL_DIG)
C(FLT_MIN_EXP)
C(DBL_MIN_EXP)
C(LDBL_MIN_EXP)
C(FLT_MIN_10_EXP)
C(DBL_MIN_10_EXP)
C(LDBL_MIN_10_EXP)
C(FLT_MAX_EXP)
C(DBL_MAX_EXP)
C(LDBL_MAX_EXP)
C(FLT_MAX_10_EXP)
C(DBL_MAX_10_EXP)
C(LDBL_MAX_10_EXP)
D(FLT_MAX)
D(DBL_MAX)
D(LDBL_MAX)
D(FLT_EPSILON)
D(DBL_EPSILON)
D(LDBL_EPSILON)
D(FLT_MIN)
D(DBL_MIN)
D(LDBL_MIN)
}

View file

@ -0,0 +1,29 @@
#ifdef X_FMTMSG
#include <fmtmsg.h>
#define C(n) switch(n){case n:;}
static void f()
{
C(MM_HARD)
C(MM_SOFT)
C(MM_FIRM)
C(MM_APPL)
C(MM_UTIL)
C(MM_OPSYS)
C(MM_RECOVER)
C(MM_NRECOV)
C(MM_HALT)
C(MM_ERROR)
C(MM_WARNING)
C(MM_INFO)
C(MM_NOSEV)
C(MM_PRINT)
C(MM_CONSOLE)
C(MM_OK)
C(MM_NOTOK)
C(MM_NOMSG)
C(MM_NOCON)
{int(*p)(long,const char*,int,const char*,const char*,const char*) = fmtmsg;}
}
#else
static void f(){}
#endif

View file

@ -0,0 +1,10 @@
#include <fnmatch.h>
#define C(n) switch(n){case n:;}
static void f()
{
C(FNM_NOMATCH)
C(FNM_PATHNAME)
C(FNM_PERIOD)
C(FNM_NOESCAPE)
{int(*p)(const char*,const char*,int) = fnmatch;}
}

View file

@ -0,0 +1,76 @@
#ifdef _XOPEN_SOURCE
#include <ftw.h>
#define T(t) (t*)0;
#define F(t,n) {t *y = &x.n;}
#define C(n) switch(n){case n:;}
static void f()
{
T(struct FTW)
T(struct stat)
C(FTW_F)
C(FTW_D)
C(FTW_DNR)
C(FTW_DP)
C(FTW_NS)
C(FTW_SL)
C(FTW_SLN)
C(FTW_PHYS)
C(FTW_MOUNT)
C(FTW_DEPTH)
C(FTW_CHDIR)
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)
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)
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 FTW x;
F(int, base)
F(int, level)
}
{
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)
}
{int(*p)(const char*,int(*)(const char*,const struct stat*,int),int) = ftw;}
{int(*p)(const char*,int(*)(const char*,const struct stat*,int,struct FTW*),int,int) = nftw;}
}
#endif

View file

@ -0,0 +1,27 @@
#include <glob.h>
#define T(t) (t*)0;
#define F(t,n) {t *y = &x.n;}
#define C(n) switch(n){case n:;}
static void f()
{
T(glob_t)
T(size_t)
{
glob_t x;
F(size_t, gl_pathc)
F(char**, gl_pathv)
F(size_t, gl_offs)
}
C(GLOB_APPEND)
C(GLOB_DOOFFS)
C(GLOB_ERR)
C(GLOB_MARK)
C(GLOB_NOCHECK)
C(GLOB_NOESCAPE)
C(GLOB_NOSORT)
C(GLOB_ABORTED)
C(GLOB_NOMATCH)
C(GLOB_NOSPACE)
{int(*p)(const char*restrict,int,int(*)(const char*,int),glob_t*restrict) = glob;}
{void(*p)(glob_t*) = globfree;}
}

View file

@ -0,0 +1,23 @@
#include <grp.h>
#define T(t) (t*)0;
#define F(t,n) {t *y = &x.n;}
static void f()
{
T(gid_t)
T(size_t)
{
struct group x;
F(char*, gr_name)
F(gid_t, gr_gid)
F(char**, gr_mem)
}
{void(*p)(void) = endgrent;}
{struct group*(*p)(void) = getgrent;}
{struct group*(*p)(gid_t) = getgrgid;}
{int(*p)(gid_t,struct group*,char*,size_t,struct group**) = getgrgid_r;}
{struct group*(*p)(const char*) = getgrnam;}
{int(*p)(const char*,struct group*,char*,size_t,struct group**) = getgrnam_r;}
#ifdef _XOPEN_SOURCE
{void(*p)(void) = setgrent;}
#endif
}

View file

@ -0,0 +1,10 @@
#include <iconv.h>
#define T(t) (t*)0;
static void f()
{
T(iconv_t)
T(size_t)
{size_t(*p)(iconv_t,char**restrict,size_t*restrict,char**restrict,size_t*restrict) = iconv;}
{int(*p)(iconv_t) = iconv_close;}
{iconv_t(*p)(const char*,const char*) = iconv_open;}
}

View file

@ -0,0 +1,263 @@
#include <inttypes.h>
#define T(t) (t*)0;
#define S(n) {char s[] = "" n;}
#define C(n) switch(n){case n:;}
static void f()
{
T(imaxdiv_t)
T(int8_t)
T(int16_t)
T(int32_t)
T(int64_t)
T(uint8_t)
T(uint16_t)
T(uint32_t)
T(uint64_t)
T(int_least8_t)
T(int_least16_t)
T(int_least32_t)
T(int_least64_t)
T(uint_least8_t)
T(uint_least16_t)
T(uint_least32_t)
T(uint_least64_t)
T(int_fast8_t)
T(int_fast16_t)
T(int_fast32_t)
T(int_fast64_t)
T(uint_fast8_t)
T(uint_fast16_t)
T(uint_fast32_t)
T(uint_fast64_t)
#ifdef _XOPEN_SOURCE
T(intptr_t)
T(uintptr_t)
#endif
T(intmax_t)
T(uintmax_t)
C(INT8_MIN)
C(INT16_MIN)
C(INT32_MIN)
C(INT64_MIN)
C(INT8_MAX)
C(INT16_MAX)
C(INT32_MAX)
C(INT64_MAX)
C(UINT8_MAX)
C(UINT16_MAX)
C(UINT32_MAX)
C(UINT64_MAX)
C(INT_LEAST8_MIN)
C(INT_LEAST16_MIN)
C(INT_LEAST32_MIN)
C(INT_LEAST64_MIN)
C(INT_LEAST8_MAX)
C(INT_LEAST16_MAX)
C(INT_LEAST32_MAX)
C(INT_LEAST64_MAX)
C(UINT_LEAST8_MAX)
C(UINT_LEAST16_MAX)
C(UINT_LEAST32_MAX)
C(UINT_LEAST64_MAX)
C(INT_FAST8_MIN)
C(INT_FAST16_MIN)
C(INT_FAST32_MIN)
C(INT_FAST64_MIN)
C(INT_FAST8_MAX)
C(INT_FAST16_MAX)
C(INT_FAST32_MAX)
C(INT_FAST64_MAX)
C(UINT_FAST8_MAX)
C(UINT_FAST16_MAX)
C(UINT_FAST32_MAX)
C(UINT_FAST64_MAX)
C(INTPTR_MIN)
C(INTPTR_MAX)
C(UINTPTR_MAX)
C(INTMAX_MIN)
C(INTMAX_MAX)
C(UINTMAX_MAX)
C(PTRDIFF_MIN)
C(PTRDIFF_MAX)
C(SIG_ATOMIC_MIN)
C(SIG_ATOMIC_MAX)
C(SIZE_MAX)
C(WCHAR_MIN)
C(WCHAR_MAX)
C(WINT_MIN)
C(WINT_MAX)
C(INT8_C(0))
C(INT16_C(0))
C(INT32_C(0))
C(INT64_C(0))
C(UINT8_C(0))
C(UINT16_C(0))
C(UINT32_C(0))
C(UINT64_C(0))
C(INTMAX_C(0))
C(UINTMAX_C(0))
S(PRId8)
S(PRId16)
S(PRId32)
S(PRId64)
S(PRIdLEAST8)
S(PRIdLEAST16)
S(PRIdLEAST32)
S(PRIdLEAST64)
S(PRIdFAST8)
S(PRIdFAST16)
S(PRIdFAST32)
S(PRIdFAST64)
S(PRIdMAX)
S(PRIdPTR)
S(PRIi8)
S(PRIi16)
S(PRIi32)
S(PRIi64)
S(PRIiLEAST8)
S(PRIiLEAST16)
S(PRIiLEAST32)
S(PRIiLEAST64)
S(PRIiFAST8)
S(PRIiFAST16)
S(PRIiFAST32)
S(PRIiFAST64)
S(PRIiMAX)
S(PRIiPTR)
S(PRIo8)
S(PRIo16)
S(PRIo32)
S(PRIo64)
S(PRIoLEAST8)
S(PRIoLEAST16)
S(PRIoLEAST32)
S(PRIoLEAST64)
S(PRIoFAST8)
S(PRIoFAST16)
S(PRIoFAST32)
S(PRIoFAST64)
S(PRIoMAX)
S(PRIoPTR)
S(PRIu8)
S(PRIu16)
S(PRIu32)
S(PRIu64)
S(PRIuLEAST8)
S(PRIuLEAST16)
S(PRIuLEAST32)
S(PRIuLEAST64)
S(PRIuFAST8)
S(PRIuFAST16)
S(PRIuFAST32)
S(PRIuFAST64)
S(PRIuMAX)
S(PRIuPTR)
S(PRIx8)
S(PRIx16)
S(PRIx32)
S(PRIx64)
S(PRIxLEAST8)
S(PRIxLEAST16)
S(PRIxLEAST32)
S(PRIxLEAST64)
S(PRIxFAST8)
S(PRIxFAST16)
S(PRIxFAST32)
S(PRIxFAST64)
S(PRIxMAX)
S(PRIxPTR)
S(PRIX8)
S(PRIX16)
S(PRIX32)
S(PRIX64)
S(PRIXLEAST8)
S(PRIXLEAST16)
S(PRIXLEAST32)
S(PRIXLEAST64)
S(PRIXFAST8)
S(PRIXFAST16)
S(PRIXFAST32)
S(PRIXFAST64)
S(PRIXMAX)
S(PRIXPTR)
S(SCNd8)
S(SCNd16)
S(SCNd32)
S(SCNd64)
S(SCNdLEAST8)
S(SCNdLEAST16)
S(SCNdLEAST32)
S(SCNdLEAST64)
S(SCNdFAST8)
S(SCNdFAST16)
S(SCNdFAST32)
S(SCNdFAST64)
S(SCNdMAX)
S(SCNdPTR)
S(SCNi8)
S(SCNi16)
S(SCNi32)
S(SCNi64)
S(SCNiLEAST8)
S(SCNiLEAST16)
S(SCNiLEAST32)
S(SCNiLEAST64)
S(SCNiFAST8)
S(SCNiFAST16)
S(SCNiFAST32)
S(SCNiFAST64)
S(SCNiMAX)
S(SCNiPTR)
S(SCNo8)
S(SCNo16)
S(SCNo32)
S(SCNo64)
S(SCNoLEAST8)
S(SCNoLEAST16)
S(SCNoLEAST32)
S(SCNoLEAST64)
S(SCNoFAST8)
S(SCNoFAST16)
S(SCNoFAST32)
S(SCNoFAST64)
S(SCNoMAX)
S(SCNoPTR)
S(SCNu8)
S(SCNu16)
S(SCNu32)
S(SCNu64)
S(SCNuLEAST8)
S(SCNuLEAST16)
S(SCNuLEAST32)
S(SCNuLEAST64)
S(SCNuFAST8)
S(SCNuFAST16)
S(SCNuFAST32)
S(SCNuFAST64)
S(SCNuMAX)
S(SCNuPTR)
S(SCNx8)
S(SCNx16)
S(SCNx32)
S(SCNx64)
S(SCNxLEAST8)
S(SCNxLEAST16)
S(SCNxLEAST32)
S(SCNxLEAST64)
S(SCNxFAST8)
S(SCNxFAST16)
S(SCNxFAST32)
S(SCNxFAST64)
S(SCNxMAX)
S(SCNxPTR)
{intmax_t(*p)(intmax_t) = imaxabs;}
{imaxdiv_t(*p)(intmax_t,intmax_t) = imaxdiv;}
{intmax_t(*p)(const char*restrict,char**restrict,int) = strtoimax;}
{uintmax_t(*p)(const char*restrict,char**restrict,int) = strtoumax;}
}
#include <stddef.h>
static void g()
{
{intmax_t(*p)(const wchar_t*restrict,wchar_t**restrict,int) = wcstoimax;}
{uintmax_t(*p)(const wchar_t*restrict,wchar_t**restrict,int) = wcstoumax;}
}

View file

@ -0,0 +1,16 @@
#include <iso646.h>
#define C(n) switch(n){case n:;}
static void f(){
int i = 0;
i and_eq 1;
i or_eq 1;
i xor_eq 1;
C(0 not_eq 1)
C(0 and 1)
C(0 or 1)
C(0 bitand 1)
C(0 bitor 1)
C(0 xor 1)
C(not 0)
C(compl 0)
}

View file

@ -0,0 +1,65 @@
#include <langinfo.h>
#define T(t) (t*)0;
#define C(n) switch(n){case n:;}
static void f()
{
T(locale_t)
T(nl_item)
C(CODESET)
C(D_T_FMT)
C(D_FMT)
C(T_FMT)
C(T_FMT_AMPM)
C(AM_STR)
C(PM_STR)
C(DAY_1)
C(DAY_2)
C(DAY_3)
C(DAY_4)
C(DAY_5)
C(DAY_6)
C(DAY_7)
C(ABDAY_1)
C(ABDAY_2)
C(ABDAY_3)
C(ABDAY_4)
C(ABDAY_5)
C(ABDAY_6)
C(ABDAY_7)
C(MON_1)
C(MON_2)
C(MON_3)
C(MON_4)
C(MON_5)
C(MON_6)
C(MON_7)
C(MON_8)
C(MON_9)
C(MON_10)
C(MON_11)
C(MON_12)
C(ABMON_1)
C(ABMON_2)
C(ABMON_3)
C(ABMON_4)
C(ABMON_5)
C(ABMON_6)
C(ABMON_7)
C(ABMON_8)
C(ABMON_9)
C(ABMON_10)
C(ABMON_11)
C(ABMON_12)
C(ERA)
C(ERA_D_FMT)
C(ERA_D_T_FMT)
C(ERA_T_FMT)
C(ALT_DIGITS)
C(RADIXCHAR)
C(THOUSEP)
C(YESEXPR)
C(NOEXPR)
C(CRNCYSTR)
{char*(*p)(nl_item) = nl_langinfo;}
{char*(*p)(nl_item,locale_t) = nl_langinfo_l;}
}

View file

@ -0,0 +1,9 @@
#ifdef _XOPEN_SOURCE
#include <libgen.h>
static void f()
{
{char*(*p)(char*) = basename;}
{char*(*p)(char*) = dirname;}
}
#endif

View file

@ -0,0 +1,99 @@
#include <limits.h>
#include "options.h"
#define C(n) switch(n){case n:;}
static void f()
{
C(BC_BASE_MAX)
C(BC_DIM_MAX)
C(BC_SCALE_MAX)
C(BC_STRING_MAX)
C(CHARCLASS_NAME_MAX)
C(COLL_WEIGHTS_MAX)
C(EXPR_NEST_MAX)
C(LINE_MAX)
C(NGROUPS_MAX)
C(RE_DUP_MAX)
C(_POSIX_CLOCKRES_MIN)
C(_POSIX_AIO_LISTIO_MAX)
C(_POSIX_AIO_MAX)
C(_POSIX_ARG_MAX)
C(_POSIX_CHILD_MAX)
C(_POSIX_DELAYTIMER_MAX)
C(_POSIX_HOST_NAME_MAX)
C(_POSIX_LINK_MAX)
C(_POSIX_LOGIN_NAME_MAX)
C(_POSIX_MAX_CANON)
C(_POSIX_MAX_INPUT)
#ifdef POSIX_MESSAGE_PASSING
C(_POSIX_MQ_OPEN_MAX)
C(_POSIX_MQ_PRIO_MAX)
#endif
C(_POSIX_NAME_MAX)
C(_POSIX_NGROUPS_MAX)
C(_POSIX_OPEN_MAX)
C(_POSIX_PATH_MAX)
C(_POSIX_PIPE_BUF)
C(_POSIX_RE_DUP_MAX)
C(_POSIX_RTSIG_MAX)
C(_POSIX_SEM_NSEMS_MAX)
C(_POSIX_SEM_VALUE_MAX)
C(_POSIX_SIGQUEUE_MAX)
C(_POSIX_SSIZE_MAX)
#if defined(POSIX_SPORADIC_SERVER) || defined(POSIX_THREAD_SPORADIC_SERVER)
C(_POSIX_SS_REPL_MAX)
#endif
C(_POSIX_STREAM_MAX)
C(_POSIX_SYMLINK_MAX)
C(_POSIX_SYMLOOP_MAX)
C(_POSIX_THREAD_DESTRUCTOR_ITERATIONS)
C(_POSIX_THREAD_KEYS_MAX)
C(_POSIX_THREAD_THREADS_MAX)
C(_POSIX_TIMER_MAX)
C(_POSIX_TTY_NAME_MAX)
C(_POSIX_TZNAME_MAX)
C(_POSIX2_BC_BASE_MAX)
C(_POSIX2_BC_DIM_MAX)
C(_POSIX2_BC_SCALE_MAX)
C(_POSIX2_BC_STRING_MAX)
C(_POSIX2_CHARCLASS_NAME_MAX)
C(_POSIX2_COLL_WEIGHTS_MAX)
C(_POSIX2_EXPR_NEST_MAX)
C(_POSIX2_LINE_MAX)
#ifdef _XOPEN_SOURCE
C(_XOPEN_IOV_MAX)
C(_XOPEN_NAME_MAX)
C(_XOPEN_PATH_MAX)
#endif
C(CHAR_BIT)
C(CHAR_MAX)
C(CHAR_MIN)
C(INT_MAX)
C(INT_MIN)
C(LLONG_MAX)
C(LLONG_MIN)
C(LONG_BIT)
C(LONG_MAX)
C(LONG_MIN)
C(MB_LEN_MAX)
C(SCHAR_MAX)
C(SCHAR_MIN)
C(SHRT_MAX)
C(SHRT_MIN)
C(SSIZE_MAX)
C(UCHAR_MAX)
C(UINT_MAX)
C(ULLONG_MAX)
C(ULONG_MAX)
C(USHRT_MAX)
C(WORD_BIT)
C(NL_ARGMAX)
#ifdef _XOPEN_SOURCE
C(NL_LANGMAX)
#endif
C(NL_MSGMAX)
C(NL_SETMAX)
C(NL_TEXTMAX)
#ifdef _XOPEN_SOURCE
C(NZERO)
#endif
}

View file

@ -0,0 +1,61 @@
#include <locale.h>
#define T(t) (t*)0;
#define F(t,n) {t *y = &x.n;}
#define C(n) switch(n){case n:;}
static void f()
{
T(locale_t)
{
struct lconv x;
F(char*,currency_symbol)
F(char*,decimal_point)
F(char,frac_digits)
F(char*,grouping)
F(char*,int_curr_symbol)
F(char,int_frac_digits)
F(char,int_n_cs_precedes)
F(char,int_n_sep_by_space)
F(char,int_n_sign_posn)
F(char,int_p_cs_precedes)
F(char,int_p_sep_by_space)
F(char,int_p_sign_posn)
F(char*,mon_decimal_point)
F(char*,mon_grouping)
F(char*,mon_thousands_sep)
F(char*,negative_sign)
F(char,n_cs_precedes)
F(char,n_sep_by_space)
F(char,n_sign_posn)
F(char*,positive_sign)
F(char,p_cs_precedes)
F(char,p_sep_by_space)
F(char,p_sign_posn)
F(char*,thousands_sep)
}
{void *x=NULL;}
C(LC_ALL)
C(LC_COLLATE)
C(LC_CTYPE)
#ifdef _POSIX_C_SOURCE
C(LC_MESSAGES)
#endif
C(LC_MONETARY)
C(LC_NUMERIC)
C(LC_TIME)
#ifdef _POSIX_C_SOURCE
C(LC_ALL_MASK)
C(LC_COLLATE_MASK)
C(LC_CTYPE_MASK)
C(LC_MESSAGES_MASK)
C(LC_MONETARY_MASK)
C(LC_NUMERIC_MASK)
C(LC_TIME_MASK)
{locale_t x = LC_GLOBAL_LOCALE;}
{locale_t(*p)(locale_t) = duplocale;}
{void(*p)(locale_t) = freelocale;}
{locale_t(*p)(int,const char*,locale_t) = newlocale;}
{locale_t(*p)(locale_t) = uselocale;}
#endif
{struct lconv*(*p)(void) = localeconv;}
{char*(*p)(int,const char*) = setlocale;}
}

View file

@ -0,0 +1 @@
int main() {}

View file

@ -0,0 +1,235 @@
#include <math.h>
#define T(t) (t*)0;
#define C(n) switch(n){case n:;}
#define I(t,e) {t x[sizeof(t)==sizeof(e)] = {e};}
#define D(n) {double d = n;}
static void f()
{
T(float_t)
T(double_t)
I(int,fpclassify(.0))
I(int,isfinite(.0))
I(int,isgreater(.0,.0))
I(int,isgreaterequal(.0,.0))
I(int,isinf(.0))
I(int,isless(.0,.0))
I(int,islessequal(.0,.0))
I(int,islessgreater(.0,.0))
I(int,isnan(.0))
I(int,isnormal(.0))
I(int,isunordered(.0,.0))
I(int,signbit(.0))
#ifdef _XOPEN_SOURCE
I(int,signgam)
D(M_E)
D(M_LOG2E)
D(M_LOG10E)
D(M_LN2)
D(M_LN10)
D(M_PI)
D(M_PI_2)
D(M_PI_4)
D(M_1_PI)
D(M_2_PI)
D(M_2_SQRTPI)
D(M_SQRT2)
D(M_SQRT1_2)
D(MAXFLOAT)
#endif
D(HUGE_VAL)
D(HUGE_VALF)
D(HUGE_VALL)
D(INFINITY)
D(NAN)
C(FP_INFINITE)
C(FP_NAN)
C(FP_NORMAL)
C(FP_SUBNORMAL)
C(FP_ZERO)
C(FP_ILOGB0)
C(FP_ILOGBNAN)
C(MATH_ERRNO)
C(MATH_ERREXCEPT)
C(math_errhandling)
{double(*p)(double) = acos;}
{float(*p)(float) = acosf;}
{double(*p)(double) = acosh;}
{float(*p)(float) = acoshf;}
{long double(*p)(long double) = acoshl;}
{long double(*p)(long double) = acosl;}
{double(*p)(double) = asin;}
{float(*p)(float) = asinf;}
{double(*p)(double) = asinh;}
{float(*p)(float) = asinhf;}
{long double(*p)(long double) = asinhl;}
{long double(*p)(long double) = asinl;}
{double(*p)(double) = atan;}
{double(*p)(double,double) = atan2;}
{float(*p)(float,float) = atan2f;}
{long double(*p)(long double,long double) = atan2l;}
{float(*p)(float) = atanf;}
{double(*p)(double) = atanh;}
{float(*p)(float) = atanhf;}
{long double(*p)(long double) = atanhl;}
{long double(*p)(long double) = atanl;}
{double(*p)(double) = cbrt;}
{float(*p)(float) = cbrtf;}
{long double(*p)(long double) = cbrtl;}
{double(*p)(double) = ceil;}
{float(*p)(float) = ceilf;}
{long double(*p)(long double) = ceill;}
{double(*p)(double,double) = copysign;}
{float(*p)(float,float) = copysignf;}
{long double(*p)(long double,long double) = copysignl;}
{double(*p)(double) = cos;}
{float(*p)(float) = cosf;}
{double(*p)(double) = cosh;}
{float(*p)(float) = coshf;}
{long double(*p)(long double) = coshl;}
{long double(*p)(long double) = cosl;}
{double(*p)(double) = erf;}
{double(*p)(double) = erfc;}
{float(*p)(float) = erfcf;}
{long double(*p)(long double) = erfcl;}
{float(*p)(float) = erff;}
{long double(*p)(long double) = erfl;}
{double(*p)(double) = exp;}
{double(*p)(double) = exp2;}
{float(*p)(float) = exp2f;}
{long double(*p)(long double) = exp2l;}
{float(*p)(float) = expf;}
{long double(*p)(long double) = expl;}
{double(*p)(double) = expm1;}
{float(*p)(float) = expm1f;}
{long double(*p)(long double) = expm1l;}
{double(*p)(double) = fabs;}
{float(*p)(float) = fabsf;}
{long double(*p)(long double) = fabsl;}
{double(*p)(double,double) = fdim;}
{float(*p)(float,float) = fdimf;}
{long double(*p)(long double,long double) = fdiml;}
{double(*p)(double) = floor;}
{float(*p)(float) = floorf;}
{long double(*p)(long double) = floorl;}
{double(*p)(double,double,double) = fma;}
{float(*p)(float,float,float) = fmaf;}
{long double(*p)(long double,long double,long double) = fmal;}
{double(*p)(double,double) = fmax;}
{float(*p)(float,float) = fmaxf;}
{long double(*p)(long double,long double) = fmaxl;}
{double(*p)(double,double) = fmin;}
{float(*p)(float,float) = fminf;}
{long double(*p)(long double,long double) = fminl;}
{double(*p)(double,double) = fmod;}
{float(*p)(float,float) = fmodf;}
{long double(*p)(long double,long double) = fmodl;}
{double(*p)(double,int*) = frexp;}
{float(*p)(float,int*) = frexpf;}
{long double(*p)(long double,int*) = frexpl;}
{double(*p)(double,double) = hypot;}
{float(*p)(float,float) = hypotf;}
{long double(*p)(long double,long double) = hypotl;}
{int(*p)(double) = ilogb;}
{int(*p)(float) = ilogbf;}
{int(*p)(long double) = ilogbl;}
#ifdef _XOPEN_SOURCE
{double(*p)(double) = j0;}
{double(*p)(double) = j1;}
{double(*p)(int,double) = jn;}
#endif
{double(*p)(double,int) = ldexp;}
{float(*p)(float,int) = ldexpf;}
{long double(*p)(long double,int) = ldexpl;}
{double(*p)(double) = lgamma;}
{float(*p)(float) = lgammaf;}
{long double(*p)(long double) = lgammal;}
{long long(*p)(double) = llrint;}
{long long(*p)(float) = llrintf;}
{long long(*p)(long double) = llrintl;}
{long long(*p)(double) = llround;}
{long long(*p)(float) = llroundf;}
{long long(*p)(long double) = llroundl;}
{double(*p)(double) = log;}
{double(*p)(double) = log10;}
{float(*p)(float) = log10f;}
{long double(*p)(long double) = log10l;}
{double(*p)(double) = log1p;}
{float(*p)(float) = log1pf;}
{long double(*p)(long double) = log1pl;}
{double(*p)(double) = log2;}
{float(*p)(float) = log2f;}
{long double(*p)(long double) = log2l;}
{double(*p)(double) = logb;}
{float(*p)(float) = logbf;}
{long double(*p)(long double) = logbl;}
{float(*p)(float) = logf;}
{long double(*p)(long double) = logl;}
{long(*p)(double) = lrint;}
{long(*p)(float) = lrintf;}
{long(*p)(long double) = lrintl;}
{long(*p)(double) = lround;}
{long(*p)(float) = lroundf;}
{long(*p)(long double) = lroundl;}
{double(*p)(double,double*) = modf;}
{float(*p)(float,float*) = modff;}
{long double(*p)(long double,long double*) = modfl;}
{double(*p)(const char*) = nan;}
{float(*p)(const char*) = nanf;}
{long double(*p)(const char*) = nanl;}
{double(*p)(double) = nearbyint;}
{float(*p)(float) = nearbyintf;}
{long double(*p)(long double) = nearbyintl;}
{double(*p)(double,double) = nextafter;}
{float(*p)(float,float) = nextafterf;}
{long double(*p)(long double,long double) = nextafterl;}
{double(*p)(double,long double) = nexttoward;}
{float(*p)(float,long double) = nexttowardf;}
{long double(*p)(long double,long double) = nexttowardl;}
{double(*p)(double,double) = pow;}
{float(*p)(float,float) = powf;}
{long double(*p)(long double,long double) = powl;}
{double(*p)(double,double) = remainder;}
{float(*p)(float,float) = remainderf;}
{long double(*p)(long double,long double) = remainderl;}
{double(*p)(double,double,int*) = remquo;}
{float(*p)(float,float,int*) = remquof;}
{long double(*p)(long double,long double,int*) = remquol;}
{double(*p)(double) = rint;}
{float(*p)(float) = rintf;}
{long double(*p)(long double) = rintl;}
{double(*p)(double) = round;}
{float(*p)(float) = roundf;}
{long double(*p)(long double) = roundl;}
{double(*p)(double,long) = scalbln;}
{float(*p)(float,long) = scalblnf;}
{long double(*p)(long double,long) = scalblnl;}
{double(*p)(double,int) = scalbn;}
{float(*p)(float,int) = scalbnf;}
{long double(*p)(long double,int) = scalbnl;}
{double(*p)(double) = sin;}
{float(*p)(float) = sinf;}
{double(*p)(double) = sinh;}
{float(*p)(float) = sinhf;}
{long double(*p)(long double) = sinhl;}
{long double(*p)(long double) = sinl;}
{double(*p)(double) = sqrt;}
{float(*p)(float) = sqrtf;}
{long double(*p)(long double) = sqrtl;}
{double(*p)(double) = tan;}
{float(*p)(float) = tanf;}
{double(*p)(double) = tanh;}
{float(*p)(float) = tanhf;}
{long double(*p)(long double) = tanhl;}
{long double(*p)(long double) = tanl;}
{double(*p)(double) = tgamma;}
{float(*p)(float) = tgammaf;}
{long double(*p)(long double) = tgammal;}
{double(*p)(double) = trunc;}
{float(*p)(float) = truncf;}
{long double(*p)(long double) = truncl;}
#ifdef _XOPEN_SOURCE
{double(*p)(double) = y0;}
{double(*p)(double) = y1;}
{double(*p)(int,double) = yn;}
#endif
}

View file

@ -0,0 +1,10 @@
#include <monetary.h>
#define T(t) (t*)0;
static void f()
{
T(locale_t)
T(size_t)
T(ssize_t)
{ssize_t(*p)(char*restrict,size_t,const char*restrict,...) = strfmon;}
{ssize_t(*p)(char*restrict,size_t,locale_t,const char*restrict,...) = strfmon_l;}
}

View file

@ -0,0 +1,37 @@
#include "options.h"
#ifdef POSIX_MESSAGE_PASSING
#include <mqueue.h>
#define T(t) (t*)0;
#define F(t,n) {t *y = &x.n;}
static void f()
{
T(mqd_t)
T(pthread_attr_t)
T(size_t)
T(ssize_t)
T(struct timespec)
T(struct sigevent)
{
struct mq_attr x;
F(long, mq_flags)
F(long, mq_maxmsg)
F(long, mq_msgsize)
F(long, mq_curmsgs)
}
{int(*p)(mqd_t) = mq_close;}
{int(*p)(mqd_t,struct mq_attr*) = mq_getattr;}
{int(*p)(mqd_t,const struct sigevent*) = mq_notify;}
{mqd_t(*p)(const char*,int,...) = mq_open;}
{ssize_t(*p)(mqd_t,char*,size_t,unsigned*) = mq_receive;}
{int(*p)(mqd_t,const char*,size_t,unsigned) = mq_send;}
{int(*p)(mqd_t,const struct mq_attr*restrict,struct mq_attr*restrict) = mq_setattr;}
{int(*p)(const char*) = mq_unlink;}
}
#include <time.h>
static void g()
{
{ssize_t(*p)(mqd_t,char*restrict,size_t,unsigned*restrict,const struct timespec*restrict) = mq_timedreceive;}
{int(*p)(mqd_t,const char*,size_t,unsigned,const struct timespec*) = mq_timedsend;}
}
#endif

View file

@ -0,0 +1,30 @@
#ifdef X_NDBM
#include <ndbm.h>
#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(mode_t)
T(DBM)
{
datum x;
F(void*, dptr)
F(size_t, dsize)
}
C(DBM_INSERT)
C(DBM_REPLACE)
{int(*p)(DBM*) = dbm_clearerr;}
{void(*p)(DBM*) = dbm_close;}
{int(*p)(DBM*,datum) = dbm_delete;}
{int(*p)(DBM*) = dbm_error;}
{datum(*p)(DBM*,datum) = dbm_fetch;}
{datum(*p)(DBM*) = dbm_firstkey;}
{datum(*p)(DBM*) = dbm_nextkey;}
{DBM*(*p)(const char*,int,mode_t) = dbm_open;}
{int(*p)(DBM*,datum,datum,int) = dbm_store;}
}
#else
static void f(){}
#endif

View file

@ -0,0 +1,16 @@
#include <net/if.h>
#define F(t,n) {t *y = &x.n;}
#define C(n) switch(n){case n:;}
static void f()
{
{
struct if_nameindex x;
F(unsigned, if_index)
F(char*, if_name)
}
C(IF_NAMESIZE)
{void(*p)(struct if_nameindex*) = if_freenameindex;}
{char*(*p)(unsigned,char*) = if_indextoname;}
{struct if_nameindex*(*p)(void) = if_nameindex;}
{unsigned(*p)(const char*) = if_nametoindex;}
}

View file

@ -0,0 +1,98 @@
#include <netdb.h>
#define T(t) (t*)0;
#define F(t,n) {t *y = &x.n;}
#define C(n) switch(n){case n:;}
static void f()
{
T(uint32_t)
T(socklen_t)
C(IPPORT_RESERVED)
{
struct hostent x;
F(char*, h_name)
F(char**, h_aliases)
F(int, h_addrtype)
F(int, h_length)
F(char**, h_addr_list)
}
{
struct netent x;
F(char*, n_name)
F(char**, n_aliases)
F(int, n_addrtype)
F(uint32_t, n_net)
}
{
struct protoent x;
F(char*, p_name)
F(char**, p_aliases)
F(int, p_proto)
}
{
struct servent x;
F(char*, s_name)
F(char**, s_aliases)
F(int, s_port)
F(char*, s_proto)
}
{
struct addrinfo x;
F(int, ai_flags)
F(int, ai_family)
F(int, ai_socktype)
F(int, ai_protocol)
F(socklen_t, ai_addrlen)
F(struct sockaddr*, ai_addr)
F(char*, ai_canonname)
F(struct addrinfo*, ai_next)
}
C(AI_PASSIVE)
C(AI_CANONNAME)
C(AI_NUMERICHOST)
C(AI_NUMERICSERV)
C(AI_V4MAPPED)
C(AI_ALL)
C(AI_ADDRCONFIG)
C(NI_NOFQDN)
C(NI_NUMERICHOST)
C(NI_NAMEREQD)
C(NI_NUMERICSERV)
C(NI_NUMERICSCOPE)
C(NI_DGRAM)
C(EAI_AGAIN)
C(EAI_BADFLAGS)
C(EAI_FAIL)
C(EAI_FAMILY)
C(EAI_MEMORY)
C(EAI_NONAME)
C(EAI_SERVICE)
C(EAI_SOCKTYPE)
C(EAI_SYSTEM)
C(EAI_OVERFLOW)
{void(*p)(void) = endhostent;}
{void(*p)(void) = endnetent;}
{void(*p)(void) = endprotoent;}
{void(*p)(void) = endservent;}
{const char*(*p)(int) = gai_strerror;}
{struct hostent*(*p)(void) = gethostent;}
{struct netent*(*p)(uint32_t,int) = getnetbyaddr;}
{struct netent*(*p)(const char*) = getnetbyname;}
{struct netent*(*p)(void) = getnetent;}
{struct protoent*(*p)(const char*) = getprotobyname;}
{struct protoent*(*p)(int) = getprotobynumber;}
{struct protoent*(*p)(void) = getprotoent;}
{struct servent*(*p)(const char*,const char*) = getservbyname;}
{struct servent*(*p)(int,const char*) = getservbyport;}
{struct servent*(*p)(void) = getservent;}
{void(*p)(int) = sethostent;}
{void(*p)(int) = setnetent;}
{void(*p)(int) = setprotoent;}
{void(*p)(int) = setservent;}
}
#include <sys/socket.h>
static void g()
{
{void(*p)(struct addrinfo*) = freeaddrinfo;}
{int(*p)(const char*restrict,const char*restrict,const struct addrinfo*restrict,struct addrinfo**restrict) = getaddrinfo;}
{int(*p)(const struct sockaddr*restrict,socklen_t,char*restrict,socklen_t,char*restrict,socklen_t,int) = getnameinfo;}
}

View file

@ -0,0 +1,77 @@
#include <netinet/in.h>
#define T(t) (t*)0;
#define F(t,n) {t *y = &x.n;}
#define C(n) switch(n){case n:;}
#define I(t,e) {t x[sizeof(t)==sizeof(e)] = {e};}
static void f()
{
T(in_port_t)
T(in_addr_t)
T(sa_family_t)
T(uint8_t)
T(uint32_t)
{
struct in_addr x;
F(in_addr_t, s_addr)
}
{
struct sockaddr_in x;
F(sa_family_t, sin_family)
F(in_port_t, sin_port)
F(struct in_addr, sin_addr)
}
{
struct in6_addr x;
F(uint8_t, s6_addr[16])
}
{
struct sockaddr_in6 x;
F(sa_family_t, sin6_family)
F(in_port_t, sin6_port)
F(uint32_t, sin6_flowinfo)
F(struct in6_addr, sin6_addr)
F(uint32_t, sin6_scope_id)
}
{const struct in6_addr *x = &in6addr_any;}
{const struct in6_addr *x = &in6addr_loopback;}
{struct in6_addr x = IN6ADDR_ANY_INIT;}
{struct in6_addr x = IN6ADDR_LOOPBACK_INIT;}
{
struct ipv6_mreq x;
F(struct in6_addr, ipv6mr_multiaddr)
F(unsigned, ipv6mr_interface)
}
C(IPPROTO_IP)
C(IPPROTO_IPV6)
C(IPPROTO_ICMP)
C(IPPROTO_RAW)
C(IPPROTO_TCP)
C(IPPROTO_UDP)
C(INADDR_ANY)
C(INADDR_BROADCAST)
C(INET_ADDRSTRLEN)
I(uint32_t,htonl(0LL))
I(uint16_t,htons(0LL))
I(uint32_t,ntohl(0LL))
I(uint16_t,ntohs(0LL))
C(INET6_ADDRSTRLEN)
C(IPV6_JOIN_GROUP)
C(IPV6_LEAVE_GROUP)
C(IPV6_MULTICAST_HOPS)
C(IPV6_MULTICAST_IF)
C(IPV6_MULTICAST_LOOP)
C(IPV6_UNICAST_HOPS)
C(IPV6_V6ONLY)
I(int,IN6_IS_ADDR_UNSPECIFIED(&in6addr_any))
I(int,IN6_IS_ADDR_LOOPBACK(&in6addr_any))
I(int,IN6_IS_ADDR_MULTICAST(&in6addr_any))
I(int,IN6_IS_ADDR_LINKLOCAL(&in6addr_any))
I(int,IN6_IS_ADDR_SITELOCAL(&in6addr_any))
I(int,IN6_IS_ADDR_V4MAPPED(&in6addr_any))
I(int,IN6_IS_ADDR_V4COMPAT(&in6addr_any))
I(int,IN6_IS_ADDR_MC_NODELOCAL(&in6addr_any))
I(int,IN6_IS_ADDR_MC_LINKLOCAL(&in6addr_any))
I(int,IN6_IS_ADDR_MC_SITELOCAL(&in6addr_any))
I(int,IN6_IS_ADDR_MC_ORGLOCAL(&in6addr_any))
I(int,IN6_IS_ADDR_MC_GLOBAL(&in6addr_any))
}

View file

@ -0,0 +1,6 @@
#include <netinet/tcp.h>
#define C(n) switch(n){case n:;}
static void f()
{
C(TCP_NODELAY)
}

View file

@ -0,0 +1,13 @@
#include <nl_types.h>
#define T(t) (t*)0;
#define C(n) switch(n){case n:;}
static void f()
{
T(nl_catd)
T(nl_item)
C(NL_SETD)
C(NL_CAT_LOCALE)
{int(*p)(nl_catd) = catclose;}
{char*(*p)(nl_catd,int,int,const char*) = catgets;}
{nl_catd(*p)(const char*,int) = catopen;}
}

View file

@ -0,0 +1,25 @@
#include <poll.h>
#define T(t) (t*)0;
#define F(t,n) {t *y = &x.n;}
#define C(n) switch(n){case n:;}
static void f()
{
T(nfds_t)
{
struct pollfd x;
F(int, fd)
F(short, events)
F(short, revents)
}
C(POLLIN)
C(POLLRDNORM)
C(POLLRDBAND)
C(POLLPRI)
C(POLLOUT)
C(POLLWRNORM)
C(POLLWRBAND)
C(POLLERR)
C(POLLHUP)
C(POLLNVAL)
{int(*p)(struct pollfd[],nfds_t,int) = poll;}
}

View file

@ -0,0 +1,172 @@
#include <pthread.h>
#define T(t) (t*)0;
#define C(n) switch(n){case n:;}
static void f()
{
T(pthread_attr_t)
T(pthread_barrier_t)
T(pthread_barrierattr_t)
T(pthread_cond_t)
T(pthread_condattr_t)
T(pthread_key_t)
T(pthread_mutex_t)
T(pthread_mutexattr_t)
T(pthread_once_t)
T(pthread_rwlock_t)
T(pthread_rwlockattr_t)
T(pthread_spinlock_t)
T(pthread_t)
C(PTHREAD_BARRIER_SERIAL_THREAD)
C(PTHREAD_CANCEL_ASYNCHRONOUS)
C(PTHREAD_CANCEL_ENABLE)
C(PTHREAD_CANCEL_DEFERRED)
C(PTHREAD_CANCEL_DISABLE)
{void *x = PTHREAD_CANCELED;}
C(PTHREAD_CREATE_DETACHED)
C(PTHREAD_CREATE_JOINABLE)
C(PTHREAD_MUTEX_DEFAULT)
C(PTHREAD_MUTEX_ERRORCHECK)
C(PTHREAD_MUTEX_NORMAL)
C(PTHREAD_MUTEX_RECURSIVE)
C(PTHREAD_MUTEX_ROBUST)
C(PTHREAD_MUTEX_STALLED)
C(PTHREAD_ONCE_INIT)
#if defined(POSIX_THREAD_ROBUST_PRIO_INHERIT) || defined(POSIX_THREAD_PRIO_INHERIT)
C(PTHREAD_PRIO_INHERIT)
#endif
#if defined(POSIX_THREAD_ROBUST_PRIO_INHERIT) || defined(POSIX_THREAD_PRIO_INHERIT) \
|| defined(POSIX_THREAD_ROBUST_PRIO_PROTECT) || defined(POSIX_THREAD_PRIO_PROTECT)
C(PTHREAD_PRIO_NONE)
#endif
#if defined(POSIX_THREAD_ROBUST_PRIO_PROTECT) || defined(POSIX_THREAD_PRIO_PROTECT)
C(PTHREAD_PRIO_PROTECT)
#endif
C(PTHREAD_PROCESS_SHARED)
C(PTHREAD_PROCESS_PRIVATE)
#ifdef POSIX_THREAD_PRIORITY_SCHEDULING
C(PTHREAD_EXPLICIT_SCHED)
C(PTHREAD_INHERIT_SCHED)
C(PTHREAD_SCOPE_PROCESS)
C(PTHREAD_SCOPE_SYSTEM)
#endif
{pthread_cond_t x = PTHREAD_COND_INITIALIZER;}
{pthread_mutex_t x = PTHREAD_MUTEX_INITIALIZER;}
{pthread_rwlock_t x = PTHREAD_RWLOCK_INITIALIZER;}
{int(*p)(void(*)(void),void(*)(void),void(*)(void)) = pthread_atfork;}
{int(*p)(pthread_attr_t*) = pthread_attr_destroy;}
{int(*p)(const pthread_attr_t*,int*) = pthread_attr_getdetachstate;}
{int(*p)(const pthread_attr_t*restrict,size_t*restrict) = pthread_attr_getguardsize;}
{int(*p)(const pthread_attr_t*restrict,struct sched_param*restrict) = pthread_attr_getschedparam;}
{int(*p)(const pthread_attr_t*restrict,void**restrict,size_t*restrict) = pthread_attr_getstack;}
{int(*p)(const pthread_attr_t*restrict,size_t*restrict) = pthread_attr_getstacksize;}
{int(*p)(pthread_attr_t*) = pthread_attr_init;}
{int(*p)(pthread_attr_t*,int) = pthread_attr_setdetachstate;}
{int(*p)(pthread_attr_t*,size_t) = pthread_attr_setguardsize;}
{int(*p)(pthread_attr_t*restrict,const struct sched_param*restrict) = pthread_attr_setschedparam;}
{int(*p)(pthread_attr_t*,void*,size_t) = pthread_attr_setstack;}
{int(*p)(pthread_attr_t*,size_t) = pthread_attr_setstacksize;}
{int(*p)(pthread_barrier_t*) = pthread_barrier_destroy;}
{int(*p)(pthread_barrier_t*restrict,const pthread_barrierattr_t*restrict,unsigned) = pthread_barrier_init;}
{int(*p)(pthread_barrier_t*) = pthread_barrier_wait;}
{int(*p)(pthread_barrierattr_t*) = pthread_barrierattr_destroy;}
{int(*p)(const pthread_barrierattr_t*restrict,int*restrict) = pthread_barrierattr_getpshared;}
{int(*p)(pthread_barrierattr_t*) = pthread_barrierattr_init;}
{int(*p)(pthread_barrierattr_t*,int) = pthread_barrierattr_setpshared;}
{int(*p)(pthread_t) = pthread_cancel;}
#ifndef pthread_cleanup_pop
{void(*p)(int) = pthread_cleanup_pop;}
#endif
#ifndef pthread_cleanup_push
{void(*p)(void(*)(void*),void*) = pthread_cleanup_push;}
#endif
{int(*p)(pthread_cond_t*) = pthread_cond_broadcast;}
{int(*p)(pthread_cond_t*) = pthread_cond_destroy;}
{int(*p)(pthread_cond_t*restrict,const pthread_condattr_t*restrict) = pthread_cond_init;}
{int(*p)(pthread_cond_t*) = pthread_cond_signal;}
{int(*p)(pthread_cond_t*restrict,pthread_mutex_t*restrict,const struct timespec*restrict) = pthread_cond_timedwait;}
{int(*p)(pthread_cond_t*restrict,pthread_mutex_t*restrict) = pthread_cond_wait;}
{int(*p)(pthread_condattr_t*) = pthread_condattr_destroy;}
{int(*p)(const pthread_condattr_t*restrict,clockid_t*restrict) = pthread_condattr_getclock;}
{int(*p)(const pthread_condattr_t*restrict,int*restrict) = pthread_condattr_getpshared;}
{int(*p)(pthread_condattr_t*) = pthread_condattr_init;}
{int(*p)(pthread_condattr_t*,clockid_t) = pthread_condattr_setclock;}
{int(*p)(pthread_condattr_t*,int) = pthread_condattr_setpshared;}
{int(*p)(pthread_t*restrict,const pthread_attr_t*restrict,void*(*)(void*),void*restrict) = pthread_create;}
{int(*p)(pthread_t) = pthread_detach;}
{int(*p)(pthread_t,pthread_t) = pthread_equal;}
{void(*p)(void*) = pthread_exit;}
{void*(*p)(pthread_key_t) = pthread_getspecific;}
{int(*p)(pthread_t,void**) = pthread_join;}
{int(*p)(pthread_key_t*,void(*)(void*)) = pthread_key_create;}
{int(*p)(pthread_key_t) = pthread_key_delete;}
{int(*p)(pthread_mutex_t*) = pthread_mutex_consistent;}
{int(*p)(pthread_mutex_t*) = pthread_mutex_destroy;}
{int(*p)(pthread_mutex_t*restrict,const pthread_mutexattr_t*restrict) = pthread_mutex_init;}
{int(*p)(pthread_mutex_t*) = pthread_mutex_lock;}
{int(*p)(pthread_mutex_t*) = pthread_mutex_trylock;}
{int(*p)(pthread_mutex_t*) = pthread_mutex_unlock;}
{int(*p)(pthread_mutexattr_t*) = pthread_mutexattr_destroy;}
#if defined(POSIX_THREAD_ROBUST_PRIO_INHERIT) || defined(POSIX_THREAD_PRIO_INHERIT) \
|| defined(POSIX_THREAD_ROBUST_PRIO_PROTECT) || defined(POSIX_THREAD_PRIO_PROTECT)
{int(*p)(const pthread_mutexattr_t*restrict,int*restrict) = pthread_mutexattr_getprotocol;}
{int(*p)(pthread_mutexattr_t*,int) = pthread_mutexattr_setprotocol;}
#endif
{int(*p)(const pthread_mutexattr_t*restrict,int*restrict) = pthread_mutexattr_getpshared;}
{int(*p)(const pthread_mutexattr_t*restrict,int*restrict) = pthread_mutexattr_getrobust;}
{int(*p)(const pthread_mutexattr_t*restrict,int*restrict) = pthread_mutexattr_gettype;}
{int(*p)(pthread_mutexattr_t*) = pthread_mutexattr_init;}
{int(*p)(pthread_mutexattr_t*,int) = pthread_mutexattr_setpshared;}
{int(*p)(pthread_mutexattr_t*,int) = pthread_mutexattr_setrobust;}
{int(*p)(pthread_mutexattr_t*,int) = pthread_mutexattr_settype;}
{int(*p)(pthread_once_t*,void(*)(void)) = pthread_once;}
{int(*p)(pthread_rwlock_t*) = pthread_rwlock_destroy;}
{int(*p)(pthread_rwlock_t*restrict,const pthread_rwlockattr_t*restrict) = pthread_rwlock_init;}
{int(*p)(pthread_rwlock_t*) = pthread_rwlock_rdlock;}
{int(*p)(pthread_rwlock_t*) = pthread_rwlock_tryrdlock;}
{int(*p)(pthread_rwlock_t*) = pthread_rwlock_trywrlock;}
{int(*p)(pthread_rwlock_t*) = pthread_rwlock_unlock;}
{int(*p)(pthread_rwlock_t*) = pthread_rwlock_wrlock;}
{int(*p)(pthread_rwlockattr_t*) = pthread_rwlockattr_destroy;}
{int(*p)(const pthread_rwlockattr_t*restrict,int*restrict) = pthread_rwlockattr_getpshared;}
{int(*p)(pthread_rwlockattr_t*) = pthread_rwlockattr_init;}
{int(*p)(pthread_rwlockattr_t*,int) = pthread_rwlockattr_setpshared;}
{pthread_t(*p)(void) = pthread_self;}
{int(*p)(int,int*) = pthread_setcancelstate;}
{int(*p)(int,int*) = pthread_setcanceltype;}
#if defined _XOPEN_SOURCE && defined OBSOLETE
{int(*p)(void) = pthread_getconcurrency;}
{int(*p)(int) = pthread_setconcurrency;}
#endif
{int(*p)(pthread_t,int) = pthread_setschedprio;}
{int(*p)(pthread_key_t,const void*) = pthread_setspecific;}
{int(*p)(pthread_spinlock_t*) = pthread_spin_destroy;}
{int(*p)(pthread_spinlock_t*,int) = pthread_spin_init;}
{int(*p)(pthread_spinlock_t*) = pthread_spin_lock;}
{int(*p)(pthread_spinlock_t*) = pthread_spin_trylock;}
{int(*p)(pthread_spinlock_t*) = pthread_spin_unlock;}
{void(*p)(void) = pthread_testcancel;}
#if defined(POSIX_THREAD_ROBUST_PRIO_PROTECT) || defined(POSIX_THREAD_PRIO_PROTECT)
{int(*p)(const pthread_mutex_t*restrict,int*restrict) = pthread_mutex_getprioceiling;}
{int(*p)(pthread_mutex_t*restrict,int,int*restrict) = pthread_mutex_setprioceiling;}
{int(*p)(const pthread_mutexattr_t*restrict,int*restrict) = pthread_mutexattr_getprioceiling;}
{int(*p)(pthread_mutexattr_t*,int) = pthread_mutexattr_setprioceiling;}
#endif
#ifdef POSIX_THREAD_PRIORITY_SCHEDULING
{int(*p)(const pthread_attr_t*restrict,int*restrict) = pthread_attr_getinheritsched;}
{int(*p)(const pthread_attr_t*restrict,int*restrict) = pthread_attr_getschedpolicy;}
{int(*p)(const pthread_attr_t*restrict,int*restrict) = pthread_attr_getscope;}
{int(*p)(pthread_attr_t*,int) = pthread_attr_setinheritsched;}
{int(*p)(pthread_attr_t*,int) = pthread_attr_setschedpolicy;}
{int(*p)(pthread_attr_t*,int) = pthread_attr_setscope;}
{int(*p)(pthread_t,int*restrict,struct sched_param*restrict) = pthread_getschedparam;}
{int(*p)(pthread_t,int,const struct sched_param*) = pthread_setschedparam;}
#endif
}
#include <time.h>
static void g()
{
{int(*p)(pthread_t,clockid_t*) = pthread_getcpuclockid;}
{int(*p)(pthread_mutex_t*restrict,const struct timespec*restrict) = pthread_mutex_timedlock;}
{int(*p)(pthread_rwlock_t*restrict,const struct timespec*restrict) = pthread_rwlock_timedrdlock;}
{int(*p)(pthread_rwlock_t*restrict,const struct timespec*restrict) = pthread_rwlock_timedwrlock;}
}

View file

@ -0,0 +1,26 @@
#include <pwd.h>
#define T(t) (t*)0;
#define F(t,n) {t *y = &x.n;}
static void f()
{
T(gid_t)
T(uid_t)
T(size_t)
{
struct passwd x;
F(char*,pw_name)
F(uid_t,pw_uid)
F(gid_t,pw_gid)
F(char*,pw_dir)
F(char*,pw_shell)
}
{struct passwd*(*p)(const char*) = getpwnam;}
{int(*p)(const char*,struct passwd*,char*,size_t,struct passwd**) = getpwnam_r;}
{struct passwd*(*p)(uid_t) = getpwuid;}
{int(*p)(uid_t,struct passwd*,char*,size_t,struct passwd**) = getpwuid_r;}
#ifdef _XOPEN_SOURCE
{void(*p)(void) = endpwent;}
{struct passwd*(*p)(void) = getpwent;}
{void(*p)(void) = setpwent;}
#endif
}

View file

@ -0,0 +1,41 @@
#include <regex.h>
#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(regoff_t)
{
regex_t x;
F(size_t,re_nsub)
}
{
regmatch_t x;
F(regoff_t,rm_so)
F(regoff_t,rm_eo)
}
C(REG_EXTENDED)
C(REG_ICASE)
C(REG_NOSUB)
C(REG_NEWLINE)
C(REG_NOTBOL)
C(REG_NOTEOL)
C(REG_NOMATCH)
C(REG_BADPAT)
C(REG_ECOLLATE)
C(REG_ECTYPE)
C(REG_EESCAPE)
C(REG_ESUBREG)
C(REG_EBRACK)
C(REG_EPAREN)
C(REG_EBRACE)
C(REG_BADBR)
C(REG_ERANGE)
C(REG_ESPACE)
C(REG_BADRPT)
{int(*p)(regex_t*restrict,const char*restrict,int) = regcomp;}
{size_t(*p)(int,const regex_t*restrict,char*restrict,size_t) = regerror;}
{int(*p)(const regex_t*restrict,const char*restrict,size_t,regmatch_t[restrict],int) = regexec;}
{void(*p)(regex_t*) = regfree;}
}

View file

@ -0,0 +1,35 @@
#include <sched.h>
#include "options.h"
#define T(t) (t*)0;
#define F(t,n) {t *y = &x.n;}
#define C(n) switch(n){case n:;}
static void f()
{
T(struct timespec)
{
struct sched_param x;
F(int,sched_priority)
#if defined(POSIX_SPORADIC_SERVER) || defined(POSIX_THREAD_SPORADIC_SERVER)
F(int,sched_ss_low_priority)
F(struct timespec,sched_ss_repl_period)
F(struct timespec,sched_ss_init_budget)
F(int,sched_ss_max_repl)
T(time_t)
C(SCHED_SPORADIC)
#endif
}
#ifdef POSIX_PRIORITY_SCHEDULING
T(pid_t)
{int(*p)(pid_t,struct sched_param*) = sched_getparam;}
{int(*p)(pid_t) = sched_getscheduler;}
{int(*p)(pid_t,const struct sched_param*) = sched_setparam;}
{int(*p)(pid_t,int,const struct sched_param*) = sched_setscheduler;}
#endif
C(SCHED_FIFO)
C(SCHED_RR)
C(SCHED_OTHER)
{int(*p)(int) = sched_get_priority_max;}
{int(*p)(int) = sched_get_priority_min;}
{int(*p)(pid_t,struct timespec*) = sched_rr_get_interval;}
{int(*p)(void) = sched_yield;}
}

View file

@ -0,0 +1,37 @@
#include <search.h>
#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(ACTION)
T(VISIT)
T(ENTRY)
{
struct entry x;
F(char*,key)
F(void*,data)
}
switch((ACTION)0){
case FIND:
case ENTER:;
}
switch((VISIT)0){
case preorder:
case postorder:
case endorder:
case leaf:;
}
{int(*p)(size_t) = hcreate;}
{void(*p)(void) = hdestroy;}
{ENTRY*(*p)(ENTRY,ACTION) = hsearch;}
{void(*p)(void*,void*) = insque;}
{void*(*p)(const void*,const void*,size_t*,size_t,int(*)(const void*,const void*)) = lfind;}
{void*(*p)(const void*,void*,size_t*,size_t,int(*)(const void*,const void*)) = lsearch;}
{void(*p)(void*) = remque;}
{void*(*p)(const void*restrict,void**restrict,int(*)(const void*,const void*)) = tdelete;}
{void*(*p)(const void*,void*const*,int(*)(const void*,const void*)) = tfind;}
{void*(*p)(const void*,void**,int(*)(const void*,const void*)) = tsearch;}
{void(*p)(const void*,void(*)(const void*,VISIT,int)) = twalk;}
}

View file

@ -0,0 +1,19 @@
#include <semaphore.h>
static void f()
{
{sem_t *x = SEM_FAILED;}
{int(*p)(sem_t*) = sem_close;}
{int(*p)(sem_t*) = sem_destroy;}
{int(*p)(sem_t*restrict,int*restrict) = sem_getvalue;}
{int(*p)(sem_t*,int,unsigned) = sem_init;}
{sem_t*(*p)(const char*,int,...) = sem_open;}
{int(*p)(sem_t*) = sem_post;}
{int(*p)(sem_t*) = sem_trywait;}
{int(*p)(const char*) = sem_unlink;}
{int(*p)(sem_t*) = sem_wait;}
}
#include <time.h>
static void g()
{
{int(*p)(sem_t*restrict,const struct timespec*restrict) = sem_timedwait;}
}

View file

@ -0,0 +1,29 @@
#include <setjmp.h>
#define T(t) (t*)0;
static void f()
{
T(jmp_buf)
{void(*p)(jmp_buf,int) = longjmp;}
#ifdef setjmp
{int x = setjmp((jmp_buf){0});}
#else
{int(*p)(jmp_buf) = setjmp;}
#endif
#ifdef _POSIX_C_SOURCE
T(sigjmp_buf)
{void(*p)(sigjmp_buf,int) = siglongjmp;}
#ifdef sigsetjmp
{int x = sigsetjmp((sigjmp_buf){0}, 0);}
#else
{int(*p)(sigjmp_buf,int) = sigsetjmp;}
#endif
#endif
#if defined _XOPEN_SOURCE && defined OBSOLETE
{void(*p)(jmp_buf,int) = _longjmp;}
#ifdef _setjmp
{int x = _setjmp((jmp_buf){0});}
#else
{int(*p)(jmp_buf) = _setjmp;}
#endif
#endif
}

View file

@ -0,0 +1,183 @@
#include <signal.h>
#define T(t) (t*)0;
#define F(t,n) {t *y = &x.n;}
#define C(n) switch(n){case n:;}
static void f()
{
T(sig_atomic_t)
{void(*x)(int) = SIG_DFL;}
{void(*x)(int) = SIG_ERR;}
{void(*x)(int) = SIG_IGN;}
#ifdef _POSIX_C_SOURCE
{void(*x)(int) = SIG_HOLD;}
T(size_t)
T(sigset_t)
T(pid_t)
T(uid_t)
T(pthread_t)
T(pthread_attr_t)
T(struct timespec)
{
struct sigevent x;
F(int,sigev_notify)
F(int,sigev_signo)
F(union sigval,sigev_value)
{void (**y)(union sigval) = &x.sigev_notify_function;}
F(pthread_attr_t*,sigev_notify_attributes)
}
C(SIGEV_NONE)
C(SIGEV_SIGNAL)
C(SIGEV_THREAD)
{
union sigval x;
F(int,sival_int)
F(void*,sival_ptr)
}
{int i = SIGRTMIN;}
{int i = SIGRTMAX;}
#endif
C(SIGABRT)
C(SIGFPE)
C(SIGILL)
C(SIGINT)
C(SIGSEGV)
C(SIGTERM)
#ifdef _POSIX_C_SOURCE
C(SIGALRM)
C(SIGBUS)
C(SIGCHLD)
C(SIGCONT)
C(SIGHUP)
C(SIGKILL)
C(SIGPIPE)
C(SIGQUIT)
C(SIGSTOP)
C(SIGTSTP)
C(SIGTTIN)
C(SIGTTOU)
C(SIGUSR1)
C(SIGUSR2)
C(SIGURG)
#ifdef _XOPEN_SOURCE
C(SIGSYS)
C(SIGTRAP)
C(SIGVTALRM)
C(SIGXCPU)
C(SIGXFSZ)
#endif
{
struct sigaction x;
{void (**y)(int) = &x.sa_handler;}
F(sigset_t, sa_mask)
F(int,sa_flags)
{void (**y)(int, siginfo_t *, void *) = &x.sa_sigaction;}
}
C(SIG_BLOCK)
C(SIG_UNBLOCK)
C(SIG_SETMASK)
C(SA_NOCLDSTOP)
C(SA_RESETHAND)
C(SA_RESTART)
C(SA_SIGINFO)
C(SA_NOCLDWAIT)
C(SA_NODEFER)
#ifdef _XOPEN_SOURCE
C(SA_ONSTACK)
C(SS_ONSTACK)
C(SS_DISABLE)
C(MINSIGSTKSZ)
C(SIGSTKSZ)
#endif
T(mcontext_t)
{
ucontext_t x;
F(ucontext_t*,uc_link)
F(sigset_t,uc_sigmask)
F(stack_t, uc_stack)
F(mcontext_t,uc_mcontext)
}
{
stack_t x;
F(void *,ss_sp)
F(size_t,ss_size)
F(int, ss_flags)
}
{
siginfo_t x;
F(int, si_signo)
F(int, si_code)
#ifdef _XOPEN_SOURCE
F(int, si_errno)
#endif
F(pid_t, si_pid)
F(uid_t, si_uid)
F(void *,si_addr)
F(int, si_status)
F(union sigval,si_value)
}
C(ILL_ILLOPC)
C(ILL_ILLOPN)
C(ILL_ILLADR)
C(ILL_ILLTRP)
C(ILL_PRVOPC)
C(ILL_PRVREG)
C(ILL_COPROC)
C(ILL_BADSTK)
C(FPE_INTDIV)
C(FPE_INTOVF)
C(FPE_FLTDIV)
C(FPE_FLTOVF)
C(FPE_FLTUND)
C(FPE_FLTRES)
C(FPE_FLTINV)
C(FPE_FLTSUB)
C(SEGV_MAPERR)
C(SEGV_ACCERR)
C(BUS_ADRALN)
C(BUS_ADRERR)
C(BUS_OBJERR)
#ifdef _XOPEN_SOURCE
C(TRAP_BRKPT)
C(TRAP_TRACE)
#endif
C(CLD_EXITED)
C(CLD_KILLED)
C(CLD_DUMPED)
C(CLD_TRAPPED)
C(CLD_STOPPED)
C(CLD_CONTINUED)
C(SI_USER)
C(SI_QUEUE)
C(SI_TIMER)
C(SI_ASYNCIO)
C(SI_MESGQ)
{int(*p)(pid_t,int) = kill;}
{int(*p)(pid_t,int) = killpg;}
{void(*p)(const siginfo_t*,const char*) = psiginfo;}
{void(*p)(int,const char*) = psignal;}
{int(*p)(pthread_t,int) = pthread_kill;}
{int(*p)(int,const sigset_t*restrict,sigset_t*restrict) = pthread_sigmask;}
{int(*p)(int,const struct sigaction*restrict,struct sigaction*restrict) = sigaction;}
{int(*p)(sigset_t*,int) = sigaddset;}
{int(*p)(const stack_t*restrict,stack_t*restrict) = sigaltstack;}
{int(*p)(sigset_t*,int) = sigdelset;}
{int(*p)(sigset_t*) = sigemptyset;}
{int(*p)(sigset_t*) = sigfillset;}
{int(*p)(int) = sighold;}
{int(*p)(int) = sigignore;}
{int(*p)(int,int) = siginterrupt;}
{int(*p)(const sigset_t*,int) = sigismember;}
{int(*p)(int) = sigpause;}
{int(*p)(sigset_t*) = sigpending;}
{int(*p)(int,const sigset_t*restrict,sigset_t*restrict) = sigprocmask;}
{int(*p)(pid_t,int,const union sigval) = sigqueue;}
{int(*p)(int) = sigrelse;}
{void(*(*p)(int,void(*)(int)))(int) = sigset;}
{int(*p)(const sigset_t*) = sigsuspend;}
{int(*p)(const sigset_t*restrict,siginfo_t*restrict,const struct timespec*restrict) = sigtimedwait;}
{int(*p)(const sigset_t*restrict,int*restrict) = sigwait;}
{int(*p)(const sigset_t*restrict,siginfo_t*restrict) = sigwaitinfo;}
#endif
{int(*p)(int) = raise;}
{void(*(*p)(int,void(*)(int)))(int) = signal;}
}

View file

@ -0,0 +1,52 @@
#include <spawn.h>
#include "options.h"
#define T(t) (t*)0;
#define C(n) switch(n){case n:;}
static void f()
{
T(posix_spawnattr_t)
T(posix_spawn_file_actions_t)
T(mode_t)
T(pid_t)
T(sigset_t)
T(struct sched_param)
C(POSIX_SPAWN_RESETIDS)
C(POSIX_SPAWN_SETPGROUP)
#ifdef POSIX_PRIORITY_SCHEDULING
C(POSIX_SPAWN_SETSCHEDPARAM)
C(POSIX_SPAWN_SETSCHEDULER)
#endif
C(POSIX_SPAWN_SETSIGDEF)
C(POSIX_SPAWN_SETSIGMASK)
{int(*p)(pid_t*restrict,const char*restrict,const posix_spawn_file_actions_t*,const posix_spawnattr_t*restrict,char*const[restrict],char*const[restrict]) = posix_spawn;}
{int(*p)(posix_spawn_file_actions_t*,int) = posix_spawn_file_actions_addclose;}
{int(*p)(posix_spawn_file_actions_t*,int,int) = posix_spawn_file_actions_adddup2;}
{int(*p)(posix_spawn_file_actions_t*restrict,int,const char*restrict,int,mode_t) = posix_spawn_file_actions_addopen;}
{int(*p)(posix_spawn_file_actions_t*) = posix_spawn_file_actions_destroy;}
{int(*p)(posix_spawn_file_actions_t*) = posix_spawn_file_actions_init;}
{int(*p)(posix_spawnattr_t*) = posix_spawnattr_destroy;}
{int(*p)(const posix_spawnattr_t*restrict,short*restrict) = posix_spawnattr_getflags;}
{int(*p)(const posix_spawnattr_t*restrict,pid_t*restrict) = posix_spawnattr_getpgroup;}
{int(*p)(posix_spawnattr_t*) = posix_spawnattr_init;}
{int(*p)(posix_spawnattr_t*,short) = posix_spawnattr_setflags;}
{int(*p)(posix_spawnattr_t*,pid_t) = posix_spawnattr_setpgroup;}
{int(*p)(pid_t*restrict,const char*restrict,const posix_spawn_file_actions_t*,const posix_spawnattr_t*restrict,char*const[restrict],char*const[restrict]) = posix_spawnp;}
}
#include <signal.h>
static void g()
{
{int(*p)(const posix_spawnattr_t*restrict,sigset_t*restrict) = posix_spawnattr_getsigdefault;}
{int(*p)(const posix_spawnattr_t*restrict,sigset_t*restrict) = posix_spawnattr_getsigmask;}
{int(*p)(posix_spawnattr_t*restrict,const sigset_t*restrict) = posix_spawnattr_setsigdefault;}
{int(*p)(posix_spawnattr_t*restrict,const sigset_t*restrict) = posix_spawnattr_setsigmask;}
}
#ifdef POSIX_PRIORITY_SCHEDULING
#include <sched.h>
static void h()
{
{int(*p)(const posix_spawnattr_t*restrict,struct sched_param*restrict) = posix_spawnattr_getschedparam;}
{int(*p)(const posix_spawnattr_t*restrict,int*restrict) = posix_spawnattr_getschedpolicy;}
{int(*p)(posix_spawnattr_t*restrict,const struct sched_param*restrict) = posix_spawnattr_setschedparam;}
{int(*p)(posix_spawnattr_t*,int) = posix_spawnattr_setschedpolicy;}
}
#endif

View file

@ -0,0 +1,18 @@
#include <stdarg.h>
#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
}

View file

@ -0,0 +1,10 @@
#include <stdbool.h>
#define T(t) (t*)0;
#define C(n) switch(n){case n:;}
static void f()
{
T(bool)
C(true)
C(false)
C(__bool_true_false_are_defined)
}

View file

@ -0,0 +1,11 @@
#include <stddef.h>
#define T(t) (t*)0;
#define C(n) switch(n){case n:;}
static void f()
{
{void *p=NULL;}
C(offsetof(struct{int i;}, i))
T(ptrdiff_t)
T(wchar_t)
T(size_t)
}

View file

@ -0,0 +1,97 @@
#include <stdint.h>
#define T(t) (t*)0;
#define C(n) switch(n){case n:;}
static void f()
{
T(int8_t)
T(int16_t)
T(int32_t)
T(int64_t)
T(uint8_t)
T(uint16_t)
T(uint32_t)
T(uint64_t)
T(int_least8_t)
T(int_least16_t)
T(int_least32_t)
T(int_least64_t)
T(uint_least8_t)
T(uint_least16_t)
T(uint_least32_t)
T(uint_least64_t)
T(int_fast8_t)
T(int_fast16_t)
T(int_fast32_t)
T(int_fast64_t)
T(uint_fast8_t)
T(uint_fast16_t)
T(uint_fast32_t)
T(uint_fast64_t)
#ifdef _XOPEN_SOURCE
T(intptr_t)
T(uintptr_t)
#endif
T(intmax_t)
T(uintmax_t)
C(INT8_MIN)
C(INT16_MIN)
C(INT32_MIN)
C(INT64_MIN)
C(INT8_MAX)
C(INT16_MAX)
C(INT32_MAX)
C(INT64_MAX)
C(UINT8_MAX)
C(UINT16_MAX)
C(UINT32_MAX)
C(UINT64_MAX)
C(INT_LEAST8_MIN)
C(INT_LEAST16_MIN)
C(INT_LEAST32_MIN)
C(INT_LEAST64_MIN)
C(INT_LEAST8_MAX)
C(INT_LEAST16_MAX)
C(INT_LEAST32_MAX)
C(INT_LEAST64_MAX)
C(UINT_LEAST8_MAX)
C(UINT_LEAST16_MAX)
C(UINT_LEAST32_MAX)
C(UINT_LEAST64_MAX)
C(INT_FAST8_MIN)
C(INT_FAST16_MIN)
C(INT_FAST32_MIN)
C(INT_FAST64_MIN)
C(INT_FAST8_MAX)
C(INT_FAST16_MAX)
C(INT_FAST32_MAX)
C(INT_FAST64_MAX)
C(UINT_FAST8_MAX)
C(UINT_FAST16_MAX)
C(UINT_FAST32_MAX)
C(UINT_FAST64_MAX)
C(INTPTR_MIN)
C(INTPTR_MAX)
C(UINTPTR_MAX)
C(INTMAX_MIN)
C(INTMAX_MAX)
C(UINTMAX_MAX)
C(PTRDIFF_MIN)
C(PTRDIFF_MAX)
C(SIG_ATOMIC_MIN)
C(SIG_ATOMIC_MAX)
C(SIZE_MAX)
C(WCHAR_MIN)
C(WCHAR_MAX)
C(WINT_MIN)
C(WINT_MAX)
C(INT8_C(0))
C(INT16_C(0))
C(INT32_C(0))
C(INT64_C(0))
C(UINT8_C(0))
C(UINT16_C(0))
C(UINT32_C(0))
C(UINT64_C(0))
C(INTMAX_C(0))
C(UINTMAX_C(0))
}

View file

@ -0,0 +1,132 @@
#include <stdio.h>
#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
#ifdef OBSOLETE
C(L_tmpnam)
#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)(FILE*) = clearerr;}
{char*(*p)(char*) = ctermid;}
{int(*p)(int,const char*restrict,...) = dprintf;}
{int(*p)(FILE*) = fclose;}
{FILE*(*p)(int,const char*) = fdopen;}
{int(*p)(FILE*) = feof;}
{int(*p)(FILE*) = ferror;}
{int(*p)(FILE*) = fflush;}
{int(*p)(FILE*) = fgetc;}
{int(*p)(FILE*restrict,fpos_t*restrict) = fgetpos;}
{char*(*p)(char*restrict,int,FILE*restrict) = fgets;}
{int(*p)(FILE*) = fileno;}
{void(*p)(FILE*) = flockfile;}
{FILE*(*p)(void*restrict,size_t,const char*restrict) = fmemopen;}
{FILE*(*p)(const char*restrict,const char*restrict) = fopen;}
{int(*p)(FILE*restrict,const char*restrict,...) = fprintf;}
{int(*p)(int,FILE*) = fputc;}
{int(*p)(const char*restrict,FILE*restrict) = fputs;}
{size_t(*p)(void*restrict,size_t,size_t,FILE*restrict) = fread;}
{FILE*(*p)(const char*restrict,const char*restrict,FILE*restrict) = freopen;}
{int(*p)(FILE*restrict,const char*restrict,...) = fscanf;}
{int(*p)(FILE*,long,int) = fseek;}
{int(*p)(FILE*,off_t,int) = fseeko;}
{int(*p)(FILE*,const fpos_t*) = fsetpos;}
{long(*p)(FILE*) = ftell;}
{off_t(*p)(FILE*) = ftello;}
{int(*p)(FILE*) = ftrylockfile;}
{void(*p)(FILE*) = funlockfile;}
{size_t(*p)(const void*restrict,size_t,size_t,FILE*restrict) = fwrite;}
{int(*p)(FILE*) = getc;}
{int(*p)(FILE*) = getc_unlocked;}
{int(*p)(void) = getchar;}
{int(*p)(void) = getchar_unlocked;}
{ssize_t(*p)(char**restrict,size_t*restrict,int,FILE*restrict) = getdelim;}
{ssize_t(*p)(char**restrict,size_t*restrict,FILE*restrict) = getline;}
{char*(*p)(char*) = gets;}
{FILE*(*p)(char**,size_t*) = open_memstream;}
{int(*p)(FILE*) = pclose;}
{void(*p)(const char*) = perror;}
{FILE*(*p)(const char*,const char*) = popen;}
{int(*p)(const char*restrict,...) = printf;}
{int(*p)(int,FILE*) = putc;}
{int(*p)(int,FILE*) = putc_unlocked;}
{int(*p)(int) = putchar;}
{int(*p)(int) = putchar_unlocked;}
{int(*p)(const char*) = puts;}
{int(*p)(const char*) = remove;}
{int(*p)(const char*,const char*) = rename;}
{int(*p)(int,const char*,int,const char*) = renameat;}
{void(*p)(FILE*) = rewind;}
{int(*p)(const char*restrict,...) = scanf;}
{void(*p)(FILE*restrict,char*restrict) = setbuf;}
{int(*p)(FILE*restrict,char*restrict,int,size_t) = setvbuf;}
{int(*p)(char*restrict,size_t,const char*restrict,...) = snprintf;}
{int(*p)(char*restrict,const char*restrict,...) = sprintf;}
{int(*p)(const char*restrict,const char*restrict,...) = sscanf;}
{char*(*p)(const char*,const char*) = tempnam;}
{FILE*(*p)(void) = tmpfile;}
{char*(*p)(char*) = tmpnam;}
{int(*p)(int,FILE*) = ungetc;}
}
#include <wchar.h>
static void g()
{
{wint_t(*p)(int) = btowc;}
{wint_t(*p)(FILE*) = fgetwc;}
{wchar_t*(*p)(wchar_t*restrict,int,FILE*restrict) = fgetws;}
{wint_t(*p)(wchar_t,FILE*) = fputwc;}
{int(*p)(const wchar_t*restrict,FILE*restrict) = fputws;}
{int(*p)(FILE*,int) = fwide;}
{int(*p)(FILE*restrict,const wchar_t*restrict,...) = fwprintf;}
{int(*p)(FILE*restrict,const wchar_t*restrict,...) = fwscanf;}
{wint_t(*p)(FILE*) = getwc;}
{wint_t(*p)(wchar_t,FILE*) = putwc;}
{int(*p)(wchar_t*restrict,size_t,const wchar_t*restrict,...) = swprintf;}
{int(*p)(const wchar_t*restrict,const wchar_t*restrict,...) = swscanf;}
{wint_t(*p)(wint_t,FILE*) = ungetwc;}
{int(*p)(wint_t) = wctob;}
{int(*p)(const wchar_t*restrict,...) = wprintf;}
{int(*p)(const wchar_t*restrict,...) = wscanf;}
}
#include <stdarg.h>
static void h()
{
{int(*p)(int,const char*restrict,va_list) = vdprintf;}
{int(*p)(FILE*restrict,const char*restrict,va_list) = vfprintf;}
{int(*p)(FILE*restrict,const char*restrict,va_list) = vfscanf;}
{int(*p)(const char*restrict,va_list) = vprintf;}
{int(*p)(const char*restrict,va_list) = vscanf;}
{int(*p)(char*restrict,size_t,const char*restrict,va_list) = vsnprintf;}
{int(*p)(char*restrict,const char*restrict,va_list) = vsprintf;}
{int(*p)(const char*restrict,const char*restrict,va_list) = vsscanf;}
{int(*p)(FILE*restrict,const wchar_t*restrict,va_list) = vfwprintf;}
{int(*p)(FILE*restrict,const wchar_t*restrict,va_list) = vfwscanf;}
{int(*p)(wchar_t*restrict,size_t,const wchar_t*restrict,va_list) = vswprintf;}
{int(*p)(const wchar_t*restrict,const wchar_t*restrict,va_list) = vswscanf;}
{int(*p)(const wchar_t*restrict,va_list) = vwprintf;}
{int(*p)(const wchar_t*restrict,va_list) = vwscanf;}
}

View file

@ -0,0 +1,104 @@
#include <stdlib.h>
#define T(t) (t*)0;
#define F(t,n) {t *y = &x.n;}
#define C(n) switch(n){case n:;}
#define I(t,e) {t x[sizeof(t)==sizeof(e)] = {e};}
static void f()
{
C(EXIT_FAILURE)
C(EXIT_SUCCESS)
C(RAND_MAX)
I(size_t,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)(int) = _Exit;}
{void(*p)(void) = abort;}
{int(*p)(int) = abs;}
{int(*p)(void(*)(void)) = atexit;}
{double(*p)(const char*) = atof;}
{int(*p)(const char*) = atoi;}
{long(*p)(const char*) = atol;}
{long long(*p)(const char*) = atoll;}
{void*(*p)(const void*,const void*,size_t,size_t,int(*)(const void*,const void*)) = bsearch;}
{void*(*p)(size_t,size_t) = calloc;}
{div_t(*p)(int,int) = div;}
{void(*p)(int) = exit;}
{void(*p)(void*) = free;}
{char*(*p)(const char*) = getenv;}
{int(*p)(char**,char*const*,char**) = getsubopt;}
{long(*p)(long) = labs;}
{ldiv_t(*p)(long,long) = ldiv;}
{long long(*p)(long long) = llabs;}
{lldiv_t(*p)(long long,long long) = lldiv;}
{void*(*p)(size_t) = malloc;}
{int(*p)(const char*,size_t) = mblen;}
{size_t(*p)(wchar_t*restrict,const char*restrict,size_t) = mbstowcs;}
{int(*p)(wchar_t*restrict,const char*restrict,size_t) = mbtowc;}
{int(*p)(void**,size_t,size_t) = posix_memalign;}
{void(*p)(void*,size_t,size_t,int(*)(const void*,const void*)) = qsort;}
{int(*p)(void) = rand;}
{void*(*p)(void*,size_t) = realloc;}
{void(*p)(unsigned) = srand;}
{double(*p)(const char*restrict,char**restrict) = strtod;}
{float(*p)(const char*restrict,char**restrict) = strtof;}
{long(*p)(const char*restrict,char**restrict,int) = strtol;}
{long double(*p)(const char*restrict,char**restrict) = strtold;}
{long long(*p)(const char*restrict,char**restrict,int) = strtoll;}
{unsigned long(*p)(const char*restrict,char**restrict,int) = strtoul;}
{unsigned long long(*p)(const char*restrict,char**restrict,int) = strtoull;}
{int(*p)(const char*) = system;}
{size_t(*p)(char*restrict,const wchar_t*restrict,size_t) = wcstombs;}
{int(*p)(char*,wchar_t) = wctomb;}
#ifdef _POSIX_C_SOURCE
{char*(*p)(char*) = mkdtemp;}
{int(*p)(char*) = mkstemp;}
{int(*p)(const char*,const char*,int) = setenv;}
{int(*p)(const char*) = unsetenv;}
#endif
#ifdef _XOPEN_SOURCE
{long(*p)(const char*) = a64l;}
{double(*p)(void) = drand48;}
{double(*p)(unsigned short[]) = erand48;}
{int(*p)(int) = grantpt;}
{char*(*p)(unsigned,char*,size_t) = initstate;}
{long(*p)(unsigned short[]) = jrand48;}
{char*(*p)(long) = l64a;}
{void(*p)(unsigned short[]) = lcong48;}
{long(*p)(void) = lrand48;}
{long(*p)(void) = mrand48;}
{long(*p)(unsigned short[]) = nrand48;}
{char*(*p)(int) = ptsname;}
{int(*p)(char*) = putenv;}
{long(*p)(void) = random;}
{char*(*p)(const char*restrict,char*restrict) = realpath;}
{unsigned short*(*p)(unsigned short[]) = seed48;}
{void(*p)(const char*) = setkey;}
{char*(*p)(char*) = setstate;}
{void(*p)(long) = srand48;}
{void(*p)(unsigned) = srandom;}
{int(*p)(int) = unlockpt;}
#endif
}
#ifdef _XOPEN_SOURCE
#include <fcntl.h>
static void g()
{
{int(*p)(int) = posix_openpt;}
}
#endif

View file

@ -0,0 +1,46 @@
#include <string.h>
#define T(t) (t*)0;
static void f()
{
T(size_t)
{void *x=NULL;}
{void*(*p)(const void*,int,size_t) = memchr;}
{int(*p)(const void*,const void*,size_t) = memcmp;}
{void*(*p)(void*restrict,const void*restrict,size_t) = memcpy;}
{void*(*p)(void*,const void*,size_t) = memmove;}
{void*(*p)(void*,int,size_t) = memset;}
{char*(*p)(char*restrict,const char*restrict) = strcat;}
{char*(*p)(const char*,int) = strchr;}
{int(*p)(const char*,const char*) = strcmp;}
{int(*p)(const char*,const char*) = strcoll;}
{char*(*p)(char*restrict,const char*restrict) = strcpy;}
{size_t(*p)(const char*,const char*) = strcspn;}
{char*(*p)(int) = strerror;}
{size_t(*p)(const char*) = strlen;}
{char*(*p)(char*restrict,const char*restrict,size_t) = strncat;}
{int(*p)(const char*,const char*,size_t) = strncmp;}
{char*(*p)(char*restrict,const char*restrict,size_t) = strncpy;}
{char*(*p)(const char*,const char*) = strpbrk;}
{char*(*p)(const char*,int) = strrchr;}
{char*(*p)(int) = strsignal;}
{size_t(*p)(const char*,const char*) = strspn;}
{char*(*p)(const char*,const char*) = strstr;}
{char*(*p)(char*restrict,const char*restrict) = strtok;}
{size_t(*p)(char*restrict,const char*restrict,size_t) = strxfrm;}
#ifdef _POSIX_C_SOURCE
T(locale_t)
{char*(*p)(char*restrict,const char*restrict) = stpcpy;}
{char*(*p)(char*restrict,const char*restrict,size_t) = stpncpy;}
{int(*p)(const char*,const char*,locale_t) = strcoll_l;}
{char*(*p)(const char*) = strdup;}
{char*(*p)(int,locale_t) = strerror_l;}
{int(*p)(int,char*,size_t) = strerror_r;}
{char*(*p)(const char*,size_t) = strndup;}
{size_t(*p)(const char*,size_t) = strnlen;}
{char*(*p)(char*restrict,const char*restrict,char**restrict) = strtok_r;}
{size_t(*p)(char*restrict,const char*restrict,size_t,locale_t) = strxfrm_l;}
#endif
#ifdef _XOPEN_SOURCE
{void*(*p)(void*restrict,const void*restrict,int,size_t) = memccpy;}
#endif
}

View file

@ -0,0 +1,14 @@
#include <strings.h>
#define T(t) (t*)0;
static void f()
{
T(size_t)
T(locale_t)
#ifdef _XOPEN_SOURCE
{int(*p)(int) = ffs;}
#endif
{int(*p)(const char*,const char*) = strcasecmp;}
{int(*p)(const char*,const char*,locale_t) = strcasecmp_l;}
{int(*p)(const char*,const char*,size_t) = strncasecmp;}
{int(*p)(const char*,const char*,size_t,locale_t) = strncasecmp_l;}
}

View file

@ -0,0 +1,27 @@
#include <sys/ipc.h>
#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)(const char*,int) = ftok;}
}

View file

@ -0,0 +1,61 @@
#include <sys/mman.h>
#include "options.h"
#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)
#ifdef POSIX_TYPED_MEMORY_OBJECTS
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)(const void*restrict,size_t,off_t*restrict,size_t*restrict,int*restrict) = posix_mem_offset;
int(*p)(int,struct posix_typed_mem_info*) = posix_typed_mem_get_info;
int(*p)(const char*,int,int) = posix_typed_mem_open;
#endif
{int(*p)(const void*,size_t) = mlock;}
{int(*p)(int) = mlockall;}
{void*(*p)(void*,size_t,int,int,int,off_t) = mmap;}
{int(*p)(void*,size_t,int) = mprotect;}
#ifdef _XOPEN_SOURCE
{int(*p)(void*,size_t,int) = msync;}
#endif
{int(*p)(const void*,size_t) = munlock;}
{int(*p)(void) = munlockall;}
{int(*p)(void*,size_t) = munmap;}
{int(*p)(void*,size_t,int) = posix_madvise;}
#ifdef POSIX_SHARED_MEMORY_OBJECTS
{int(*p)(const char*,int,mode_t) = shm_open;}
{int(*p)(const char*) = shm_unlink;}
#endif
}

View file

@ -0,0 +1,29 @@
#include <sys/msg.h>
#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)(int,int,struct msqid_ds*) = msgctl;}
{int(*p)(key_t,int) = msgget;}
{ssize_t(*p)(int,void*,size_t,long,int) = msgrcv;}
{int(*p)(int,const void*,size_t,int) = msgsnd;}
}

View file

@ -0,0 +1,40 @@
#include <sys/resource.h>
#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(id_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)(int,id_t) = getpriority;}
{int(*p)(int,struct rlimit*) = getrlimit;}
{int(*p)(int,struct rusage*) = getrusage;}
{int(*p)(int,id_t,int) = setpriority;}
{int(*p)(int,const struct rlimit*) = setrlimit;}
}

View file

@ -0,0 +1,32 @@
#include <sys/select.h>
#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)(int,fd_set*) = FD_CLR;}
#endif
#ifndef FD_ISSET
{int(*p)(int,fd_set*) = FD_ISSET;}
#endif
#ifndef FD_SET
{void(*p)(int,fd_set*) = FD_SET;}
#endif
#ifndef FD_ZERO
{void(*p)(fd_set*) = FD_ZERO;}
#endif
{int(*p)(int,fd_set*restrict,fd_set*restrict,fd_set*restrict,const struct timespec*restrict,const sigset_t*restrict) = pselect;}
{int(*p)(int,fd_set*restrict,fd_set*restrict,fd_set*restrict,struct timeval*restrict) = select;}
}

View file

@ -0,0 +1,55 @@
#include <sys/sem.h>
#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)(int,int,int,...) = semctl;}
{int(*p)(key_t,int,int) = semget;}
{int(*p)(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)(const char*,int) = ftok;}
}

View file

@ -0,0 +1,50 @@
#include <sys/shm.h>
#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)(int,const void*,int) = shmat;}
{int(*p)(int,int,struct shmid_ds*) = shmctl;}
{int(*p)(const void*) = shmdt;}
{int(*p)(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)(const char*,int) = ftok;}
}

View file

@ -0,0 +1,111 @@
#include <sys/socket.h>
#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 iovec x;
F(void *,iov_base)
F(size_t,iov_len)
}
{
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)(int,struct sockaddr*restrict,socklen_t*restrict) = accept;}
{int(*p)(int,const struct sockaddr*,socklen_t) = bind;}
{int(*p)(int,const struct sockaddr*,socklen_t) = connect;}
{int(*p)(int,struct sockaddr*restrict,socklen_t*restrict) = getpeername;}
{int(*p)(int,struct sockaddr*restrict,socklen_t*restrict) = getsockname;}
{int(*p)(int,int,int,void*restrict,socklen_t*restrict) = getsockopt;}
{int(*p)(int,int) = listen;}
{ssize_t(*p)(int,void*,size_t,int) = recv;}
{ssize_t(*p)(int,void*restrict,size_t,int,struct sockaddr*restrict,socklen_t*restrict) = recvfrom;}
{ssize_t(*p)(int,struct msghdr*,int) = recvmsg;}
{ssize_t(*p)(int,const void*,size_t,int) = send;}
{ssize_t(*p)(int,const struct msghdr*,int) = sendmsg;}
{ssize_t(*p)(int,const void*,size_t,int,const struct sockaddr*,socklen_t) = sendto;}
{int(*p)(int,int,int,const void*,socklen_t) = setsockopt;}
{int(*p)(int,int) = shutdown;}
{int(*p)(int) = sockatmark;}
{int(*p)(int,int,int) = socket;}
{int(*p)(int,int,int,int[]) = socketpair;}
}

View file

@ -0,0 +1,104 @@
#include <sys/stat.h>
#include "options.h"
#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)
{
struct timespec x;
F(time_t,tv_sec)
F(long,tv_nsec)
}
{
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)
F(time_t, st_mtime)
F(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);}
#ifdef POSIX_TYPED_MEMORY_OBJECTS
{int i = S_TYPEISTMO(&x);}
#endif
}
C(UTIME_NOW)
C(UTIME_OMIT)
{int(*p)(const char*,mode_t) = chmod;}
{int(*p)(int,mode_t) = fchmod;}
{int(*p)(int,const char*,mode_t,int) = fchmodat;}
{int(*p)(int,struct stat*) = fstat;}
{int(*p)(int,const char*restrict,struct stat*restrict,int) = fstatat;}
{int(*p)(int,const struct timespec[]) = futimens;}
{int(*p)(const char*restrict,struct stat*restrict) = lstat;}
{int(*p)(const char*,mode_t) = mkdir;}
{int(*p)(int,const char*,mode_t) = mkdirat;}
{int(*p)(const char*,mode_t) = mkfifo;}
{int(*p)(int,const char*,mode_t) = mkfifoat;}
#ifdef _XOPEN_SOURCE
{int(*p)(const char*,mode_t,dev_t) = mknod;}
{int(*p)(int,const char*,mode_t,dev_t) = mknodat;}
#endif
{int(*p)(const char*restrict,struct stat*restrict) = stat;}
{mode_t(*p)(mode_t) = umask;}
{int(*p)(int,const char*,const struct timespec[],int) = utimensat;}
}

View file

@ -0,0 +1,27 @@
#include <sys/statvfs.h>
#define T(t) (t*)0;
#define F(t,n) {t *y = &x.n;}
#define C(n) switch(n){case n:;}
static void f()
{
T(fsblkcnt_t)
T(fsfilcnt_t)
{
struct statvfs x;
F(unsigned long, f_bsize)
F(unsigned long, f_frsize)
F(fsblkcnt_t,f_blocks)
F(fsblkcnt_t,f_bfree)
F(fsblkcnt_t,f_bavail)
F(fsfilcnt_t,f_files)
F(fsfilcnt_t,f_ffree)
F(fsfilcnt_t,f_favail)
F(unsigned long, f_fsid)
F(unsigned long, f_flag)
F(unsigned long, f_namemax)
}
C(ST_RDONLY)
C(ST_NOSUID)
{int(*p)(int,struct statvfs*) = fstatvfs;}
{int(*p)(const char*restrict,struct statvfs*restrict) = statvfs;}
}

View file

@ -0,0 +1,30 @@
#include <sys/time.h>
#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(fd_set)
{
struct timeval x;
F(time_t, tv_sec)
F(suseconds_t,tv_usec)
}
C(FD_SETSIZE)
#ifndef FD_CLR
{void(*p)(int,fd_set*) = FD_CLR;}
#endif
#ifndef FD_ISSET
{int(*p)(int,fd_set*) = FD_ISSET;}
#endif
#ifndef FD_SET
{void(*p)(int,fd_set*) = FD_SET;}
#endif
#ifndef FD_ZERO
{void(*p)(fd_set*) = FD_ZERO;}
#endif
{int(*p)(int,fd_set*restrict,fd_set*restrict,fd_set*restrict,struct timeval*restrict) = select;}
{int(*p)(const char*,const struct timeval[]) = utimes;}
}

View file

@ -0,0 +1,16 @@
#include <sys/times.h>
#define T(t) (t*)0;
#define F(t,n) {t *y = &x.n;}
#define C(n) switch(n){case n:;}
static void f()
{
T(clock_t)
{
struct tms x;
F(clock_t,tms_utime)
F(clock_t,tms_stime)
F(clock_t,tms_cutime)
F(clock_t,tms_cstime)
}
{clock_t(*p)(struct tms*) = times;}
}

View file

@ -0,0 +1,43 @@
#include <sys/types.h>
#define T(t) (t*)0;
#define N(t) {t x = 1;}
static void f()
{
N(blkcnt_t)
N(blksize_t)
N(clock_t)
N(clockid_t)
N(dev_t)
N(gid_t)
N(id_t)
N(ino_t)
N(mode_t)
N(nlink_t)
N(off_t)
N(pid_t)
N(size_t)
N(ssize_t)
N(time_t)
T(timer_t)
N(uid_t)
#ifdef _XOPEN_SOURCE
N(fsblkcnt_t)
N(fsfilcnt_t)
N(key_t)
N(suseconds_t)
#endif
T(pthread_attr_t)
T(pthread_barrier_t)
T(pthread_barrierattr_t)
T(pthread_cond_t)
T(pthread_condattr_t)
T(pthread_key_t)
T(pthread_mutex_t)
T(pthread_mutexattr_t)
T(pthread_once_t)
T(pthread_rwlock_t)
T(pthread_rwlockattr_t)
T(pthread_spinlock_t)
T(pthread_t)
}

View file

@ -0,0 +1,15 @@
#include <sys/uio.h>
#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)(int,const struct iovec*,int) = readv;}
{ssize_t(*p)(int,const struct iovec*,int) = writev;}
}

View file

@ -0,0 +1,13 @@
#include <sys/un.h>
#define T(t) (t*)0;
#define F(t,n) {t *y = &x.n;}
static void f()
{
T(sa_family_t)
{
struct sockaddr_un x;
F(sa_family_t,sun_family)
F(char, sun_path[0])
}
}

View file

@ -0,0 +1,14 @@
#include <sys/utsname.h>
#define F(t,n) {t *y = &x.n;}
static void f()
{
{
struct utsname x;
F(char,sysname[1])
F(char,nodename[1])
F(char,release[1])
F(char,version[1])
F(char,machine[1])
}
{int(*p)(struct utsname*) = uname;}
}

View file

@ -0,0 +1,31 @@
#include <sys/wait.h>
#define T(t) (t*)0;
#define F(t,n) {t *y = &x.n;}
#define C(n) switch(n){case n:;}
static void f()
{
T(id_t)
T(pid_t)
T(siginfo_t)
C(WEXITSTATUS(0))
C(WIFEXITED(0))
C(WIFSIGNALED(0))
C(WIFSTOPPED(0))
C(WNOHANG)
C(WSTOPSIG(0))
C(WTERMSIG(0))
C(WUNTRACED)
#ifdef _XOPEN_SOURCE
C(WCONTINUED)
C(WIFCONTINUED(0))
#endif
C(WEXITED)
C(WNOWAIT)
C(WSTOPPED)
{idtype_t x = P_ALL;}
{idtype_t x = P_PGID;}
{idtype_t x = P_PID;}
{pid_t(*p)(int*) = wait;}
{int(*p)(idtype_t,id_t,siginfo_t*,int) = waitid;}
{pid_t(*p)(pid_t,int*,int) = waitpid;}
}

View file

@ -0,0 +1,42 @@
#include <syslog.h>
#define T(t) (t*)0;
#define F(t,n) {t *y = &x.n;}
#define C(n) switch(n){case n:;}
static void f()
{
C(LOG_PID)
C(LOG_CONS)
C(LOG_NDELAY)
C(LOG_ODELAY)
C(LOG_NOWAIT)
C(LOG_KERN)
C(LOG_USER)
C(LOG_MAIL)
C(LOG_NEWS)
C(LOG_UUCP)
C(LOG_DAEMON)
C(LOG_AUTH)
C(LOG_CRON)
C(LOG_LPR)
C(LOG_LOCAL0)
C(LOG_LOCAL1)
C(LOG_LOCAL2)
C(LOG_LOCAL3)
C(LOG_LOCAL4)
C(LOG_LOCAL5)
C(LOG_LOCAL6)
C(LOG_LOCAL7)
{int i = LOG_MASK(0);}
C(LOG_EMERG)
C(LOG_ALERT)
C(LOG_CRIT)
C(LOG_ERR)
C(LOG_WARNING)
C(LOG_NOTICE)
C(LOG_INFO)
C(LOG_DEBUG)
{void(*p)(void) = closelog;}
{void(*p)(const char*,int,int) = openlog;}
{int(*p)(int) = setlogmask;}
{void(*p)(int,const char*,...) = syslog;}
}

View file

@ -0,0 +1,33 @@
#include <tar.h>
#define C(n) switch(n){case n:;}
static void f()
{
{char s[] = "" TMAGIC;}
C(TMAGLEN)
{char s[] = "" TVERSION;}
C(TVERSLEN)
C(REGTYPE)
C(AREGTYPE)
C(LNKTYPE)
C(SYMTYPE)
C(CHRTYPE)
C(BLKTYPE)
C(DIRTYPE)
C(FIFOTYPE)
C(CONTTYPE)
C(TSUID)
C(TSGID)
#ifdef _XOPEN_SOURCE
C(TSVTX)
#endif
C(TUREAD)
C(TUWRITE)
C(TUEXEC)
C(TGREAD)
C(TGWRITE)
C(TGEXEC)
C(TOREAD)
C(TOWRITE)
C(TOEXEC)
}

View file

@ -0,0 +1,131 @@
#include <termios.h>
#define T(t) (t*)0;
#define F(t,n) {t *y = &x.n;}
#define C(n) switch(n){case n:;}
static void f()
{
T(cc_t)
T(speed_t)
T(tcflag_t)
T(pid_t)
{
struct termios x;
F(tcflag_t,c_iflag)
F(tcflag_t,c_oflag)
F(tcflag_t,c_cflag)
F(tcflag_t,c_lflag)
F(cc_t,c_cc[NCCS])
}
C(NCCS)
C(VEOF)
C(VEOL)
C(VERASE)
C(VINTR)
C(VKILL)
C(VMIN)
C(VQUIT)
C(VSTART)
C(VSTOP)
C(VSUSP)
C(VTIME)
C(BRKINT)
C(ICRNL)
C(IGNBRK)
C(IGNCR)
C(IGNPAR)
C(INLCR)
C(INPCK)
C(ISTRIP)
C(IXANY)
C(IXOFF)
C(IXON)
C(PARMRK)
C(OPOST)
#ifdef _XOPEN_SOURCE
C(ONLCR)
C(OCRNL)
C(ONOCR)
C(ONLRET)
C(OFDEL)
C(OFILL)
C(NLDLY)
C(NL0)
C(NL1)
C(CRDLY)
C(CR0)
C(CR1)
C(CR2)
C(CR3)
C(TABDLY)
C(TAB0)
C(TAB1)
C(TAB2)
C(TAB3)
C(BSDLY)
C(BS0)
C(BS1)
C(VTDLY)
C(VT0)
C(VT1)
C(FFDLY)
C(FF0)
C(FF1)
#endif
C(B0)
C(B50)
C(B75)
C(B110)
C(B134)
C(B150)
C(B200)
C(B300)
C(B600)
C(B1200)
C(B1800)
C(B2400)
C(B4800)
C(B9600)
C(B19200)
C(B38400)
C(CSIZE)
C(CS5)
C(CS6)
C(CS7)
C(CS8)
C(CSTOPB)
C(CREAD)
C(PARENB)
C(PARODD)
C(HUPCL)
C(CLOCAL)
C(ECHO)
C(ECHOE)
C(ECHOK)
C(ECHONL)
C(ICANON)
C(IEXTEN)
C(ISIG)
C(NOFLSH)
C(TOSTOP)
C(TCSANOW)
C(TCSADRAIN)
C(TCSAFLUSH)
C(TCIFLUSH)
C(TCIOFLUSH)
C(TCOFLUSH)
C(TCIOFF)
C(TCION)
C(TCOOFF)
C(TCOON)
{speed_t(*p)(const struct termios*) = cfgetispeed;}
{speed_t(*p)(const struct termios*) = cfgetospeed;}
{int(*p)(struct termios*,speed_t) = cfsetispeed;}
{int(*p)(struct termios*,speed_t) = cfsetospeed;}
{int(*p)(int) = tcdrain;}
{int(*p)(int,int) = tcflow;}
{int(*p)(int,int) = tcflush;}
{int(*p)(int,struct termios*) = tcgetattr;}
{pid_t(*p)(int) = tcgetsid;}
{int(*p)(int,int) = tcsendbreak;}
{int(*p)(int,int,const struct termios*) = tcsetattr;}
}

View file

@ -0,0 +1,307 @@
#include <tgmath.h>
static void f()
{
double x=0, y=0, z=0;
int i;
#ifdef acos
{double r = acos(x);}
#else
#error no acos(x)
#endif
#ifdef acosh
{double r = acosh(x);}
#else
#error no acosh(x)
#endif
#ifdef asin
{double r = asin(x);}
#else
#error no asin(x)
#endif
#ifdef asinh
{double r = asinh(x);}
#else
#error no asinh(x)
#endif
#ifdef atan
{double r = atan(x);}
#else
#error no atan(x)
#endif
#ifdef atan2
{double r = atan2(x,y);}
#else
#error no atan2(x,y)
#endif
#ifdef atanh
{double r = atanh(x);}
#else
#error no atanh(x)
#endif
#ifdef carg
{double r = carg(x);}
#else
#error no carg(x)
#endif
#ifdef cbrt
{double r = cbrt(x);}
#else
#error no cbrt(x)
#endif
#ifdef ceil
{double r = ceil(x);}
#else
#error no ceil(x)
#endif
#ifdef cimag
{double r = cimag(x);}
#else
#error no cimag(x)
#endif
#ifdef conj
{double r = conj(x);}
#else
#error no conj(x)
#endif
#ifdef copysign
{double r = copysign(x,y);}
#else
#error no copysign(x,y)
#endif
#ifdef cos
{double r = cos(x);}
#else
#error no cos(x)
#endif
#ifdef cosh
{double r = cosh(x);}
#else
#error no cosh(x)
#endif
#ifdef cproj
{double r = cproj(x);}
#else
#error no cproj(x)
#endif
#ifdef creal
{double r = creal(x);}
#else
#error no creal(x)
#endif
#ifdef erf
{double r = erf(x);}
#else
#error no erf(x)
#endif
#ifdef erfc
{double r = erfc(x);}
#else
#error no erfc(x)
#endif
#ifdef exp
{double r = exp(x);}
#else
#error no exp(x)
#endif
#ifdef exp2
{double r = exp2(x);}
#else
#error no exp2(x)
#endif
#ifdef expm1
{double r = expm1(x);}
#else
#error no expm1(x)
#endif
#ifdef fabs
{double r = fabs(x);}
#else
#error no fabs(x)
#endif
#ifdef fdim
{double r = fdim(x,y);}
#else
#error no fdim(x,y)
#endif
#ifdef floor
{double r = floor(x);}
#else
#error no floor(x)
#endif
#ifdef fma
{double r = fma(x,y,z);}
#else
#error no fma(x,y,z)
#endif
#ifdef fmax
{double r = fmax(x,y);}
#else
#error no fmax(x,y)
#endif
#ifdef fmin
{double r = fmin(x,y);}
#else
#error no fmin(x,y)
#endif
#ifdef fmod
{double r = fmod(x,y);}
#else
#error no fmod(x,y)
#endif
#ifdef frexp
{double r = frexp(x,&i);}
#else
#error no frexp(x,y)
#endif
#ifdef hypot
{double r = hypot(x,y);}
#else
#error no hypot(x,y)
#endif
#ifdef ilogb
{double r = ilogb(x);}
#else
#error no ilogb(x)
#endif
#ifdef ldexp
{double r = ldexp(x,y);}
#else
#error no ldexp(x,y)
#endif
#ifdef lgamma
{double r = lgamma(x);}
#else
#error no lgamma(x)
#endif
#ifdef llrint
{double r = llrint(x);}
#else
#error no llrint(x)
#endif
#ifdef llround
{double r = llround(x);}
#else
#error no llround(x)
#endif
#ifdef log
{double r = log(x);}
#else
#error no log(x)
#endif
#ifdef log10
{double r = log10(x);}
#else
#error no log10(x)
#endif
#ifdef log1p
{double r = log1p(x);}
#else
#error no log1p(x)
#endif
#ifdef log2
{double r = log2(x);}
#else
#error no log2(x)
#endif
#ifdef logb
{double r = logb(x);}
#else
#error no logb(x)
#endif
#ifdef lrint
{double r = lrint(x);}
#else
#error no lrint(x)
#endif
#ifdef lround
{double r = lround(x);}
#else
#error no lround(x)
#endif
#ifdef nearbyint
{double r = nearbyint(x);}
#else
#error no nearbyint(x)
#endif
#ifdef nextafter
{double r = nextafter(x,y);}
#else
#error no nextafter(x,y)
#endif
#ifdef nexttoward
{double r = nexttoward(x,y);}
#else
#error no nexttoward(x,y)
#endif
#ifdef pow
{double r = pow(x,y);}
#else
#error no pow(x,y)
#endif
#ifdef remainder
{double r = remainder(x,y);}
#else
#error no remainder(x,y)
#endif
#ifdef remquo
{double r = remquo(x,y,&i);}
#else
#error no remquo(x,y,z)
#endif
#ifdef rint
{double r = rint(x);}
#else
#error no rint(x)
#endif
#ifdef round
{double r = round(x);}
#else
#error no round(x)
#endif
#ifdef scalbln
{double r = scalbln(x,y);}
#else
#error no scalbln(x,y)
#endif
#ifdef scalbn
{double r = scalbn(x,y);}
#else
#error no scalbn(x,y)
#endif
#ifdef sin
{double r = sin(x);}
#else
#error no sin(x)
#endif
#ifdef sinh
{double r = sinh(x);}
#else
#error no sinh(x)
#endif
#ifdef sqrt
{double r = sqrt(x);}
#else
#error no sqrt(x)
#endif
#ifdef tan
{double r = tan(x);}
#else
#error no tan(x)
#endif
#ifdef tanh
{double r = tanh(x);}
#else
#error no tanh(x)
#endif
#ifdef tgamma
{double r = tgamma(x);}
#else
#error no tgamma(x)
#endif
#ifdef trunc
{double r = trunc(x);}
#else
#error no trunc(x)
#endif
}

View file

@ -0,0 +1,82 @@
#include <time.h>
#define T(t) (t*)0;
#define F(t,n) {t *y = &x.n;}
#define C(n) switch(n){case n:;}
static void f()
{
T(clock_t)
T(size_t)
T(time_t)
#ifdef _POSIX_C_SOURCE
T(clockid_t)
T(timer_t)
T(locale_t)
T(pid_t)
T(struct sigevent)
{
struct timespec x;
F(time_t,tv_sec)
F(long,tv_nsec)
}
{
struct itimerspec x;
F(struct timespec,it_interval)
F(struct timespec,it_value)
}
C(CLOCK_MONOTONIC)
C(CLOCK_PROCESS_CPUTIME_ID)
C(CLOCK_REALTIME)
C(CLOCK_THREAD_CPUTIME_ID)
#endif
{
struct tm x;
F(int,tm_sec)
F(int,tm_min)
F(int,tm_hour)
F(int,tm_mday)
F(int,tm_mon)
F(int,tm_year)
F(int,tm_wday)
F(int,tm_yday)
F(int,tm_isdst)
}
{void *x = NULL;}
{int x = CLOCKS_PER_SEC;}
C(TIMER_ABSTIME)
{char*(*p)(const struct tm*) = asctime;}
{clock_t(*p)(void) = clock;}
{char*(*p)(const time_t*) = ctime;}
{double(*p)(time_t,time_t) = difftime;}
{struct tm*(*p)(const time_t*) = gmtime;}
{struct tm*(*p)(const time_t*) = localtime;}
{time_t(*p)(struct tm*) = mktime;}
{size_t(*p)(char*restrict,size_t,const char*restrict,const struct tm*restrict) = strftime;}
{time_t(*p)(time_t*) = time;}
#ifdef _POSIX_C_SOURCE
{char*(*p)(const struct tm*restrict,char*restrict) = asctime_r;}
{int(*p)(pid_t,clockid_t*) = clock_getcpuclockid;}
{int(*p)(clockid_t,struct timespec*) = clock_getres;}
{int(*p)(clockid_t,struct timespec*) = clock_gettime;}
{int(*p)(clockid_t,int,const struct timespec*,struct timespec*) = clock_nanosleep;}
{int(*p)(clockid_t,const struct timespec*) = clock_settime;}
{char*(*p)(const time_t*,char*) = ctime_r;}
{struct tm*(*p)(const time_t*restrict,struct tm*restrict) = gmtime_r;}
{struct tm*(*p)(const time_t*restrict,struct tm*restrict) = localtime_r;}
{int(*p)(const struct timespec*,struct timespec*) = nanosleep;}
{size_t(*p)(char*restrict,size_t,const char*restrict,const struct tm*restrict,locale_t) = strftime_l;}
{int(*p)(clockid_t,struct sigevent*restrict,timer_t*restrict) = timer_create;}
{int(*p)(timer_t) = timer_delete;}
{int(*p)(timer_t) = timer_getoverrun;}
{int(*p)(timer_t,struct itimerspec*) = timer_gettime;}
{int(*p)(timer_t,int,const struct itimerspec*restrict,struct itimerspec*restrict) = timer_settime;}
{char **x = tzname;}
{void(*p)(void) = tzset;}
#endif
#ifdef _XOPEN_SOURCE
{struct tm*(*p)(const char*) = getdate;}
{int i = getdate_err;}
{char*(*p)(const char*restrict,const char*restrict,struct tm*restrict) = strptime;}
{long i = timezone;}
{int i = daylight;}
#endif
}

View file

@ -0,0 +1,341 @@
#include <unistd.h>
#include "options.h"
#define T(t) (t*)0;
#define F(t,n) {t *y = &x.n;}
#define C(n) switch(n){case n:;}
#define A(n) {char p[n];}
static void f()
{
A(_POSIX_VERSION >= 200809L)
A(_POSIX2_VERSION >= 200809L)
#ifdef _XOPEN_SOURCE
A(_XOPEN_VERSION >= 700)
// A(_XOPEN_CRYPT >= 0)
A(_XOPEN_ENH_I18N > 0)
// A(_XOPEN_REALTIME >= 0)
// A(_XOPEN_REALTIME_THREADS >= 0)
// A(_XOPEN_SHM >= 0)
A(_XOPEN_UNIX >= 0)
#endif
A(_POSIX_ASYNCHRONOUS_IO >= 200809L)
A(_POSIX_BARRIERS >= 200809L)
A(_POSIX_CHOWN_RESTRICTED >= 0)
A(_POSIX_CLOCK_SELECTION >= 200809L)
A(_POSIX_JOB_CONTROL > 0)
A(_POSIX_MAPPED_FILES >= 200809L)
A(_POSIX_MEMORY_PROTECTION >= 200809L)
A(_POSIX_NO_TRUNC >= 0)
A(_POSIX_READER_WRITER_LOCKS >= 200809L)
A(_POSIX_REALTIME_SIGNALS >= 200809L)
A(_POSIX_REGEXP > 0)
A(_POSIX_SAVED_IDS > 0)
A(_POSIX_SEMAPHORES >= 200809L)
A(_POSIX_SHELL > 0)
A(_POSIX_SPIN_LOCKS >= 200809L)
A(_POSIX_THREAD_SAFE_FUNCTIONS >= 200809L)
A(_POSIX_THREADS >= 200809L)
A(_POSIX_TIMEOUTS >= 200809L)
A(_POSIX_TIMERS >= 200809L)
#if _POSIX_V7_ILP32_OFFBIG<=0 && _POSIX_V7_LP64_OFF64<=0 && _POSIX_V7_LPBIG_OFFBIG<=0
#error _POSIX_V7_ILP32_OFFBIG<=0 && _POSIX_V7_LP64_OFF64<=0 && _POSIX_V7_LPBIG_OFFBIG<=0
#endif
A(_POSIX2_C_BIND >= 200809L)
// not required by the standard
A(_POSIX_ADVISORY_INFO >= 0)
A(_POSIX_CPUTIME >= 0)
A(_POSIX_FSYNC >= 0)
A(_POSIX_IPV6 >= 0)
A(_POSIX_MEMLOCK >= 0)
A(_POSIX_MEMLOCK_RANGE >= 0)
A(_POSIX_MESSAGE_PASSING >= 0)
A(_POSIX_MONOTONIC_CLOCK >= 0)
// A(_POSIX_PRIORITIZED_IO >= 0)
// A(_POSIX_PRIORITY_SCHEDULING >= 0)
A(_POSIX_RAW_SOCKETS >= 0)
// A(_POSIX_SHARED_MEMORY_OBJECTS >= 0)
A(_POSIX_SPAWN >= 0)
// A(_POSIX_SPORADIC_SERVER >= 0)
// A(_POSIX_SYNCHRONIZED_IO >= 0)
A(_POSIX_THREAD_ATTR_STACKADDR >= 0)
A(_POSIX_THREAD_ATTR_STACKSIZE >= 0)
A(_POSIX_THREAD_CPUTIME >= 0)
// A(_POSIX_THREAD_PRIO_INHERIT >= 0)
// A(_POSIX_THREAD_PRIO_PROTECT >= 0)
A(_POSIX_THREAD_PRIORITY_SCHEDULING >= 0)
A(_POSIX_THREAD_PROCESS_SHARED >= 0)
// A(_POSIX_THREAD_ROBUST_PRIO_INHERIT >= 0)
// A(_POSIX_THREAD_ROBUST_PRIO_PROTECT >= 0)
// A(_POSIX_THREAD_SPORADIC_SERVER >= 0)
// A(_POSIX_TYPED_MEMORY_OBJECTS >= 0)
C(F_OK)
C(R_OK)
C(W_OK)
C(X_OK)
C(_CS_PATH)
C(_CS_POSIX_V7_ILP32_OFF32_CFLAGS)
C(_CS_POSIX_V7_ILP32_OFF32_LDFLAGS)
C(_CS_POSIX_V7_ILP32_OFF32_LIBS)
C(_CS_POSIX_V7_ILP32_OFFBIG_CFLAGS)
C(_CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS)
C(_CS_POSIX_V7_ILP32_OFFBIG_LIBS)
C(_CS_POSIX_V7_LP64_OFF64_CFLAGS)
C(_CS_POSIX_V7_LP64_OFF64_LDFLAGS)
C(_CS_POSIX_V7_LP64_OFF64_LIBS)
C(_CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS)
C(_CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS)
C(_CS_POSIX_V7_LPBIG_OFFBIG_LIBS)
C(_CS_POSIX_V7_THREADS_CFLAGS)
C(_CS_POSIX_V7_THREADS_LDFLAGS)
C(_CS_POSIX_V7_WIDTH_RESTRICTED_ENVS)
C(_CS_V7_ENV)
C(SEEK_CUR)
C(SEEK_END)
C(SEEK_SET)
C(F_LOCK)
C(F_TEST)
C(F_TLOCK)
C(F_ULOCK)
C(_PC_2_SYMLINKS)
C(_PC_ALLOC_SIZE_MIN)
C(_PC_ASYNC_IO)
C(_PC_CHOWN_RESTRICTED)
C(_PC_FILESIZEBITS)
C(_PC_LINK_MAX)
C(_PC_MAX_CANON)
C(_PC_MAX_INPUT)
C(_PC_NAME_MAX)
C(_PC_NO_TRUNC)
C(_PC_PATH_MAX)
C(_PC_PIPE_BUF)
C(_PC_PRIO_IO)
C(_PC_REC_INCR_XFER_SIZE)
C(_PC_REC_MAX_XFER_SIZE)
C(_PC_REC_MIN_XFER_SIZE)
C(_PC_REC_XFER_ALIGN)
C(_PC_SYMLINK_MAX)
C(_PC_SYNC_IO)
C(_PC_TIMESTAMP_RESOLUTION)
C(_PC_VDISABLE)
C(_SC_2_C_BIND)
C(_SC_2_C_DEV)
C(_SC_2_CHAR_TERM)
C(_SC_2_FORT_DEV)
C(_SC_2_FORT_RUN)
C(_SC_2_LOCALEDEF)
C(_SC_2_PBS)
C(_SC_2_PBS_ACCOUNTING)
C(_SC_2_PBS_CHECKPOINT)
C(_SC_2_PBS_LOCATE)
C(_SC_2_PBS_MESSAGE)
C(_SC_2_PBS_TRACK)
C(_SC_2_SW_DEV)
C(_SC_2_UPE)
C(_SC_2_VERSION)
C(_SC_ADVISORY_INFO)
C(_SC_AIO_LISTIO_MAX)
C(_SC_AIO_MAX)
C(_SC_AIO_PRIO_DELTA_MAX)
C(_SC_ARG_MAX)
C(_SC_ASYNCHRONOUS_IO)
C(_SC_ATEXIT_MAX)
C(_SC_BARRIERS)
C(_SC_BC_BASE_MAX)
C(_SC_BC_DIM_MAX)
C(_SC_BC_SCALE_MAX)
C(_SC_BC_STRING_MAX)
C(_SC_CHILD_MAX)
C(_SC_CLK_TCK)
C(_SC_CLOCK_SELECTION)
C(_SC_COLL_WEIGHTS_MAX)
C(_SC_CPUTIME)
C(_SC_DELAYTIMER_MAX)
C(_SC_EXPR_NEST_MAX)
C(_SC_FSYNC)
C(_SC_GETGR_R_SIZE_MAX)
C(_SC_GETPW_R_SIZE_MAX)
C(_SC_HOST_NAME_MAX)
C(_SC_IOV_MAX)
C(_SC_IPV6)
C(_SC_JOB_CONTROL)
C(_SC_LINE_MAX)
C(_SC_LOGIN_NAME_MAX)
C(_SC_MAPPED_FILES)
C(_SC_MEMLOCK)
C(_SC_MEMLOCK_RANGE)
C(_SC_MEMORY_PROTECTION)
C(_SC_MESSAGE_PASSING)
C(_SC_MONOTONIC_CLOCK)
C(_SC_MQ_OPEN_MAX)
C(_SC_MQ_PRIO_MAX)
C(_SC_NGROUPS_MAX)
C(_SC_OPEN_MAX)
C(_SC_PAGE_SIZE)
C(_SC_PAGESIZE)
C(_SC_PRIORITIZED_IO)
C(_SC_PRIORITY_SCHEDULING)
C(_SC_RAW_SOCKETS)
C(_SC_RE_DUP_MAX)
C(_SC_READER_WRITER_LOCKS)
C(_SC_REALTIME_SIGNALS)
C(_SC_REGEXP)
C(_SC_RTSIG_MAX)
C(_SC_SAVED_IDS)
C(_SC_SEM_NSEMS_MAX)
C(_SC_SEM_VALUE_MAX)
C(_SC_SEMAPHORES)
C(_SC_SHARED_MEMORY_OBJECTS)
C(_SC_SHELL)
C(_SC_SIGQUEUE_MAX)
C(_SC_SPAWN)
C(_SC_SPIN_LOCKS)
C(_SC_SPORADIC_SERVER)
C(_SC_SS_REPL_MAX)
C(_SC_STREAM_MAX)
C(_SC_SYMLOOP_MAX)
C(_SC_SYNCHRONIZED_IO)
C(_SC_THREAD_ATTR_STACKADDR)
C(_SC_THREAD_ATTR_STACKSIZE)
C(_SC_THREAD_CPUTIME)
C(_SC_THREAD_DESTRUCTOR_ITERATIONS)
C(_SC_THREAD_KEYS_MAX)
C(_SC_THREAD_PRIO_INHERIT)
C(_SC_THREAD_PRIO_PROTECT)
C(_SC_THREAD_PRIORITY_SCHEDULING)
C(_SC_THREAD_PROCESS_SHARED)
C(_SC_THREAD_ROBUST_PRIO_INHERIT)
C(_SC_THREAD_ROBUST_PRIO_PROTECT)
C(_SC_THREAD_SAFE_FUNCTIONS)
C(_SC_THREAD_SPORADIC_SERVER)
C(_SC_THREAD_STACK_MIN)
C(_SC_THREAD_THREADS_MAX)
C(_SC_THREADS)
C(_SC_TIMEOUTS)
C(_SC_TIMER_MAX)
C(_SC_TIMERS)
C(_SC_TRACE)
C(_SC_TRACE_EVENT_FILTER)
C(_SC_TRACE_EVENT_NAME_MAX)
C(_SC_TRACE_INHERIT)
C(_SC_TRACE_LOG)
C(_SC_TRACE_NAME_MAX)
C(_SC_TRACE_SYS_MAX)
C(_SC_TRACE_USER_EVENT_MAX)
C(_SC_TTY_NAME_MAX)
C(_SC_TYPED_MEMORY_OBJECTS)
C(_SC_TZNAME_MAX)
C(_SC_V7_ILP32_OFF32)
C(_SC_V7_ILP32_OFFBIG)
C(_SC_V7_LP64_OFF64)
C(_SC_V7_LPBIG_OFFBIG)
C(_SC_VERSION)
C(_SC_XOPEN_CRYPT)
C(_SC_XOPEN_ENH_I18N)
C(_SC_XOPEN_REALTIME)
C(_SC_XOPEN_REALTIME_THREADS)
C(_SC_XOPEN_SHM)
C(_SC_XOPEN_STREAMS)
C(_SC_XOPEN_UNIX)
C(_SC_XOPEN_UUCP)
C(_SC_XOPEN_VERSION)
C(STDERR_FILENO)
C(STDIN_FILENO)
C(STDOUT_FILENO)
C(_POSIX_VDISABLE)
T(size_t)
T(ssize_t)
T(uid_t)
T(gid_t)
T(off_t)
T(pid_t)
T(intptr_t)
{void(*p)(int) = _exit;}
{int(*p)(const char*,int) = access;}
{unsigned(*p)(unsigned) = alarm;}
{int(*p)(const char*) = chdir;}
{int(*p)(const char*,uid_t,gid_t) = chown;}
{int(*p)(int) = close;}
{size_t(*p)(int,char*,size_t) = confstr;}
{int(*p)(int) = dup;}
{int(*p)(int,int) = dup2;}
{extern char **environ; char **x = environ;};
{int(*p)(const char*,const char*,...) = execl;}
{int(*p)(const char*,const char*,...) = execle;}
{int(*p)(const char*,const char*,...) = execlp;}
{int(*p)(const char*,char*const[]) = execv;}
{int(*p)(const char*,char*const[],char*const[]) = execve;}
{int(*p)(const char*,char*const[]) = execvp;}
{int(*p)(int,const char*,int,int) = faccessat;}
{int(*p)(int) = fchdir;}
{int(*p)(int,uid_t,gid_t) = fchown;}
{int(*p)(int,const char*,uid_t,gid_t,int) = fchownat;}
#ifdef POSIX_SYNCHRONIZED_IO
{int(*p)(int) = fdatasync;}
#endif
{int(*p)(int,char*const[],char*const[]) = fexecve;}
{pid_t(*p)(void) = fork;}
{long(*p)(int,int) = fpathconf;}
{int(*p)(int) = fsync;}
{int(*p)(int,off_t) = ftruncate;}
{char*(*p)(char*,size_t) = getcwd;}
{gid_t(*p)(void) = getegid;}
{uid_t(*p)(void) = geteuid;}
{gid_t(*p)(void) = getgid;}
{int(*p)(int,gid_t[]) = getgroups;}
{int(*p)(char*,size_t) = gethostname;}
{char*(*p)(void) = getlogin;}
{int(*p)(char*,size_t) = getlogin_r;}
{int(*p)(int,char*const[],const char*) = getopt;}
{pid_t(*p)(pid_t) = getpgid;}
{pid_t(*p)(void) = getpgrp;}
{pid_t(*p)(void) = getpid;}
{pid_t(*p)(void) = getppid;}
{pid_t(*p)(pid_t) = getsid;}
{uid_t(*p)(void) = getuid;}
{int(*p)(int) = isatty;}
{int(*p)(const char*,uid_t,gid_t) = lchown;}
{int(*p)(const char*,const char*) = link;}
{int(*p)(int,const char*,int,const char*,int) = linkat;}
{off_t(*p)(int,off_t,int) = lseek;}
{char *x = optarg;}
{int i = opterr;}
{int i = optind;}
{int i = optopt;}
{long(*p)(const char*,int) = pathconf;}
{int(*p)(void) = pause;}
{int(*p)(int[]) = pipe;}
{ssize_t(*p)(int,void*,size_t,off_t) = pread;}
{ssize_t(*p)(int,const void*,size_t,off_t) = pwrite;}
{ssize_t(*p)(int,void*,size_t) = read;}
{ssize_t(*p)(const char*restrict,char*restrict,size_t) = readlink;}
{ssize_t(*p)(int,const char*restrict,char*restrict,size_t) = readlinkat;}
{int(*p)(const char*) = rmdir;}
{int(*p)(gid_t) = setegid;}
{int(*p)(uid_t) = seteuid;}
{int(*p)(gid_t) = setgid;}
{int(*p)(pid_t,pid_t) = setpgid;}
{pid_t(*p)(void) = setsid;}
{int(*p)(uid_t) = setuid;}
{unsigned(*p)(unsigned) = sleep;}
{int(*p)(const char*,const char*) = symlink;}
{int(*p)(const char*,int,const char*) = symlinkat;}
{long(*p)(int) = sysconf;}
{pid_t(*p)(int) = tcgetpgrp;}
{int(*p)(int,pid_t) = tcsetpgrp;}
{int(*p)(const char*,off_t) = truncate;}
{char*(*p)(int) = ttyname;}
{int(*p)(int,char*,size_t) = ttyname_r;}
{int(*p)(const char*) = unlink;}
{int(*p)(int,const char*,int) = unlinkat;}
{ssize_t(*p)(int,const void*,size_t) = write;}
#ifdef _XOPEN_SOURCE
{char*(*p)(const char*,const char*) = crypt;}
{void(*p)(char[],int) = encrypt;}
{long(*p)(void) = gethostid;}
{int(*p)(int,int,off_t) = lockf;}
{int(*p)(int) = nice;}
{int(*p)(gid_t,gid_t) = setregid;}
{int(*p)(uid_t,uid_t) = setreuid;}
{void(*p)(const void*restrict,void*restrict,ssize_t) = swab;}
{void(*p)(void) = sync;}
#endif
}

View file

@ -0,0 +1,32 @@
#include <utmpx.h>
#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(struct timeval)
{
struct utmpx x;
F(char,ut_user[0])
F(char,ut_id[0])
F(char,ut_line[0])
F(pid_t, ut_pid)
F(short, ut_type)
F(struct timeval,ut_tv)
}
C(EMPTY)
C(BOOT_TIME)
C(OLD_TIME)
C(NEW_TIME)
C(USER_PROCESS)
C(INIT_PROCESS)
C(LOGIN_PROCESS)
C(DEAD_PROCESS)
{void(*p)(void) = endutxent;}
{struct utmpx*(*p)(void) = getutxent;}
{struct utmpx*(*p)(const struct utmpx*) = getutxid;}
{struct utmpx*(*p)(const struct utmpx*) = getutxline;}
{struct utmpx*(*p)(const struct utmpx*) = pututxline;}
{void(*p)(void) = setutxent;}
}

View file

@ -0,0 +1,97 @@
#include <wchar.h>
#define T(t) (t*)0;
#define F(t,n) {t *y = &x.n;}
#define C(n) switch(n){case n:;}
static void f()
{
#ifdef _POSIX_C_SOURCE
T(FILE)
T(locale_t)
T(va_list)
#endif
T(mbstate_t)
T(size_t)
T(wchar_t)
T(wint_t)
T(struct tm)
C(WCHAR_MAX)
C(WCHAR_MIN)
C(WEOF)
{void *x=NULL;}
{wint_t(*p)(int) = btowc;}
{wint_t(*p)(FILE*) = fgetwc;}
{wchar_t*(*p)(wchar_t*restrict,int,FILE*restrict) = fgetws;}
{wint_t(*p)(wchar_t,FILE*) = fputwc;}
{int(*p)(const wchar_t*restrict,FILE*restrict) = fputws;}
{int(*p)(FILE*,int) = fwide;}
{int(*p)(FILE*restrict,const wchar_t*restrict,...) = fwprintf;}
{int(*p)(FILE*restrict,const wchar_t*restrict,...) = fwscanf;}
{wint_t(*p)(FILE*) = getwc;}
{wint_t(*p)(void) = getwchar;}
{size_t(*p)(const char*restrict,size_t,mbstate_t*restrict) = mbrlen;}
{size_t(*p)(wchar_t*restrict,const char*restrict,size_t,mbstate_t*restrict) = mbrtowc;}
{int(*p)(const mbstate_t*) = mbsinit;}
{size_t(*p)(wchar_t*restrict,const char**restrict,size_t,mbstate_t*restrict) = mbsrtowcs;}
{wint_t(*p)(wchar_t,FILE*) = putwc;}
{wint_t(*p)(wchar_t) = putwchar;}
{int(*p)(wchar_t*restrict,size_t,const wchar_t*restrict,...) = swprintf;}
{int(*p)(const wchar_t*restrict,const wchar_t*restrict,...) = swscanf;}
{wint_t(*p)(wint_t,FILE*) = ungetwc;}
{int(*p)(FILE*restrict,const wchar_t*restrict,va_list) = vfwprintf;}
{int(*p)(FILE*restrict,const wchar_t*restrict,va_list) = vfwscanf;}
{int(*p)(wchar_t*restrict,size_t,const wchar_t*restrict,va_list) = vswprintf;}
{int(*p)(const wchar_t*restrict,const wchar_t*restrict,va_list) = vswscanf;}
{int(*p)(const wchar_t*restrict,va_list) = vwprintf;}
{int(*p)(const wchar_t*restrict,va_list) = vwscanf;}
{size_t(*p)(char*restrict,wchar_t,mbstate_t*restrict) = wcrtomb;}
{wchar_t*(*p)(wchar_t*restrict,const wchar_t*restrict) = wcscat;}
{wchar_t*(*p)(const wchar_t*,wchar_t) = wcschr;}
{int(*p)(const wchar_t*,const wchar_t*) = wcscmp;}
{int(*p)(const wchar_t*,const wchar_t*) = wcscoll;}
{wchar_t*(*p)(wchar_t*restrict,const wchar_t*restrict) = wcscpy;}
{size_t(*p)(const wchar_t*,const wchar_t*) = wcscspn;}
{size_t(*p)(wchar_t*restrict,size_t,const wchar_t*restrict,const struct tm*restrict) = wcsftime;}
{size_t(*p)(const wchar_t*) = wcslen;}
{wchar_t*(*p)(wchar_t*restrict,const wchar_t*restrict,size_t) = wcsncat;}
{int(*p)(const wchar_t*,const wchar_t*,size_t) = wcsncmp;}
{wchar_t*(*p)(wchar_t*restrict,const wchar_t*restrict,size_t) = wcsncpy;}
{wchar_t*(*p)(const wchar_t*,const wchar_t*) = wcspbrk;}
{wchar_t*(*p)(const wchar_t*,wchar_t) = wcsrchr;}
{size_t(*p)(char*restrict,const wchar_t**restrict,size_t,mbstate_t*restrict) = wcsrtombs;}
{size_t(*p)(const wchar_t*,const wchar_t*) = wcsspn;}
{wchar_t*(*p)(const wchar_t*restrict,const wchar_t*restrict) = wcsstr;}
{double(*p)(const wchar_t*restrict,wchar_t**restrict) = wcstod;}
{float(*p)(const wchar_t*restrict,wchar_t**restrict) = wcstof;}
{wchar_t*(*p)(wchar_t*restrict,const wchar_t*restrict,wchar_t**restrict) = wcstok;}
{long(*p)(const wchar_t*restrict,wchar_t**restrict,int) = wcstol;}
{long double(*p)(const wchar_t*restrict,wchar_t**restrict) = wcstold;}
{long long(*p)(const wchar_t*restrict,wchar_t**restrict,int) = wcstoll;}
{unsigned long(*p)(const wchar_t*restrict,wchar_t**restrict,int) = wcstoul;}
{unsigned long long(*p)(const wchar_t*restrict,wchar_t**restrict,int) = wcstoull;}
{size_t(*p)(wchar_t*restrict,const wchar_t*restrict,size_t) = wcsxfrm;}
{int(*p)(wint_t) = wctob;}
{wchar_t*(*p)(const wchar_t*,wchar_t,size_t) = wmemchr;}
{int(*p)(const wchar_t*,const wchar_t*,size_t) = wmemcmp;}
{wchar_t*(*p)(wchar_t*restrict,const wchar_t*restrict,size_t) = wmemcpy;}
{wchar_t*(*p)(wchar_t*,const wchar_t*,size_t) = wmemmove;}
{wchar_t*(*p)(wchar_t*,wchar_t,size_t) = wmemset;}
#ifdef _POSIX_C_SOURCE
{size_t(*p)(wchar_t*restrict,const char**restrict,size_t,size_t,mbstate_t*restrict) = mbsnrtowcs;}
{FILE*(*p)(wchar_t**,size_t*) = open_wmemstream;}
{wchar_t*(*p)(wchar_t*restrict,const wchar_t*restrict) = wcpcpy;}
{wchar_t*(*p)(wchar_t*restrict,const wchar_t*restrict,size_t) = wcpncpy;}
{int(*p)(const wchar_t*,const wchar_t*) = wcscasecmp;}
{int(*p)(const wchar_t*,const wchar_t*,locale_t) = wcscasecmp_l;}
{int(*p)(const wchar_t*,const wchar_t*,locale_t) = wcscoll_l;}
{wchar_t*(*p)(const wchar_t*) = wcsdup;}
{int(*p)(const wchar_t*,const wchar_t*,size_t) = wcsncasecmp;}
{int(*p)(const wchar_t*,const wchar_t*,size_t,locale_t) = wcsncasecmp_l;}
{size_t(*p)(const wchar_t*,size_t) = wcsnlen;}
{size_t(*p)(char*restrict,const wchar_t**restrict,size_t,size_t,mbstate_t*restrict) = wcsnrtombs;}
{size_t(*p)(wchar_t*restrict,const wchar_t*restrict,size_t,locale_t) = wcsxfrm_l;}
#endif
#ifdef _XOPEN_SOURCE
{int(*p)(const wchar_t*,size_t) = wcswidth;}
{int(*p)(wchar_t) = wcwidth;}
#endif
}

View file

@ -0,0 +1,52 @@
#include <wctype.h>
#define T(t) (t*)0;
#define F(t,n) {t *y = &x.n;}
#define C(n) switch(n){case n:;}
static void f()
{
T(wint_t)
T(wctrans_t)
T(wctype_t)
#ifdef _POSIX_C_SOURCE
T(locale_t)
#endif
C(WEOF)
{int(*p)(wint_t) = iswalnum;}
{int(*p)(wint_t) = iswalpha;}
{int(*p)(wint_t) = iswblank;}
{int(*p)(wint_t) = iswcntrl;}
{int(*p)(wint_t,wctype_t) = iswctype;}
{int(*p)(wint_t) = iswdigit;}
{int(*p)(wint_t) = iswgraph;}
{int(*p)(wint_t) = iswlower;}
{int(*p)(wint_t) = iswprint;}
{int(*p)(wint_t) = iswpunct;}
{int(*p)(wint_t) = iswspace;}
{int(*p)(wint_t) = iswupper;}
{int(*p)(wint_t) = iswxdigit;}
{wint_t(*p)(wint_t,wctrans_t) = towctrans;}
{wint_t(*p)(wint_t) = towlower;}
{wint_t(*p)(wint_t) = towupper;}
{wctrans_t(*p)(const char*) = wctrans;}
{wctype_t(*p)(const char*) = wctype;}
#ifdef _POSIX_C_SOURCE
{int(*p)(wint_t,locale_t) = iswalnum_l;}
{int(*p)(wint_t,locale_t) = iswalpha_l;}
{int(*p)(wint_t,locale_t) = iswblank_l;}
{int(*p)(wint_t,locale_t) = iswcntrl_l;}
{int(*p)(wint_t,wctype_t,locale_t) = iswctype_l;}
{int(*p)(wint_t,locale_t) = iswdigit_l;}
{int(*p)(wint_t,locale_t) = iswgraph_l;}
{int(*p)(wint_t,locale_t) = iswlower_l;}
{int(*p)(wint_t,locale_t) = iswprint_l;}
{int(*p)(wint_t,locale_t) = iswpunct_l;}
{int(*p)(wint_t,locale_t) = iswspace_l;}
{int(*p)(wint_t,locale_t) = iswupper_l;}
{int(*p)(wint_t,locale_t) = iswxdigit_l;}
{wint_t(*p)(wint_t,wctrans_t,locale_t) = towctrans_l;}
{wint_t(*p)(wint_t,locale_t) = towlower_l;}
{wint_t(*p)(wint_t,locale_t) = towupper_l;}
{wctrans_t(*p)(const char*,locale_t) = wctrans_l;}
{wctype_t(*p)(const char*,locale_t) = wctype_l;}
#endif
}

View file

@ -0,0 +1,27 @@
#include <wordexp.h>
#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)
{
wordexp_t x;
F(size_t, we_wordc)
F(char **,we_wordv)
F(size_t, we_offs)
}
C(WRDE_APPEND)
C(WRDE_DOOFFS)
C(WRDE_NOCMD)
C(WRDE_REUSE)
C(WRDE_SHOWERR)
C(WRDE_UNDEF)
C(WRDE_BADCHAR)
C(WRDE_BADVAL)
C(WRDE_CMDSUB)
C(WRDE_NOSPACE)
C(WRDE_SYNTAX)
{int(*p)(const char*restrict,wordexp_t*restrict,int) = wordexp;}
{void(*p)(wordexp_t*) = wordfree;}
}

View file

@ -0,0 +1,5 @@
all:
%: FORCE
$(MAKE) -C ../.. B=src src/common/$@
.SUFFIXES:
FORCE: ;

View file

@ -0,0 +1,15 @@
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include "test.h"
void t_fdfill(void)
{
int fd = 1;
if (dup(fd) == -1) {
if (errno == EMFILE)
return;
fd = open("/dev/null", O_RDONLY);
}
while(dup(fd) != -1);
}

View file

@ -0,0 +1,22 @@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <sys/resource.h>
#include "test.h"
int t_memfill()
{
int r = 0;
/* alloc mmap space with PROT_NONE */
if (t_vmfill(0,0,0) < 0) {
t_error("vmfill failed: %s\n", strerror(errno));
r = -1;
}
/* limit brk space */
if (t_setrlim(RLIMIT_DATA, 0) < 0)
r = -1;
if (!r)
/* use up libc reserves if any */
while (malloc(1));
return r;
}

View file

@ -0,0 +1,144 @@
#include <stdio.h>
#include <stdint.h>
#include "mtest.h"
int eulpf(float x)
{
union { float f; uint32_t i; } u = { x };
int e = u.i>>23 & 0xff;
if (!e)
e++;
return e - 0x7f - 23;
}
int eulp(double x)
{
union { double f; uint64_t i; } u = { x };
int e = u.i>>52 & 0x7ff;
if (!e)
e++;
return e - 0x3ff - 52;
}
int eulpl(long double x)
{
#if LDBL_MANT_DIG == 53
return eulp(x);
#elif LDBL_MANT_DIG == 64
union { long double f; struct {uint64_t m; uint16_t e; uint16_t pad;} i; } u = { x };
int e = u.i.e & 0x7fff;
if (!e)
e++;
return e - 0x3fff - 63;
#else
// TODO
return 0;
#endif
}
float ulperrf(float got, float want, float dwant)
{
if (isnan(got) && isnan(want))
return 0;
if (got == want) {
if (signbit(got) == signbit(want))
return dwant;
return inf;
}
if (isinf(got)) {
got = copysignf(0x1p127, got);
want *= 0.5;
}
return scalbn(got - want, -eulpf(want)) + dwant;
}
float ulperr(double got, double want, float dwant)
{
if (isnan(got) && isnan(want))
return 0;
if (got == want) {
if (signbit(got) == signbit(want))
return dwant;
return inf; // treat 0 sign errors badly
}
if (isinf(got)) {
got = copysign(0x1p1023, got);
want *= 0.5;
}
return scalbn(got - want, -eulp(want)) + dwant;
}
float ulperrl(long double got, long double want, float dwant)
{
#if LDBL_MANT_DIG == 53
return ulperr(got, want, dwant);
#elif LDBL_MANT_DIG == 64
if (isnan(got) && isnan(want))
return 0;
if (got == want) {
if (signbit(got) == signbit(want))
return dwant;
return inf;
}
if (isinf(got)) {
got = copysignl(0x1p16383L, got);
want *= 0.5;
}
return scalbnl(got - want, -eulpl(want)) + dwant;
#else
// TODO
return inf;
#endif
}
#define length(a) (sizeof(a)/sizeof*(a))
#define flag(x) {x, #x}
static struct {
int flag;
char *s;
} eflags[] = {
flag(INEXACT),
flag(INVALID),
flag(DIVBYZERO),
flag(UNDERFLOW),
flag(OVERFLOW)
};
char *estr(int f)
{
static char buf[256];
char *p = buf;
int i, all = 0;
for (i = 0; i < length(eflags); i++)
if (f & eflags[i].flag) {
p += sprintf(p, "%s%s", all ? "|" : "", eflags[i].s);
all |= eflags[i].flag;
}
if (all != f) {
p += sprintf(p, "%s%d", all ? "|" : "", f & ~all);
all = f;
}
p += sprintf(p, "%s", all ? "" : "0");
return buf;
}
char *rstr(int r)
{
switch (r) {
case RN: return "RN";
#ifdef FE_TOWARDZERO
case RZ: return "RZ";
#endif
#ifdef FE_UPWARD
case RU: return "RU";
#endif
#ifdef FE_DOWNWARD
case RD: return "RD";
#endif
}
return "R?";
}

View file

@ -0,0 +1,135 @@
#include <fenv.h>
#include <float.h>
#include <math.h>
#undef RN
#undef RZ
#undef RD
#undef RU
#ifdef FE_TONEAREST
#define RN FE_TONEAREST
#else
#define RN 0
#endif
#ifdef FE_TOWARDZERO
#define RZ FE_TOWARDZERO
#else
#define RZ -1
#endif
#ifdef FE_DOWNWARD
#define RD FE_DOWNWARD
#else
#define RD -1
#endif
#ifdef FE_UPWARD
#define RU FE_UPWARD
#else
#define RU -1
#endif
#undef INEXACT
#undef INVALID
#undef DIVBYZERO
#undef UNDERFLOW
#undef OVERFLOW
#ifdef FE_INEXACT
#define INEXACT FE_INEXACT
#else
#define INEXACT 0
#endif
#ifdef FE_INVALID
#define INVALID FE_INVALID
#else
#define INVALID 0
#endif
#ifdef FE_DIVBYZERO
#define DIVBYZERO FE_DIVBYZERO
#else
#define DIVBYZERO 0
#endif
#ifdef FE_UNDERFLOW
#define UNDERFLOW FE_UNDERFLOW
#else
#define UNDERFLOW 0
#endif
#ifdef FE_OVERFLOW
#define OVERFLOW FE_OVERFLOW
#else
#define OVERFLOW 0
#endif
#undef inf
#undef nan
#define inf INFINITY
#define nan NAN
#define T(...) {__FILE__, __LINE__, __VA_ARGS__},
#define POS char *file; int line;
struct d_d {POS int r; double x; double y; float dy; int e; };
struct f_f {POS int r; float x; float y; float dy; int e; };
struct l_l {POS int r; long double x; long double y; float dy; int e; };
struct ff_f {POS int r; float x; float x2; float y; float dy; int e; };
struct dd_d {POS int r; double x; double x2; double y; float dy; int e; };
struct ll_l {POS int r; long double x; long double x2; long double y; float dy; int e; };
struct d_di {POS int r; double x; double y; float dy; long long i; int e; };
struct f_fi {POS int r; float x; float y; float dy; long long i; int e; };
struct l_li {POS int r; long double x; long double y; float dy; long long i; int e; };
struct di_d {POS int r; double x; long long i; double y; float dy; int e; };
struct fi_f {POS int r; float x; long long i; float y; float dy; int e; };
struct li_l {POS int r; long double x; long long i; long double y; float dy; int e; };
struct d_i {POS int r; double x; long long i; int e; };
struct f_i {POS int r; float x; long long i; int e; };
struct l_i {POS int r; long double x; long long i; int e; };
struct d_dd {POS int r; double x; double y; float dy; double y2; float dy2; int e; };
struct f_ff {POS int r; float x; float y; float dy; float y2; float dy2; int e; };
struct l_ll {POS int r; long double x; long double y; float dy; long double y2; float dy2; int e; };
struct ff_fi {POS int r; float x; float x2; float y; float dy; long long i; int e; };
struct dd_di {POS int r; double x; double x2; double y; float dy; long long i; int e; };
struct ll_li {POS int r; long double x; long double x2; long double y; float dy; long long i; int e; };
struct fff_f {POS int r; float x; float x2; float x3; float y; float dy; int e; };
struct ddd_d {POS int r; double x; double x2; double x3; double y; float dy; int e; };
struct lll_l {POS int r; long double x; long double x2; long double x3; long double y; float dy; int e; };
#undef POS
char *estr(int);
char *rstr(int);
float ulperr(double got, double want, float dwant);
float ulperrf(float got, float want, float dwant);
float ulperrl(long double got, long double want, float dwant);
static int checkexcept(int got, int want, int r)
{
if (r == RN)
#if defined CHECK_INEXACT
return got == want;
#elif defined CHECK_INEXACT_OMISSION
return got == want || got == (want|INEXACT);
#else
return (got|INEXACT) == (want|INEXACT);
#endif
return (got|INEXACT|UNDERFLOW) == (want|INEXACT|UNDERFLOW);
}
static int checkexceptall(int got, int want, int r)
{
return got == want;
}
static int checkulp(float d, int r)
{
// TODO: we only care about >=1.5 ulp errors for now, should be 1.0
if (r == RN)
return fabsf(d) < 1.5;
// accept larger error in non-nearest rounding mode
return fabsf(d) < 3.0;
}
static int checkcr(long double y, long double ywant, int r)
{
if (isnan(ywant))
return isnan(y);
return y == ywant && signbit(y) == signbit(ywant);
}

View file

@ -0,0 +1,125 @@
/* Usage: pipe the output of running the preprocessor on this file to:
* sed -e '1,/optiongroups_unistd_end/d' -e '/^#/d' -e '/^[[:space:]]*$/d' -e 's/^/#define /'
*/
#include <unistd.h>
optiongroups_unistd_end
#if defined _POSIX_ADVISORY_INFO && _POSIX_ADVISORY_INFO >= 0
POSIX_ADVISORY_INFO _POSIX_ADVISORY_INFO
#endif
#if defined _POSIX_CPUTIME && _POSIX_CPUTIME >= 0
POSIX_CPUTIME _POSIX_CPUTIME
#endif
#if defined _POSIX_FSYNC && _POSIX_FSYNC >= 0
POSIX_FSYNC _POSIX_FSYNC
#endif
#if defined _POSIX_IPV6 && _POSIX_IPV6 >= 0
POSIX_IPV6 _POSIX_IPV6
#endif
#if defined _POSIX_MEMLOCK && _POSIX_MEMLOCK >= 0
POSIX_MEMLOCK _POSIX_MEMLOCK
#endif
#if defined _POSIX_MEMLOCK_RANGE && _POSIX_MEMLOCK_RANGE >= 0
POSIX_MEMLOCK_RANGE _POSIX_MEMLOCK_RANGE
#endif
#if defined _POSIX_MESSAGE_PASSING && _POSIX_MESSAGE_PASSING >= 0
POSIX_MESSAGE_PASSING _POSIX_MESSAGE_PASSING
#endif
#if defined _POSIX_MONOTONIC_CLOCK && _POSIX_MONOTONIC_CLOCK >= 0
POSIX_MONOTONIC_CLOCK _POSIX_MONOTONIC_CLOCK
#endif
#if defined _POSIX_PRIORITIZED_IO && _POSIX_PRIORITIZED_IO >= 0
POSIX_PRIORITIZED_IO _POSIX_PRIORITIZED_IO
#endif
#if defined _POSIX_PRIORITY_SCHEDULING && _POSIX_PRIORITY_SCHEDULING >= 0
POSIX_PRIORITY_SCHEDULING _POSIX_PRIORITY_SCHEDULING
#endif
#if defined _POSIX_RAW_SOCKETS && _POSIX_RAW_SOCKETS >= 0
POSIX_RAW_SOCKETS _POSIX_RAW_SOCKETS
#endif
#if defined _POSIX_SHARED_MEMORY_OBJECTS && _POSIX_SHARED_MEMORY_OBJECTS >= 0
POSIX_SHARED_MEMORY_OBJECTS _POSIX_SHARED_MEMORY_OBJECTS
#endif
#if defined _POSIX_SPAWN && _POSIX_SPAWN >= 0
POSIX_SPAWN _POSIX_SPAWN
#endif
#if defined _POSIX_SPORADIC_SERVER && _POSIX_SPORADIC_SERVER >= 0
POSIX_SPORADIC_SERVER _POSIX_SPORADIC_SERVER
#endif
#if defined _POSIX_SYNCHRONIZED_IO && _POSIX_SYNCHRONIZED_IO >= 0
POSIX_SYNCHRONIZED_IO _POSIX_SYNCHRONIZED_IO
#endif
#if defined _POSIX_THREAD_ATTR_STACKADDR && _POSIX_THREAD_ATTR_STACKADDR >= 0
POSIX_THREAD_ATTR_STACKADDR _POSIX_THREAD_ATTR_STACKADDR
#endif
#if defined _POSIX_THREAD_ATTR_STACKSIZE && _POSIX_THREAD_ATTR_STACKSIZE >= 0
POSIX_THREAD_ATTR_STACKSIZE _POSIX_THREAD_ATTR_STACKSIZE
#endif
#if defined _POSIX_THREAD_CPUTIME && _POSIX_THREAD_CPUTIME >= 0
POSIX_THREAD_CPUTIME _POSIX_THREAD_CPUTIME
#endif
#if defined _POSIX_THREAD_PRIO_INHERIT && _POSIX_THREAD_PRIO_INHERIT >= 0
POSIX_THREAD_PRIO_INHERIT _POSIX_THREAD_PRIO_INHERIT
#endif
#if defined _POSIX_THREAD_PRIO_PROTECT && _POSIX_THREAD_PRIO_PROTECT >= 0
POSIX_THREAD_PRIO_PROTECT _POSIX_THREAD_PRIO_PROTECT
#endif
#if defined _POSIX_THREAD_PRIORITY_SCHEDULING && _POSIX_THREAD_PRIORITY_SCHEDULING >= 0
POSIX_THREAD_PRIORITY_SCHEDULING _POSIX_THREAD_PRIORITY_SCHEDULING
#endif
#if defined _POSIX_THREAD_PROCESS_SHARED && _POSIX_THREAD_PROCESS_SHARED >= 0
POSIX_THREAD_PROCESS_SHARED _POSIX_THREAD_PROCESS_SHARED
#endif
#if defined _POSIX_THREAD_ROBUST_PRIO_INHERIT && _POSIX_THREAD_ROBUST_PRIO_INHERIT >= 0
POSIX_THREAD_ROBUST_PRIO_INHERIT _POSIX_THREAD_ROBUST_PRIO_INHERIT
#endif
#if defined _POSIX_THREAD_ROBUST_PRIO_PROTECT && _POSIX_THREAD_ROBUST_PRIO_PROTECT >= 0
POSIX_THREAD_ROBUST_PRIO_PROTECT _POSIX_THREAD_ROBUST_PRIO_PROTECT
#endif
#if defined _POSIX_THREAD_SPORADIC_SERVER && _POSIX_THREAD_SPORADIC_SERVER >= 0
POSIX_THREAD_SPORADIC_SERVER _POSIX_THREAD_SPORADIC_SERVER
#endif
#if defined _POSIX_TYPED_MEMORY_OBJECTS && _POSIX_TYPED_MEMORY_OBJECTS >= 0
POSIX_TYPED_MEMORY_OBJECTS _POSIX_TYPED_MEMORY_OBJECTS
#endif
#if defined _XOPEN_CRYPT && _XOPEN_CRYPT >= 0
XOPEN_CRYPT _XOPEN_CRYPT
#endif
#if defined _XOPEN_REALTIME && _XOPEN_REALTIME >= 0
XOPEN_REALTIME _XOPEN_REALTIME
#endif
#if defined _XOPEN_REALTIME_THREADS && _XOPEN_REALTIME_THREADS >= 0
XOPEN_REALTIME_THREADS _XOPEN_REALTIME_THREADS
#endif
#if defined _XOPEN_UNIX && _XOPEN_UNIX >= 0
XOPEN_UNIX _XOPEN_UNIX
#endif

View file

@ -0,0 +1,18 @@
#include <string.h>
#include <stdio.h>
#include "test.h"
/* relative path to p */
char *t_pathrel(char *buf, size_t n, char *argv0, char *p)
{
char *s = strrchr(argv0, '/');
int k;
if (s)
k = snprintf(buf, n, "%.*s/%s", (int)(s-argv0), argv0, p);
else
k = snprintf(buf, n, "./%s", p);
if ((size_t)k >= n)
return 0;
return buf;
}

View file

@ -0,0 +1,28 @@
#include <stdio.h>
#include <stdarg.h>
#include <unistd.h>
#include "test.h"
volatile int t_status = 0;
int t_printf(const char *s, ...)
{
va_list ap;
char buf[512];
int n;
t_status = 1;
va_start(ap, s);
n = vsnprintf(buf, sizeof buf, s, ap);
va_end(ap);
if (n < 0)
n = 0;
else if (n >= sizeof buf) {
n = sizeof buf;
buf[n - 1] = '\n';
buf[n - 2] = '.';
buf[n - 3] = '.';
buf[n - 4] = '.';
}
return write(1, buf, n);
}

View file

@ -0,0 +1,169 @@
#include <float.h>
#include <stdint.h>
#include <stdlib.h>
// TODO: use large period prng
static uint64_t seed = -1;
static uint32_t rand32(void)
{
seed = 6364136223846793005ULL*seed + 1;
return seed >> 32;
}
static uint64_t rand64(void)
{
uint64_t u = rand32();
return u<<32 | rand32();
}
static double frand()
{
return rand64() * 0x1p-64;
}
static float frandf()
{
return rand32() * 0x1p-32f;
}
static long double frandl()
{
return rand64() * 0x1p-64L
#if LDBL_MANT_DIG > 64
+ rand64() * 0x1p-128L
#endif
;
}
void t_randseed(uint64_t s)
{
seed = s;
}
/* uniform random in [0,n), n > 0 must hold */
uint64_t t_randn(uint64_t n)
{
uint64_t r, m;
/* m is the largest multiple of n */
m = -1;
m -= m%n;
while ((r = rand64()) >= m);
return r%n;
}
/* uniform on [a,b], a <= b must hold */
uint64_t t_randint(uint64_t a, uint64_t b)
{
uint64_t n = b - a + 1;
if (n)
return a + t_randn(n);
return rand64();
}
/* shuffle the elements of p and q until the elements in p are well shuffled */
static void shuffle2(uint64_t *p, uint64_t *q, size_t np, size_t nq)
{
size_t r;
uint64_t t;
while (np) {
r = t_randn(nq+np--);
t = p[np];
if (r < nq) {
p[np] = q[r];
q[r] = t;
} else {
p[np] = p[r-nq];
p[r-nq] = t;
}
}
}
/* shuffle the elements of p */
void t_shuffle(uint64_t *p, size_t n)
{
shuffle2(p,0,n,0);
}
void t_randrange(uint64_t *p, size_t n)
{
size_t i;
for (i = 0; i < n; i++)
p[i] = i;
t_shuffle(p, n);
}
/* hash table insert, 0 means empty, v > 0 must hold, len is power-of-2 */
static int insert(uint64_t *tab, size_t len, uint64_t v)
{
size_t i = v & (len-1);
size_t j = 1;
while (tab[i]) {
if (tab[i] == v)
return -1;
i += j++;
i &= len-1;
}
tab[i] = v;
return 0;
}
/* choose k unique numbers from [0,n), k <= n */
int t_choose(uint64_t n, size_t k, uint64_t *p)
{
uint64_t *tab;
size_t i, j, len;
if (n < k)
return -1;
if (n < 16) {
/* no alloc */
while (k)
if (t_randn(n--) < k)
p[--k] = n;
return 0;
}
if (k < 8) {
/* no alloc, n > 15 > 2*k */
for (i = 0; i < k;) {
p[i] = t_randn(n);
for (j = 0; p[j] != p[i]; j++);
if (j == i)
i++;
}
return 0;
}
// TODO: if k < n/k use k*log(k) solution without alloc
if (n < 5*k && (n-k)*sizeof *tab < (size_t)-1) {
/* allocation is n-k < 4*k */
tab = malloc((n-k) * sizeof *tab);
if (!tab)
return -1;
for (i = 0; i < k; i++)
p[i] = i;
for (; i < n; i++)
tab[i-k] = i;
if (k < n-k)
shuffle2(p, tab, k, n-k);
else
shuffle2(tab, p, n-k, k);
free(tab);
return 0;
}
/* allocation is 2*k <= len < 4*k */
for (len = 16; len < 2*k; len *= 2);
tab = calloc(len, sizeof *tab);
if (!tab)
return -1;
for (i = 0; i < k; i++)
while (insert(tab, len, t_randn(n)+1));
for (i = 0; i < len; i++)
if (tab[i])
*p++ = tab[i]-1;
free(tab);
return 0;
}

View file

@ -0,0 +1,100 @@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <signal.h>
#include <time.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <unistd.h>
#include "test.h"
static void handler(int s)
{
}
static int start(char *wrap, char *argv[])
{
int pid;
pid = fork();
if (pid == 0) {
t_setrlim(RLIMIT_STACK, 100*1024);
if (*wrap) {
argv--;
argv[0] = wrap;
}
execv(argv[0], argv);
t_error("%s exec failed: %s\n", argv[0], strerror(errno));
exit(1);
}
return pid;
}
static void usage(char *argv[])
{
t_error("usage: %s [-t timeoutsec] [-w wrapcmd] cmd [args..]\n", argv[0]);
exit(-1);
}
int main(int argc, char *argv[])
{
char *wrap = "";
int timeoutsec = 5;
int timeout = 0;
int status;
sigset_t set;
int opt;
int pid;
while ((opt = getopt(argc, argv, "w:t:")) != -1) {
switch (opt) {
case 'w':
wrap = optarg;
break;
case 't':
timeoutsec = atoi(optarg);
break;
default:
usage(argv);
}
}
if (optind >= argc)
usage(argv);
argv += optind;
sigemptyset(&set);
sigaddset(&set, SIGCHLD);
sigprocmask(SIG_BLOCK, &set, 0);
signal(SIGCHLD, handler);
pid = start(wrap, argv);
if (pid == -1) {
t_error("%s fork failed: %s\n", argv[0], strerror(errno));
t_printf("FAIL %s [internal]\n", argv[0]);
return -1;
}
if (sigtimedwait(&set, 0, &(struct timespec){timeoutsec,0}) == -1) {
if (errno == EAGAIN)
timeout = 1;
else
t_error("%s sigtimedwait failed: %s\n", argv[0], strerror(errno));
if (kill(pid, SIGKILL) == -1)
t_error("%s kill failed: %s\n", argv[0], strerror(errno));
}
if (waitpid(pid, &status, 0) != pid) {
t_error("%s waitpid failed: %s\n", argv[0], strerror(errno));
t_printf("FAIL %s [internal]\n", argv[0]);
return -1;
}
if (WIFEXITED(status)) {
if (WEXITSTATUS(status) == 0)
return t_status;
t_printf("FAIL %s [status %d]\n", argv[0], WEXITSTATUS(status));
} else if (timeout) {
t_printf("FAIL %s [timed out]\n", argv[0]);
} else if (WIFSIGNALED(status)) {
t_printf("FAIL %s [signal %s]\n", argv[0], strsignal(WTERMSIG(status)));
} else
t_printf("FAIL %s [unknown]\n", argv[0]);
return 1;
}

Some files were not shown because too many files have changed in this diff Show more