Skip to content

Commit

Permalink
unix: support TIOCGETA on GNU/Hurd
Browse files Browse the repository at this point in the history
Add minimal support for GNU/Hurd to allow building third party packages
which detect terminal support.

Change-Id: Ia13fe8e9e4880e8ab062f9a2efb581320637f017
GitHub-Last-Rev: f612efb
GitHub-Pull-Request: #144
Reviewed-on: https://go-review.googlesource.com/c/sys/+/459895
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
  • Loading branch information
sthibaul authored and gopherbot committed Dec 31, 2022
1 parent 3086868 commit b360406
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 6 deletions.
4 changes: 2 additions & 2 deletions unix/gccgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build gccgo && !aix
// +build gccgo,!aix
//go:build gccgo && !aix && !hurd
// +build gccgo,!aix,!hurd

package unix

Expand Down
4 changes: 2 additions & 2 deletions unix/gccgo_c.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// +build gccgo
// +build !aix
// +build gccgo,!hurd
// +build !aix,!hurd

#include <errno.h>
#include <stdint.h>
Expand Down
4 changes: 2 additions & 2 deletions unix/ioctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris
// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris
//go:build aix || darwin || dragonfly || freebsd || hurd || linux || netbsd || openbsd || solaris
// +build aix darwin dragonfly freebsd hurd linux netbsd openbsd solaris

package unix

Expand Down
23 changes: 23 additions & 0 deletions unix/syscall_hurd.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright 2022 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build hurd
// +build hurd

package unix

/*
#include <stdint.h>
int ioctl(int, unsigned long int, uintptr_t);
*/
import "C"

func ioctl(fd int, req uint, arg uintptr) (err error) {
r0, er := C.ioctl(C.int(fd), C.ulong(req), C.uintptr_t(arg))
if r0 == -1 && er != nil {
err = er
}
return
}

29 changes: 29 additions & 0 deletions unix/syscall_hurd_386.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright 2022 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build 386 && hurd
// +build 386,hurd

package unix

const (
TIOCGETA = 0x62251713
)

type Winsize struct {
Row uint16
Col uint16
Xpixel uint16
Ypixel uint16
}

type Termios struct {
Iflag uint32
Oflag uint32
Cflag uint32
Lflag uint32
Cc [20]uint8
Ispeed int32
Ospeed int32
}

0 comments on commit b360406

Please sign in to comment.