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(_WIN32)
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 #define ScreenCols() 80
62 #define ScreenRows() 24
63 #define ScreenSetCursor() abort();
64 #define ScreenGetCursor() abort();
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 # if defined (USG) || defined (hpux) || defined (__hpux) || defined (Xenix) || defined (sgi) || defined (DGUX)
70 # undef NEW_TTY_DRIVER
71 # define TERMIO_TTY_DRIVER
76 # endif /* USG || hpux || Xenix || sgi || DUGX */
77 #endif /* !_POSIX_VERSION */
79 /* Posix systems use termios and the Posix signal functions. */
80 #if defined (_POSIX_VERSION)
81 # if !defined (TERMIOS_MISSING)
82 # undef NEW_TTY_DRIVER
83 # define TERMIOS_TTY_DRIVER
85 # endif /* !TERMIOS_MISSING */
86 # define HAVE_POSIX_SIGNALS
87 # if !defined (O_NDELAY)
88 # define O_NDELAY O_NONBLOCK /* Posix-style non-blocking i/o */
89 # endif /* O_NDELAY */
90 #endif /* _POSIX_VERSION */
92 /* System V.3 machines have the old 4.1 BSD `reliable' signal interface. */
93 #if !defined (HAVE_BSD_SIGNALS) && !defined (HAVE_POSIX_SIGNALS)
95 # if !defined (HAVE_USG_SIGHOLD)
96 # define HAVE_USG_SIGHOLD
97 # endif /* !HAVE_USG_SIGHOLD */
99 #endif /* !HAVE_BSD_SIGNALS && !HAVE_POSIX_SIGNALS */
101 /* Other (BSD) machines use sgtty. */
102 #if defined (NEW_TTY_DRIVER)
106 /* Define _POSIX_VDISABLE if we are not using the `new' tty driver and
107 it is not already defined. It is used both to determine if a
108 special character is disabled and to disable certain special
109 characters. Posix systems should set to 0, USG systems to -1. */
110 #if !defined (NEW_TTY_DRIVER) && !defined (_POSIX_VDISABLE)
111 # if defined (_POSIX_VERSION)
112 # define _POSIX_VDISABLE 0
113 # else /* !_POSIX_VERSION */
114 # define _POSIX_VDISABLE -1
115 # endif /* !_POSIX_VERSION */
116 #endif /* !NEW_TTY_DRIVER && !_POSIX_VDISABLE */
119 # define D_NAMLEN(d) strlen ((d)->d_name)
122 #if !defined (SHELL) && (defined (_POSIX_VERSION) || defined (USGr3))
123 # if !defined (HAVE_DIRENT_H)
124 # define HAVE_DIRENT_H
125 # endif /* !HAVE_DIRENT_H */
126 #endif /* !SHELL && (_POSIX_VERSION || USGr3) */
128 #if defined (HAVE_DIRENT_H)
130 # if !defined (direct)
131 # define direct dirent
132 # endif /* !direct */
133 # define D_NAMLEN(d) strlen ((d)->d_name)
134 #else /* !HAVE_DIRENT_H */
135 # define D_NAMLEN(d) ((d)->d_namlen)
138 # include <sys/ndir.h>
139 # else /* !Xenix (but USG...) */
143 # include <sys/dir.h>
145 #endif /* !HAVE_DIRENT_H */
148 #if defined (USG) && defined (TIOCGWINSZ) && !defined (Linux)
150 /* AIX 4.x seems to reference struct uio within a prototype
151 in stream.h, but doesn't cause the uio include file to
153 # include <sys/uio.h>
155 # include <sys/stream.h>
156 # if defined (HAVE_SYS_PTEM_H)
157 # include <sys/ptem.h>
158 # endif /* HAVE_SYS_PTEM_H */
159 # if defined (HAVE_SYS_PTE_H)
160 # include <sys/pte.h>
161 # endif /* HAVE_SYS_PTE_H */
162 #endif /* USG && TIOCGWINSZ && !Linux */
164 /* Posix macro to check file in statbuf for directory-ness.
165 This requires that <sys/stat.h> be included before this test. */
166 #if defined (S_IFDIR) && !defined (S_ISDIR)
167 #define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR)
169 /* Posix macro to check file in statbuf for file-ness.
170 This requires that <sys/stat.h> be included before this test. */
171 #if defined (S_IFREG) && !defined (S_ISREG)
172 #define S_ISREG(m) (((m)&S_IFMT) == S_IFREG)
175 #if !defined (strchr) && !defined (__STDC__)
176 extern char *strchr (), *strrchr ();
177 #endif /* !strchr && !__STDC__ */
179 #if defined (HAVE_VARARGS_H)
180 # include <varargs.h>
181 #endif /* HAVE_VARARGS_H */
183 /* This definition is needed by readline.c, rltty.c, and signals.c. */
184 /* If on, then readline handles signals in a way that doesn't screw. */
185 #define HANDLE_SIGNALS
187 #if defined(_WIN32) || defined(__MSDOS__)
188 #undef HANDLE_SIGNALS
192 #if !defined (emacs_mode)
195 # define emacs_mode 1
198 /* Define some macros for dealing with assorted signalling disciplines.
200 These macros provide a way to use signal blocking and disabling
201 without smothering your code in a pile of #ifdef's.
203 SIGNALS_UNBLOCK; Stop blocking all signals.
206 SIGNALS_DECLARE_SAVED (name); Declare a variable to save the
207 signal blocking state.
209 SIGNALS_BLOCK (SIGSTOP, name); Block a signal, and save the previous
210 state for restoration later.
212 SIGNALS_RESTORE (name); Restore previous signals.
217 #ifdef HAVE_POSIX_SIGNALS
220 #define SIGNALS_UNBLOCK \
222 sigemptyset (&set); \
223 sigprocmask (SIG_SETMASK, &set, (sigset_t *)NULL); \
226 #define SIGNALS_DECLARE_SAVED(name) sigset_t name
228 #define SIGNALS_BLOCK(SIG, saved) \
230 sigemptyset (&set); \
231 sigaddset (&set, SIG); \
232 sigprocmask (SIG_BLOCK, &set, &saved); \
235 #define SIGNALS_RESTORE(saved) \
236 sigprocmask (SIG_SETMASK, &saved, (sigset_t *)NULL)
239 #else /* HAVE_POSIX_SIGNALS */
240 #ifdef HAVE_BSD_SIGNALS
243 #define SIGNALS_UNBLOCK sigsetmask (0)
244 #define SIGNALS_DECLARE_SAVED(name) int name
245 #define SIGNALS_BLOCK(SIG, saved) saved = sigblock (sigmask (SIG))
246 #define SIGNALS_RESTORE(saved) sigsetmask (saved)
249 #else /* HAVE_BSD_SIGNALS */
250 /* None of the Above */
252 #define SIGNALS_UNBLOCK /* nothing */
253 #define SIGNALS_DECLARE_SAVED(name) /* nothing */
254 #define SIGNALS_BLOCK(SIG, saved) /* nothing */
255 #define SIGNALS_RESTORE(saved) /* nothing */
258 #endif /* HAVE_BSD_SIGNALS */
259 #endif /* HAVE_POSIX_SIGNALS */
261 #if !defined (strchr)
262 extern char *strchr ();
264 #if !defined (strrchr)
265 extern char *strrchr ();
269 extern size_t strlen (const char *s);
270 #endif /* __STDC__ */
272 /* End of signal handling definitions. */
273 #endif /* !_RLDEFS_H */