2 * This calculates the platform-variable portion of the libc module.
3 * Move code in here only as you discover it is platform-variable.
19 #include <sys/types.h>
24 #define S(T) ((((T)-1)<0) ? 'i' : 'u')
25 #define B(T) (((int)sizeof(T)) * CHAR_BIT)
26 #define put_type(N,T) \
27 printf(" type %s = %c%d;\n", N, S(T), B(T))
29 #define put_ftype(N,T) \
30 printf(" type %s = f%d;\n", N, B(T))
32 #define CT(T) ((((T)-1)<0) ? "int" : "uint")
33 #define CS(T) ((((T)-1)<0) ? "" : "_u")
34 #define put_const(N,T) \
35 printf(" const %s : %s = %d%s;\n", \
39 printf(" mod c95 {\n");
41 put_type("c_char", char);
42 put_type("c_schar", signed char);
43 put_type("c_uchar", unsigned char);
45 put_type("c_short", short);
46 put_type("c_ushort", unsigned short);
48 put_type("c_int", int);
49 put_type("c_uint", unsigned int);
51 put_type("c_long", long);
52 put_type("c_ulong", unsigned long);
54 put_ftype("c_float", float);
55 put_ftype("c_double", double);
57 put_type("size_t", size_t);
58 put_type("ptrdiff_t", ptrdiff_t);
60 put_type("clock_t", clock_t);
61 put_type("time_t", time_t);
63 put_type("wchar_t", wchar_t);
69 printf(" mod c99 {\n");
71 put_type("c_longlong", long long);
72 put_type("c_ulonglong", unsigned long long);
74 put_type("intptr_t", intptr_t);
75 put_type("uintptr_t", uintptr_t);
80 void posix88_types() {
81 printf(" mod posix88 {\n");
83 put_type("off_t", off_t);
84 put_type("dev_t", dev_t);
85 put_type("ino_t", ino_t);
86 put_type("pid_t", pid_t);
88 put_type("uid_t", uid_t);
89 put_type("gid_t", gid_t);
91 put_type("useconds_t", useconds_t);
92 put_type("mode_t", mode_t);
94 put_type("ssize_t", ssize_t);
100 printf(" mod extra {\n");
106 printf(" mod c95 {\n");
108 put_const(EXIT_FAILURE, int);
109 put_const(EXIT_SUCCESS, int);
110 put_const(RAND_MAX, int);
113 put_const(SEEK_SET, int);
114 put_const(SEEK_CUR, int);
115 put_const(SEEK_END, int);
117 put_const(_IOFBF, int);
118 put_const(_IONBF, int);
119 put_const(_IOLBF, int);
121 put_const(BUFSIZ, size_t);
122 put_const(FOPEN_MAX, size_t);
123 put_const(FILENAME_MAX, size_t);
124 put_const(L_tmpnam, size_t);
125 put_const(TMP_MAX, size_t);
131 void posix88_consts() {
132 printf(" mod posix88 {\n");
133 put_const(O_RDONLY, int);
134 put_const(O_WRONLY, int);
135 put_const(O_RDWR, int);
136 put_const(O_APPEND, int);
137 put_const(O_CREAT, int);
138 put_const(O_EXCL, int);
139 put_const(O_TRUNC, int);
141 put_const(S_IFIFO, int);
142 put_const(S_IFCHR, int);
143 put_const(S_IFBLK, int);
144 put_const(S_IFDIR, int);
145 put_const(S_IFREG, int);
146 put_const(S_IFLNK, int);
147 put_const(S_IFMT, int);
149 put_const(S_IEXEC, int);
150 put_const(S_IWRITE, int);
151 put_const(S_IREAD, int);
153 put_const(S_IRWXU, int);
154 put_const(S_IXUSR, int);
155 put_const(S_IWUSR, int);
156 put_const(S_IRUSR, int);
159 put_const(F_OK, int);
162 put_const(R_OK, int);
165 put_const(W_OK, int);
168 put_const(X_OK, int);
172 put_const(STDIN_FILENO, int);
175 put_const(STDOUT_FILENO, int);
178 put_const(STDERR_FILENO, int);
182 put_const(F_LOCK, int);
186 put_const(F_TEST, int);
190 put_const(F_TLOCK, int);
194 put_const(F_ULOCK, int);
200 void extra_consts() {
201 printf(" mod extra {\n");
203 put_const(O_RSYNC, int);
207 put_const(O_DSYNC, int);
211 put_const(O_SYNC, int);
215 put_const(O_TEXT, int);
219 put_const(O_BINARY, int);
223 put_const(O_IRUSR, int);
227 put_const(O_IWUSR, int);
234 printf("mod types {");
241 printf("mod consts {\n");