diff options
author | Alon Zakai <alonzakai@gmail.com> | 2011-10-02 21:48:08 +0200 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2011-10-02 21:48:08 +0200 |
commit | c2a8a5b364e6b888c6563af371603eb5ce86c1b5 (patch) | |
tree | 2f1a53c921d5b20f7f79c3962b550f33a6fe6565 | |
parent | 9b00cf0da46154b27e439ced5d4a6abd388979ec (diff) |
fix test_poll
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | src/library.js | 6 | ||||
-rw-r--r-- | system/include/poll.h | 22 | ||||
-rw-r--r-- | tests/runner.py | 22 |
4 files changed, 38 insertions, 14 deletions
@@ -1,2 +1,4 @@ *.diff *.pyc +*~ + diff --git a/src/library.js b/src/library.js index 7bc3158c..3387a326 100644 --- a/src/library.js +++ b/src/library.js @@ -1077,10 +1077,10 @@ LibraryManager.library = { var revents = 0; if (fd in FS.streams) { var stream = FS.streams[fd]; - if (events & 0x1) revents |= 0x1; // POLLIN. - if (events & 0x4) revents |= 0x4; // POLLOUT. + if (events & {{{ cDefine('POLLIN') }}}) revents |= {{{ cDefine('POLLIN') }}}; + if (events & {{{ cDefine('POLLOUT') }}}) revents |= {{{ cDefine('POLLOUT') }}}; } else { - if (events & 0x20) revents |= 0x20; // POLLNVAL. + if (events & {{{ cDefine('POLLNVAL') }}}) revents |= {{{ cDefine('POLLNVAL') }}}; } if (revents) nonzero++; {{{ makeSetValue('pollfd', 'offsets.revents', 'revents', 'i16') }}} diff --git a/system/include/poll.h b/system/include/poll.h new file mode 100644 index 00000000..230f93c6 --- /dev/null +++ b/system/include/poll.h @@ -0,0 +1,22 @@ + +#ifdef __cplusplus +extern "C" { +#endif + +#define POLLIN 1 +#define POLLOUT 2 +#define POLLNVAL 4 +#define POLLERR 8 + +struct pollfd { + int fd; + short events; + short revents; +}; + +int poll(pollfd *data, int num, int extra); + +#ifdef __cplusplus +} +#endif + diff --git a/tests/runner.py b/tests/runner.py index 549f63f1..bea7fa6b 100644 --- a/tests/runner.py +++ b/tests/runner.py @@ -2572,11 +2572,11 @@ if 'benchmark' not in str(sys.argv): printf("ret: %d\n", poll(multi, 5, 123)); printf("errno: %d\n", errno); - printf("multi[0].revents: 0x%x\n", multi[0].revents); - printf("multi[1].revents: 0x%x\n", multi[1].revents); - printf("multi[2].revents: 0x%x\n", multi[2].revents); - printf("multi[3].revents: 0x%x\n", multi[3].revents); - printf("multi[4].revents: 0x%x\n", multi[4].revents); + printf("multi[0].revents: %d\n", multi[0].revents == (POLLIN | POLLOUT)); + printf("multi[1].revents: %d\n", multi[1].revents == (POLLIN | POLLOUT)); + printf("multi[2].revents: %d\n", multi[2].revents == POLLNVAL); + printf("multi[3].revents: %d\n", multi[3].revents == 0); + printf("multi[4].revents: %d\n", multi[4].revents == POLLOUT); return 0; } @@ -2584,13 +2584,13 @@ if 'benchmark' not in str(sys.argv): expected = r''' ret: 4 errno: 0 - multi[0].revents: 0x5 - multi[1].revents: 0x5 - multi[2].revents: 0x20 - multi[3].revents: 0x0 - multi[4].revents: 0x4 + multi[0].revents: 1 + multi[1].revents: 1 + multi[2].revents: 1 + multi[3].revents: 1 + multi[4].revents: 1 ''' - self.do_test(src, re.sub('(^|\n)\s+', '\\1', expected), post_build=add_pre_run) + self.do_test(src, re.sub('(^|\n)\s+', '\\1', expected), post_build=add_pre_run, extra_emscripten_args=['-H', 'libc/fcntl.h,poll.h']) def test_statvfs(self): src = r''' |