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. */
5 /* Copyright (C) 1987,1989 Free Software Foundation, Inc.
7 This file contains the Readline Library (the Library), a set of
8 routines for providing Emacs style line input to programs that ask
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)
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.
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. */
26 #if !defined (_RLDEFS_H)
29 #if defined (__GNUC__)
31 # define alloca __builtin_alloca
33 # if defined (sparc) || defined (HAVE_ALLOCA_H)
39 #define NEW_TTY_DRIVER
40 #define HAVE_BSD_SIGNALS
41 /* #define USE_XON_XOFF */
43 #if defined(__MSDOS__) || defined(_MSC_VER)
47 #undef HAVE_BSD_SIGNALS
51 #if defined (__linux__)
53 #endif /* __linux__ */
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
61 #if defined (__WIN32__) && !defined(_MSC_VER)
64 #undef HAVE_BSD_SIGNALS
65 #define TERMIOS_TTY_DRIVER
68 /*#define HAVE_POSIX_SIGNALS*/
71 /* System V machines use termio. */
72 #if !defined (_POSIX_VERSION)
73 /* CYGNUS LOCAL accept __hpux as well as hpux for HP compiler in ANSI mode. */
74 # if defined (USG) || defined (hpux) || defined (__hpux) || defined (Xenix) || defined (sgi) || defined (DGUX)
75 # undef NEW_TTY_DRIVER
76 # define TERMIO_TTY_DRIVER
81 # endif /* USG || hpux || Xenix || sgi || DUGX */
82 #endif /* !_POSIX_VERSION */
84 /* Posix systems use termios and the Posix signal functions. */
85 #if defined (_POSIX_VERSION)
86 # if !defined (TERMIOS_MISSING)
87 # undef NEW_TTY_DRIVER
88 # define TERMIOS_TTY_DRIVER
90 # endif /* !TERMIOS_MISSING */
91 # define HAVE_POSIX_SIGNALS
92 # if !defined (O_NDELAY)
93 # define O_NDELAY O_NONBLOCK /* Posix-style non-blocking i/o */
94 # endif /* O_NDELAY */
95 #endif /* _POSIX_VERSION */
97 /* System V.3 machines have the old 4.1 BSD `reliable' signal interface. */
98 #if !defined (HAVE_BSD_SIGNALS) && !defined (HAVE_POSIX_SIGNALS)
100 # if !defined (HAVE_USG_SIGHOLD)
101 # define HAVE_USG_SIGHOLD
102 # endif /* !HAVE_USG_SIGHOLD */
104 #endif /* !HAVE_BSD_SIGNALS && !HAVE_POSIX_SIGNALS */
106 /* Other (BSD) machines use sgtty. */
107 #if defined (NEW_TTY_DRIVER)
111 /* Define _POSIX_VDISABLE if we are not using the `new' tty driver and
112 it is not already defined. It is used both to determine if a
113 special character is disabled and to disable certain special
114 characters. Posix systems should set to 0, USG systems to -1. */
115 #if !defined (NEW_TTY_DRIVER) && !defined (_POSIX_VDISABLE)
116 # if defined (_POSIX_VERSION)
117 # define _POSIX_VDISABLE 0
118 # else /* !_POSIX_VERSION */
119 # define _POSIX_VDISABLE -1
120 # endif /* !_POSIX_VERSION */
121 #endif /* !NEW_TTY_DRIVER && !_POSIX_VDISABLE */
124 # define D_NAMLEN(d) strlen ((d)->d_name)
127 #if !defined (SHELL) && (defined (_POSIX_VERSION) || defined (USGr3))
128 # if !defined (HAVE_DIRENT_H)
129 # define HAVE_DIRENT_H
130 # endif /* !HAVE_DIRENT_H */
131 #endif /* !SHELL && (_POSIX_VERSION || USGr3) */
133 #if defined (HAVE_DIRENT_H)
135 # if !defined (direct)
136 # define direct dirent
137 # endif /* !direct */
138 # define D_NAMLEN(d) strlen ((d)->d_name)
139 #else /* !HAVE_DIRENT_H */
140 # define D_NAMLEN(d) ((d)->d_namlen)
143 # include <sys/ndir.h>
144 # else /* !Xenix (but USG...) */
148 # include <sys/dir.h>
150 #endif /* !HAVE_DIRENT_H */
153 #if defined (USG) && defined (TIOCGWINSZ) && !defined (Linux)
155 /* AIX 4.x seems to reference struct uio within a prototype
156 in stream.h, but doesn't cause the uio include file to
158 # include <sys/uio.h>
160 # include <sys/stream.h>
161 # if defined (HAVE_SYS_PTEM_H)
162 # include <sys/ptem.h>
163 # endif /* HAVE_SYS_PTEM_H */
164 # if defined (HAVE_SYS_PTE_H)
165 # include <sys/pte.h>
166 # endif /* HAVE_SYS_PTE_H */
167 #endif /* USG && TIOCGWINSZ && !Linux */
169 /* Posix macro to check file in statbuf for directory-ness.
170 This requires that <sys/stat.h> be included before this test. */
171 #if defined (S_IFDIR) && !defined (S_ISDIR)
172 #define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR)
174 /* Posix macro to check file in statbuf for file-ness.
175 This requires that <sys/stat.h> be included before this test. */
176 #if defined (S_IFREG) && !defined (S_ISREG)
177 #define S_ISREG(m) (((m)&S_IFMT) == S_IFREG)
180 #if !defined (strchr) && !defined (__STDC__)
181 extern char *strchr (), *strrchr ();
182 #endif /* !strchr && !__STDC__ */
184 #if defined (HAVE_VARARGS_H)
185 # include <varargs.h>
186 #endif /* HAVE_VARARGS_H */
188 /* This definition is needed by readline.c, rltty.c, and signals.c. */
189 /* If on, then readline handles signals in a way that doesn't screw. */
190 #define HANDLE_SIGNALS
192 #if defined(__WIN32__) || defined(__MSDOS__)
193 #undef HANDLE_SIGNALS
197 #if !defined (emacs_mode)
200 # define emacs_mode 1
203 /* Define some macros for dealing with assorted signalling disciplines.
205 These macros provide a way to use signal blocking and disabling
206 without smothering your code in a pile of #ifdef's.
208 SIGNALS_UNBLOCK; Stop blocking all signals.
211 SIGNALS_DECLARE_SAVED (name); Declare a variable to save the
212 signal blocking state.
214 SIGNALS_BLOCK (SIGSTOP, name); Block a signal, and save the previous
215 state for restoration later.
217 SIGNALS_RESTORE (name); Restore previous signals.
222 #ifdef HAVE_POSIX_SIGNALS
225 #define SIGNALS_UNBLOCK \
227 sigemptyset (&set); \
228 sigprocmask (SIG_SETMASK, &set, (sigset_t *)NULL); \
231 #define SIGNALS_DECLARE_SAVED(name) sigset_t name
233 #define SIGNALS_BLOCK(SIG, saved) \
235 sigemptyset (&set); \
236 sigaddset (&set, SIG); \
237 sigprocmask (SIG_BLOCK, &set, &saved); \
240 #define SIGNALS_RESTORE(saved) \
241 sigprocmask (SIG_SETMASK, &saved, (sigset_t *)NULL)
244 #else /* HAVE_POSIX_SIGNALS */
245 #ifdef HAVE_BSD_SIGNALS
248 #define SIGNALS_UNBLOCK sigsetmask (0)
249 #define SIGNALS_DECLARE_SAVED(name) int name
250 #define SIGNALS_BLOCK(SIG, saved) saved = sigblock (sigmask (SIG))
251 #define SIGNALS_RESTORE(saved) sigsetmask (saved)
254 #else /* HAVE_BSD_SIGNALS */
255 /* None of the Above */
257 #define SIGNALS_UNBLOCK /* nothing */
258 #define SIGNALS_DECLARE_SAVED(name) /* nothing */
259 #define SIGNALS_BLOCK(SIG, saved) /* nothing */
260 #define SIGNALS_RESTORE(saved) /* nothing */
263 #endif /* HAVE_BSD_SIGNALS */
264 #endif /* HAVE_POSIX_SIGNALS */
266 #if !defined (strchr)
267 extern char *strchr ();
269 #if !defined (strrchr)
270 extern char *strrchr ();
274 extern size_t strlen (const char *s);
275 #endif /* __STDC__ */
277 /* End of signal handling definitions. */
278 #endif /* !_RLDEFS_H */