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>
26 #include <sys/times.h>
28 #include <sys/ioctl.h>
29 #include <sys/termios.h>
31 #include "../src/runtime/ppc-darwin-dlshim.h"
32 #include "../src/runtime/ppc-darwin-langinfo.h"
45 #include "genesis/config.h"
47 #define DEFTYPE(lispname,cname) { cname foo; \
48 printf("(define-alien-type " lispname " (%s %d))\n", (((foo=-1)<0) ? "sb!alien:signed" : "unsigned"), (8 * (sizeof foo))); }
51 defconstant(char* lisp_name, long unix_number)
53 printf("(defconstant %s %ld) ; #x%lx\n",
54 lisp_name, unix_number, unix_number);
57 void deferrno(char* lisp_name, long unix_number)
59 defconstant(lisp_name, unix_number);
62 void defsignal(char* lisp_name, long unix_number)
64 defconstant(lisp_name, unix_number);
68 main(int argc, char *argv[])
70 /* don't need no steenking command line arguments */
72 fprintf(stderr, "argh! command line argument(s)\n");
76 /* don't need no steenking hand-editing */
78 ";;;; This is an automatically generated file, please do not hand-edit it.\n\
79 ;;;; See the program \"grovel-headers.c\".\n\
83 printf (";;; This file is presently unused for the Windows version of sbcl.\n");
85 printf("(in-package \"SB!ALIEN\")\n\n");
87 printf (";;;flags for dlopen()\n");
89 defconstant ("rtld-lazy", RTLD_LAZY);
90 defconstant ("rtld-now", RTLD_NOW);
91 defconstant ("rtld-global", RTLD_GLOBAL);
93 printf("(in-package \"SB!UNIX\")\n\n");
95 printf(";;; langinfo\n");
96 defconstant("codeset", CODESET);
98 printf(";;; types, types, types\n");
99 DEFTYPE("clock-t", clock_t);
100 DEFTYPE("dev-t", dev_t);
101 DEFTYPE("gid-t", gid_t);
102 DEFTYPE("ino-t", ino_t);
103 DEFTYPE("mode-t", mode_t);
104 DEFTYPE("nlink-t", nlink_t);
105 DEFTYPE("off-t", off_t);
106 DEFTYPE("size-t", size_t);
107 DEFTYPE("time-t", time_t);
108 DEFTYPE("uid-t", uid_t);
111 printf(";;; fcntl.h (or unistd.h on OpenBSD and NetBSD)\n");
112 defconstant("r_ok", R_OK);
113 defconstant("w_ok", W_OK);
114 defconstant("x_ok", X_OK);
115 defconstant("f_ok", F_OK);
118 printf(";;; fcntlbits.h\n");
119 defconstant("o_rdonly", O_RDONLY);
120 defconstant("o_wronly", O_WRONLY);
121 defconstant("o_rdwr", O_RDWR);
122 defconstant("o_accmode", O_ACCMODE);
123 defconstant("o_creat", O_CREAT);
124 defconstant("o_excl", O_EXCL);
125 defconstant("o_noctty", O_NOCTTY);
126 defconstant("o_trunc", O_TRUNC);
127 defconstant("o_append", O_APPEND);
129 defconstant("s-ifmt", S_IFMT);
130 defconstant("s-ififo", S_IFIFO);
131 defconstant("s-ifchr", S_IFCHR);
132 defconstant("s-ifdir", S_IFDIR);
133 defconstant("s-ifblk", S_IFBLK);
134 defconstant("s-ifreg", S_IFREG);
137 defconstant("s-iflnk", S_IFLNK);
138 defconstant("s-ifsock", S_IFSOCK);
141 printf(";;; error numbers\n");
142 deferrno("enoent", ENOENT);
143 deferrno("eintr", EINTR);
144 deferrno("eio", EIO);
145 deferrno("eexist", EEXIST);
146 deferrno("espipe", ESPIPE);
147 deferrno("ewouldblock", EWOULDBLOCK);
150 printf(";;; for wait3(2) in run-program.lisp\n");
151 defconstant("wnohang", WNOHANG);
152 defconstant("wuntraced", WUNTRACED);
155 printf(";;; various ioctl(2) flags\n");
156 defconstant("tiocnotty", TIOCNOTTY);
157 defconstant("tiocgwinsz", TIOCGWINSZ);
158 defconstant("tiocswinsz", TIOCSWINSZ);
159 defconstant("tiocgpgrp", TIOCGPGRP);
160 defconstant("tiocspgrp", TIOCSPGRP);
161 /* KLUDGE: These are referenced by old CMUCL-derived code, but
162 * Linux doesn't define them.
164 * I think these are the BSD names, but I don't know what the
165 * corresponding SysV/Linux names are. As a point of reference,
166 * CMUCL doesn't have these defined either (although the defining
167 * forms *do* exist in src/code/unix.lisp), so I don't feel nearly
168 * so bad about not hunting them down. Insight into renamed
169 * obscure ioctl(2) flags appreciated. --njf, 2002-08-26
171 * I note that the first one I grepped for, TIOCSIGSEND, is
172 * referenced in SBCL conditional on #+HPUX. Maybe the porters of
173 * Oxbridge know more about things like that? And even if they
174 * don't, one benefit of the Rhodes crusade to heal the worthy
175 * ports should be that afterwards, if we grep for something like
176 * this in CVS and it's not there, we can lightheartedly nuke it.
177 * -- WHN 2002-08-30 */
179 defconstant("tiocsigsend", TIOCSIGSEND);
180 defconstant("tiocflush", TIOCFLUSH);
181 defconstant("tiocgetp", TIOCGETP);
182 defconstant("tiocsetp", TIOCSETP);
183 defconstant("tiocgetc", TIOCGETC);
184 defconstant("tiocsetc", TIOCSETC);
185 defconstant("tiocgltc", TIOCGLTC);
186 defconstant("tiocsltc", TIOCSLTC);
190 printf(";;; signals\n");
191 defsignal("sigalrm", SIGALRM);
192 defsignal("sigbus", SIGBUS);
193 defsignal("sigchld", SIGCHLD);
194 defsignal("sigcont", SIGCONT);
196 defsignal("sigemt", SIGEMT);
198 defsignal("sigfpe", SIGFPE);
199 defsignal("sighup", SIGHUP);
200 defsignal("sigill", SIGILL);
201 defsignal("sigint", SIGINT);
202 defsignal("sigio", SIGIO);
203 defsignal("sigiot", SIGIOT);
204 defsignal("sigkill", SIGKILL);
205 defsignal("sigpipe", SIGPIPE);
206 defsignal("sigprof", SIGPROF);
207 defsignal("sigquit", SIGQUIT);
208 defsignal("sigsegv", SIGSEGV);
209 #if ((defined LISP_FEATURE_LINUX) && (defined LISP_FEATURE_X86))
210 defsignal("sigstkflt", SIGSTKFLT);
212 defsignal("sigstop", SIGSTOP);
213 #if (!((defined LISP_FEATURE_LINUX) && (defined LISP_FEATURE_X86)))
214 defsignal("sigsys", SIGSYS);
216 defsignal("sigterm", SIGTERM);
217 defsignal("sigtrap", SIGTRAP);
218 defsignal("sigtstp", SIGTSTP);
219 defsignal("sigttin", SIGTTIN);
220 defsignal("sigttou", SIGTTOU);
221 defsignal("sigurg", SIGURG);
222 defsignal("sigusr1", SIGUSR1);
223 defsignal("sigusr2", SIGUSR2);
224 defsignal("sigvtalrm", SIGVTALRM);
225 #ifdef LISP_FEATURE_SUNOS
226 defsignal("sigwaiting", SIGWAITING);
228 defsignal("sigwinch", SIGWINCH);
229 #ifndef LISP_FEATURE_HPUX
230 defsignal("sigxcpu", SIGXCPU);
231 defsignal("sigxfsz", SIGXFSZ);