aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-03-05 12:40:27 -0800
committerAlon Zakai <alonzakai@gmail.com>2013-03-05 12:40:27 -0800
commit010873fc624f7e6536f3ddb797718bd806e44ab2 (patch)
treefa3dac8f903eb50619c76c300cd4ce32dde725f8 /src
parent469f25baf613e8b961bddded80bbb46167ce58e4 (diff)
parentc12116003db5731b20329ae2ba7683a25c8f5d76 (diff)
Merge pull request #912 from waywardmonkeys/implement-nanosleep
Implement nanosleep.
Diffstat (limited to 'src')
-rw-r--r--src/library.js9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/library.js b/src/library.js
index 38c1d662..a288b739 100644
--- a/src/library.js
+++ b/src/library.js
@@ -6065,6 +6065,15 @@ LibraryManager.library = {
__timespec_struct_layout: Runtime.generateStructInfo([
['i32', 'tv_sec'],
['i32', 'tv_nsec']]),
+ nanosleep__deps: ['usleep', '__timespec_struct_layout'],
+ nanosleep: function(rqtp, rmtp) {
+ // int nanosleep(const struct timespec *rqtp, struct timespec *rmtp);
+ var seconds = {{{ makeGetValue('rqtp', '___timespec_struct_layout.tv_sec', 'i32') }}};
+ var nanoseconds = {{{ makeGetValue('rqtp', '___timespec_struct_layout.tv_nsec', 'i32') }}};
+ {{{ makeSetValue('rmtp', '___timespec_struct_layout.tv_sec', '0', 'i32') }}}
+ {{{ makeSetValue('rmtp', '___timespec_struct_layout.tv_nsec', '0', 'i32') }}}
+ return _usleep((seconds * 1e6) + (nanoseconds / 1000));
+ },
// TODO: Implement these for real.
clock_gettime__deps: ['__timespec_struct_layout'],
clock_gettime: function(clk_id, tp) {