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