| 1 | /* Common terminal interface definitions for GDB and gdbserver. |
| 2 | Copyright (C) 1986-2017 Free Software Foundation, Inc. |
| 3 | |
| 4 | This file is part of GDB. |
| 5 | |
| 6 | This program is free software; you can redistribute it and/or modify |
| 7 | it under the terms of the GNU General Public License as published by |
| 8 | the Free Software Foundation; either version 3 of the License, or |
| 9 | (at your option) any later version. |
| 10 | |
| 11 | This program is distributed in the hope that it will be useful, |
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | GNU General Public License for more details. |
| 15 | |
| 16 | You should have received a copy of the GNU General Public License |
| 17 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
| 18 | |
| 19 | #ifndef GDB_TERMIOS_H |
| 20 | #define GDB_TERMIOS_H |
| 21 | |
| 22 | /* If we're using autoconf, it will define HAVE_TERMIOS_H, |
| 23 | HAVE_TERMIO_H and HAVE_SGTTY_H for us. One day we can rewrite |
| 24 | ser-unix.c and inflow.c to inspect those names instead of |
| 25 | HAVE_TERMIOS, HAVE_TERMIO and the implicit HAVE_SGTTY (when neither |
| 26 | HAVE_TERMIOS or HAVE_TERMIO is set). Until then, make sure that |
| 27 | nothing has already defined the one of the names, and do the right |
| 28 | thing. */ |
| 29 | |
| 30 | #if !defined (HAVE_TERMIOS) && !defined(HAVE_TERMIO) && !defined(HAVE_SGTTY) |
| 31 | #if defined(HAVE_TERMIOS_H) |
| 32 | #define HAVE_TERMIOS |
| 33 | #else /* ! defined (HAVE_TERMIOS_H) */ |
| 34 | #if defined(HAVE_TERMIO_H) |
| 35 | #define HAVE_TERMIO |
| 36 | #else /* ! defined (HAVE_TERMIO_H) */ |
| 37 | #if defined(HAVE_SGTTY_H) |
| 38 | #define HAVE_SGTTY |
| 39 | #endif /* ! defined (HAVE_SGTTY_H) */ |
| 40 | #endif /* ! defined (HAVE_TERMIO_H) */ |
| 41 | #endif /* ! defined (HAVE_TERMIOS_H) */ |
| 42 | #endif /* !defined (HAVE_TERMIOS) && !defined (HAVE_TERMIO) && |
| 43 | !defined (HAVE_SGTTY) */ |
| 44 | |
| 45 | #if defined(HAVE_TERMIOS) |
| 46 | #include <termios.h> |
| 47 | #endif |
| 48 | |
| 49 | #if !defined(_WIN32) && !defined (HAVE_TERMIOS) |
| 50 | |
| 51 | /* Define a common set of macros -- BSD based -- and redefine whatever |
| 52 | the system offers to make it look like that. FIXME: serial.h and |
| 53 | ser-*.c deal with this in a much cleaner fashion; as soon as stuff |
| 54 | is converted to use them, can get rid of this crap. */ |
| 55 | |
| 56 | #ifdef HAVE_TERMIO |
| 57 | |
| 58 | #include <termio.h> |
| 59 | |
| 60 | #undef TIOCGETP |
| 61 | #define TIOCGETP TCGETA |
| 62 | #undef TIOCSETN |
| 63 | #define TIOCSETN TCSETA |
| 64 | #undef TIOCSETP |
| 65 | #define TIOCSETP TCSETAF |
| 66 | #define TERMINAL struct termio |
| 67 | |
| 68 | #else /* sgtty */ |
| 69 | |
| 70 | #include <fcntl.h> |
| 71 | #include <sgtty.h> |
| 72 | #include <sys/ioctl.h> |
| 73 | #define TERMINAL struct sgttyb |
| 74 | |
| 75 | #endif /* sgtty */ |
| 76 | #endif |
| 77 | |
| 78 | #endif /* ! GDB_TERMIOS_H */ |