aboutsummaryrefslogtreecommitdiff
path: root/src/library.js
diff options
context:
space:
mode:
authorBruce Mitchener <bruce.mitchener@gmail.com>2013-09-05 11:02:23 +0700
committerBruce Mitchener <bruce.mitchener@gmail.com>2013-09-05 11:44:39 +0700
commitb6962e8d1cfa5189e5643f08bb231e76758f4c45 (patch)
tree059d1f7355e1efe7ae1ce9d5ad0803b2abfb6306 /src/library.js
parent9bf72e56b5494cb5de102332d6e5c5e20082ff85 (diff)
Improve precision of clock_gettime(). Update clock_getres().
Diffstat (limited to 'src/library.js')
-rw-r--r--src/library.js4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/library.js b/src/library.js
index 25d880a0..3c9bcb10 100644
--- a/src/library.js
+++ b/src/library.js
@@ -6065,7 +6065,7 @@ LibraryManager.library = {
// int clock_gettime(clockid_t clk_id, struct timespec *tp);
var now = Date.now();
{{{ makeSetValue('tp', '___timespec_struct_layout.tv_sec', 'Math.floor(now/1000)', 'i32') }}}; // seconds
- {{{ makeSetValue('tp', '___timespec_struct_layout.tv_nsec', '0', 'i32') }}}; // nanoseconds - not supported
+ {{{ makeSetValue('tp', '___timespec_struct_layout.tv_nsec', '(now % 1000) * 1000 * 1000', 'i32') }}}; // nanoseconds (really milliseconds)
return 0;
},
clock_settime: function(clk_id, tp) {
@@ -6077,7 +6077,7 @@ LibraryManager.library = {
clock_getres: function(clk_id, res) {
// int clock_getres(clockid_t clk_id, struct timespec *res);
{{{ makeSetValue('res', '___timespec_struct_layout.tv_sec', '1', 'i32') }}}
- {{{ makeSetValue('res', '___timespec_struct_layout.tv_nsec', '0', 'i32') }}}
+ {{{ makeSetValue('res', '___timespec_struct_layout.tv_nsec', '1000 * 1000', 'i32') }}} // resolution is milliseconds
return 0;
},