Actually optimize in PACK-TN
[sbcl.git] / tools-for-build / grovel-headers.c
1 /*
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
5  * Lisp code.
6  */
7
8 /*
9  * This software is part of the SBCL system. See the README file for
10  * more information.
11  *
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.
15  *
16  * This software is in the public domain and is provided with
17  * absolutely no warranty. See the COPYING and CREDITS files for
18  * more information.
19  */
20
21 #include "genesis/config.h"
22
23 #include <stdio.h>
24 #include <stdlib.h>
25 #include <sys/types.h>
26 #ifdef _WIN32
27   /* KLUDGE: From src/runtime/runtime.h, avoid double definition of
28      boolean.  We really should clean up our act on this one. */
29   #define boolean rpcndr_boolean
30   #define WIN32_LEAN_AND_MEAN
31   #include <windows.h>
32   #include <shlobj.h>
33   #include <wincrypt.h>
34   #include <winsock2.h>
35   #undef boolean
36 #else
37   #include <poll.h>
38   #include <sys/select.h>
39   #include <sys/times.h>
40   #include <sys/wait.h>
41   #include <sys/ioctl.h>
42   #include <sys/termios.h>
43   #include <sys/time.h>
44   #include <langinfo.h>
45   #include <dlfcn.h>
46 #endif
47
48 #include <sys/stat.h>
49 #include <fcntl.h>
50 #include <unistd.h>
51 #include <signal.h>
52 #include <errno.h>
53 #include <time.h>
54
55 #ifdef LISP_FEATURE_HPUX
56 #include <sys/bsdtty.h> /* for TIOCGPGRP */
57 #endif
58
59 #ifdef LISP_FEATURE_BSD
60   #include <sys/param.h>
61   #include <sys/sysctl.h>
62 #endif
63
64 #ifdef _WIN32
65   #include "pthreads_win32.h"
66 #endif
67
68 #include "wrap.h"
69 #include "gc.h"
70
71 #define DEFTYPE(lispname,cname) { cname foo; \
72     printf("(define-alien-type " lispname " (%s %d))\n", (((foo=-1)<0) ? "sb!alien:signed" : "unsigned"), (8 * (sizeof foo))); }
73
74 #define DEFSTRUCT(lispname,cname,body) { cname bar; \
75     printf("(define-alien-type nil\n  (struct %s", #lispname); \
76     body; \
77     printf("))\n"); }
78 #define DEFSLOT(lispname,cname) \
79     printf("\n          (%s (%s %d))", \
80            #lispname, \
81            (((bar.cname=-1)<0) ? "sb!alien:signed" : "unsigned"), \
82            (8 * (sizeof bar.cname)))
83
84 void
85 defconstant(char* lisp_name, unsigned long unix_number)
86 {
87     printf("(defconstant %s %lu) ; #x%lx\n",
88            lisp_name, unix_number, unix_number);
89 }
90
91 void deferrno(char* lisp_name, unsigned long unix_number)
92 {
93     defconstant(lisp_name, unix_number);
94 }
95
96 void defsignal(char* lisp_name, unsigned long unix_number)
97 {
98     defconstant(lisp_name, unix_number);
99 }
100
101 int
102 main(int argc, char *argv[])
103 {
104     /* don't need no steenking command line arguments */
105     if (1 != argc) {
106         fprintf(stderr, "argh! command line argument(s)\n");
107         exit(1);
108     }
109
110     /* don't need no steenking hand-editing */
111     printf(
112 ";;;; This is an automatically generated file, please do not hand-edit it.\n\
113 ;;;; See the program \"grovel-headers.c\".\n\
114 \n\
115 ");
116 #ifdef _WIN32
117     printf("(in-package \"SB!WIN32\")\n\n");
118
119     defconstant ("input-record-size", sizeof (INPUT_RECORD));
120
121     defconstant ("MAX_PATH", MAX_PATH);
122
123     printf(";;; CSIDL\n");
124
125     defconstant ("CSIDL_DESKTOP", CSIDL_DESKTOP);
126     defconstant ("CSIDL_INTERNET", CSIDL_INTERNET);
127     defconstant ("CSIDL_PROGRAMS", CSIDL_PROGRAMS);
128     defconstant ("CSIDL_CONTROLS", CSIDL_CONTROLS);
129     defconstant ("CSIDL_PRINTERS", CSIDL_PRINTERS);
130     defconstant ("CSIDL_PERSONAL", CSIDL_PERSONAL);
131     defconstant ("CSIDL_FAVORITES", CSIDL_FAVORITES);
132     defconstant ("CSIDL_STARTUP", CSIDL_STARTUP);
133     defconstant ("CSIDL_RECENT", CSIDL_RECENT);
134     defconstant ("CSIDL_SENDTO", CSIDL_SENDTO);
135     defconstant ("CSIDL_BITBUCKET", CSIDL_BITBUCKET);
136     defconstant ("CSIDL_STARTMENU", CSIDL_STARTMENU);
137     defconstant ("CSIDL_DESKTOPDIRECTORY", CSIDL_DESKTOPDIRECTORY);
138     defconstant ("CSIDL_DRIVES", CSIDL_DRIVES);
139     defconstant ("CSIDL_NETWORK", CSIDL_NETWORK);
140     defconstant ("CSIDL_NETHOOD", CSIDL_NETHOOD);
141     defconstant ("CSIDL_FONTS", CSIDL_FONTS);
142     defconstant ("CSIDL_TEMPLATES", CSIDL_TEMPLATES);
143     defconstant ("CSIDL_COMMON_STARTMENU", CSIDL_COMMON_STARTMENU);
144     defconstant ("CSIDL_COMMON_PROGRAMS", CSIDL_COMMON_PROGRAMS);
145     defconstant ("CSIDL_COMMON_STARTUP", CSIDL_COMMON_STARTUP);
146     defconstant ("CSIDL_COMMON_DESKTOPDIRECTORY", CSIDL_COMMON_DESKTOPDIRECTORY);
147     defconstant ("CSIDL_APPDATA", CSIDL_APPDATA);
148     defconstant ("CSIDL_PRINTHOOD", CSIDL_PRINTHOOD);
149     defconstant ("CSIDL_LOCAL_APPDATA", CSIDL_LOCAL_APPDATA);
150     defconstant ("CSIDL_ALTSTARTUP", CSIDL_ALTSTARTUP);
151     defconstant ("CSIDL_COMMON_ALTSTARTUP", CSIDL_COMMON_ALTSTARTUP);
152     defconstant ("CSIDL_COMMON_FAVORITES", CSIDL_COMMON_FAVORITES);
153     defconstant ("CSIDL_INTERNET_CACHE", CSIDL_INTERNET_CACHE);
154     defconstant ("CSIDL_COOKIES", CSIDL_COOKIES);
155     defconstant ("CSIDL_HISTORY", CSIDL_HISTORY);
156     defconstant ("CSIDL_COMMON_APPDATA", CSIDL_COMMON_APPDATA);
157     defconstant ("CSIDL_WINDOWS", CSIDL_WINDOWS);
158     defconstant ("CSIDL_SYSTEM", CSIDL_SYSTEM);
159     defconstant ("CSIDL_PROGRAM_FILES", CSIDL_PROGRAM_FILES);
160     defconstant ("CSIDL_MYPICTURES", CSIDL_MYPICTURES);
161     defconstant ("CSIDL_PROFILE", CSIDL_PROFILE);
162     defconstant ("CSIDL_SYSTEMX86", CSIDL_SYSTEMX86);
163     defconstant ("CSIDL_PROGRAM_FILESX86", CSIDL_PROGRAM_FILESX86);
164     defconstant ("CSIDL_PROGRAM_FILES_COMMON", CSIDL_PROGRAM_FILES_COMMON);
165     defconstant ("CSIDL_PROGRAM_FILES_COMMONX86", CSIDL_PROGRAM_FILES_COMMONX86);
166     defconstant ("CSIDL_COMMON_TEMPLATES", CSIDL_COMMON_TEMPLATES);
167     defconstant ("CSIDL_COMMON_DOCUMENTS", CSIDL_COMMON_DOCUMENTS);
168     defconstant ("CSIDL_COMMON_ADMINTOOLS", CSIDL_COMMON_ADMINTOOLS);
169     defconstant ("CSIDL_ADMINTOOLS", CSIDL_ADMINTOOLS);
170     defconstant ("CSIDL_CONNECTIONS", CSIDL_CONNECTIONS);
171     defconstant ("CSIDL_COMMON_MUSIC", CSIDL_COMMON_MUSIC);
172     defconstant ("CSIDL_COMMON_PICTURES", CSIDL_COMMON_PICTURES);
173     defconstant ("CSIDL_COMMON_VIDEO", CSIDL_COMMON_VIDEO);
174     defconstant ("CSIDL_RESOURCES", CSIDL_RESOURCES);
175     defconstant ("CSIDL_RESOURCES_LOCALIZED", CSIDL_RESOURCES_LOCALIZED);
176     defconstant ("CSIDL_COMMON_OEM_LINKS", CSIDL_COMMON_OEM_LINKS);
177     defconstant ("CSIDL_CDBURN_AREA", CSIDL_CDBURN_AREA);
178     defconstant ("CSIDL_COMPUTERSNEARME", CSIDL_COMPUTERSNEARME);
179     defconstant ("CSIDL_FLAG_DONT_VERIFY", CSIDL_FLAG_DONT_VERIFY);
180     defconstant ("CSIDL_FLAG_CREATE", CSIDL_FLAG_CREATE);
181     defconstant ("CSIDL_FLAG_MASK", CSIDL_FLAG_MASK);
182
183     printf(";;; Exception codes\n");
184     defconstant("+exception-access-violation+", EXCEPTION_ACCESS_VIOLATION);
185     defconstant("+exception-array-bounds-exceeded+", EXCEPTION_ARRAY_BOUNDS_EXCEEDED);
186     defconstant("+exception-breakpoint+", EXCEPTION_BREAKPOINT);
187     defconstant("+exception-datatype-misalignment+", EXCEPTION_DATATYPE_MISALIGNMENT);
188     defconstant("+exception-flt-denormal-operand+", EXCEPTION_FLT_DENORMAL_OPERAND);
189     defconstant("+exception-flt-divide-by-zero+", EXCEPTION_FLT_DIVIDE_BY_ZERO);
190     defconstant("+exception-flt-inexact-result+", EXCEPTION_FLT_INEXACT_RESULT);
191     defconstant("+exception-flt-invalid-operation+", EXCEPTION_FLT_INVALID_OPERATION);
192     defconstant("+exception-flt-overflow+", EXCEPTION_FLT_OVERFLOW);
193     defconstant("+exception-flt-stack-check+", EXCEPTION_FLT_STACK_CHECK);
194     defconstant("+exception-flt-underflow+", EXCEPTION_FLT_UNDERFLOW);
195     defconstant("+exception-illegal-instruction+", EXCEPTION_ILLEGAL_INSTRUCTION);
196     defconstant("+exception-in-page-error+", EXCEPTION_IN_PAGE_ERROR);
197     defconstant("+exception-int-divide-by-zero+", EXCEPTION_INT_DIVIDE_BY_ZERO);
198     defconstant("+exception-int-overflow+", EXCEPTION_INT_OVERFLOW);
199     defconstant("+exception-invalid-disposition+", EXCEPTION_INVALID_DISPOSITION);
200     defconstant("+exception-noncontinuable-exception+", EXCEPTION_NONCONTINUABLE_EXCEPTION);
201     defconstant("+exception-priv-instruction+", EXCEPTION_PRIV_INSTRUCTION);
202     defconstant("+exception-single-step+", EXCEPTION_SINGLE_STEP);
203     defconstant("+exception-stack-overflow+", EXCEPTION_STACK_OVERFLOW);
204
205     printf(";;; FormatMessage\n");
206
207     defconstant("format-message-allocate-buffer", FORMAT_MESSAGE_ALLOCATE_BUFFER);
208     defconstant("format-message-from-system", FORMAT_MESSAGE_FROM_SYSTEM);
209     defconstant("format-message-max-width-mask", FORMAT_MESSAGE_MAX_WIDTH_MASK);
210     defconstant("format-message-ignore-inserts", FORMAT_MESSAGE_IGNORE_INSERTS);
211
212     printf(";;; Errors\n");
213
214     printf(";;; Errors\n");
215
216     defconstant("ERROR_ENVVAR_NOT_FOUND", ERROR_ENVVAR_NOT_FOUND);
217     defconstant("ERROR_ALREADY_EXISTS", ERROR_ALREADY_EXISTS);
218     defconstant("ERROR_FILE_EXISTS", ERROR_FILE_EXISTS);
219     defconstant("ERROR_FILE_NOT_FOUND", ERROR_FILE_NOT_FOUND);
220     defconstant("ERROR_ACCESS_DENIED", ERROR_ACCESS_DENIED);
221
222     printf(";;; GetComputerName\n");
223
224     defconstant ("MAX_COMPUTERNAME_LENGTH", MAX_COMPUTERNAME_LENGTH);
225     defconstant ("ERROR_BUFFER_OVERFLOW", ERROR_BUFFER_OVERFLOW);
226
227     printf(";;; Windows Types\n");
228     DEFTYPE("int-ptr", INT_PTR);
229     DEFTYPE("dword",   DWORD);
230     DEFTYPE("bool",    BOOL);
231     DEFTYPE("uint",    UINT);
232     DEFTYPE("ulong",   ULONG);
233
234     printf(";;; File Desired Access\n");
235     defconstant ("FILE_GENERIC_READ", FILE_GENERIC_READ);
236     defconstant ("FILE_GENERIC_WRITE", FILE_GENERIC_WRITE);
237     defconstant ("FILE_GENERIC_EXECUTE", FILE_GENERIC_EXECUTE);
238     defconstant ("FILE_SHARE_READ", FILE_SHARE_READ);
239     defconstant ("FILE_SHARE_WRITE", FILE_SHARE_WRITE);
240     defconstant ("FILE_SHARE_DELETE", FILE_SHARE_DELETE);
241
242     printf(";;; File Creation Dispositions\n");
243     defconstant("CREATE_NEW", CREATE_NEW);
244     defconstant("CREATE_ALWAYS", CREATE_ALWAYS);
245     defconstant("OPEN_EXISTING", OPEN_EXISTING);
246     defconstant("OPEN_ALWAYS", OPEN_ALWAYS);
247     defconstant("TRUNCATE_EXISTING", TRUNCATE_EXISTING);
248
249     printf(";;; Desired Access\n");
250     defconstant("ACCESS_GENERIC_READ", GENERIC_READ);
251     defconstant("ACCESS_GENERIC_WRITE", GENERIC_WRITE);
252     defconstant("ACCESS_GENERIC_EXECUTE", GENERIC_EXECUTE);
253     defconstant("ACCESS_GENERIC_ALL", GENERIC_ALL);
254     defconstant("ACCESS_FILE_APPEND_DATA", FILE_APPEND_DATA);
255     defconstant("ACCESS_DELETE", DELETE);
256
257     printf(";;; Handle Information Flags\n");
258     defconstant("HANDLE_FLAG_INHERIT", HANDLE_FLAG_INHERIT);
259     defconstant("HANDLE_FLAG_PROTECT_FROM_CLOSE", HANDLE_FLAG_PROTECT_FROM_CLOSE);
260
261     printf(";;; Standard Handle Keys\n");
262     defconstant("STD_INPUT_HANDLE", STD_INPUT_HANDLE);
263     defconstant("STD_OUTPUT_HANDLE", STD_OUTPUT_HANDLE);
264     defconstant("STD_ERROR_HANDLE", STD_ERROR_HANDLE);
265
266     printf(";;; WinCrypt\n");
267     defconstant("crypt-verifycontext", CRYPT_VERIFYCONTEXT);
268     defconstant("crypt-silent", CRYPT_SILENT);
269     defconstant("prov-rsa-full", PROV_RSA_FULL);
270
271     /* FIXME: SB-UNIX and SB-WIN32 really need to be untangled. */
272     printf("(in-package \"SB!UNIX\")\n\n");
273     printf(";;; Unix-like constants and types on Windows\n");
274     defconstant("o_rdonly", _O_RDONLY);
275     defconstant("o_wronly", _O_WRONLY);
276     defconstant("o_rdwr",   _O_RDWR);
277     defconstant("o_creat",  _O_CREAT);
278     defconstant("o_trunc",  _O_TRUNC);
279     defconstant("o_append", _O_APPEND);
280     defconstant("o_excl",   _O_EXCL);
281     defconstant("o_binary", _O_BINARY);
282     defconstant("o_noinherit", _O_NOINHERIT);
283
284     defconstant("enoent", ENOENT);
285     defconstant("eexist", EEXIST);
286     defconstant("eintr", EINTR);
287     defconstant("eagain", EAGAIN);
288     defconstant("ebadf", EBADF);
289
290     defconstant("s-ifmt",  S_IFMT);
291     defconstant("s-ifdir", S_IFDIR);
292     defconstant("s-ifreg", S_IFREG);
293
294     DEFTYPE("ino-t",  ino_t);
295     DEFTYPE("time-t", time_t);
296     DEFTYPE("off-t",  off_t);
297     DEFTYPE("size-t", size_t);
298     DEFTYPE("mode-t", mode_t);
299
300     DEFTYPE("wst-dev-t", wst_dev_t);
301     DEFTYPE("wst-off-t", wst_off_t);
302     DEFTYPE("wst-blksize-t", wst_blksize_t);
303     DEFTYPE("wst-blkcnt-t", wst_blkcnt_t);
304     DEFTYPE("wst-nlink-t", wst_nlink_t);
305     DEFTYPE("wst-uid-t", wst_uid_t);
306     DEFTYPE("wst-gid-t", wst_gid_t);
307
308     /* KLUDGE */
309     defconstant("fd-setsize", 1024);
310     printf("\n");
311 #else
312     printf("(in-package \"SB!ALIEN\")\n\n");
313
314     printf (";;;flags for dlopen()\n");
315
316     defconstant ("rtld-lazy", RTLD_LAZY);
317     defconstant ("rtld-now", RTLD_NOW);
318     defconstant ("rtld-global", RTLD_GLOBAL);
319
320     printf("(in-package \"SB!UNIX\")\n\n");
321
322     printf(";;; select()\n");
323     defconstant("fd-setsize", FD_SETSIZE);
324
325     printf(";;; poll()\n");
326     defconstant("pollin", POLLIN);
327     defconstant("pollout", POLLOUT);
328     defconstant("pollpri", POLLPRI);
329     defconstant("pollhup", POLLHUP);
330     DEFTYPE("nfds-t", nfds_t);
331
332     printf(";;; langinfo\n");
333     defconstant("codeset", CODESET);
334
335     printf(";;; types, types, types\n");
336     DEFTYPE("clock-t", clock_t);
337     DEFTYPE("dev-t",   dev_t);
338     DEFTYPE("gid-t",   gid_t);
339     DEFTYPE("ino-t",   ino_t);
340     DEFTYPE("mode-t",  mode_t);
341     DEFTYPE("nlink-t", nlink_t);
342     DEFTYPE("off-t",   off_t);
343     DEFTYPE("size-t",  size_t);
344     DEFTYPE("time-t",  time_t);
345 #if !defined(LISP_FEATURE_OS_PROVIDES_SUSECONDS_T)
346     /* Similar kludge in sb-posix. */
347     DEFTYPE("suseconds-t", long);
348 #else
349     DEFTYPE("suseconds-t", suseconds_t);
350 #endif
351     DEFTYPE("uid-t",   uid_t);
352     printf(";; Types in src/runtime/wrap.h. See that file for explantion.\n");
353     printf(";; Don't use these types for anything other than the stat wrapper.\n");
354     DEFTYPE("wst-dev-t", wst_dev_t);
355     DEFTYPE("wst-off-t", wst_off_t);
356     DEFTYPE("wst-blksize-t", wst_blksize_t);
357     DEFTYPE("wst-blkcnt-t", wst_blkcnt_t);
358     DEFTYPE("wst-nlink-t", wst_nlink_t);
359     DEFTYPE("wst-uid-t", wst_uid_t);
360     DEFTYPE("wst-gid-t", wst_gid_t);
361     printf("\n");
362
363     printf(";;; fcntl.h (or unistd.h on OpenBSD and NetBSD)\n");
364     defconstant("r_ok", R_OK);
365     defconstant("w_ok", W_OK);
366     defconstant("x_ok", X_OK);
367     defconstant("f_ok", F_OK);
368     printf("\n");
369
370     printf(";;; fcntlbits.h\n");
371     defconstant("o_rdonly",  O_RDONLY);
372     defconstant("o_wronly",  O_WRONLY);
373     defconstant("o_rdwr",    O_RDWR);
374     defconstant("o_accmode", O_ACCMODE);
375     defconstant("o_creat",   O_CREAT);
376     defconstant("o_excl",    O_EXCL);
377     defconstant("o_noctty",  O_NOCTTY);
378     defconstant("o_trunc",   O_TRUNC);
379     defconstant("o_append",  O_APPEND);
380 #ifdef LISP_FEATURE_LARGEFILE
381     defconstant("o_largefile", O_LARGEFILE);
382 #endif
383
384     printf(";;;\n");
385     defconstant("s-ifmt",  S_IFMT);
386     defconstant("s-ififo", S_IFIFO);
387     defconstant("s-ifchr", S_IFCHR);
388     defconstant("s-ifdir", S_IFDIR);
389     defconstant("s-ifblk", S_IFBLK);
390     defconstant("s-ifreg", S_IFREG);
391     printf("\n");
392
393     defconstant("s-iflnk",  S_IFLNK);
394     defconstant("s-ifsock", S_IFSOCK);
395     printf("\n");
396
397     printf(";;; error numbers\n");
398     deferrno("ebadf", EBADF);
399     deferrno("enoent", ENOENT);
400     deferrno("eintr", EINTR);
401     deferrno("eagain", EAGAIN);
402     deferrno("eio", EIO);
403     deferrno("eexist", EEXIST);
404     deferrno("eloop", ELOOP);
405     deferrno("espipe", ESPIPE);
406     deferrno("ewouldblock", EWOULDBLOCK);
407     printf("\n");
408
409     printf(";;; for wait3(2) in run-program.lisp\n");
410     defconstant("wnohang", WNOHANG);
411     defconstant("wuntraced", WUNTRACED);
412     printf("\n");
413
414     printf(";;; various ioctl(2) flags\n");
415     defconstant("tiocgpgrp",  TIOCGPGRP);
416     defconstant("tiocspgrp",  TIOCSPGRP);
417     defconstant("tiocgwinsz", TIOCGWINSZ);
418     defconstant("tiocswinsz", TIOCSWINSZ);
419     /* KLUDGE: These are referenced by old CMUCL-derived code, but
420      * Linux doesn't define them.
421      *
422      * I think these are the BSD names, but I don't know what the
423      * corresponding SysV/Linux names are. As a point of reference,
424      * CMUCL doesn't have these defined either (although the defining
425      * forms *do* exist in src/code/unix.lisp), so I don't feel nearly
426      * so bad about not hunting them down. Insight into renamed
427      * obscure ioctl(2) flags appreciated. --njf, 2002-08-26
428      *
429      * I note that the first one I grepped for, TIOCSIGSEND, is
430      * referenced in SBCL conditional on #+HPUX. Maybe the porters of
431      * Oxbridge know more about things like that? And even if they
432      * don't, one benefit of the Rhodes crusade to heal the worthy
433      * ports should be that afterwards, if we grep for something like
434      * this in CVS and it's not there, we can lightheartedly nuke it.
435      * -- WHN 2002-08-30 */
436     /*
437       defconstant("tiocsigsend", TIOCSIGSEND);
438       defconstant("tiocflush", TIOCFLUSH);
439       defconstant("tiocgetp", TIOCGETP);
440       defconstant("tiocsetp", TIOCSETP);
441       defconstant("tiocgetc", TIOCGETC);
442       defconstant("tiocsetc", TIOCSETC);
443       defconstant("tiocgltc", TIOCGLTC);
444       defconstant("tiocsltc", TIOCSLTC);
445     */
446     printf("\n");
447
448     printf(";;; signals\n");
449     defconstant("sig-dfl", (unsigned long)SIG_DFL);
450     defconstant("sig-ign", (unsigned long)SIG_IGN);
451
452     defsignal("sigalrm", SIGALRM);
453     defsignal("sigbus", SIGBUS);
454     defsignal("sigchld", SIGCHLD);
455     defsignal("sigcont", SIGCONT);
456 #ifdef SIGEMT
457     defsignal("sigemt", SIGEMT);
458 #endif
459     defsignal("sigfpe", SIGFPE);
460     defsignal("sighup", SIGHUP);
461     defsignal("sigill", SIGILL);
462     defsignal("sigint", SIGINT);
463     defsignal("sigio", SIGIO);
464     defsignal("sigiot", SIGIOT);
465     defsignal("sigkill", SIGKILL);
466     defsignal("sigpipe", SIGPIPE);
467     defsignal("sigprof", SIGPROF);
468     defsignal("sigquit", SIGQUIT);
469     defsignal("sigsegv", SIGSEGV);
470 #ifdef SIGSTKFLT
471     defsignal("sigstkflt", SIGSTKFLT);
472 #endif
473     defsignal("sigstop", SIGSTOP);
474 #ifdef SIGSYS
475     defsignal("sigsys", SIGSYS);
476 #endif
477     defsignal("sigterm", SIGTERM);
478     defsignal("sigtrap", SIGTRAP);
479     defsignal("sigtstp", SIGTSTP);
480     defsignal("sigttin", SIGTTIN);
481     defsignal("sigttou", SIGTTOU);
482     defsignal("sigurg", SIGURG);
483     defsignal("sigusr1", SIGUSR1);
484     defsignal("sigusr2", SIGUSR2);
485     defsignal("sigvtalrm", SIGVTALRM);
486 #ifdef SIGWAITING
487     defsignal("sigwaiting", SIGWAITING);
488 #endif
489     defsignal("sigwinch", SIGWINCH);
490 #ifdef SIGXCPU
491     defsignal("sigxcpu", SIGXCPU);
492 #endif
493 #ifdef SIGXFSZ
494     defsignal("sigxfsz", SIGXFSZ);
495 #endif
496
497    /* Floating point exception codes. Some of these
498     * are missing on Darwin. */
499 #ifdef FPE_INTOVF
500     defconstant("fpe-intovf", FPE_INTOVF);
501 #else
502     defconstant("fpe-intovf", -1);
503 #endif
504 #ifdef FPE_INTDIV
505     defconstant("fpe-intdiv", FPE_INTDIV);
506 #else
507     defconstant("fpe-intdiv", -1);
508 #endif
509     defconstant("fpe-fltdiv", FPE_FLTDIV);
510     defconstant("fpe-fltovf", FPE_FLTOVF);
511     defconstant("fpe-fltund", FPE_FLTUND);
512     defconstant("fpe-fltres", FPE_FLTRES);
513     defconstant("fpe-fltinv", FPE_FLTINV);
514 #ifdef FPE_FLTSUB
515     defconstant("fpe-fltsub", FPE_FLTSUB);
516 #else
517     defconstant("fpe-fltsub", -1);
518 #endif
519 #endif // !WIN32
520     printf("\n");
521
522     printf(";;; structures\n");
523     DEFSTRUCT(timeval, struct timeval,
524         DEFSLOT(tv-sec, tv_sec);
525         DEFSLOT(tv-usec, tv_usec));
526     DEFSTRUCT(timespec, struct timespec,
527         DEFSLOT(tv-sec, tv_sec);
528         DEFSLOT(tv-nsec, tv_nsec));
529     printf("\n");
530
531 #ifdef LISP_FEATURE_BSD
532     printf(";;; sysctl(3) names\n");
533     printf("(in-package \"SB!IMPL\")\n");
534     defconstant("ctl-kern", CTL_KERN);
535     defconstant("ctl-hw", CTL_HW);
536     defconstant("ctl-maxname", CTL_MAXNAME);
537     defconstant("kern-ostype", KERN_OSTYPE);
538     defconstant("kern-osrelease", KERN_OSRELEASE);
539     defconstant("hw-model", HW_MODEL);
540     defconstant("hw-pagesize", HW_PAGESIZE);
541     printf("\n");
542 #endif
543
544     printf("(in-package \"SB!KERNEL\")\n\n");
545 #ifdef LISP_FEATURE_GENCGC
546     printf(";;; GENCGC related\n");
547     DEFTYPE("page-index-t", page_index_t);
548     DEFTYPE("generation-index-t", generation_index_t);
549     printf("\n");
550 #endif
551
552     printf(";;; Our runtime types\n");
553     DEFTYPE("os-vm-size-t", os_vm_size_t);
554
555     return 0;
556 }