ref: 05d6f166bfbae35f412ac8276b34a61ecfb3a384
parent: 11795725f2ee181399c264d7f2aec213f635891a
author: Ori Bernstein <[email protected]>
date: Tue Sep 10 09:31:16 EDT 2013
Add uname() functionality.
--- a/libstd/sys-linux.myr
+++ b/libstd/sys-linux.myr
@@ -46,6 +46,15 @@
_unused2: uint
;;
+ type utsname = struct
+ system : byte[65]
+ node : byte[65]
+ release : byte[65]
+ version : byte[65]
+ machine : byte[65]
+ domain : byte[65]
+ ;;
+
/* open options */
const Ordonly : fdopt = 0x0
const Owronly : fdopt = 0x1
@@ -414,6 +423,9 @@
const clock_getres : (clk : clock, ts : timespec# -> int32)
const clock_gettime : (clk : clock, ts : timespec# -> int32)
const clock_settime : (clk : clock, ts : timespec# -> int32)
+
+ /* system information */
+ const uname : (buf : utsname# -> int)
;;
/* process management */
@@ -438,6 +450,9 @@
const clock_getres = {clk, ts; -> syscall(Sysclock_getres, clockid(clk), ts) castto(int32)}
const clock_gettime = {clk, ts; -> syscall(Sysclock_gettime, clockid(clk), ts) castto(int32)}
const clock_settime = {clk, ts; -> syscall(Sysclock_settime, clockid(clk), ts) castto(int32)}
+
+/* system information */
+const uname = {buf; -> syscall(Sysuname, buf) castto(int)}
const clockid = {clk
match clk
--- a/libstd/sys-osx.myr
+++ b/libstd/sys-osx.myr
@@ -49,6 +49,14 @@
qspare1 : int64
;;
+ type utsname = struct
+ system : byte[256]
+ node : byte[256]
+ release : byte[256]
+ version : byte[256]
+ machine : byte[256]
+ ;;
+
/* open options */
const Ordonly : fdopt = 0x0
const Owronly : fdopt = 0x1
@@ -458,6 +466,9 @@
const clock_getres : (clk : clock, ts : timespec# -> int)
const clock_gettime : (clk : clock, ts : timespec# -> int)
const clock_settime : (clk : clock, ts : timespec# -> int)
+
+ /* system information */
+ const uname : (buf : utsname# -> int)
;;
/* process control */
@@ -506,3 +517,6 @@
tv.usec = ts.nsec / 1000
-> settimeofday(&tv, 0 castto(timezone#))
}
+
+/* system information */
+const uname = {buf; -> syscall(Sysuname, buf) castto(int)}