2 * Rummage through the system header files using the C compiler itself
3 * as a parser, extracting stuff like preprocessor constants and the
4 * sizes and signedness of basic system types, and write it out as
9 * This software is part of the SBCL system. See the README file for
12 * While most of SBCL is derived from the CMU CL system, many
13 * utilities for the build process (like this one) were written from
14 * scratch after the fork from CMU CL.
16 * This software is in the public domain and is provided with
17 * absolutely no warranty. See the COPYING and CREDITS files for
22 #include <sys/types.h>
24 #define WIN32_LEAN_AND_MEAN
28 #include <sys/times.h>
30 #include <sys/ioctl.h>
31 #include <sys/termios.h>
33 #include "../src/runtime/ppc-darwin-dlshim.h"
34 #include "../src/runtime/ppc-darwin-langinfo.h"
47 #include "genesis/config.h"
49 #define DEFTYPE(lispname,cname) { cname foo; \
50 printf("(define-alien-type " lispname " (%s %d))\n", (((foo=-1)<0) ? "sb!alien:signed" : "unsigned"), (8 * (sizeof foo))); }
53 defconstant(char* lisp_name, long unix_number)
55 printf("(defconstant %s %ld) ; #x%lx\n",
56 lisp_name, unix_number, unix_number);
59 void deferrno(char* lisp_name, long unix_number)
61 defconstant(lisp_name, unix_number);
64 void defsignal(char* lisp_name, long unix_number)
66 defconstant(lisp_name, unix_number);
70 main(int argc, char *argv[])
72 /* don't need no steenking command line arguments */
74 fprintf(stderr, "argh! command line argument(s)\n");
78 /* don't need no steenking hand-editing */
80 ";;;; This is an automatically generated file, please do not hand-edit it.\n\
81 ;;;; See the program \"grovel-headers.c\".\n\
85 printf("(in-package \"SB!WIN32\")\n\n");
87 defconstant ("input-record-size", sizeof (INPUT_RECORD));
89 printf("(in-package \"SB!ALIEN\")\n\n");
91 printf (";;;flags for dlopen()\n");
93 defconstant ("rtld-lazy", RTLD_LAZY);
94 defconstant ("rtld-now", RTLD_NOW);
95 defconstant ("rtld-global", RTLD_GLOBAL);
97 printf("(in-package \"SB!UNIX\")\n\n");
99 printf(";;; langinfo\n");
100 defconstant("codeset", CODESET);
102 printf(";;; types, types, types\n");
103 DEFTYPE("clock-t", clock_t);
104 DEFTYPE("dev-t", dev_t);
105 DEFTYPE("gid-t", gid_t);
106 DEFTYPE("ino-t", ino_t);
107 DEFTYPE("mode-t", mode_t);
108 DEFTYPE("nlink-t", nlink_t);
109 DEFTYPE("off-t", off_t);
110 DEFTYPE("size-t", size_t);
111 DEFTYPE("time-t", time_t);
112 DEFTYPE("uid-t", uid_t);
115 printf(";;; fcntl.h (or unistd.h on OpenBSD and NetBSD)\n");
116 defconstant("r_ok", R_OK);
117 defconstant("w_ok", W_OK);
118 defconstant("x_ok", X_OK);
119 defconstant("f_ok", F_OK);
122 printf(";;; fcntlbits.h\n");
123 defconstant("o_rdonly", O_RDONLY);
124 defconstant("o_wronly", O_WRONLY);
125 defconstant("o_rdwr", O_RDWR);
126 defconstant("o_accmode", O_ACCMODE);
127 defconstant("o_creat", O_CREAT);
128 defconstant("o_excl", O_EXCL);
129 defconstant("o_noctty", O_NOCTTY);
130 defconstant("o_trunc", O_TRUNC);
131 defconstant("o_append", O_APPEND);
133 defconstant("s-ifmt", S_IFMT);
134 defconstant("s-ififo", S_IFIFO);
135 defconstant("s-ifchr", S_IFCHR);
136 defconstant("s-ifdir", S_IFDIR);
137 defconstant("s-ifblk", S_IFBLK);
138 defconstant("s-ifreg", S_IFREG);
141 defconstant("s-iflnk", S_IFLNK);
142 defconstant("s-ifsock", S_IFSOCK);
145 printf(";;; error numbers\n");
146 deferrno("enoent", ENOENT);
147 deferrno("eintr", EINTR);
148 deferrno("eio", EIO);
149 deferrno("eexist", EEXIST);
150 deferrno("espipe", ESPIPE);
151 deferrno("ewouldblock", EWOULDBLOCK);
154 printf(";;; for wait3(2) in run-program.lisp\n");
155 defconstant("wnohang", WNOHANG);
156 defconstant("wuntraced", WUNTRACED);
159 printf(";;; various ioctl(2) flags\n");
160 defconstant("tiocnotty", TIOCNOTTY);
161 defconstant("tiocgwinsz", TIOCGWINSZ);
162 defconstant("tiocswinsz", TIOCSWINSZ);
163 defconstant("tiocgpgrp", TIOCGPGRP);
164 defconstant("tiocspgrp", TIOCSPGRP);
165 /* KLUDGE: These are referenced by old CMUCL-derived code, but
166 * Linux doesn't define them.
168 * I think these are the BSD names, but I don't know what the
169 * corresponding SysV/Linux names are. As a point of reference,
170 * CMUCL doesn't have these defined either (although the defining
171 * forms *do* exist in src/code/unix.lisp), so I don't feel nearly
172 * so bad about not hunting them down. Insight into renamed
173 * obscure ioctl(2) flags appreciated. --njf, 2002-08-26
175 * I note that the first one I grepped for, TIOCSIGSEND, is
176 * referenced in SBCL conditional on #+HPUX. Maybe the porters of
177 * Oxbridge know more about things like that? And even if they
178 * don't, one benefit of the Rhodes crusade to heal the worthy
179 * ports should be that afterwards, if we grep for something like
180 * this in CVS and it's not there, we can lightheartedly nuke it.
181 * -- WHN 2002-08-30 */
183 defconstant("tiocsigsend", TIOCSIGSEND);
184 defconstant("tiocflush", TIOCFLUSH);
185 defconstant("tiocgetp", TIOCGETP);
186 defconstant("tiocsetp", TIOCSETP);
187 defconstant("tiocgetc", TIOCGETC);
188 defconstant("tiocsetc", TIOCSETC);
189 defconstant("tiocgltc", TIOCGLTC);
190 defconstant("tiocsltc", TIOCSLTC);
194 printf(";;; signals\n");
195 defsignal("sigalrm", SIGALRM);
196 defsignal("sigbus", SIGBUS);
197 defsignal("sigchld", SIGCHLD);
198 defsignal("sigcont", SIGCONT);
200 defsignal("sigemt", SIGEMT);
202 defsignal("sigfpe", SIGFPE);
203 defsignal("sighup", SIGHUP);
204 defsignal("sigill", SIGILL);
205 defsignal("sigint", SIGINT);
206 defsignal("sigio", SIGIO);
207 defsignal("sigiot", SIGIOT);
208 defsignal("sigkill", SIGKILL);
209 defsignal("sigpipe", SIGPIPE);
210 defsignal("sigprof", SIGPROF);
211 defsignal("sigquit", SIGQUIT);
212 defsignal("sigsegv", SIGSEGV);
213 #if ((defined LISP_FEATURE_LINUX) && (defined LISP_FEATURE_X86))
214 defsignal("sigstkflt", SIGSTKFLT);
216 defsignal("sigstop", SIGSTOP);
217 #if (!((defined LISP_FEATURE_LINUX) && (defined LISP_FEATURE_X86)))
218 defsignal("sigsys", SIGSYS);
220 defsignal("sigterm", SIGTERM);
221 defsignal("sigtrap", SIGTRAP);
222 defsignal("sigtstp", SIGTSTP);
223 defsignal("sigttin", SIGTTIN);
224 defsignal("sigttou", SIGTTOU);
225 defsignal("sigurg", SIGURG);
226 defsignal("sigusr1", SIGUSR1);
227 defsignal("sigusr2", SIGUSR2);
228 defsignal("sigvtalrm", SIGVTALRM);
229 #ifdef LISP_FEATURE_SUNOS
230 defsignal("sigwaiting", SIGWAITING);
232 defsignal("sigwinch", SIGWINCH);
233 #ifndef LISP_FEATURE_HPUX
234 defsignal("sigxcpu", SIGXCPU);
235 defsignal("sigxfsz", SIGXFSZ);