2 * This calculates the platform-variable portion of the libc module.
3 * Move code in here only as you discover it is platform-variable.
18 #include <sys/types.h>
23 #define S(T) ((((T)-1)<0) ? 'i' : 'u')
24 #define B(T) (((int)sizeof(T)) * CHAR_BIT)
25 #define put_type(N,T) \
26 printf(" type %s = %c%d;\n", N, S(T), B(T))
28 #define CT(T) ((((T)-1)<0) ? "int" : "uint")
29 #define CS(T) ((((T)-1)<0) ? "" : "_u")
30 #define put_const(N,T) \
31 printf(" const %s : %s = %d%s;\n", \
35 printf(" mod c95 {\n");
37 put_type("c_char", char);
38 put_type("c_schar", signed char);
39 put_type("c_uchar", unsigned char);
41 put_type("c_short", short);
42 put_type("c_ushort", unsigned short);
44 put_type("c_int", int);
45 put_type("c_uint", unsigned int);
47 put_type("c_long", long);
48 put_type("c_ulong", unsigned long);
50 put_type("size_t", size_t);
51 put_type("ptrdiff_t", ptrdiff_t);
53 put_type("clock_t", clock_t);
54 put_type("time_t", time_t);
60 printf(" mod c99 {\n");
62 put_type("c_longlong", long long);
63 put_type("c_ulonglong", unsigned long long);
65 put_type("intptr_t", intptr_t);
66 put_type("uintptr_t", uintptr_t);
71 void posix88_types() {
72 printf(" mod posix88 {\n");
74 put_type("off_t", off_t);
75 put_type("dev_t", dev_t);
76 put_type("ino_t", ino_t);
77 put_type("pid_t", pid_t);
79 put_type("uid_t", uid_t);
80 put_type("gid_t", gid_t);
82 put_type("useconds_t", useconds_t);
83 put_type("mode_t", mode_t);
85 put_type("ssize_t", ssize_t);
91 printf(" mod extra {\n");
97 printf(" mod c95 {\n");
99 put_const(EXIT_FAILURE, int);
100 put_const(EXIT_SUCCESS, int);
101 put_const(RAND_MAX, int);
104 put_const(SEEK_SET, int);
105 put_const(SEEK_CUR, int);
106 put_const(SEEK_END, int);
108 put_const(_IOFBF, int);
109 put_const(_IONBF, int);
110 put_const(_IOLBF, int);
112 put_const(BUFSIZ, size_t);
113 put_const(FOPEN_MAX, size_t);
114 put_const(FILENAME_MAX, size_t);
115 put_const(L_tmpnam, size_t);
116 put_const(TMP_MAX, size_t);
122 void posix88_consts() {
123 printf(" mod posix88 {\n");
124 put_const(O_RDONLY, int);
125 put_const(O_WRONLY, int);
126 put_const(O_RDWR, int);
127 put_const(O_APPEND, int);
128 put_const(O_CREAT, int);
129 put_const(O_EXCL, int);
130 put_const(O_TRUNC, int);
132 put_const(S_IFIFO, int);
133 put_const(S_IFCHR, int);
134 put_const(S_IFBLK, int);
135 put_const(S_IFDIR, int);
136 put_const(S_IFREG, int);
137 put_const(S_IFMT, int);
139 put_const(S_IEXEC, int);
140 put_const(S_IWRITE, int);
141 put_const(S_IREAD, int);
143 put_const(S_IRWXU, int);
144 put_const(S_IXUSR, int);
145 put_const(S_IWUSR, int);
146 put_const(S_IRUSR, int);
149 put_const(F_OK, int);
152 put_const(R_OK, int);
155 put_const(W_OK, int);
158 put_const(X_OK, int);
162 put_const(STDERR_FILENO, int);
165 put_const(STDIN_FILENO, int);
168 put_const(STDOUT_FILENO, int);
172 put_const(F_LOCK, int);
176 put_const(F_TEST, int);
180 put_const(F_TLOCK, int);
184 put_const(F_ULOCK, int);
190 void extra_consts() {
191 printf(" mod extra {\n");
193 put_const(O_RSYNC, int);
197 put_const(O_DSYNC, int);
201 put_const(O_SYNC, int);
205 put_const(O_TEXT, int);
209 put_const(O_BINARY, int);
213 put_const(O_IRUSR, int);
217 put_const(O_IWUSR, int);
224 printf("mod types {");
231 printf("mod consts {\n");