home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / D / GDB / GDB-4.13 / GDB-4 / gdb-4.13 / readline / rldefs.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-05-04  |  7.4 KB  |  254 lines

  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. /* Posix macro to check file in statbuf for file-ness.
  155.    This requires that <sys/stat.h> be included before this test. */
  156. #if defined (S_IFREG) && !defined (S_ISREG)
  157. #define S_ISREG(m) (((m)&S_IFMT) == S_IFREG)
  158. #endif
  159.  
  160. #if !defined (strchr) && !defined (__STDC__)
  161. extern char *strchr (), *strrchr ();
  162. #endif /* !strchr && !__STDC__ */
  163.  
  164. #if defined (HAVE_VARARGS_H)
  165. #  include <varargs.h>
  166. #endif /* HAVE_VARARGS_H */
  167.  
  168. /* This definition is needed by readline.c, rltty.c, and signals.c. */
  169. /* If on, then readline handles signals in a way that doesn't screw. */
  170. #define HANDLE_SIGNALS
  171.  
  172. #if !defined (emacs_mode)
  173. #  define no_mode -1
  174. #  define vi_mode 0
  175. #  define emacs_mode 1
  176. #endif
  177.  
  178. /* Define some macros for dealing with assorted signalling disciplines.
  179.  
  180.    These macros provide a way to use signal blocking and disabling
  181.    without smothering your code in a pile of #ifdef's.
  182.  
  183.    SIGNALS_UNBLOCK;            Stop blocking all signals.
  184.  
  185.    {
  186.      SIGNALS_DECLARE_SAVED (name);    Declare a variable to save the 
  187.                     signal blocking state.
  188.     ...
  189.      SIGNALS_BLOCK (SIGSTOP, name);    Block a signal, and save the previous
  190.                     state for restoration later.
  191.     ...
  192.      SIGNALS_RESTORE (name);        Restore previous signals.
  193.    }
  194.  
  195. */
  196.  
  197. #ifdef HAVE_POSIX_SIGNALS
  198.                             /* POSIX signals */
  199.  
  200. #define    SIGNALS_UNBLOCK \
  201.       do { sigset_t set;    \
  202.     sigemptyset (&set);    \
  203.     sigprocmask (SIG_SETMASK, &set, (sigset_t *)NULL);    \
  204.       } while (0)
  205.  
  206. #define    SIGNALS_DECLARE_SAVED(name)    sigset_t name
  207.  
  208. #define    SIGNALS_BLOCK(SIG, saved)    \
  209.     do { sigset_t set;        \
  210.       sigemptyset (&set);        \
  211.       sigaddset (&set, SIG);    \
  212.       sigprocmask (SIG_BLOCK, &set, &saved);    \
  213.     } while (0)
  214.  
  215. #define    SIGNALS_RESTORE(saved)        \
  216.   sigprocmask (SIG_SETMASK, &saved, (sigset_t *)NULL)
  217.  
  218.  
  219. #else    /* HAVE_POSIX_SIGNALS */
  220. #ifdef HAVE_BSD_SIGNALS
  221.                             /* BSD signals */
  222.  
  223. #define    SIGNALS_UNBLOCK            sigsetmask (0)
  224. #define    SIGNALS_DECLARE_SAVED(name)    int name
  225. #define    SIGNALS_BLOCK(SIG, saved)    saved = sigblock (sigmask (SIG))
  226. #define    SIGNALS_RESTORE(saved)        sigsetmask (saved)
  227.  
  228.  
  229. #else  /* HAVE_BSD_SIGNALS */
  230.                             /* None of the Above */
  231.  
  232. #define    SIGNALS_UNBLOCK            /* nothing */
  233. #define    SIGNALS_DECLARE_SAVED(name)    /* nothing */
  234. #define    SIGNALS_BLOCK(SIG, saved)    /* nothing */
  235. #define    SIGNALS_RESTORE(saved)        /* nothing */
  236.  
  237.  
  238. #endif /* HAVE_BSD_SIGNALS */
  239. #endif /* HAVE_POSIX_SIGNALS */
  240.  
  241. #if !defined (strchr)
  242. extern char *strchr ();
  243. #endif
  244. #if !defined (strrchr)
  245. extern char *strrchr ();
  246. #endif
  247. #ifdef __STDC__
  248. #include <stddef.h>
  249. extern size_t strlen (const char *s);
  250. #endif  /* __STDC__ */
  251.  
  252. /*  End of signal handling definitions.  */
  253. #endif /* !_RLDEFS_H */
  254.