]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - readline/rldefs.h
* config/sh/tm-sh.h (BELIEVE_PCC_PROMOTION): Define, so that
[thirdparty/binutils-gdb.git] / readline / rldefs.h
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
38
39 #define NEW_TTY_DRIVER
40 #define HAVE_BSD_SIGNALS
41 /* #define USE_XON_XOFF */
42
43 #if defined(__MSDOS__) || defined(_WIN32)
44 #define NO_SYS_FILE
45 #define SIGALRM 1234
46 #undef NEW_TTY_DRIVER
47 #undef HAVE_BSD_SIGNALS
48 #define MINIMAL
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.) */
56 /* CYGNUS LOCAL accept __hpux as well as hpux for HP compiler in ANSI mode. */
57 #if defined (USG) && !(defined (hpux) || defined (__hpux))
58 # undef HAVE_BSD_SIGNALS
59 #endif
60
61 #define ScreenCols() 80
62 #define ScreenRows() 24
63 #define ScreenSetCursor() abort();
64 #define ScreenGetCursor() abort();
65
66 /* System V machines use termio. */
67 #if !defined (_POSIX_VERSION)
68 /* CYGNUS LOCAL accept __hpux as well as hpux for HP compiler in ANSI mode.
69 Add __osf__ to list of machines to force use of termio.h */
70 # if defined (USG) || defined (hpux) || defined (__hpux) || defined (Xenix) || defined (sgi) || defined (DGUX) || defined (__osf__)
71 # undef NEW_TTY_DRIVER
72 # define TERMIO_TTY_DRIVER
73 # include <termio.h>
74 # if !defined (TCOON)
75 # define TCOON 1
76 # endif
77 # endif /* USG || hpux || Xenix || sgi || DUGX || __osf__ */
78 #endif /* !_POSIX_VERSION */
79
80 /* Posix systems use termios and the Posix signal functions. */
81 #if defined (_POSIX_VERSION)
82 # if !defined (TERMIOS_MISSING)
83 # undef NEW_TTY_DRIVER
84 # define TERMIOS_TTY_DRIVER
85 # include <termios.h>
86 # endif /* !TERMIOS_MISSING */
87 # define HAVE_POSIX_SIGNALS
88 # if !defined (O_NDELAY)
89 # define O_NDELAY O_NONBLOCK /* Posix-style non-blocking i/o */
90 # endif /* O_NDELAY */
91 #endif /* _POSIX_VERSION */
92
93 /* System V.3 machines have the old 4.1 BSD `reliable' signal interface. */
94 #if !defined (HAVE_BSD_SIGNALS) && !defined (HAVE_POSIX_SIGNALS)
95 # if defined (USGr3)
96 # if !defined (HAVE_USG_SIGHOLD)
97 # define HAVE_USG_SIGHOLD
98 # endif /* !HAVE_USG_SIGHOLD */
99 # endif /* USGr3 */
100 #endif /* !HAVE_BSD_SIGNALS && !HAVE_POSIX_SIGNALS */
101
102 /* Other (BSD) machines use sgtty. */
103 #if defined (NEW_TTY_DRIVER)
104 # include <sgtty.h>
105 #endif
106
107 /* Define _POSIX_VDISABLE if we are not using the `new' tty driver and
108 it is not already defined. It is used both to determine if a
109 special character is disabled and to disable certain special
110 characters. Posix systems should set to 0, USG systems to -1. */
111 #if !defined (NEW_TTY_DRIVER) && !defined (_POSIX_VDISABLE)
112 # if defined (_POSIX_VERSION)
113 # define _POSIX_VDISABLE 0
114 # else /* !_POSIX_VERSION */
115 # define _POSIX_VDISABLE -1
116 # endif /* !_POSIX_VERSION */
117 #endif /* !NEW_TTY_DRIVER && !_POSIX_VDISABLE */
118
119 #if 1
120 # define D_NAMLEN(d) strlen ((d)->d_name)
121 #else /* !1 */
122
123 #if !defined (SHELL) && (defined (_POSIX_VERSION) || defined (USGr3))
124 # if !defined (HAVE_DIRENT_H)
125 # define HAVE_DIRENT_H
126 # endif /* !HAVE_DIRENT_H */
127 #endif /* !SHELL && (_POSIX_VERSION || USGr3) */
128
129 #if defined (HAVE_DIRENT_H)
130 # include <dirent.h>
131 # if !defined (direct)
132 # define direct dirent
133 # endif /* !direct */
134 # define D_NAMLEN(d) strlen ((d)->d_name)
135 #else /* !HAVE_DIRENT_H */
136 # define D_NAMLEN(d) ((d)->d_namlen)
137 # if defined (USG)
138 # if defined (Xenix)
139 # include <sys/ndir.h>
140 # else /* !Xenix (but USG...) */
141 # include "ndir.h"
142 # endif /* !Xenix */
143 # else /* !USG */
144 # include <sys/dir.h>
145 # endif /* !USG */
146 #endif /* !HAVE_DIRENT_H */
147 #endif /* !1 */
148
149 #if defined (USG) && defined (TIOCGWINSZ) && !defined (Linux)
150 # if defined (_AIX)
151 /* AIX 4.x seems to reference struct uio within a prototype
152 in stream.h, but doesn't cause the uio include file to
153 be included. */
154 # include <sys/uio.h>
155 # endif
156 # include <sys/stream.h>
157 # if defined (HAVE_SYS_PTEM_H)
158 # include <sys/ptem.h>
159 # endif /* HAVE_SYS_PTEM_H */
160 # if defined (HAVE_SYS_PTE_H)
161 # include <sys/pte.h>
162 # endif /* HAVE_SYS_PTE_H */
163 #endif /* USG && TIOCGWINSZ && !Linux */
164
165 /* Posix macro to check file in statbuf for directory-ness.
166 This requires that <sys/stat.h> be included before this test. */
167 #if defined (S_IFDIR) && !defined (S_ISDIR)
168 #define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR)
169 #endif
170 /* Posix macro to check file in statbuf for file-ness.
171 This requires that <sys/stat.h> be included before this test. */
172 #if defined (S_IFREG) && !defined (S_ISREG)
173 #define S_ISREG(m) (((m)&S_IFMT) == S_IFREG)
174 #endif
175
176 #if !defined (strchr) && !defined (__STDC__)
177 extern char *strchr (), *strrchr ();
178 #endif /* !strchr && !__STDC__ */
179
180 #if defined (HAVE_VARARGS_H)
181 # include <varargs.h>
182 #endif /* HAVE_VARARGS_H */
183
184 /* This definition is needed by readline.c, rltty.c, and signals.c. */
185 /* If on, then readline handles signals in a way that doesn't screw. */
186 #define HANDLE_SIGNALS
187
188 #if defined(_WIN32) || defined(__MSDOS__)
189 #undef HANDLE_SIGNALS
190 #endif
191
192
193 #if !defined (emacs_mode)
194 # define no_mode -1
195 # define vi_mode 0
196 # define emacs_mode 1
197 #endif
198
199 /* Define some macros for dealing with assorted signalling disciplines.
200
201 These macros provide a way to use signal blocking and disabling
202 without smothering your code in a pile of #ifdef's.
203
204 SIGNALS_UNBLOCK; Stop blocking all signals.
205
206 {
207 SIGNALS_DECLARE_SAVED (name); Declare a variable to save the
208 signal blocking state.
209 ...
210 SIGNALS_BLOCK (SIGSTOP, name); Block a signal, and save the previous
211 state for restoration later.
212 ...
213 SIGNALS_RESTORE (name); Restore previous signals.
214 }
215
216 */
217
218 #ifdef HAVE_POSIX_SIGNALS
219 /* POSIX signals */
220
221 #define SIGNALS_UNBLOCK \
222 do { sigset_t set; \
223 sigemptyset (&set); \
224 sigprocmask (SIG_SETMASK, &set, (sigset_t *)NULL); \
225 } while (0)
226
227 #define SIGNALS_DECLARE_SAVED(name) sigset_t name
228
229 #define SIGNALS_BLOCK(SIG, saved) \
230 do { sigset_t set; \
231 sigemptyset (&set); \
232 sigaddset (&set, SIG); \
233 sigprocmask (SIG_BLOCK, &set, &saved); \
234 } while (0)
235
236 #define SIGNALS_RESTORE(saved) \
237 sigprocmask (SIG_SETMASK, &saved, (sigset_t *)NULL)
238
239
240 #else /* HAVE_POSIX_SIGNALS */
241 #ifdef HAVE_BSD_SIGNALS
242 /* BSD signals */
243
244 #define SIGNALS_UNBLOCK sigsetmask (0)
245 #define SIGNALS_DECLARE_SAVED(name) int name
246 #define SIGNALS_BLOCK(SIG, saved) saved = sigblock (sigmask (SIG))
247 #define SIGNALS_RESTORE(saved) sigsetmask (saved)
248
249
250 #else /* HAVE_BSD_SIGNALS */
251 /* None of the Above */
252
253 #define SIGNALS_UNBLOCK /* nothing */
254 #define SIGNALS_DECLARE_SAVED(name) /* nothing */
255 #define SIGNALS_BLOCK(SIG, saved) /* nothing */
256 #define SIGNALS_RESTORE(saved) /* nothing */
257
258
259 #endif /* HAVE_BSD_SIGNALS */
260 #endif /* HAVE_POSIX_SIGNALS */
261
262 #if !defined (strchr)
263 extern char *strchr ();
264 #endif
265 #if !defined (strrchr)
266 extern char *strrchr ();
267 #endif
268 #ifdef __STDC__
269 #include <stddef.h>
270 extern size_t strlen (const char *s);
271 #endif /* __STDC__ */
272
273 /* End of signal handling definitions. */
274 #endif /* !_RLDEFS_H */