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