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)
38 #define NEW_TTY_DRIVER
39 #define HAVE_BSD_SIGNALS
40 /* #define USE_XON_XOFF */
44 #undef HAVE_BSD_SIGNALS
47 #if defined (__linux__)
49 #endif /* __linux__ */
51 /* Some USG machines have BSD signal handling (sigblock, sigsetmask, etc.) */
52 #if defined (USG) && !defined (hpux)
53 # undef HAVE_BSD_SIGNALS
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
65 # endif /* USG || hpux || Xenix || sgi || DUGX */
66 #endif /* !_POSIX_VERSION */
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
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 */
81 /* System V.3 machines have the old 4.1 BSD `reliable' signal interface. */
82 #if !defined (HAVE_BSD_SIGNALS) && !defined (HAVE_POSIX_SIGNALS)
84 # if !defined (HAVE_USG_SIGHOLD)
85 # define HAVE_USG_SIGHOLD
86 # endif /* !HAVE_USG_SIGHOLD */
88 #endif /* !HAVE_BSD_SIGNALS && !HAVE_POSIX_SIGNALS */
90 /* Other (BSD) machines use sgtty. */
91 #if defined (NEW_TTY_DRIVER)
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 */
108 # define D_NAMLEN(d) strlen ((d)->d_name)
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) */
117 #if defined (HAVE_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)
127 # include <sys/ndir.h>
128 # else /* !Xenix (but USG...) */
132 # include <sys/dir.h>
134 #endif /* !HAVE_DIRENT_H */
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 */
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)
153 /* Decide which flavor of the header file describing the C library
154 string functions to include and include it. */
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 */
162 #if defined (HAVE_STRING_H)
164 #else /* !HAVE_STRING_H */
165 # include <strings.h>
166 #endif /* !HAVE_STRING_H */
168 #if !defined (strchr) && !defined (__STDC__)
169 extern char *strchr (), *strrchr ();
170 #endif /* !strchr && !__STDC__ */
172 #if defined (HAVE_VARARGS_H)
173 # include <varargs.h>
174 #endif /* HAVE_VARARGS_H */
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
180 #if !defined (emacs_mode)
183 # define emacs_mode 1
186 /* Define some macros for dealing with assorted signalling disciplines.
188 These macros provide a way to use signal blocking and disabling
189 without smothering your code in a pile of #ifdef's.
191 SIGNALS_UNBLOCK; Stop blocking all signals.
194 SIGNALS_DECLARE_SAVED (name); Declare a variable to save the
195 signal blocking state.
197 SIGNALS_BLOCK (SIGSTOP, name); Block a signal, and save the previous
198 state for restoration later.
200 SIGNALS_RESTORE (name); Restore previous signals.
205 #ifdef HAVE_POSIX_SIGNALS
208 #define SIGNALS_UNBLOCK \
210 sigemptyset (&set); \
211 sigprocmask (SIG_SETMASK, &set, (sigset_t *)NULL); \
214 #define SIGNALS_DECLARE_SAVED(name) sigset_t name
216 #define SIGNALS_BLOCK(SIG, saved) \
218 sigemptyset (&set); \
219 sigaddset (&set, SIG); \
220 sigprocmask (SIG_BLOCK, &set, &saved); \
223 #define SIGNALS_RESTORE(saved) \
224 sigprocmask (SIG_SETMASK, &saved, (sigset_t *)NULL)
227 #else /* HAVE_POSIX_SIGNALS */
228 #ifdef HAVE_BSD_SIGNALS
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)
237 #else /* HAVE_BSD_SIGNALS */
238 /* None of the Above */
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 */
246 #endif /* HAVE_BSD_SIGNALS */
247 #endif /* HAVE_POSIX_SIGNALS */
249 /* End of signal handling definitions. */
250 #endif /* !_RLDEFS_H */