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>
31 #define DEFTYPE(lispname,cname) { cname foo; \
32 printf("(define-alien-type " lispname " (%s %d))\n", (((foo=-1)<0) ? "sb!alien:signed" : "unsigned"), (8 * (sizeof foo))); }
35 defconstant(char* lisp_name, long unix_number)
37 printf("(defconstant %s %ld) ; #x%lx\n",
38 lisp_name, unix_number, unix_number);
42 main(int argc, char *argv[])
44 /* don't need no steenking command line arguments */
46 fprintf(stderr, "argh! command line argument(s)\n");
50 /* don't need no steenking hand-editing */
52 ";;;; This is an automatically generated file, please do not hand-edit it.\n\
53 ;;;; See the program \"grovel_headers.c\".\n\
57 printf("(in-package \"SB!UNIX\")\n\n");
59 printf(";;; types, types, types\n");
60 DEFTYPE("clock-t", clock_t);
61 DEFTYPE("dev-t", dev_t);
62 DEFTYPE("gid-t", gid_t);
63 DEFTYPE("ino-t", ino_t);
64 DEFTYPE("mode-t", mode_t);
65 DEFTYPE("nlink-t", nlink_t);
66 DEFTYPE("off-t", off_t);
67 DEFTYPE("size-t", size_t);
68 DEFTYPE("time-t", time_t);
69 DEFTYPE("uid-t", uid_t);
72 printf(";;; fcntl.h (or unistd.h on OpenBSD)\n");
73 defconstant("r_ok", R_OK);
74 defconstant("w_ok", W_OK);
75 defconstant("x_ok", X_OK);
76 defconstant("f_ok", F_OK);
79 printf(";;; fcntlbits.h\n");
80 defconstant("o_rdonly", O_RDONLY);
81 defconstant("o_wronly", O_WRONLY);
82 defconstant("o_rdwr", O_RDWR);
83 defconstant("o_accmode", O_ACCMODE);
84 defconstant("o_creat", O_CREAT);
85 defconstant("o_excl", O_EXCL);
86 defconstant("o_noctty", O_NOCTTY);
87 defconstant("o_trunc", O_TRUNC);
88 defconstant("o_append", O_APPEND);
90 defconstant("s-ifmt", S_IFMT);
91 defconstant("s-ififo", S_IFIFO);
92 defconstant("s-ifchr", S_IFCHR);
93 defconstant("s-ifdir", S_IFDIR);
94 defconstant("s-ifblk", S_IFBLK);
95 defconstant("s-ifreg", S_IFREG);
98 defconstant("s-iflnk", S_IFLNK);
99 defconstant("s-ifsock", S_IFSOCK);
102 printf(";;; for wait3(2) in run-program.lisp\n");
103 defconstant("wnohang", WNOHANG);
104 defconstant("wuntraced", WUNTRACED);
107 printf(";;; various ioctl(2) flags\n");
108 defconstant("tiocnotty", TIOCNOTTY);
109 defconstant("tiocgwinsz", TIOCGWINSZ);
110 defconstant("tiocswinsz", TIOCSWINSZ);
111 defconstant("tiocgpgrp", TIOCGPGRP);
112 defconstant("tiocspgrp", TIOCSPGRP);
113 /* KLUDGE: These are referenced by old CMUCL-derived code, but
114 * Linux doesn't define them.
116 * I think these are the BSD names, but I don't know what the
117 * corresponding SysV/Linux names are. As a point of reference,
118 * CMUCL doesn't have these defined either (although the defining
119 * forms *do* exist in src/code/unix.lisp), so I don't feel nearly
120 * so bad about not hunting them down. Insight into renamed
121 * obscure ioctl(2) flags appreciated. --njf, 2002-08-26
123 * I note that the first one I grepped for, TIOCSIGSEND, is
124 * referenced in SBCL conditional on #+HPUX. Maybe the porters of
125 * Oxbridge know more about things like that? And even if they
126 * don't, one benefit of the Rhodes crusade to heal the worthy
127 * ports should be that afterwards, if we grep for something like
128 * this in CVS and it's not there, we can lightheartedly nuke it.
129 * -- WHN 2002-08-30 */
131 defconstant("tiocsigsend", TIOCSIGSEND);
132 defconstant("tiocflush", TIOCFLUSH);
133 defconstant("tiocgetp", TIOCGETP);
134 defconstant("tiocsetp", TIOCSETP);
135 defconstant("tiocgetc", TIOCGETC);
136 defconstant("tiocsetc", TIOCSETC);
137 defconstant("tiocgltc", TIOCGLTC);
138 defconstant("tiocsltc", TIOCSLTC);