aboutsummaryrefslogtreecommitdiffstats
path: root/gdb-common_linux.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_linux.go
Initial commitv0.0.1
Signed-off-by: Sebastien Douheret <sebastien.douheret@iot.bzh>
Diffstat (limited to 'gdb-common_linux.go')
-rw-r--r--gdb-common_linux.go37
1 files changed, 37 insertions, 0 deletions
diff --git a/gdb-common_linux.go b/gdb-common_linux.go
new file mode 100644
index 0000000..a2f4bf6
--- /dev/null
+++ b/gdb-common_linux.go
@@ -0,0 +1,37 @@
+package main
+
+import (
+ "os"
+ "syscall"
+ "unsafe"
+)
+
+const syscallEBADE = syscall.EBADE
+
+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
+}