shithub: mc

Download patch

ref: 1252169ce7027d50158d5a12bad0a2a1b92ce3f7
parent: 1f07ea309194e550b726d4abc4295876854c3781
author: Ori Bernstein <[email protected]>
date: Thu Aug 29 15:27:51 EDT 2013

Compile libstd on OSX

    Some bugs had crept in over time.

--- a/libstd/now.myr
+++ b/libstd/now.myr
@@ -9,9 +9,13 @@
 /* milliseconds since epoch */
 const now = {
 	var tm
-
+	var sec
+	var nsec
+	
+	sec = tm.sec
+	nsec = tm.nsec castto(uint64)
 	if clock_gettime(`Clockrealtime, &tm) == 0
-		-> (tm.sec*1000 + tm.nsec / (1000*1000)) castto(time)
+		-> (sec*1000 + nsec/(1000*1000)) castto(time)
 	else
 		-> -1
 	;;
--- a/libstd/sys-linux.myr
+++ b/libstd/sys-linux.myr
@@ -411,9 +411,9 @@
 	const mmap	: (addr:byte#, len:size, prot:mprot, flags:mopt, fd:fd, off:off -> byte#)
 
 	/* time */
-	const clock_getres	: (clk : clock, ts : timespec# -> int32)
-	const clock_gettime	: (clk : clock, ts : timespec# -> int32)
-	const clock_settime	: (clk : clock, ts : timespec# -> int32)
+	const clock_getres	: (clk : clock, ts : timespec# -> int)
+	const clock_gettime	: (clk : clock, ts : timespec# -> int)
+	const clock_settime	: (clk : clock, ts : timespec# -> int)
 ;;
 
 /* process management */
--- a/libstd/sys-osx.myr
+++ b/libstd/sys-osx.myr
@@ -452,12 +452,12 @@
 	const mmap	: (addr:byte#, len:size, prot:mprot, flags:mopt, fd:fd, off:off -> byte#)
 
 	/* time */
-	const gettimeofday	: (tv : timeval#, tz : tz : timezone# -> int)
-	const settimeofday	: (tv : timeval#, tz : tz : timezone# -> int)
+	const gettimeofday	: (tv : timeval#, tz : timezone# -> int)
+	const settimeofday	: (tv : timeval#, tz : timezone# -> int)
 	/* faked with gettimeofday */
-	const clock_getres	: (clk : clock, ts : timespec# -> int32)
-	const clock_gettime	: (clk : clock, ts : timespec# -> int32)
-	const clock_settime	: (clk : clock, ts : timespec# -> int32)
+	const clock_getres	: (clk : clock, ts : timespec# -> int)
+	const clock_gettime	: (clk : clock, ts : timespec# -> int)
+	const clock_settime	: (clk : clock, ts : timespec# -> int)
 ;;
 
 /* process control */
@@ -479,21 +479,21 @@
 const mmap	= {addr, len, prot, flags, fd, off;	-> syscall(Sysmmap, addr, len, prot, flags, fd, off) castto(byte#)}
 
 /* time */
-const gettimeofday = {tv, tz;	-> syscall(Sysgettimeofday, tv, tz)}
-const settimeofday = {tv, tz;	-> syscall(Syssettimeofday, tv, tz)}
+const gettimeofday = {tv, tz;	-> syscall(Sysgettimeofday, tv, tz) castto(int)}
+const settimeofday = {tv, tz;	-> syscall(Syssettimeofday, tv, tz) castto(int)}
+
 /* faked  with gettimeofday */
 const clock_getres = {clk, ts
-	var ts
 	ts.sec = 0
 	ts.nsec = 1000*10 /* 10ms is reasonable resolution */
+	-> 0
 }
 
 const clock_gettime = {clk, ts
-	var ts
 	var tv
 	var ret
 
-	ret = gettimeofday(&tv, 0 castto(void#))
+	ret = gettimeofday(&tv, 0 castto(timezone#))
 	ts.sec = tv.sec
 	ts.nsec = tv.usec * 1000
 	-> ret
@@ -503,6 +503,6 @@
 	var tv
 	
 	tv.sec = ts.sec
-	tv.usec = tv.nsec / 1000
-	-> settimeofday(&tv, 0 castto(void#)
+	tv.usec = ts.nsec / 1000
+	-> settimeofday(&tv, 0 castto(timezone#))
 }