diff options
author | alon@honor <none@none> | 2010-10-21 23:20:08 -0700 |
---|---|---|
committer | alon@honor <none@none> | 2010-10-21 23:20:08 -0700 |
commit | d8bda252d5a1a43cb64a8f733fbf59c004017ea6 (patch) | |
tree | 363ab977cb891191e0d9b7e0bbc4e8318df527f4 /src/library.js | |
parent | f57cfb99176a2ec61db5b91aeed1f3ff6a719634 (diff) |
gettimeofday(), and more stuff in Runtime
Diffstat (limited to 'src/library.js')
-rw-r--r-- | src/library.js | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/library.js b/src/library.js index 210b79e1..c064b928 100644 --- a/src/library.js +++ b/src/library.js @@ -250,6 +250,15 @@ var Library = { } return ret; }, + + gettimeofday: function(ptr) { + // %struct.timeval = type { i32, i32 } + var indexes = Runtime.calculateStructAlignment({ fields: ['i32', 'i32'] }); + var now = Date.now(); + IHEAP[ptr + indexes[0]] = Math.floor(now/1000); // seconds + IHEAP[ptr + indexes[1]] = Math.floor((now-1000*Math.floor(now/1000))*1000); // microseconds + return 0; + }, }; load('library_sdl.js'); |