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>
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("time-t", time_t);
158 #if !defined(LISP_FEATURE_OS_PROVIDES_SUSECONDS_T)
159 /* Similar kludge in sb-posix. */
160 DEFTYPE("suseconds-t", long);
162 DEFTYPE("suseconds-t", suseconds_t
);
164 DEFTYPE("uid-t", uid_t
);
165 printf(";; Types in src/runtime/wrap.h. See that file for explantion.\n");
166 printf(";; Don't use these types for anything other than the stat wrapper.\n");
167 DEFTYPE("wst-ino-t", wst_ino_t
);
168 DEFTYPE("wst-dev-t", wst_dev_t
);
169 DEFTYPE("wst-off-t", wst_off_t
);
170 DEFTYPE("wst-blksize-t", wst_blksize_t
);
171 DEFTYPE("wst-blkcnt-t", wst_blkcnt_t
);
172 DEFTYPE("wst-nlink-t", wst_nlink_t
);
173 DEFTYPE("wst-uid-t", wst_uid_t
);
174 DEFTYPE("wst-gid-t", wst_gid_t
);
177 printf(";;; fcntl.h (or unistd.h on OpenBSD and NetBSD)\n");
178 defconstant("r_ok", R_OK
);
179 defconstant("w_ok", W_OK
);
180 defconstant("x_ok", X_OK
);
181 defconstant("f_ok", F_OK
);
184 printf(";;; fcntlbits.h\n");
185 defconstant("o_rdonly", O_RDONLY
);
186 defconstant("o_wronly", O_WRONLY
);
187 defconstant("o_rdwr", O_RDWR
);
188 defconstant("o_accmode", O_ACCMODE
);
189 defconstant("o_creat", O_CREAT
);
190 defconstant("o_excl", O_EXCL
);
191 defconstant("o_noctty", O_NOCTTY
);
192 defconstant("o_trunc", O_TRUNC
);
193 defconstant("o_append", O_APPEND
);
194 #ifdef LISP_FEATURE_LARGEFILE
195 defconstant("o_largefile", O_LARGEFILE
);
199 defconstant("s-ifmt", S_IFMT
);
200 defconstant("s-ififo", S_IFIFO
);
201 defconstant("s-ifchr", S_IFCHR
);
202 defconstant("s-ifdir", S_IFDIR
);
203 defconstant("s-ifblk", S_IFBLK
);
204 defconstant("s-ifreg", S_IFREG
);
207 defconstant("s-iflnk", S_IFLNK
);
208 defconstant("s-ifsock", S_IFSOCK
);
211 printf(";;; error numbers\n");
212 deferrno("ebadf", EBADF
);
213 deferrno("enoent", ENOENT
);
214 deferrno("eintr", EINTR
);
215 deferrno("eagain", EAGAIN
);
216 deferrno("eio", EIO
);
217 deferrno("eexist", EEXIST
);
218 deferrno("eloop", ELOOP
);
219 deferrno("espipe", ESPIPE
);
220 deferrno("ewouldblock", EWOULDBLOCK
);
223 printf(";;; for wait3(2) in run-program.lisp\n");
224 defconstant("wnohang", WNOHANG
);
225 defconstant("wuntraced", WUNTRACED
);
228 printf(";;; various ioctl(2) flags\n");
229 defconstant("tiocgpgrp", TIOCGPGRP
);
230 defconstant("tiocspgrp", TIOCSPGRP
);
231 defconstant("tiocgwinsz", TIOCGWINSZ
);
232 defconstant("tiocswinsz", TIOCSWINSZ
);
233 /* KLUDGE: These are referenced by old CMUCL-derived code, but
234 * Linux doesn't define them.
236 * I think these are the BSD names, but I don't know what the
237 * corresponding SysV/Linux names are. As a point of reference,
238 * CMUCL doesn't have these defined either (although the defining
239 * forms *do* exist in src/code/unix.lisp), so I don't feel nearly
240 * so bad about not hunting them down. Insight into renamed
241 * obscure ioctl(2) flags appreciated. --njf, 2002-08-26
243 * I note that the first one I grepped for, TIOCSIGSEND, is
244 * referenced in SBCL conditional on #+HPUX. Maybe the porters of
245 * Oxbridge know more about things like that? And even if they
246 * don't, one benefit of the Rhodes crusade to heal the worthy
247 * ports should be that afterwards, if we grep for something like
248 * this in CVS and it's not there, we can lightheartedly nuke it.
249 * -- WHN 2002-08-30 */
251 defconstant("tiocsigsend", TIOCSIGSEND);
252 defconstant("tiocflush", TIOCFLUSH);
253 defconstant("tiocgetp", TIOCGETP);
254 defconstant("tiocsetp", TIOCSETP);
255 defconstant("tiocgetc", TIOCGETC);
256 defconstant("tiocsetc", TIOCSETC);
257 defconstant("tiocgltc", TIOCGLTC);
258 defconstant("tiocsltc", TIOCSLTC);
262 printf(";;; signals\n");
263 defconstant("sig-dfl", (unsigned long)SIG_DFL
);
264 defconstant("sig-ign", (unsigned long)SIG_IGN
);
266 defsignal("sigalrm", SIGALRM
);
267 defsignal("sigbus", SIGBUS
);
268 defsignal("sigchld", SIGCHLD
);
269 defsignal("sigcont", SIGCONT
);
271 defsignal("sigemt", SIGEMT
);
273 defsignal("sigfpe", SIGFPE
);
274 defsignal("sighup", SIGHUP
);
275 defsignal("sigill", SIGILL
);
276 defsignal("sigint", SIGINT
);
277 defsignal("sigio", SIGIO
);
278 defsignal("sigiot", SIGIOT
);
279 defsignal("sigkill", SIGKILL
);
280 defsignal("sigpipe", SIGPIPE
);
281 defsignal("sigprof", SIGPROF
);
282 defsignal("sigquit", SIGQUIT
);
283 defsignal("sigsegv", SIGSEGV
);
285 defsignal("sigstkflt", SIGSTKFLT
);
287 defsignal("sigstop", SIGSTOP
);
289 defsignal("sigsys", SIGSYS
);
291 defsignal("sigterm", SIGTERM
);
292 defsignal("sigtrap", SIGTRAP
);
293 defsignal("sigtstp", SIGTSTP
);
294 defsignal("sigttin", SIGTTIN
);
295 defsignal("sigttou", SIGTTOU
);
296 defsignal("sigurg", SIGURG
);
297 defsignal("sigusr1", SIGUSR1
);
298 defsignal("sigusr2", SIGUSR2
);
299 defsignal("sigvtalrm", SIGVTALRM
);
301 defsignal("sigwaiting", SIGWAITING
);
303 defsignal("sigwinch", SIGWINCH
);
305 defsignal("sigxcpu", SIGXCPU
);
308 defsignal("sigxfsz", SIGXFSZ
);
311 /* Floating point exception codes. Some of these
312 * are missing on Darwin. */
314 defconstant("fpe-intovf", FPE_INTOVF
);
316 defconstant("fpe-intovf", -1);
319 defconstant("fpe-intdiv", FPE_INTDIV
);
321 defconstant("fpe-intdiv", -1);
323 defconstant("fpe-fltdiv", FPE_FLTDIV
);
324 defconstant("fpe-fltovf", FPE_FLTOVF
);
325 defconstant("fpe-fltund", FPE_FLTUND
);
326 defconstant("fpe-fltres", FPE_FLTRES
);
327 defconstant("fpe-fltinv", FPE_FLTINV
);
329 defconstant("fpe-fltsub", FPE_FLTSUB
);
331 defconstant("fpe-fltsub", -1);
336 printf(";;; structures\n");
337 DEFSTRUCT(timeval
, struct timeval
,
338 DEFSLOT(tv
-sec
, tv_sec
);
339 DEFSLOT(tv
-usec
, tv_usec
));
340 DEFSTRUCT(timespec
, struct timespec
,
341 DEFSLOT(tv
-sec
, tv_sec
);
342 DEFSLOT(tv
-nsec
, tv_nsec
));
345 #ifdef LISP_FEATURE_ANDROID
346 defconstant("path-max", PATH_MAX
);
350 #ifdef LISP_FEATURE_BSD
351 printf(";;; sysctl(3) names\n");
352 printf("(in-package \"SB!IMPL\")\n");
353 defconstant("ctl-kern", CTL_KERN
);
354 defconstant("ctl-hw", CTL_HW
);
355 defconstant("ctl-maxname", CTL_MAXNAME
);
356 defconstant("kern-ostype", KERN_OSTYPE
);
357 defconstant("kern-osrelease", KERN_OSRELEASE
);
358 defconstant("hw-model", HW_MODEL
);
359 defconstant("hw-pagesize", HW_PAGESIZE
);
361 defconstant("path-max", PATH_MAX
);
365 printf("(in-package \"SB!KERNEL\")\n\n");
366 #ifdef LISP_FEATURE_GENCGC
367 printf(";;; GENCGC related\n");
368 DEFTYPE("page-index-t", page_index_t
);
369 DEFTYPE("generation-index-t", generation_index_t
);
373 printf(";;; Our runtime types\n");
374 DEFTYPE("os-vm-size-t", os_vm_size_t
);