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