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>
34 #include "genesis/config.h"
36 #define DEFTYPE(lispname,cname) { cname foo; \
37 printf("(define-alien-type " lispname " (%s %d))\n", (((foo=-1)<0) ? "sb!alien:signed" : "unsigned"), (8 * (sizeof foo))); }
40 defconstant(char* lisp_name, long unix_number)
42 printf("(defconstant %s %ld) ; #x%lx\n",
43 lisp_name, unix_number, unix_number);
46 #define DEFERRNO(name) defconstant(#name, name)
47 #define DEFSIGNAL(name) defconstant(#name, name)
50 main(int argc, char *argv[])
52 /* don't need no steenking command line arguments */
54 fprintf(stderr, "argh! command line argument(s)\n");
58 /* don't need no steenking hand-editing */
60 ";;;; This is an automatically generated file, please do not hand-edit it.\n\
61 ;;;; See the program \"grovel-headers.c\".\n\
65 printf("(in-package \"SB!ALIEN\")\n\n");
67 printf (";;;flags for dlopen()\n");
69 defconstant ("rtld-lazy", RTLD_LAZY);
70 defconstant ("rtld-now", RTLD_NOW);
71 defconstant ("rtld-global", RTLD_GLOBAL);
73 printf("(in-package \"SB!UNIX\")\n\n");
75 printf(";;; types, types, types\n");
76 DEFTYPE("clock-t", clock_t);
77 DEFTYPE("dev-t", dev_t);
78 DEFTYPE("gid-t", gid_t);
79 DEFTYPE("ino-t", ino_t);
80 DEFTYPE("mode-t", mode_t);
81 DEFTYPE("nlink-t", nlink_t);
82 DEFTYPE("off-t", off_t);
83 DEFTYPE("size-t", size_t);
84 DEFTYPE("time-t", time_t);
85 DEFTYPE("uid-t", uid_t);
88 printf(";;; fcntl.h (or unistd.h on OpenBSD and NetBSD)\n");
89 defconstant("r_ok", R_OK);
90 defconstant("w_ok", W_OK);
91 defconstant("x_ok", X_OK);
92 defconstant("f_ok", F_OK);
95 printf(";;; fcntlbits.h\n");
96 defconstant("o_rdonly", O_RDONLY);
97 defconstant("o_wronly", O_WRONLY);
98 defconstant("o_rdwr", O_RDWR);
99 defconstant("o_accmode", O_ACCMODE);
100 defconstant("o_creat", O_CREAT);
101 defconstant("o_excl", O_EXCL);
102 defconstant("o_noctty", O_NOCTTY);
103 defconstant("o_trunc", O_TRUNC);
104 defconstant("o_append", O_APPEND);
106 defconstant("s-ifmt", S_IFMT);
107 defconstant("s-ififo", S_IFIFO);
108 defconstant("s-ifchr", S_IFCHR);
109 defconstant("s-ifdir", S_IFDIR);
110 defconstant("s-ifblk", S_IFBLK);
111 defconstant("s-ifreg", S_IFREG);
114 defconstant("s-iflnk", S_IFLNK);
115 defconstant("s-ifsock", S_IFSOCK);
118 printf(";;; error numbers\n");
124 DEFERRNO(EWOULDBLOCK);
127 printf(";;; for wait3(2) in run-program.lisp\n");
128 defconstant("wnohang", WNOHANG);
129 defconstant("wuntraced", WUNTRACED);
132 printf(";;; various ioctl(2) flags\n");
133 defconstant("tiocnotty", TIOCNOTTY);
134 defconstant("tiocgwinsz", TIOCGWINSZ);
135 defconstant("tiocswinsz", TIOCSWINSZ);
136 defconstant("tiocgpgrp", TIOCGPGRP);
137 defconstant("tiocspgrp", TIOCSPGRP);
138 /* KLUDGE: These are referenced by old CMUCL-derived code, but
139 * Linux doesn't define them.
141 * I think these are the BSD names, but I don't know what the
142 * corresponding SysV/Linux names are. As a point of reference,
143 * CMUCL doesn't have these defined either (although the defining
144 * forms *do* exist in src/code/unix.lisp), so I don't feel nearly
145 * so bad about not hunting them down. Insight into renamed
146 * obscure ioctl(2) flags appreciated. --njf, 2002-08-26
148 * I note that the first one I grepped for, TIOCSIGSEND, is
149 * referenced in SBCL conditional on #+HPUX. Maybe the porters of
150 * Oxbridge know more about things like that? And even if they
151 * don't, one benefit of the Rhodes crusade to heal the worthy
152 * ports should be that afterwards, if we grep for something like
153 * this in CVS and it's not there, we can lightheartedly nuke it.
154 * -- WHN 2002-08-30 */
156 defconstant("tiocsigsend", TIOCSIGSEND);
157 defconstant("tiocflush", TIOCFLUSH);
158 defconstant("tiocgetp", TIOCGETP);
159 defconstant("tiocsetp", TIOCSETP);
160 defconstant("tiocgetc", TIOCGETC);
161 defconstant("tiocsetc", TIOCSETC);
162 defconstant("tiocgltc", TIOCGLTC);
163 defconstant("tiocsltc", TIOCSLTC);
167 printf(";;; signals\n");
186 #if ((defined LISP_FEATURE_LINUX) && (defined LISP_FEATURE_X86))
187 DEFSIGNAL(SIGSTKFLT);
190 #if (!((defined LISP_FEATURE_LINUX) && (defined LISP_FEATURE_X86)))
201 DEFSIGNAL(SIGVTALRM);
202 #ifdef LISP_FEATURE_SUNOS
203 DEFSIGNAL(SIGWAITING);
206 #ifndef LISP_FEATURE_HPUX