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
21 #include "genesis/config.h"
25 #include <sys/types.h>
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
38 #include <sys/select.h>
39 #include <sys/times.h>
41 #include <sys/ioctl.h>
42 #ifdef LISP_FEATURE_ANDROID
45 #include <sys/termios.h>
59 #ifdef LISP_FEATURE_HPUX
60 #include <sys/bsdtty.h> /* for TIOCGPGRP */
63 #ifdef LISP_FEATURE_BSD
64 #include <sys/param.h>
65 #include <sys/sysctl.h>
68 #if defined(LISP_FEATURE_WIN32) && defined(LISP_FEATURE_SB_THREAD)
69 #include "pthreads_win32.h"
75 #define DEFTYPE(lispname,cname) { cname foo; \
76 printf("(define-alien-type " lispname " (%s %lu))\n", \
77 (((foo=-1)<0) ? "signed" : "unsigned"), (8LU * (sizeof foo))); }
79 #define DEFSTRUCT(lispname,cname,body) { cname bar; \
80 printf("(define-alien-type nil\n (struct %s", #lispname); \
83 #define DEFSLOT(lispname,cname) \
84 printf("\n (%s (%s %lu))", \
86 (((bar.cname=-1)<0) ? "signed" : "unsigned"), \
87 (8LU * (sizeof bar.cname)))
90 defconstant(char* lisp_name
, unsigned long unix_number
)
92 printf("(defconstant %s %lu) ; #x%lx\n",
93 lisp_name
, unix_number
, unix_number
);
96 void deferrno(char* lisp_name
, unsigned long unix_number
)
98 defconstant(lisp_name
, unix_number
);
101 void defsignal(char* lisp_name
, unsigned long unix_number
)
103 defconstant(lisp_name
, unix_number
);
107 main(int argc
, char *argv
[])
109 /* don't need no steenking command line arguments */
111 fprintf(stderr
, "argh! command line argument(s)\n");
115 /* don't need no steenking hand-editing */
117 ";;;; This is an automatically generated file, please do not hand-edit it.\n\
118 ;;;; See the program \"grovel-headers.c\".\n\
122 #include "grovel-headers-win32.h"
124 printf("(in-package \"SB!ALIEN\")\n\n");
126 printf (";;;flags for dlopen()\n");
128 defconstant ("rtld-lazy", RTLD_LAZY
);
129 defconstant ("rtld-now", RTLD_NOW
);
130 defconstant ("rtld-global", RTLD_GLOBAL
);
132 printf("(in-package \"SB!UNIX\")\n\n");
134 printf(";;; select()\n");
135 defconstant("fd-setsize", FD_SETSIZE
);
137 printf(";;; poll()\n");
138 defconstant("pollin", POLLIN
);
139 defconstant("pollout", POLLOUT
);
140 defconstant("pollpri", POLLPRI
);
141 defconstant("pollhup", POLLHUP
);
142 defconstant("pollnval", POLLNVAL
);
143 defconstant("pollerr", POLLERR
);
144 DEFTYPE("nfds-t", nfds_t
);
145 #ifndef LISP_FEATURE_ANDROID
146 printf(";;; langinfo\n");
147 defconstant("codeset", CODESET
);
149 printf(";;; types, types, types\n");
150 DEFTYPE("clock-t", clock_t);
151 DEFTYPE("dev-t", dev_t
);
152 DEFTYPE("gid-t", gid_t
);
153 DEFTYPE("ino-t", ino_t
);
154 DEFTYPE("mode-t", mode_t
);
155 DEFTYPE("nlink-t", nlink_t
);
156 DEFTYPE("off-t", off_t
);
157 DEFTYPE("size-t", size_t);
158 DEFTYPE("ssize-t", ssize_t
);
159 DEFTYPE("time-t", time_t);
160 #if !defined(LISP_FEATURE_OS_PROVIDES_SUSECONDS_T)
161 /* Similar kludge in sb-posix. */
162 DEFTYPE("suseconds-t", long);
164 DEFTYPE("suseconds-t", suseconds_t
);
166 DEFTYPE("uid-t", uid_t
);
167 printf(";; Types in src/runtime/wrap.h. See that file for explantion.\n");
168 printf(";; Don't use these types for anything other than the stat wrapper.\n");
169 DEFTYPE("wst-ino-t", wst_ino_t
);
170 DEFTYPE("wst-dev-t", wst_dev_t
);
171 DEFTYPE("wst-off-t", wst_off_t
);
172 DEFTYPE("wst-blksize-t", wst_blksize_t
);
173 DEFTYPE("wst-blkcnt-t", wst_blkcnt_t
);
174 DEFTYPE("wst-nlink-t", wst_nlink_t
);
175 DEFTYPE("wst-uid-t", wst_uid_t
);
176 DEFTYPE("wst-gid-t", wst_gid_t
);
179 printf(";;; fcntl.h (or unistd.h on OpenBSD and NetBSD)\n");
180 defconstant("r_ok", R_OK
);
181 defconstant("w_ok", W_OK
);
182 defconstant("x_ok", X_OK
);
183 defconstant("f_ok", F_OK
);
186 printf(";;; fcntlbits.h\n");
187 defconstant("o_rdonly", O_RDONLY
);
188 defconstant("o_wronly", O_WRONLY
);
189 defconstant("o_rdwr", O_RDWR
);
190 defconstant("o_accmode", O_ACCMODE
);
191 defconstant("o_creat", O_CREAT
);
192 defconstant("o_excl", O_EXCL
);
193 defconstant("o_noctty", O_NOCTTY
);
194 defconstant("o_trunc", O_TRUNC
);
195 defconstant("o_append", O_APPEND
);
196 #ifdef LISP_FEATURE_LARGEFILE
197 defconstant("o_largefile", O_LARGEFILE
);
201 defconstant("s-ifmt", S_IFMT
);
202 defconstant("s-ififo", S_IFIFO
);
203 defconstant("s-ifchr", S_IFCHR
);
204 defconstant("s-ifdir", S_IFDIR
);
205 defconstant("s-ifblk", S_IFBLK
);
206 defconstant("s-ifreg", S_IFREG
);
209 defconstant("s-iflnk", S_IFLNK
);
210 defconstant("s-ifsock", S_IFSOCK
);
213 printf(";;; error numbers\n");
214 deferrno("ebadf", EBADF
);
215 deferrno("enoent", ENOENT
);
216 deferrno("eintr", EINTR
);
217 deferrno("eagain", EAGAIN
);
218 deferrno("eio", EIO
);
219 deferrno("eexist", EEXIST
);
220 deferrno("eloop", ELOOP
);
221 deferrno("espipe", ESPIPE
);
222 deferrno("ewouldblock", EWOULDBLOCK
);
225 printf(";;; for wait3(2) in run-program.lisp\n");
227 defconstant("wcontinued", WCONTINUED
);
229 defconstant("wcontinued", 0);
232 defconstant("wnohang", WNOHANG
);
233 defconstant("wuntraced", WUNTRACED
);
236 printf(";;; various ioctl(2) flags\n");
237 defconstant("tiocgpgrp", TIOCGPGRP
);
238 defconstant("tiocspgrp", TIOCSPGRP
);
239 defconstant("tiocgwinsz", TIOCGWINSZ
);
240 defconstant("tiocswinsz", TIOCSWINSZ
);
241 /* KLUDGE: These are referenced by old CMUCL-derived code, but
242 * Linux doesn't define them.
244 * I think these are the BSD names, but I don't know what the
245 * corresponding SysV/Linux names are. As a point of reference,
246 * CMUCL doesn't have these defined either (although the defining
247 * forms *do* exist in src/code/unix.lisp), so I don't feel nearly
248 * so bad about not hunting them down. Insight into renamed
249 * obscure ioctl(2) flags appreciated. --njf, 2002-08-26
251 * I note that the first one I grepped for, TIOCSIGSEND, is
252 * referenced in SBCL conditional on #+HPUX. Maybe the porters of
253 * Oxbridge know more about things like that? And even if they
254 * don't, one benefit of the Rhodes crusade to heal the worthy
255 * ports should be that afterwards, if we grep for something like
256 * this in CVS and it's not there, we can lightheartedly nuke it.
257 * -- WHN 2002-08-30 */
259 defconstant("tiocsigsend", TIOCSIGSEND);
260 defconstant("tiocflush", TIOCFLUSH);
261 defconstant("tiocgetp", TIOCGETP);
262 defconstant("tiocsetp", TIOCSETP);
263 defconstant("tiocgetc", TIOCGETC);
264 defconstant("tiocsetc", TIOCSETC);
265 defconstant("tiocgltc", TIOCGLTC);
266 defconstant("tiocsltc", TIOCSLTC);
270 printf(";;; signals\n");
271 defconstant("sig-dfl", (unsigned long)SIG_DFL
);
272 defconstant("sig-ign", (unsigned long)SIG_IGN
);
274 defsignal("sigalrm", SIGALRM
);
275 defsignal("sigbus", SIGBUS
);
276 defsignal("sigchld", SIGCHLD
);
277 defsignal("sigcont", SIGCONT
);
279 defsignal("sigemt", SIGEMT
);
281 defsignal("sigfpe", SIGFPE
);
282 defsignal("sighup", SIGHUP
);
283 defsignal("sigill", SIGILL
);
284 defsignal("sigint", SIGINT
);
285 defsignal("sigio", SIGIO
);
286 defsignal("sigiot", SIGIOT
);
287 defsignal("sigkill", SIGKILL
);
288 defsignal("sigpipe", SIGPIPE
);
289 defsignal("sigprof", SIGPROF
);
290 defsignal("sigquit", SIGQUIT
);
291 defsignal("sigsegv", SIGSEGV
);
293 defsignal("sigstkflt", SIGSTKFLT
);
295 defsignal("sigstop", SIGSTOP
);
297 defsignal("sigsys", SIGSYS
);
299 defsignal("sigterm", SIGTERM
);
300 defsignal("sigtrap", SIGTRAP
);
301 defsignal("sigtstp", SIGTSTP
);
302 defsignal("sigttin", SIGTTIN
);
303 defsignal("sigttou", SIGTTOU
);
304 defsignal("sigurg", SIGURG
);
305 defsignal("sigusr1", SIGUSR1
);
306 defsignal("sigusr2", SIGUSR2
);
307 defsignal("sigvtalrm", SIGVTALRM
);
309 defsignal("sigwaiting", SIGWAITING
);
311 defsignal("sigwinch", SIGWINCH
);
313 defsignal("sigxcpu", SIGXCPU
);
316 defsignal("sigxfsz", SIGXFSZ
);
319 /* Floating point exception codes. Some of these
320 * are missing on Darwin. */
322 defconstant("fpe-intovf", FPE_INTOVF
);
324 defconstant("fpe-intovf", -1);
327 defconstant("fpe-intdiv", FPE_INTDIV
);
329 defconstant("fpe-intdiv", -1);
331 defconstant("fpe-fltdiv", FPE_FLTDIV
);
332 defconstant("fpe-fltovf", FPE_FLTOVF
);
333 defconstant("fpe-fltund", FPE_FLTUND
);
334 defconstant("fpe-fltres", FPE_FLTRES
);
335 defconstant("fpe-fltinv", FPE_FLTINV
);
337 defconstant("fpe-fltsub", FPE_FLTSUB
);
339 defconstant("fpe-fltsub", -1);
344 printf(";;; structures\n");
345 DEFSTRUCT(timeval
, struct timeval
,
346 DEFSLOT(tv
-sec
, tv_sec
);
347 DEFSLOT(tv
-usec
, tv_usec
));
348 DEFSTRUCT(timespec
, struct timespec
,
349 DEFSLOT(tv
-sec
, tv_sec
);
350 DEFSLOT(tv
-nsec
, tv_nsec
));
353 #ifdef LISP_FEATURE_ANDROID
354 defconstant("path-max", PATH_MAX
);
358 #ifdef LISP_FEATURE_BSD
359 printf(";;; sysctl(3) names\n");
360 printf("(in-package \"SB!IMPL\")\n");
361 defconstant("ctl-kern", CTL_KERN
);
362 defconstant("ctl-hw", CTL_HW
);
363 defconstant("ctl-maxname", CTL_MAXNAME
);
364 defconstant("kern-ostype", KERN_OSTYPE
);
365 defconstant("kern-osrelease", KERN_OSRELEASE
);
366 defconstant("hw-model", HW_MODEL
);
367 defconstant("hw-pagesize", HW_PAGESIZE
);
369 defconstant("path-max", PATH_MAX
);
373 printf("(in-package \"SB!KERNEL\")\n\n");
374 #ifdef LISP_FEATURE_GENCGC
375 printf(";;; GENCGC related\n");
376 DEFTYPE("page-index-t", page_index_t
);
377 DEFTYPE("generation-index-t", generation_index_t
);
381 printf(";;; Our runtime types\n");
382 DEFTYPE("os-vm-size-t", os_vm_size_t
);