authorgravatar for tgschultz@gmail.comtgschultz <tgschultz@gmail.com> 2018-04-18 17:43:35-05:00
committergravatar for tgschultz@gmail.comtgschultz <tgschultz@gmail.com> 2018-04-18 17:43:35-05:00
log7cfe328a16ef0d1436d8eb37980d6ebf6908a0d8
tree94043146d9fcf4a56d00c8ac83119651c34c6195
parentbf9cf28322bf19aef72cbc5876e2ca083f762d7c

fixed typos.


2 files changed, 11 insertions(+), 11 deletions(-)

std/os/linux/index.zig+1-1
...@@ -511,7 +511,7 @@ pub fn gettimeofday(tv: &timeval, tz: &timezone) usize {...@@ -511,7 +511,7 @@ pub fn gettimeofday(tv: &timeval, tz: &timezone) usize {
511 return syscall2(SYS_gettimeofday, @ptrToInt(tv), @ptrToInt(tz));511 return syscall2(SYS_gettimeofday, @ptrToInt(tv), @ptrToInt(tz));
512}512}
513513
514pub fn settimeofdat(tv: &const timeval, tz: &const timezone) usize {514pub fn settimeofday(tv: &const timeval, tz: &const timezone) usize {
515 return syscall2(SYS_settimeofday, @ptrToInt(tv), @ptrToInt(tz));515 return syscall2(SYS_settimeofday, @ptrToInt(tv), @ptrToInt(tz));
516}516}
517517
std/os/time.zig+10-10
...@@ -52,18 +52,18 @@ pub fn posixSleep(seconds: u63, nanoseconds: u63) void {...@@ -52,18 +52,18 @@ pub fn posixSleep(seconds: u63, nanoseconds: u63) void {
5252
53/// Get the posix timestamp, UTC, in seconds53/// Get the posix timestamp, UTC, in seconds
54pub fn timestamp() u64 {54pub fn timestamp() u64 {
55 return @divFloor(miliTimestamp(), ms_per_s);55 return @divFloor(milliTimestamp(), ms_per_s);
56}56}
5757
58/// Get the posix timestamp, UTC, in nanoseconds58/// Get the posix timestamp, UTC, in nanoseconds
59pub const miliTimestamp = switch(builtin.os) {59pub const milliTimestamp = switch(builtin.os) {
60 Os.windows => miliTimestampWindows,60 Os.windows => milliTimestampWindows,
61 Os.linux => miliTimestampPosix,61 Os.linux => milliTimestampPosix,
62 Os.macosx, Os.ios => miliTimestampDarwin,62 Os.macosx, Os.ios => milliTimestampDarwin,
63 else => @compileError("Unsupported OS"),63 else => @compileError("Unsupported OS"),
64};64};
6565
66fn miliTimestampWindows() u64 {66fn milliTimestampWindows() u64 {
67 //FileTime has a granularity of 100 nanoseconds67 //FileTime has a granularity of 100 nanoseconds
68 // and uses the NTFS/Windows epoch68 // and uses the NTFS/Windows epoch
69 var ft: i64 = undefined;69 var ft: i64 = undefined;
...@@ -73,7 +73,7 @@ fn miliTimestampWindows() u64 {...@@ -73,7 +73,7 @@ fn miliTimestampWindows() u64 {
73 return u64(@divFloor(ft, hns_per_ms) + epoch_adj);73 return u64(@divFloor(ft, hns_per_ms) + epoch_adj);
74}74}
7575
76fn miliTimestampDarwin() u64 {76fn milliTimestampDarwin() u64 {
77 //Sources suggest MacOS 10.12 has support for77 //Sources suggest MacOS 10.12 has support for
78 // posix clock_gettime.78 // posix clock_gettime.
79 var tv: darwin.timeval = undefined;79 var tv: darwin.timeval = undefined;
...@@ -84,7 +84,7 @@ fn miliTimestampDarwin() u64 {...@@ -84,7 +84,7 @@ fn miliTimestampDarwin() u64 {
84 return u64(sec_ms) + u64(usec_ms); 84 return u64(sec_ms) + u64(usec_ms);
85}85}
8686
87fn miliTimestampPosix() u64 {87fn milliTimestampPosix() u64 {
88 //From what I can tell there's no reason clock_gettime88 //From what I can tell there's no reason clock_gettime
89 // should ever fail for us with CLOCK_REALTIME89 // should ever fail for us with CLOCK_REALTIME
90 var ts: posix.timespec = undefined;90 var ts: posix.timespec = undefined;
...@@ -238,9 +238,9 @@ test "os.time.timestamp" {...@@ -238,9 +238,9 @@ test "os.time.timestamp" {
238 const ns_per_ms = (ns_per_s / ms_per_s);238 const ns_per_ms = (ns_per_s / ms_per_s);
239 const margin = 50;239 const margin = 50;
240 240
241 const time_0 = miliTimestamp();241 const time_0 = milliTimestamp();
242 sleep(0, ns_per_ms);242 sleep(0, ns_per_ms);
243 const time_1 = miliTimestamp();243 const time_1 = milliTimestamp();
244 const interval = time_1 - time_0;244 const interval = time_1 - time_0;
245 debug.assert(interval > 0 and interval < margin);245 debug.assert(interval > 0 and interval < margin);
246}246}