From f4fe90ea6db587096e1b56981619b93bc6fb4dbe Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Fri, 22 Nov 2019 19:00:56 +0300 Subject: [PATCH] C fn definitions on Linux --- vlib/builtin/cfns.v | 2 ++ vlib/clipboard/clipboard_linux.v | 1 + vlib/os/os.v | 7 +++++-- vlib/readline/readline_linux.v | 7 ++++++- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/vlib/builtin/cfns.v b/vlib/builtin/cfns.v index 862a7d1470..570bc21038 100644 --- a/vlib/builtin/cfns.v +++ b/vlib/builtin/cfns.v @@ -85,6 +85,8 @@ fn C.DEFAULT_LT() bool fn C.DEFAULT_GE() bool fn C.isatty() int +fn C.syscall() int + diff --git a/vlib/clipboard/clipboard_linux.v b/vlib/clipboard/clipboard_linux.v index 0f6e2bef57..fa91e1bb53 100644 --- a/vlib/clipboard/clipboard_linux.v +++ b/vlib/clipboard/clipboard_linux.v @@ -15,6 +15,7 @@ import ( struct C.Display struct C.Atom struct C.Window +fn C.XFree() fn C.XInitThreads() int fn C.XCloseDisplay(d &Display) fn C.XFlush(d &Display) diff --git a/vlib/os/os.v b/vlib/os/os.v index 546dd798a5..2e12419f6f 100644 --- a/vlib/os/os.v +++ b/vlib/os/os.v @@ -752,12 +752,15 @@ fn on_segfault(f voidptr) { fn C.getpid() int fn C.proc_pidpath (int, byteptr, int) int +fn C.readlink() int -// executable return the path name of the executable that started the current process. + +// executable returns the path name of the executable that started the current +// process. pub fn executable() string { $if linux { mut result := malloc(MAX_PATH) - count := int(C.readlink('/proc/self/exe', result, MAX_PATH )) + count := C.readlink('/proc/self/exe', result, MAX_PATH) if count < 0 { panic('error reading /proc/self/exe to get exe path') } diff --git a/vlib/readline/readline_linux.v b/vlib/readline/readline_linux.v index 759df0cf04..161708199f 100644 --- a/vlib/readline/readline_linux.v +++ b/vlib/readline/readline_linux.v @@ -34,10 +34,15 @@ enum Action { suspend } +fn C.tcgetattr() int +fn C.tcsetattr() int +fn C.ioctl() int +fn C.raise() + // Toggle raw mode of the terminal by changing its attributes // Catches SIGUSER (CTRL+C) Signal to reset tty fn (r mut Readline) enable_raw_mode() { - if ( C.tcgetattr(0, &r.orig_termios) == -1 ) { + if C.tcgetattr(0, &r.orig_termios) == -1 { r.is_tty = false r.is_raw = false return