From 25f974f062f244ffdfba52ed11456ce1ac9e1150 Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Mon, 15 Dec 2014 18:06:48 +0100 Subject: [PATCH] linux: use Syscall for ioctl calls --- serial_linux.go | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/serial_linux.go b/serial_linux.go index d06fa60..e8a1662 100644 --- a/serial_linux.go +++ b/serial_linux.go @@ -32,11 +32,6 @@ package serial const tcflag_t FIXED_PAR_FLAG = 0; #endif -// ioctl call is not available through syscall package -//int ioctl_wrapper(int d, unsigned long request) { -// return ioctl(d, request); -//} - //int fcntl_wrapper(int fd, int cmd, int arg) { // return fcntl(fd, cmd, arg); //} @@ -55,22 +50,21 @@ void setTIOCNXCL(int handle) { #endif } -//int selectRead(int handle) { -// fd_set rfds; -// FD_ZERO(&rfds); -// FD_SET(handle, &rfds); -// int ret = select(handle+1, &rfds, NULL, NULL, NULL); -// if (ret==-1) -// return -1; -// else -// return 0; -//} - */ import "C" import "io/ioutil" import "regexp" import "syscall" +import "unsafe" + +//sys ioctl(fd int, req uint64, data uintptr) (err error) +func ioctl(fd int, req uint64, data uintptr) (err error) { + _, _, e1 := syscall.Syscall(syscall.SYS_IOCTL, uintptr(fd), uintptr(req), uintptr(data)) + if e1 != 0 { + err = e1 + } + return +} // native syscall wrapper functions