• Nick Patavalis's avatar
    unix: Fix Termios type definition · 2bacc619
    Nick Patavalis authored
    - types_linux.go: Use the kernel-defined termios structure, *not* the
      LIBC-defined one. The LIBC termios structure cannot be safely used
      to do tty-related ioctls on all architectures (e.g. ppc64,
      ppc64le). The kernel termios structure, and the associated
      macros/constants, are defined in: "asm/termbits.h" which is included
      by "linux/termios.h". The LIBC termios structure is defined in
      "bits/termios.h" which is included by "termios.h". These structures
      are *not* the same.
    
      For systems that have both "struct termios" and "struct termios2"
      use the latter to define the Termios type. This is ok, since the
      "struct termios2" memory layout is compatible with "struct termios"
      (with a couple of fields added at the end). This way, type Termios
      can be used with both: the "old-style" TCSETS[FW], TCGETS ioctls,
      *and* with the new TCSETS[FW]2, TCGETS2 ioctls. The new ioctls allow
      configuring arbitrary baudrates.
    
      The new Termios definitions (kernel-compatible) have the same fields
      as the old ones (LIBC-derived) so there should be no user-code
      compatibility issues.
    
    Change-Id: I3c1484c60f45b28e13404765c01616c33063afd5
    Reviewed-on: https://go-review.googlesource.com/17185Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
    Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
    2bacc619
ztypes_linux_ppc64.go 10.3 KB