api: shorten function checks (and put each into a different scope)
[libc-test] / src / api / fcntl.c
1 #include <fcntl.h>
2 #define T(t) (t*)0;
3 #define F(t,n) {t *y = &x.n;}
4 #define C(n) switch(n){case n:;}
5 static void f()
6 {
7 C(F_DUPFD)
8 C(F_DUPFD_CLOEXEC)
9 C(F_GETFD)
10 C(F_SETFD)
11 C(F_GETFL)
12 C(F_SETFL)
13 C(F_GETLK)
14 C(F_SETLK)
15 C(F_SETLKW)
16 C(F_GETOWN)
17 C(F_SETOWN)
18 C(FD_CLOEXEC)
19 C(F_RDLCK)
20 C(F_UNLCK)
21 C(F_WRLCK)
22 C(SEEK_SET)
23 C(SEEK_CUR)
24 C(SEEK_END)
25 C(O_CREAT)
26 C(O_EXCL)
27 C(O_NOCTTY)
28 C(O_TRUNC)
29 C(O_TTY_INIT)
30 C(O_APPEND)
31 C(O_DSYNC)
32 C(O_NONBLOCK)
33 C(O_RSYNC)
34 C(O_SYNC)
35 C(O_ACCMODE)
36 C(O_EXEC)
37 C(O_RDONLY)
38 C(O_RDWR)
39 C(O_SEARCH)
40 C(O_WRONLY)
41 C(S_IRWXU)
42 C(S_IRUSR)
43 C(S_IWUSR)
44 C(S_IXUSR)
45 C(S_IRWXG)
46 C(S_IRGRP)
47 C(S_IWGRP)
48 C(S_IXGRP)
49 C(S_IRWXO)
50 C(S_IROTH)
51 C(S_IWOTH)
52 C(S_IXOTH)
53 C(S_ISUID)
54 C(S_ISGID)
55 #ifdef _XOPEN_SOURCE
56 C(S_ISVTX)
57 #endif
58 C(AT_FDCWD)
59 C(AT_EACCESS)
60 C(AT_SYMLINK_NOFOLLOW)
61 C(AT_SYMLINK_FOLLOW)
62 C(O_CLOEXEC)
63 C(O_DIRECTORY)
64 C(O_NOFOLLOW)
65 C(AT_REMOVEDIR)
66 C(POSIX_FADV_DONTNEED)
67 C(POSIX_FADV_NOREUSE)
68 C(POSIX_FADV_NORMAL)
69 C(POSIX_FADV_RANDOM)
70 C(POSIX_FADV_SEQUENTIAL)
71 C(POSIX_FADV_WILLNEED)
72
73 {
74 struct flock x;
75 F(short, l_type)
76 F(short, l_whence)
77 F(off_t, l_start)
78 F(off_t, l_len)
79 F(pid_t, l_pid)
80 }
81
82 T(mode_t)
83 T(off_t)
84 T(pid_t)
85
86 {int(*p)(int,int,...) = fcntl;}
87 {int(*p)(int,off_t,off_t,int) = posix_fadvise;}
88 {int(*p)(int,off_t,off_t) = posix_fallocate;}
89 }
90 #ifndef _XOPEN_SOURCE
91 #include <sys/stat.h>
92 #endif
93 static void g()
94 {
95 {int(*p)(const char*,mode_t) = creat;}
96 {int(*p)(const char*,int,...) = open;}
97 {int(*p)(int,const char*,int,...) = openat;}
98 }