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