C fn definitions on Linux

pull/2871/head
Alexander Medvednikov 2019-11-22 19:00:56 +03:00
parent e9e931fe4a
commit f4fe90ea6d
4 changed files with 14 additions and 3 deletions

View File

@ -85,6 +85,8 @@ fn C.DEFAULT_LT() bool
fn C.DEFAULT_GE() bool fn C.DEFAULT_GE() bool
fn C.isatty() int fn C.isatty() int
fn C.syscall() int

View File

@ -15,6 +15,7 @@ import (
struct C.Display struct C.Display
struct C.Atom struct C.Atom
struct C.Window struct C.Window
fn C.XFree()
fn C.XInitThreads() int fn C.XInitThreads() int
fn C.XCloseDisplay(d &Display) fn C.XCloseDisplay(d &Display)
fn C.XFlush(d &Display) fn C.XFlush(d &Display)

View File

@ -752,12 +752,15 @@ fn on_segfault(f voidptr) {
fn C.getpid() int fn C.getpid() int
fn C.proc_pidpath (int, byteptr, int) 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 { pub fn executable() string {
$if linux { $if linux {
mut result := malloc(MAX_PATH) 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 { if count < 0 {
panic('error reading /proc/self/exe to get exe path') panic('error reading /proc/self/exe to get exe path')
} }

View File

@ -34,10 +34,15 @@ enum Action {
suspend 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 // Toggle raw mode of the terminal by changing its attributes
// Catches SIGUSER (CTRL+C) Signal to reset tty // Catches SIGUSER (CTRL+C) Signal to reset tty
fn (r mut Readline) enable_raw_mode() { 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_tty = false
r.is_raw = false r.is_raw = false
return return