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
9 * This software is part of the SBCL system. See the README file for
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
22 #include <sys/types.h>
23 #include <sys/times.h>
26 #include <sys/ioctl.h>
27 #include <sys/termios.h>
32 #include "genesis/config.h"
34 #define DEFTYPE(lispname,cname) { cname foo; \
35 printf("(define-alien-type " lispname " (%s %d))\n", (((foo=-1)<0) ? "sb!alien:signed" : "unsigned"), (8 * (sizeof foo))); }
38 defconstant(char* lisp_name, long unix_number)
40 printf("(defconstant %s %ld) ; #x%lx\n",
41 lisp_name, unix_number, unix_number);
44 #define DEFSIGNAL(name) defconstant(#name, name)
47 main(int argc, char *argv[])
49 /* don't need no steenking command line arguments */
51 fprintf(stderr, "argh! command line argument(s)\n");
55 /* don't need no steenking hand-editing */
57 ";;;; This is an automatically generated file, please do not hand-edit it.\n\
58 ;;;; See the program \"grovel_headers.c\".\n\
62 printf("(in-package \"SB!UNIX\")\n\n");
64 printf(";;; types, types, types\n");
65 DEFTYPE("clock-t", clock_t);
66 DEFTYPE("dev-t", dev_t);
67 DEFTYPE("gid-t", gid_t);
68 DEFTYPE("ino-t", ino_t);
69 DEFTYPE("mode-t", mode_t);
70 DEFTYPE("nlink-t", nlink_t);
71 DEFTYPE("off-t", off_t);
72 DEFTYPE("size-t", size_t);
73 DEFTYPE("time-t", time_t);
74 DEFTYPE("uid-t", uid_t);
77 printf(";;; fcntl.h (or unistd.h on OpenBSD)\n");
78 defconstant("r_ok", R_OK);
79 defconstant("w_ok", W_OK);
80 defconstant("x_ok", X_OK);
81 defconstant("f_ok", F_OK);
84 printf(";;; fcntlbits.h\n");
85 defconstant("o_rdonly", O_RDONLY);
86 defconstant("o_wronly", O_WRONLY);
87 defconstant("o_rdwr", O_RDWR);
88 defconstant("o_accmode", O_ACCMODE);
89 defconstant("o_creat", O_CREAT);
90 defconstant("o_excl", O_EXCL);
91 defconstant("o_noctty", O_NOCTTY);
92 defconstant("o_trunc", O_TRUNC);
93 defconstant("o_append", O_APPEND);
95 defconstant("s-ifmt", S_IFMT);
96 defconstant("s-ififo", S_IFIFO);
97 defconstant("s-ifchr", S_IFCHR);
98 defconstant("s-ifdir", S_IFDIR);
99 defconstant("s-ifblk", S_IFBLK);
100 defconstant("s-ifreg", S_IFREG);
103 defconstant("s-iflnk", S_IFLNK);
104 defconstant("s-ifsock", S_IFSOCK);
107 printf(";;; for wait3(2) in run-program.lisp\n");
108 defconstant("wnohang", WNOHANG);
109 defconstant("wuntraced", WUNTRACED);
112 printf(";;; various ioctl(2) flags\n");
113 defconstant("tiocnotty", TIOCNOTTY);
114 defconstant("tiocgwinsz", TIOCGWINSZ);
115 defconstant("tiocswinsz", TIOCSWINSZ);
116 defconstant("tiocgpgrp", TIOCGPGRP);
117 defconstant("tiocspgrp", TIOCSPGRP);
118 /* KLUDGE: These are referenced by old CMUCL-derived code, but
119 * Linux doesn't define them.
121 * I think these are the BSD names, but I don't know what the
122 * corresponding SysV/Linux names are. As a point of reference,
123 * CMUCL doesn't have these defined either (although the defining
124 * forms *do* exist in src/code/unix.lisp), so I don't feel nearly
125 * so bad about not hunting them down. Insight into renamed
126 * obscure ioctl(2) flags appreciated. --njf, 2002-08-26
128 * I note that the first one I grepped for, TIOCSIGSEND, is
129 * referenced in SBCL conditional on #+HPUX. Maybe the porters of
130 * Oxbridge know more about things like that? And even if they
131 * don't, one benefit of the Rhodes crusade to heal the worthy
132 * ports should be that afterwards, if we grep for something like
133 * this in CVS and it's not there, we can lightheartedly nuke it.
134 * -- WHN 2002-08-30 */
136 defconstant("tiocsigsend", TIOCSIGSEND);
137 defconstant("tiocflush", TIOCFLUSH);
138 defconstant("tiocgetp", TIOCGETP);
139 defconstant("tiocsetp", TIOCSETP);
140 defconstant("tiocgetc", TIOCGETC);
141 defconstant("tiocsetc", TIOCSETC);
142 defconstant("tiocgltc", TIOCGLTC);
143 defconstant("tiocsltc", TIOCSLTC);
147 printf(";;; signals\n");
152 #ifndef LISP_FEATURE_LINUX
166 #ifdef LISP_FEATURE_LINUX
167 DEFSIGNAL(SIGSTKFLT);
170 #ifndef LISP_FEATURE_LINUX
181 DEFSIGNAL(SIGVTALRM);
182 #ifdef LISP_FEATURE_SVR4
183 DEFSIGNAL(SIGWAITING);
186 #ifndef LISP_FEATURE_HPUX