Commit | Line | Data |
---|---|---|
5e98bbab PB |
1 | /* rldefs.h -- an attempt to isolate some of the system-specific defines |
2 | for readline. This should be included after any files that define | |
3 | system-specific constants like _POSIX_VERSION or USG. */ | |
4 | ||
5 | /* Copyright (C) 1987,1989 Free Software Foundation, Inc. | |
6 | ||
7 | This file contains the Readline Library (the Library), a set of | |
8 | routines for providing Emacs style line input to programs that ask | |
9 | for it. | |
10 | ||
11 | The Library is free software; you can redistribute it and/or modify | |
12 | it under the terms of the GNU General Public License as published by | |
13 | the Free Software Foundation; either version 1, or (at your option) | |
14 | any later version. | |
15 | ||
16 | The Library is distributed in the hope that it will be useful, but | |
17 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
19 | General Public License for more details. | |
20 | ||
21 | The GNU General Public License is often shipped with GNU software, and | |
22 | is generally kept in a file called COPYING or LICENSE. If you do not | |
23 | have a copy of the license, write to the Free Software Foundation, | |
24 | 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
25 | ||
26 | #if !defined (_RLDEFS_H) | |
27 | #define _RLDEFS_H | |
28 | ||
29 | #if defined (__GNUC__) | |
30 | # undef alloca | |
31 | # define alloca __builtin_alloca | |
32 | #else | |
33 | # if defined (sparc) || defined (HAVE_ALLOCA_H) | |
34 | # include <alloca.h> | |
35 | # endif | |
36 | #endif | |
37 | ||
9e9cf21f | 38 | |
5e98bbab PB |
39 | #define NEW_TTY_DRIVER |
40 | #define HAVE_BSD_SIGNALS | |
41 | /* #define USE_XON_XOFF */ | |
42 | ||
46b6fdbd | 43 | #if defined(__MSDOS__) || defined(_WIN32) |
9e9cf21f MM |
44 | #define NO_SYS_FILE |
45 | #define SIGALRM 1234 | |
5e98bbab PB |
46 | #undef NEW_TTY_DRIVER |
47 | #undef HAVE_BSD_SIGNALS | |
9e9cf21f | 48 | #define MINIMAL |
5e98bbab PB |
49 | #endif |
50 | ||
51 | #if defined (__linux__) | |
52 | # include <termcap.h> | |
53 | #endif /* __linux__ */ | |
54 | ||
55 | /* Some USG machines have BSD signal handling (sigblock, sigsetmask, etc.) */ | |
f550cec5 PB |
56 | /* CYGNUS LOCAL accept __hpux as well as hpux for HP compiler in ANSI mode. */ |
57 | #if defined (USG) && !(defined (hpux) || defined (__hpux)) | |
5e98bbab PB |
58 | # undef HAVE_BSD_SIGNALS |
59 | #endif | |
60 | ||
46b6fdbd SG |
61 | #define ScreenCols() 80 |
62 | #define ScreenRows() 24 | |
63 | #define ScreenSetCursor() abort(); | |
64 | #define ScreenGetCursor() abort(); | |
9e9cf21f | 65 | |
5e98bbab PB |
66 | /* System V machines use termio. */ |
67 | #if !defined (_POSIX_VERSION) | |
f550cec5 PB |
68 | /* CYGNUS LOCAL accept __hpux as well as hpux for HP compiler in ANSI mode. */ |
69 | # if defined (USG) || defined (hpux) || defined (__hpux) || defined (Xenix) || defined (sgi) || defined (DGUX) | |
5e98bbab PB |
70 | # undef NEW_TTY_DRIVER |
71 | # define TERMIO_TTY_DRIVER | |
72 | # include <termio.h> | |
73 | # if !defined (TCOON) | |
74 | # define TCOON 1 | |
75 | # endif | |
76 | # endif /* USG || hpux || Xenix || sgi || DUGX */ | |
77 | #endif /* !_POSIX_VERSION */ | |
78 | ||
79 | /* Posix systems use termios and the Posix signal functions. */ | |
80 | #if defined (_POSIX_VERSION) | |
81 | # if !defined (TERMIOS_MISSING) | |
82 | # undef NEW_TTY_DRIVER | |
83 | # define TERMIOS_TTY_DRIVER | |
84 | # include <termios.h> | |
85 | # endif /* !TERMIOS_MISSING */ | |
86 | # define HAVE_POSIX_SIGNALS | |
87 | # if !defined (O_NDELAY) | |
88 | # define O_NDELAY O_NONBLOCK /* Posix-style non-blocking i/o */ | |
89 | # endif /* O_NDELAY */ | |
90 | #endif /* _POSIX_VERSION */ | |
91 | ||
92 | /* System V.3 machines have the old 4.1 BSD `reliable' signal interface. */ | |
93 | #if !defined (HAVE_BSD_SIGNALS) && !defined (HAVE_POSIX_SIGNALS) | |
94 | # if defined (USGr3) | |
95 | # if !defined (HAVE_USG_SIGHOLD) | |
96 | # define HAVE_USG_SIGHOLD | |
97 | # endif /* !HAVE_USG_SIGHOLD */ | |
98 | # endif /* USGr3 */ | |
99 | #endif /* !HAVE_BSD_SIGNALS && !HAVE_POSIX_SIGNALS */ | |
100 | ||
101 | /* Other (BSD) machines use sgtty. */ | |
102 | #if defined (NEW_TTY_DRIVER) | |
103 | # include <sgtty.h> | |
104 | #endif | |
105 | ||
106 | /* Define _POSIX_VDISABLE if we are not using the `new' tty driver and | |
107 | it is not already defined. It is used both to determine if a | |
108 | special character is disabled and to disable certain special | |
109 | characters. Posix systems should set to 0, USG systems to -1. */ | |
110 | #if !defined (NEW_TTY_DRIVER) && !defined (_POSIX_VDISABLE) | |
111 | # if defined (_POSIX_VERSION) | |
112 | # define _POSIX_VDISABLE 0 | |
113 | # else /* !_POSIX_VERSION */ | |
114 | # define _POSIX_VDISABLE -1 | |
115 | # endif /* !_POSIX_VERSION */ | |
116 | #endif /* !NEW_TTY_DRIVER && !_POSIX_VDISABLE */ | |
117 | ||
118 | #if 1 | |
119 | # define D_NAMLEN(d) strlen ((d)->d_name) | |
120 | #else /* !1 */ | |
121 | ||
122 | #if !defined (SHELL) && (defined (_POSIX_VERSION) || defined (USGr3)) | |
123 | # if !defined (HAVE_DIRENT_H) | |
124 | # define HAVE_DIRENT_H | |
125 | # endif /* !HAVE_DIRENT_H */ | |
126 | #endif /* !SHELL && (_POSIX_VERSION || USGr3) */ | |
127 | ||
128 | #if defined (HAVE_DIRENT_H) | |
129 | # include <dirent.h> | |
130 | # if !defined (direct) | |
131 | # define direct dirent | |
132 | # endif /* !direct */ | |
133 | # define D_NAMLEN(d) strlen ((d)->d_name) | |
134 | #else /* !HAVE_DIRENT_H */ | |
135 | # define D_NAMLEN(d) ((d)->d_namlen) | |
136 | # if defined (USG) | |
137 | # if defined (Xenix) | |
138 | # include <sys/ndir.h> | |
139 | # else /* !Xenix (but USG...) */ | |
140 | # include "ndir.h" | |
141 | # endif /* !Xenix */ | |
142 | # else /* !USG */ | |
143 | # include <sys/dir.h> | |
144 | # endif /* !USG */ | |
145 | #endif /* !HAVE_DIRENT_H */ | |
146 | #endif /* !1 */ | |
147 | ||
148 | #if defined (USG) && defined (TIOCGWINSZ) && !defined (Linux) | |
9e9cf21f MM |
149 | # if defined (_AIX) |
150 | /* AIX 4.x seems to reference struct uio within a prototype | |
151 | in stream.h, but doesn't cause the uio include file to | |
152 | be included. */ | |
153 | # include <sys/uio.h> | |
154 | # endif | |
5e98bbab PB |
155 | # include <sys/stream.h> |
156 | # if defined (HAVE_SYS_PTEM_H) | |
157 | # include <sys/ptem.h> | |
158 | # endif /* HAVE_SYS_PTEM_H */ | |
159 | # if defined (HAVE_SYS_PTE_H) | |
160 | # include <sys/pte.h> | |
161 | # endif /* HAVE_SYS_PTE_H */ | |
162 | #endif /* USG && TIOCGWINSZ && !Linux */ | |
163 | ||
164 | /* Posix macro to check file in statbuf for directory-ness. | |
165 | This requires that <sys/stat.h> be included before this test. */ | |
166 | #if defined (S_IFDIR) && !defined (S_ISDIR) | |
167 | #define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR) | |
168 | #endif | |
9e9cf21f MM |
169 | /* Posix macro to check file in statbuf for file-ness. |
170 | This requires that <sys/stat.h> be included before this test. */ | |
171 | #if defined (S_IFREG) && !defined (S_ISREG) | |
172 | #define S_ISREG(m) (((m)&S_IFMT) == S_IFREG) | |
173 | #endif | |
5e98bbab | 174 | |
5e98bbab PB |
175 | #if !defined (strchr) && !defined (__STDC__) |
176 | extern char *strchr (), *strrchr (); | |
177 | #endif /* !strchr && !__STDC__ */ | |
178 | ||
179 | #if defined (HAVE_VARARGS_H) | |
180 | # include <varargs.h> | |
181 | #endif /* HAVE_VARARGS_H */ | |
182 | ||
183 | /* This definition is needed by readline.c, rltty.c, and signals.c. */ | |
184 | /* If on, then readline handles signals in a way that doesn't screw. */ | |
185 | #define HANDLE_SIGNALS | |
186 | ||
46b6fdbd | 187 | #if defined(_WIN32) || defined(__MSDOS__) |
9e9cf21f MM |
188 | #undef HANDLE_SIGNALS |
189 | #endif | |
190 | ||
191 | ||
5e98bbab PB |
192 | #if !defined (emacs_mode) |
193 | # define no_mode -1 | |
194 | # define vi_mode 0 | |
195 | # define emacs_mode 1 | |
196 | #endif | |
197 | ||
198 | /* Define some macros for dealing with assorted signalling disciplines. | |
199 | ||
200 | These macros provide a way to use signal blocking and disabling | |
201 | without smothering your code in a pile of #ifdef's. | |
202 | ||
203 | SIGNALS_UNBLOCK; Stop blocking all signals. | |
204 | ||
205 | { | |
206 | SIGNALS_DECLARE_SAVED (name); Declare a variable to save the | |
207 | signal blocking state. | |
208 | ... | |
209 | SIGNALS_BLOCK (SIGSTOP, name); Block a signal, and save the previous | |
210 | state for restoration later. | |
211 | ... | |
212 | SIGNALS_RESTORE (name); Restore previous signals. | |
213 | } | |
214 | ||
215 | */ | |
216 | ||
217 | #ifdef HAVE_POSIX_SIGNALS | |
218 | /* POSIX signals */ | |
219 | ||
220 | #define SIGNALS_UNBLOCK \ | |
221 | do { sigset_t set; \ | |
222 | sigemptyset (&set); \ | |
223 | sigprocmask (SIG_SETMASK, &set, (sigset_t *)NULL); \ | |
224 | } while (0) | |
225 | ||
226 | #define SIGNALS_DECLARE_SAVED(name) sigset_t name | |
227 | ||
228 | #define SIGNALS_BLOCK(SIG, saved) \ | |
229 | do { sigset_t set; \ | |
230 | sigemptyset (&set); \ | |
231 | sigaddset (&set, SIG); \ | |
232 | sigprocmask (SIG_BLOCK, &set, &saved); \ | |
233 | } while (0) | |
234 | ||
235 | #define SIGNALS_RESTORE(saved) \ | |
236 | sigprocmask (SIG_SETMASK, &saved, (sigset_t *)NULL) | |
237 | ||
238 | ||
239 | #else /* HAVE_POSIX_SIGNALS */ | |
240 | #ifdef HAVE_BSD_SIGNALS | |
241 | /* BSD signals */ | |
242 | ||
243 | #define SIGNALS_UNBLOCK sigsetmask (0) | |
244 | #define SIGNALS_DECLARE_SAVED(name) int name | |
245 | #define SIGNALS_BLOCK(SIG, saved) saved = sigblock (sigmask (SIG)) | |
246 | #define SIGNALS_RESTORE(saved) sigsetmask (saved) | |
247 | ||
248 | ||
249 | #else /* HAVE_BSD_SIGNALS */ | |
250 | /* None of the Above */ | |
251 | ||
252 | #define SIGNALS_UNBLOCK /* nothing */ | |
253 | #define SIGNALS_DECLARE_SAVED(name) /* nothing */ | |
254 | #define SIGNALS_BLOCK(SIG, saved) /* nothing */ | |
255 | #define SIGNALS_RESTORE(saved) /* nothing */ | |
256 | ||
257 | ||
258 | #endif /* HAVE_BSD_SIGNALS */ | |
259 | #endif /* HAVE_POSIX_SIGNALS */ | |
260 | ||
9e9cf21f MM |
261 | #if !defined (strchr) |
262 | extern char *strchr (); | |
263 | #endif | |
264 | #if !defined (strrchr) | |
265 | extern char *strrchr (); | |
266 | #endif | |
267 | #ifdef __STDC__ | |
268 | #include <stddef.h> | |
269 | extern size_t strlen (const char *s); | |
270 | #endif /* __STDC__ */ | |
271 | ||
5e98bbab PB |
272 | /* End of signal handling definitions. */ |
273 | #endif /* !_RLDEFS_H */ |