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