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 %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); \
82 #define DEFSLOT(lispname,cname) \
83 printf("\n (%s (%s %d))", \
85 (((bar.cname=-1)<0) ? "signed" : "unsigned"), \
86 (8 * (sizeof bar.cname)))
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 */
110 fprintf(stderr
, "argh! command line argument(s)\n");
114 /* don't need no steenking hand-editing */
116 ";;;; This is an automatically generated file, please do not hand-edit it.\n\
117 ;;;; See the program \"grovel-headers.c\".\n\
121 #include "grovel-headers-win32.h"
123 printf("(in-package \"SB!ALIEN\")\n\n");
125 printf (";;;flags for dlopen()\n");
127 defconstant ("rtld-lazy", RTLD_LAZY
);
128 defconstant ("rtld-now", RTLD_NOW
);
129 defconstant ("rtld-global", RTLD_GLOBAL
);
131 printf("(in-package \"SB!UNIX\")\n\n");
133 printf(";;; select()\n");
134 defconstant("fd-setsize", FD_SETSIZE
);
136 printf(";;; poll()\n");
137 defconstant("pollin", POLLIN
);
138 defconstant("pollout", POLLOUT
);
139 defconstant("pollpri", POLLPRI
);
140 defconstant("pollhup", POLLHUP
);
141 defconstant("pollnval", POLLNVAL
);
142 defconstant("pollerr", POLLERR
);
143 DEFTYPE("nfds-t", nfds_t
);
144 #ifndef LISP_FEATURE_ANDROID
145 printf(";;; langinfo\n");
146 defconstant("codeset", CODESET
);
148 printf(";;; types, types, types\n");
149 DEFTYPE("clock-t", clock_t);
150 DEFTYPE("dev-t", dev_t
);
151 DEFTYPE("gid-t", gid_t
);
152 DEFTYPE("ino-t", ino_t
);
153 DEFTYPE("mode-t", mode_t
);
154 DEFTYPE("nlink-t", nlink_t
);
155 DEFTYPE("off-t", off_t
);
156 DEFTYPE("size-t", size_t);
157 DEFTYPE("ssize-t", ssize_t
);
158 DEFTYPE("time-t", time_t);
159 #if !defined(LISP_FEATURE_OS_PROVIDES_SUSECONDS_T)
160 /* Similar kludge in sb-posix. */
161 DEFTYPE("suseconds-t", long);
163 DEFTYPE("suseconds-t", suseconds_t
);
165 DEFTYPE("uid-t", uid_t
);
166 printf(";; Types in src/runtime/wrap.h. See that file for explantion.\n");
167 printf(";; Don't use these types for anything other than the stat wrapper.\n");
168 DEFTYPE("wst-ino-t", wst_ino_t
);
169 DEFTYPE("wst-dev-t", wst_dev_t
);
170 DEFTYPE("wst-off-t", wst_off_t
);
171 DEFTYPE("wst-blksize-t", wst_blksize_t
);
172 DEFTYPE("wst-blkcnt-t", wst_blkcnt_t
);
173 DEFTYPE("wst-nlink-t", wst_nlink_t
);
174 DEFTYPE("wst-uid-t", wst_uid_t
);
175 DEFTYPE("wst-gid-t", wst_gid_t
);
178 printf(";;; fcntl.h (or unistd.h on OpenBSD and NetBSD)\n");
179 defconstant("r_ok", R_OK
);
180 defconstant("w_ok", W_OK
);
181 defconstant("x_ok", X_OK
);
182 defconstant("f_ok", F_OK
);
185 printf(";;; fcntlbits.h\n");
186 defconstant("o_rdonly", O_RDONLY
);
187 defconstant("o_wronly", O_WRONLY
);
188 defconstant("o_rdwr", O_RDWR
);
189 defconstant("o_accmode", O_ACCMODE
);
190 defconstant("o_creat", O_CREAT
);
191 defconstant("o_excl", O_EXCL
);
192 defconstant("o_noctty", O_NOCTTY
);
193 defconstant("o_trunc", O_TRUNC
);
194 defconstant("o_append", O_APPEND
);
195 #ifdef LISP_FEATURE_LARGEFILE
196 defconstant("o_largefile", O_LARGEFILE
);
200 defconstant("s-ifmt", S_IFMT
);
201 defconstant("s-ififo", S_IFIFO
);
202 defconstant("s-ifchr", S_IFCHR
);
203 defconstant("s-ifdir", S_IFDIR
);
204 defconstant("s-ifblk", S_IFBLK
);
205 defconstant("s-ifreg", S_IFREG
);
208 defconstant("s-iflnk", S_IFLNK
);
209 defconstant("s-ifsock", S_IFSOCK
);
212 printf(";;; error numbers\n");
213 deferrno("ebadf", EBADF
);
214 deferrno("enoent", ENOENT
);
215 deferrno("eintr", EINTR
);
216 deferrno("eagain", EAGAIN
);
217 deferrno("eio", EIO
);
218 deferrno("eexist", EEXIST
);
219 deferrno("eloop", ELOOP
);
220 deferrno("espipe", ESPIPE
);
221 deferrno("ewouldblock", EWOULDBLOCK
);
224 printf(";;; for wait3(2) in run-program.lisp\n");
226 defconstant("wcontinued", WCONTINUED
);
228 defconstant("wcontinued", 0);
231 defconstant("wnohang", WNOHANG
);
232 defconstant("wuntraced", WUNTRACED
);
235 printf(";;; various ioctl(2) flags\n");
236 defconstant("tiocgpgrp", TIOCGPGRP
);
237 defconstant("tiocspgrp", TIOCSPGRP
);
238 defconstant("tiocgwinsz", TIOCGWINSZ
);
239 defconstant("tiocswinsz", TIOCSWINSZ
);
240 /* KLUDGE: These are referenced by old CMUCL-derived code, but
241 * Linux doesn't define them.
243 * I think these are the BSD names, but I don't know what the
244 * corresponding SysV/Linux names are. As a point of reference,
245 * CMUCL doesn't have these defined either (although the defining
246 * forms *do* exist in src/code/unix.lisp), so I don't feel nearly
247 * so bad about not hunting them down. Insight into renamed
248 * obscure ioctl(2) flags appreciated. --njf, 2002-08-26
250 * I note that the first one I grepped for, TIOCSIGSEND, is
251 * referenced in SBCL conditional on #+HPUX. Maybe the porters of
252 * Oxbridge know more about things like that? And even if they
253 * don't, one benefit of the Rhodes crusade to heal the worthy
254 * ports should be that afterwards, if we grep for something like
255 * this in CVS and it's not there, we can lightheartedly nuke it.
256 * -- WHN 2002-08-30 */
258 defconstant("tiocsigsend", TIOCSIGSEND);
259 defconstant("tiocflush", TIOCFLUSH);
260 defconstant("tiocgetp", TIOCGETP);
261 defconstant("tiocsetp", TIOCSETP);
262 defconstant("tiocgetc", TIOCGETC);
263 defconstant("tiocsetc", TIOCSETC);
264 defconstant("tiocgltc", TIOCGLTC);
265 defconstant("tiocsltc", TIOCSLTC);
269 printf(";;; signals\n");
270 defconstant("sig-dfl", (unsigned long)SIG_DFL
);
271 defconstant("sig-ign", (unsigned long)SIG_IGN
);
273 defsignal("sigalrm", SIGALRM
);
274 defsignal("sigbus", SIGBUS
);
275 defsignal("sigchld", SIGCHLD
);
276 defsignal("sigcont", SIGCONT
);
278 defsignal("sigemt", SIGEMT
);
280 defsignal("sigfpe", SIGFPE
);
281 defsignal("sighup", SIGHUP
);
282 defsignal("sigill", SIGILL
);
283 defsignal("sigint", SIGINT
);
284 defsignal("sigio", SIGIO
);
285 defsignal("sigiot", SIGIOT
);
286 defsignal("sigkill", SIGKILL
);
287 defsignal("sigpipe", SIGPIPE
);
288 defsignal("sigprof", SIGPROF
);
289 defsignal("sigquit", SIGQUIT
);
290 defsignal("sigsegv", SIGSEGV
);
292 defsignal("sigstkflt", SIGSTKFLT
);
294 defsignal("sigstop", SIGSTOP
);
296 defsignal("sigsys", SIGSYS
);
298 defsignal("sigterm", SIGTERM
);
299 defsignal("sigtrap", SIGTRAP
);
300 defsignal("sigtstp", SIGTSTP
);
301 defsignal("sigttin", SIGTTIN
);
302 defsignal("sigttou", SIGTTOU
);
303 defsignal("sigurg", SIGURG
);
304 defsignal("sigusr1", SIGUSR1
);
305 defsignal("sigusr2", SIGUSR2
);
306 defsignal("sigvtalrm", SIGVTALRM
);
308 defsignal("sigwaiting", SIGWAITING
);
310 defsignal("sigwinch", SIGWINCH
);
312 defsignal("sigxcpu", SIGXCPU
);
315 defsignal("sigxfsz", SIGXFSZ
);
318 /* Floating point exception codes. Some of these
319 * are missing on Darwin. */
321 defconstant("fpe-intovf", FPE_INTOVF
);
323 defconstant("fpe-intovf", -1);
326 defconstant("fpe-intdiv", FPE_INTDIV
);
328 defconstant("fpe-intdiv", -1);
330 defconstant("fpe-fltdiv", FPE_FLTDIV
);
331 defconstant("fpe-fltovf", FPE_FLTOVF
);
332 defconstant("fpe-fltund", FPE_FLTUND
);
333 defconstant("fpe-fltres", FPE_FLTRES
);
334 defconstant("fpe-fltinv", FPE_FLTINV
);
336 defconstant("fpe-fltsub", FPE_FLTSUB
);
338 defconstant("fpe-fltsub", -1);
343 printf(";;; structures\n");
344 DEFSTRUCT(timeval
, struct timeval
,
345 DEFSLOT(tv
-sec
, tv_sec
);
346 DEFSLOT(tv
-usec
, tv_usec
));
347 DEFSTRUCT(timespec
, struct timespec
,
348 DEFSLOT(tv
-sec
, tv_sec
);
349 DEFSLOT(tv
-nsec
, tv_nsec
));
352 #ifdef LISP_FEATURE_ANDROID
353 defconstant("path-max", PATH_MAX
);
357 #ifdef LISP_FEATURE_BSD
358 printf(";;; sysctl(3) names\n");
359 printf("(in-package \"SB!IMPL\")\n");
360 defconstant("ctl-kern", CTL_KERN
);
361 defconstant("ctl-hw", CTL_HW
);
362 defconstant("ctl-maxname", CTL_MAXNAME
);
363 defconstant("kern-ostype", KERN_OSTYPE
);
364 defconstant("kern-osrelease", KERN_OSRELEASE
);
365 defconstant("hw-model", HW_MODEL
);
366 defconstant("hw-pagesize", HW_PAGESIZE
);
368 defconstant("path-max", PATH_MAX
);
372 printf("(in-package \"SB!KERNEL\")\n\n");
373 #ifdef LISP_FEATURE_GENCGC
374 printf(";;; GENCGC related\n");
375 DEFTYPE("page-index-t", page_index_t
);
376 DEFTYPE("generation-index-t", generation_index_t
);
380 printf(";;; Our runtime types\n");
381 DEFTYPE("os-vm-size-t", os_vm_size_t
);