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