aboutsummaryrefslogtreecommitdiff
path: root/src/library.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/library.js')
-rw-r--r--src/library.js9
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');