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