aboutsummaryrefslogtreecommitdiffstats
path: root/gdb-common_darwin.go
diff options
context:
space:
mode:
authorSebastien Douheret <sebastien.douheret@iot.bzh>2017-08-07 08:49:25 +0200
committerSebastien Douheret <sebastien.douheret@iot.bzh>2017-08-07 18:01:35 +0200
commit60974e66c57cacdc2483d74718c4bb0a993d2183 (patch)
tree2722369e9cf2c7a3fb499011030fc4718f31e30f /gdb-common_darwin.go
Initial commitv0.0.1
Signed-off-by: Sebastien Douheret <sebastien.douheret@iot.bzh>
Diffstat (limited to 'gdb-common_darwin.go')
-rw-r--r--gdb-common_darwin.go42
1 files changed, 42 insertions, 0 deletions
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
+}