aboutsummaryrefslogtreecommitdiff
path: root/src/library.js
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-01-24 12:24:31 -0800
committerAlon Zakai <alonzakai@gmail.com>2013-01-24 12:24:31 -0800
commitaf99c279356f4703562633214142e4cccd558a2e (patch)
treec6317ddc0ab3e2ef2d0041bdaaaf5107d597ce49 /src/library.js
parent03e2e6c321d28e3df3b37a2c0bed3ba9d04e52b3 (diff)
optimize gettimeofday
Diffstat (limited to 'src/library.js')
-rw-r--r--src/library.js7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/library.js b/src/library.js
index 74ebdc07..acbda42b 100644
--- a/src/library.js
+++ b/src/library.js
@@ -5983,14 +5983,13 @@ LibraryManager.library = {
return 0;
},
- // TODO: Implement remaining functions.
// http://pubs.opengroup.org/onlinepubs/000095399/basedefs/sys/time.h.html
gettimeofday: function(ptr) {
// %struct.timeval = type { i32, i32 }
- var indexes = Runtime.calculateStructAlignment({ fields: ['i32', 'i32'] });
+ {{{ (LibraryManager.structs.gettimeofday = Runtime.calculateStructAlignment({ fields: ['i32', 'i32'] }), null) }}}
var now = Date.now();
- {{{ makeSetValue('ptr', 'indexes[0]', 'Math.floor(now/1000)', 'i32') }}} // seconds
- {{{ makeSetValue('ptr', 'indexes[1]', 'Math.floor((now-1000*Math.floor(now/1000))*1000)', 'i32') }}} // microseconds
+ {{{ makeSetValue('ptr', LibraryManager.structs.gettimeofday[0], 'Math.floor(now/1000)', 'i32') }}}; // seconds
+ {{{ makeSetValue('ptr', LibraryManager.structs.gettimeofday[1], 'Math.floor((now-1000*Math.floor(now/1000))*1000)', 'i32') }}}; // microseconds
return 0;
},