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