]> granicus.if.org Git - strace/blobdiff - term.c
powerpc64: fix 64-bit process detection on embedded
[strace] / term.c
diff --git a/term.c b/term.c
index 5850e3377fdc14db7fa6d61e06f45a0674084308..43a15c39c02c41a617c9fe265a1969806725d20b 100644 (file)
--- a/term.c
+++ b/term.c
  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- *     $Id$
  */
 
 #include "defs.h"
-
-#ifdef __GLIBC__
-#include <termio.h>
-#endif /* __GLIBC__ */
-#include <termios.h>
+/*
+ * The C library's definition of struct termios might differ from
+ * the kernel one, and we need to use the kernel layout.
+ */
+#include <linux/termios.h>
 #ifdef HAVE_SYS_FILIO_H
-#include <sys/filio.h>
+# include <sys/filio.h>
 #endif
 
-static struct xlat tcxonc_options[] = {
-       { TCOOFF,       "TCOOFF"        },
-       { TCOON,        "TCOON"         },
-       { TCIOFF,       "TCIOFF"        },
-       { TCION,        "TCION"         },
-       { 0,            NULL            },
+static const struct xlat tcxonc_options[] = {
+       XLAT(TCOOFF),
+       XLAT(TCOON),
+       XLAT(TCIOFF),
+       XLAT(TCION),
+       XLAT_END
 };
 
-static struct xlat tcflsh_options[] = {
-       { TCIFLUSH,     "TCIFLUSH"      },
-       { TCOFLUSH,     "TCOFLUSH"      },
-       { TCIOFLUSH,    "TCIOFLUSH"     },
-       { 0,            NULL            },
+#ifdef TCLFLSH
+static const struct xlat tcflsh_options[] = {
+       XLAT(TCIFLUSH),
+       XLAT(TCOFLUSH),
+       XLAT(TCIOFLUSH),
+       XLAT_END
 };
+#endif
 
-static struct xlat baud_options[] = {
-       { B0,           "B0"            },
-       { B50,          "B50"           },
-       { B75,          "B75"           },
-       { B110,         "B110"          },
-       { B134,         "B134"          },
-       { B150,         "B150"          },
-       { B200,         "B200"          },
-       { B300,         "B300"          },
-       { B600,         "B600"          },
-       { B1200,        "B1200"         },
-       { B1800,        "B1800"         },
-       { B2400,        "B2400"         },
-       { B4800,        "B4800"         },
-       { B9600,        "B9600"         },
+static const struct xlat baud_options[] = {
+       XLAT(B0),
+       XLAT(B50),
+       XLAT(B75),
+       XLAT(B110),
+       XLAT(B134),
+       XLAT(B150),
+       XLAT(B200),
+       XLAT(B300),
+       XLAT(B600),
+       XLAT(B1200),
+       XLAT(B1800),
+       XLAT(B2400),
+       XLAT(B4800),
+       XLAT(B9600),
 #ifdef B19200
-       { B19200,       "B19200"        },
+       XLAT(B19200),
 #endif
 #ifdef B38400
-       { B38400,       "B38400"        },
+       XLAT(B38400),
+#endif
+#ifdef B57600
+       XLAT(B57600),
+#endif
+#ifdef B115200
+       XLAT(B115200),
+#endif
+#ifdef B230400
+       XLAT(B230400),
+#endif
+#ifdef B460800
+       XLAT(B460800),
+#endif
+#ifdef B500000
+       XLAT(B500000),
+#endif
+#ifdef B576000
+       XLAT(B576000),
+#endif
+#ifdef B921600
+       XLAT(B921600),
+#endif
+#ifdef B1000000
+       XLAT(B1000000),
+#endif
+#ifdef B1152000
+       XLAT(B1152000),
+#endif
+#ifdef B1500000
+       XLAT(B1500000),
+#endif
+#ifdef B2000000
+       XLAT(B2000000),
+#endif
+#ifdef B2500000
+       XLAT(B2500000),
+#endif
+#ifdef B3000000
+       XLAT(B3000000),
+#endif
+#ifdef B3500000
+       XLAT(B3500000),
+#endif
+#ifdef B4000000
+       XLAT(B4000000),
 #endif
 #ifdef EXTA
-       { EXTA,         "EXTA"          },
+       XLAT(EXTA),
 #endif
 #ifdef EXTB
-       { EXTB,         "EXTB"          },
+       XLAT(EXTB),
 #endif
-       { 0,            NULL            },
+       XLAT_END
 };
 
-static struct xlat modem_flags[] = {
+static const struct xlat modem_flags[] = {
 #ifdef TIOCM_LE
-       { TIOCM_LE,     "TIOCM_LE",     },
+       XLAT(TIOCM_LE),
 #endif
 #ifdef TIOCM_DTR
-       { TIOCM_DTR,    "TIOCM_DTR",    },
+       XLAT(TIOCM_DTR),
 #endif
 #ifdef TIOCM_RTS
-       { TIOCM_RTS,    "TIOCM_RTS",    },
+       XLAT(TIOCM_RTS),
 #endif
 #ifdef TIOCM_ST
-       { TIOCM_ST,     "TIOCM_ST",     },
+       XLAT(TIOCM_ST),
 #endif
 #ifdef TIOCM_SR
-       { TIOCM_SR,     "TIOCM_SR",     },
+       XLAT(TIOCM_SR),
 #endif
 #ifdef TIOCM_CTS
-       { TIOCM_CTS,    "TIOCM_CTS",    },
+       XLAT(TIOCM_CTS),
 #endif
 #ifdef TIOCM_CAR
-       { TIOCM_CAR,    "TIOCM_CAR",    },
+       XLAT(TIOCM_CAR),
 #endif
 #ifdef TIOCM_CD
-       { TIOCM_CD,     "TIOCM_CD",     },
+       XLAT(TIOCM_CD),
 #endif
 #ifdef TIOCM_RNG
-       { TIOCM_RNG,    "TIOCM_RNG",    },
+       XLAT(TIOCM_RNG),
 #endif
 #ifdef TIOCM_RI
-       { TIOCM_RI,     "TIOCM_RI",     },
+       XLAT(TIOCM_RI),
 #endif
 #ifdef TIOCM_DSR
-       { TIOCM_DSR,    "TIOCM_DSR",    },
+       XLAT(TIOCM_DSR),
 #endif
-       { 0,            NULL,           },
+       XLAT_END
 };
 
-
-int
-term_ioctl(tcp, code, arg)
-struct tcb *tcp;
-long code, arg;
+int term_ioctl(struct tcb *tcp, long code, long arg)
 {
        struct termios tios;
        struct termio tio;
@@ -150,7 +191,7 @@ long code, arg;
                if (!verbose(tcp) || umove(tcp, arg, &tios) < 0)
                        return 0;
                if (abbrev(tcp)) {
-                       tprintf(", {");
+                       tprints(", {");
                        printxval(baud_options, tios.c_cflag & CBAUD, "B???");
                        tprintf(" %sopost %sisig %sicanon %secho ...}",
                                (tios.c_oflag & OPOST) ? "" : "-",
@@ -163,9 +204,7 @@ long code, arg;
                        (long) tios.c_iflag, (long) tios.c_oflag);
                tprintf("c_cflags=%#lx, c_lflags=%#lx, ",
                        (long) tios.c_cflag, (long) tios.c_lflag);
-#ifndef SVR4
                tprintf("c_line=%u, ", tios.c_line);
-#endif
                if (!(tios.c_lflag & ICANON))
                        tprintf("c_cc[VMIN]=%d, c_cc[VTIME]=%d, ",
                                tios.c_cc[VMIN], tios.c_cc[VTIME]);
@@ -186,7 +225,7 @@ long code, arg;
                if (!verbose(tcp) || umove(tcp, arg, &tio) < 0)
                        return 0;
                if (abbrev(tcp)) {
-                       tprintf(", {");
+                       tprints(", {");
                        printxval(baud_options, tio.c_cflag & CBAUD, "B???");
                        tprintf(" %sopost %sisig %sicanon %secho ...}",
                                (tio.c_oflag & OPOST) ? "" : "-",
@@ -243,15 +282,23 @@ long code, arg;
 #endif
 
        /* ioctls with a direct decodable arg */
-
+#ifdef TCXONC
        case TCXONC:
-               tprintf(", ");
+               tprints(", ");
                printxval(tcxonc_options, arg, "TC???");
                return 1;
+#endif
+#ifdef TCLFLSH
        case TCFLSH:
-               tprintf(", ");
+               tprints(", ");
                printxval(tcflsh_options, arg, "TC???");
                return 1;
+#endif
+#ifdef TIOCSCTTY
+       case TIOCSCTTY:
+               tprintf(", %ld", arg);
+               return 1;
+#endif
 
        /* ioctls with an indirect parameter displayed as modem flags */
 
@@ -260,12 +307,11 @@ long code, arg;
        case TIOCMBIS:
        case TIOCMBIC:
        case TIOCMSET:
-               if (umove(tcp, arg, &arg) < 0)
+               if (umove(tcp, arg, &i) < 0)
                        return 0;
-               tprintf(", [");
-               if (!printflags(modem_flags, arg))
-                       tprintf("0");
-               tprintf("]");
+               tprints(", [");
+               printflags(modem_flags, i, "TIOCM_???");
+               tprints("]");
                return 1;
 #endif /* TIOCMGET */
 
@@ -331,32 +377,27 @@ long code, arg;
 #ifdef TIOCSINTR
        case TIOCSINTR:
 #endif
-               tprintf(", ");
-               printnum(tcp, arg, "%d");
-               return 1;
-
-#if 0
-       /* ioctls with an indirect parameter displayed in hex */
-
-               tprintf(", ");
-               printnum(tcp, arg, "%#x");
-               return 1;
+#ifdef TIOCSPTLCK
+       case TIOCSPTLCK:
 #endif
+#ifdef TIOCGPTN
+       case TIOCGPTN:
+#endif
+               tprints(", ");
+               printnum_int(tcp, arg, "%d");
+               return 1;
 
        /* ioctls with an indirect parameter displayed as a char */
 
 #ifdef TIOCSTI
        case TIOCSTI:
 #endif
-               tprintf(", ");
+               tprints(", ");
                printstr(tcp, arg, 1);
                return 1;
 
        /* ioctls with no parameters */
 
-#ifdef TIOCSCTTY
-       case TIOCSCTTY:
-#endif
 #ifdef TIOCNOTTY
        case TIOCNOTTY:
 #endif
@@ -377,4 +418,3 @@ long code, arg;
                return 0;
        }
 }
-