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