From 60974e66c57cacdc2483d74718c4bb0a993d2183 Mon Sep 17 00:00:00 2001 From: Sebastien Douheret Date: Mon, 7 Aug 2017 08:49:25 +0200 Subject: Initial commit Signed-off-by: Sebastien Douheret --- gdb-common_darwin.go | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 gdb-common_darwin.go (limited to 'gdb-common_darwin.go') diff --git a/gdb-common_darwin.go b/gdb-common_darwin.go new file mode 100644 index 0000000..d167c5d --- /dev/null +++ b/gdb-common_darwin.go @@ -0,0 +1,42 @@ +package main + +import ( + "os" + "syscall" + "unsafe" +) + +const ( + syscallEBADE = syscall.EBADEXEC + + syscall_TCGETS = 0x402c7413 + syscall_TCSETS = 0x802c7414 +) + +func fcntl(fd uintptr, cmd int, arg int) (val int, err error) { + r, _, e := syscall.Syscall(syscall.SYS_FCNTL, fd, uintptr(cmd), + uintptr(arg)) + val = int(r) + if e != 0 { + err = e + } + return +} + +func tcsetattr(fd uintptr, termios *syscall.Termios) error { + r, _, e := syscall.Syscall(syscall.SYS_IOCTL, + fd, uintptr(syscall_TCSETS), uintptr(unsafe.Pointer(termios))) + if r != 0 { + return os.NewSyscallError("SYS_IOCTL", e) + } + return nil +} + +func tcgetattr(fd uintptr, termios *syscall.Termios) error { + r, _, e := syscall.Syscall(syscall.SYS_IOCTL, + fd, uintptr(syscall_TCGETS), uintptr(unsafe.Pointer(termios))) + if r != 0 { + return os.NewSyscallError("SYS_IOCTL", e) + } + return nil +} -- cgit 1.2.3-korg