aboutsummaryrefslogtreecommitdiff
path: root/core/time/time_linux.odin
diff options
context:
space:
mode:
authorgingerBill <gingerBill@users.noreply.github.com>2019-12-01 11:33:23 +0000
committerGitHub <noreply@github.com>2019-12-01 11:33:23 +0000
commit3fd5c3cd851d8f4dfd441141ca7e96889f069933 (patch)
tree67f47e79f5c5bb80a3ed1b1e9d79a61c08c0a29d /core/time/time_linux.odin
parent0c0c83ee295fe8787a4bdc8b826a5432abba2ca9 (diff)
parent99121d6ff2b02f3d16b791eb103bb9f9e8b96475 (diff)
Merge pull request #458 from Tetralux/linux-threads
Implement core:thread and core:sync on Unix using pthreads
Diffstat (limited to 'core/time/time_linux.odin')
-rw-r--r--core/time/time_linux.odin44
1 files changed, 0 insertions, 44 deletions
diff --git a/core/time/time_linux.odin b/core/time/time_linux.odin
deleted file mode 100644
index d83d719fb..000000000
--- a/core/time/time_linux.odin
+++ /dev/null
@@ -1,44 +0,0 @@
-package time
-
-import "core:os";
-
-// NOTE(Jeroen): The times returned are in UTC
-IS_SUPPORTED :: true;
-
-now :: proc() -> Time {
-
- time_spec_now := os.clock_gettime(os.CLOCK_REALTIME);
- ns := time_spec_now.tv_sec * 1e9 + time_spec_now.tv_nsec;
- return Time{_nsec=ns};
-}
-
-boot_time :: proc() -> Time {
-
- ts_now := os.clock_gettime(os.CLOCK_REALTIME);
- ts_boottime := os.clock_gettime(os.CLOCK_BOOTTIME);
-
- ns := (ts_now.tv_sec - ts_boottime.tv_sec) * 1e9 + ts_now.tv_nsec - ts_boottime.tv_nsec;
- return Time{_nsec=ns};
-}
-
-seconds_since_boot :: proc() -> f64 {
-
- ts_boottime := os.clock_gettime(os.CLOCK_BOOTTIME);
- return f64(ts_boottime.tv_sec) + f64(ts_boottime.tv_nsec) / 1e9;
-}
-
-sleep :: proc(d: Duration) {
-
- ds := duration_seconds(d);
- seconds := u64(ds);
- nanoseconds := i64((ds - f64(seconds)) * 1e9);
-
- if seconds > 0 do os.sleep(seconds);
- if nanoseconds > 0 do os.nanosleep(nanoseconds);
-}
-
-nanosleep :: proc(d: Duration) {
- // NOTE(Jeroen): os.nanosleep returns -1 on failure, 0 on success
- // duration needs to be [0, 999999999] nanoseconds.
- os.nanosleep(i64(d));
-}