2e6b6fa73ae67c54ee5ff9bee85d3b44fd02c0f7
[libc-test] / src / api / sys_stat.c
1 #include <sys/stat.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 T(blkcnt_t)
8 T(blksize_t)
9 T(dev_t)
10 T(ino_t)
11 T(mode_t)
12 T(nlink_t)
13 T(uid_t)
14 T(gid_t)
15 T(off_t)
16 T(time_t)
17 T(struct timespec)
18
19 {
20 struct stat x;
21 F(dev_t, st_dev)
22 F(ino_t, st_ino)
23 F(mode_t, st_mode)
24 F(nlink_t, st_nlink)
25 F(uid_t, st_uid)
26 F(gid_t, st_gid)
27 F(dev_t, st_rdev)
28 F(off_t, st_size)
29 F(struct timespec, st_atim)
30 F(struct timespec, st_mtim)
31 F(struct timespec, st_ctim)
32 F(blksize_t, st_blksize)
33 F(blkcnt_t, st_blocks)
34
35 F(time_t, st_atime)
36 F(time_t, st_mtime)
37 F(time_t, st_ctime)
38 }
39 C(S_IRWXU)
40 C(S_IRUSR)
41 C(S_IWUSR)
42 C(S_IXUSR)
43 C(S_IRWXG)
44 C(S_IRGRP)
45 C(S_IWGRP)
46 C(S_IXGRP)
47 C(S_IRWXO)
48 C(S_IROTH)
49 C(S_IWOTH)
50 C(S_IXOTH)
51 C(S_ISUID)
52 C(S_ISGID)
53 #ifdef _XOPEN_SOURCE
54 C(S_ISVTX)
55 C(S_IFMT)
56 C(S_IFBLK)
57 C(S_IFCHR)
58 C(S_IFIFO)
59 C(S_IFREG)
60 C(S_IFDIR)
61 C(S_IFLNK)
62 C(S_IFSOCK)
63 #endif
64 C(S_ISBLK(0))
65 C(S_ISCHR(0))
66 C(S_ISDIR(0))
67 C(S_ISFIFO(0))
68 C(S_ISREG(0))
69 C(S_ISLNK(0))
70 C(S_ISSOCK(0))
71 {
72 struct stat x = {0};
73 {int i = S_TYPEISMQ(&x);}
74 {int i = S_TYPEISSEM(&x);}
75 {int i = S_TYPEISSHM(&x);}
76 {int i = S_TYPEISTMO(&x);}
77 }
78 C(UTIME_NOW)
79 C(UTIME_OMIT)
80 int(*p_chmod)(const char*,mode_t) = chmod;
81 int(*p_fchmod)(int,mode_t) = fchmod;
82 int(*p_fchmodat)(int,const char*,mode_t,int) = fchmodat;
83 int(*p_fstat)(int,struct stat*) = fstat;
84 int(*p_fstatat)(int,const char*restrict,struct stat*restrict,int) = fstatat;
85 int(*p_futimens)(int,const struct timespec[]) = futimens;
86 int(*p_lstat)(const char*restrict,struct stat*restrict) = lstat;
87 int(*p_mkdir)(const char*,mode_t) = mkdir;
88 int(*p_mkdirat)(int,const char*,mode_t) = mkdirat;
89 int(*p_mkfifo)(const char*,mode_t) = mkfifo;
90 int(*p_mkfifoat)(int,const char*,mode_t) = mkfifoat;
91 #ifdef _XOPEN_SOURCE
92 int(*p_mknod)(const char*,mode_t,dev_t) = mknod;
93 int(*p_mknodat)(int,const char*,mode_t,dev_t) = mknodat;
94 #endif
95 int(*p_stat)(const char*restrict,struct stat*restrict) = stat;
96 mode_t(*p_umask)(mode_t) = umask;
97 int(*p_utimensat)(int,const char*,const struct timespec[],int) = utimensat;
98 }