diff --git a/src/lib/libsyscall.js b/src/lib/libsyscall.js index cbc5d3d0a5774..9769e87d4d9cd 100644 --- a/src/lib/libsyscall.js +++ b/src/lib/libsyscall.js @@ -199,12 +199,18 @@ var SyscallsLibrary = { if (fdPtr == 0) { throw new FS.ErrnoError({{{ cDefs.EFAULT }}}); } - if (flags && flags != {{{ cDefs.O_CLOEXEC }}}) { + var validFlags = {{{ cDefs.O_CLOEXEC }}} | {{{ cDefs.O_NONBLOCK }}}; + if (flags & ~validFlags) { throw new FS.ErrnoError({{{ cDefs.ENOTSUP }}}); } var res = PIPEFS.createPipe(); + if (flags & {{{ cDefs.O_NONBLOCK }}}) { + FS.getStream(res.readable_fd).flags |= {{{ cDefs.O_NONBLOCK }}}; + FS.getStream(res.writable_fd).flags |= {{{ cDefs.O_NONBLOCK }}}; + } + {{{ makeSetValue('fdPtr', 0, 'res.readable_fd', 'i32') }}}; {{{ makeSetValue('fdPtr', 4, 'res.writable_fd', 'i32') }}}; diff --git a/test/codesize/test_codesize_cxx_ctors1.json b/test/codesize/test_codesize_cxx_ctors1.json index dff56a4063fb0..cb4134f37a55f 100644 --- a/test/codesize/test_codesize_cxx_ctors1.json +++ b/test/codesize/test_codesize_cxx_ctors1.json @@ -1,10 +1,10 @@ { "a.out.js": 19194, - "a.out.js.gz": 7969, + "a.out.js.gz": 7992, "a.out.nodebug.wasm": 132638, - "a.out.nodebug.wasm.gz": 49927, + "a.out.nodebug.wasm.gz": 50025, "total": 151832, - "total_gz": 57896, + "total_gz": 58017, "sent": [ "__cxa_throw", "_abort_js", diff --git a/test/codesize/test_codesize_cxx_ctors2.json b/test/codesize/test_codesize_cxx_ctors2.json index fb2e77ec4ae92..1a62e049e7ec2 100644 --- a/test/codesize/test_codesize_cxx_ctors2.json +++ b/test/codesize/test_codesize_cxx_ctors2.json @@ -1,10 +1,10 @@ { "a.out.js": 19171, - "a.out.js.gz": 7957, + "a.out.js.gz": 7978, "a.out.nodebug.wasm": 132064, - "a.out.nodebug.wasm.gz": 49586, + "a.out.nodebug.wasm.gz": 49696, "total": 151235, - "total_gz": 57543, + "total_gz": 57674, "sent": [ "__cxa_throw", "_abort_js", diff --git a/test/codesize/test_codesize_cxx_except.json b/test/codesize/test_codesize_cxx_except.json index c29dbd2b26b46..ce7ea8ace8d37 100644 --- a/test/codesize/test_codesize_cxx_except.json +++ b/test/codesize/test_codesize_cxx_except.json @@ -1,10 +1,10 @@ { "a.out.js": 23174, - "a.out.js.gz": 8960, + "a.out.js.gz": 8991, "a.out.nodebug.wasm": 172516, - "a.out.nodebug.wasm.gz": 57438, + "a.out.nodebug.wasm.gz": 57821, "total": 195690, - "total_gz": 66398, + "total_gz": 66812, "sent": [ "__cxa_begin_catch", "__cxa_end_catch", diff --git a/test/codesize/test_codesize_cxx_except_wasm.json b/test/codesize/test_codesize_cxx_except_wasm.json index cb737cf73678b..fdb170e6ac6ae 100644 --- a/test/codesize/test_codesize_cxx_except_wasm.json +++ b/test/codesize/test_codesize_cxx_except_wasm.json @@ -1,10 +1,10 @@ { "a.out.js": 19026, - "a.out.js.gz": 7904, + "a.out.js.gz": 7926, "a.out.nodebug.wasm": 147922, - "a.out.nodebug.wasm.gz": 55312, + "a.out.nodebug.wasm.gz": 55472, "total": 166948, - "total_gz": 63216, + "total_gz": 63398, "sent": [ "_abort_js", "_tzset_js", diff --git a/test/codesize/test_codesize_cxx_except_wasm_legacy.json b/test/codesize/test_codesize_cxx_except_wasm_legacy.json index 71fbc6b06eb6d..409de390dc16a 100644 --- a/test/codesize/test_codesize_cxx_except_wasm_legacy.json +++ b/test/codesize/test_codesize_cxx_except_wasm_legacy.json @@ -1,10 +1,10 @@ { "a.out.js": 19100, - "a.out.js.gz": 7929, + "a.out.js.gz": 7951, "a.out.nodebug.wasm": 145729, - "a.out.nodebug.wasm.gz": 54945, + "a.out.nodebug.wasm.gz": 55117, "total": 164829, - "total_gz": 62874, + "total_gz": 63068, "sent": [ "_abort_js", "_tzset_js", diff --git a/test/codesize/test_codesize_cxx_lto.json b/test/codesize/test_codesize_cxx_lto.json index f92589e8aecc0..4f963080a6973 100644 --- a/test/codesize/test_codesize_cxx_lto.json +++ b/test/codesize/test_codesize_cxx_lto.json @@ -1,10 +1,10 @@ { "a.out.js": 18563, - "a.out.js.gz": 7666, + "a.out.js.gz": 7678, "a.out.nodebug.wasm": 101956, - "a.out.nodebug.wasm.gz": 39461, + "a.out.nodebug.wasm.gz": 39539, "total": 120519, - "total_gz": 47127, + "total_gz": 47217, "sent": [ "a (emscripten_resize_heap)", "b (_setitimer_js)", diff --git a/test/codesize/test_codesize_cxx_mangle.json b/test/codesize/test_codesize_cxx_mangle.json index f2ddec2dbd75d..57db9de76d4d4 100644 --- a/test/codesize/test_codesize_cxx_mangle.json +++ b/test/codesize/test_codesize_cxx_mangle.json @@ -1,10 +1,10 @@ { "a.out.js": 23224, - "a.out.js.gz": 8983, + "a.out.js.gz": 9014, "a.out.nodebug.wasm": 238957, - "a.out.nodebug.wasm.gz": 79847, + "a.out.nodebug.wasm.gz": 80026, "total": 262181, - "total_gz": 88830, + "total_gz": 89040, "sent": [ "__cxa_begin_catch", "__cxa_end_catch", diff --git a/test/codesize/test_codesize_cxx_noexcept.json b/test/codesize/test_codesize_cxx_noexcept.json index 4881c4a93cac7..ddb03f6a683a0 100644 --- a/test/codesize/test_codesize_cxx_noexcept.json +++ b/test/codesize/test_codesize_cxx_noexcept.json @@ -1,10 +1,10 @@ { "a.out.js": 19194, - "a.out.js.gz": 7969, + "a.out.js.gz": 7992, "a.out.nodebug.wasm": 134661, - "a.out.nodebug.wasm.gz": 50777, + "a.out.nodebug.wasm.gz": 50866, "total": 153855, - "total_gz": 58746, + "total_gz": 58858, "sent": [ "__cxa_throw", "_abort_js", diff --git a/test/codesize/test_codesize_cxx_wasmfs.json b/test/codesize/test_codesize_cxx_wasmfs.json index 9d83f3e7f89b1..d55085fd5a626 100644 --- a/test/codesize/test_codesize_cxx_wasmfs.json +++ b/test/codesize/test_codesize_cxx_wasmfs.json @@ -1,10 +1,10 @@ { "a.out.js": 7023, - "a.out.js.gz": 3310, + "a.out.js.gz": 3314, "a.out.nodebug.wasm": 172714, - "a.out.nodebug.wasm.gz": 63316, + "a.out.nodebug.wasm.gz": 63360, "total": 179737, - "total_gz": 66626, + "total_gz": 66674, "sent": [ "__cxa_throw", "_abort_js", diff --git a/test/codesize/test_codesize_file_preload.json b/test/codesize/test_codesize_file_preload.json index a84ee7c65dad3..f0ae4eb04e2ae 100644 --- a/test/codesize/test_codesize_file_preload.json +++ b/test/codesize/test_codesize_file_preload.json @@ -1,10 +1,10 @@ { "a.out.js": 22141, - "a.out.js.gz": 9184, + "a.out.js.gz": 9193, "a.out.nodebug.wasm": 1648, "a.out.nodebug.wasm.gz": 939, "total": 23789, - "total_gz": 10123, + "total_gz": 10132, "sent": [ "a (fd_write)" ], diff --git a/test/codesize/test_codesize_files_js_fs.json b/test/codesize/test_codesize_files_js_fs.json index 78a3cf7f21ebf..fdd2f2e59de0f 100644 --- a/test/codesize/test_codesize_files_js_fs.json +++ b/test/codesize/test_codesize_files_js_fs.json @@ -1,10 +1,10 @@ { "a.out.js": 17834, - "a.out.js.gz": 7308, + "a.out.js.gz": 7318, "a.out.nodebug.wasm": 381, "a.out.nodebug.wasm.gz": 260, "total": 18215, - "total_gz": 7568, + "total_gz": 7578, "sent": [ "a (fd_write)", "b (fd_read)", diff --git a/test/codesize/test_codesize_files_wasmfs.json b/test/codesize/test_codesize_files_wasmfs.json index 327251e75f6b3..f6262645155cd 100644 --- a/test/codesize/test_codesize_files_wasmfs.json +++ b/test/codesize/test_codesize_files_wasmfs.json @@ -1,10 +1,10 @@ { "a.out.js": 5465, - "a.out.js.gz": 2575, + "a.out.js.gz": 2578, "a.out.nodebug.wasm": 58418, - "a.out.nodebug.wasm.gz": 18067, + "a.out.nodebug.wasm.gz": 18099, "total": 63883, - "total_gz": 20642, + "total_gz": 20677, "sent": [ "a (emscripten_date_now)", "b (emscripten_err)", diff --git a/test/codesize/test_codesize_hello_O0.json b/test/codesize/test_codesize_hello_O0.json index ed7a13ce715c6..c69d8b032c4a6 100644 --- a/test/codesize/test_codesize_hello_O0.json +++ b/test/codesize/test_codesize_hello_O0.json @@ -1,10 +1,10 @@ { "a.out.js": 24261, - "a.out.js.gz": 8714, + "a.out.js.gz": 8742, "a.out.nodebug.wasm": 14850, - "a.out.nodebug.wasm.gz": 7311, + "a.out.nodebug.wasm.gz": 7306, "total": 39111, - "total_gz": 16025, + "total_gz": 16048, "sent": [ "fd_write" ], diff --git a/test/codesize/test_codesize_hello_O1.json b/test/codesize/test_codesize_hello_O1.json index b078c77c56f44..46e3dcce36f5d 100644 --- a/test/codesize/test_codesize_hello_O1.json +++ b/test/codesize/test_codesize_hello_O1.json @@ -1,10 +1,10 @@ { "a.out.js": 6345, - "a.out.js.gz": 2456, + "a.out.js.gz": 2459, "a.out.nodebug.wasm": 2530, "a.out.nodebug.wasm.gz": 1423, "total": 8875, - "total_gz": 3879, + "total_gz": 3882, "sent": [ "fd_write" ], diff --git a/test/codesize/test_codesize_hello_dylink.json b/test/codesize/test_codesize_hello_dylink.json index efb0f7d1c501f..7763e9c3f66b3 100644 --- a/test/codesize/test_codesize_hello_dylink.json +++ b/test/codesize/test_codesize_hello_dylink.json @@ -1,10 +1,10 @@ { "a.out.js": 26185, - "a.out.js.gz": 11171, + "a.out.js.gz": 11207, "a.out.nodebug.wasm": 17668, - "a.out.nodebug.wasm.gz": 8921, + "a.out.nodebug.wasm.gz": 8946, "total": 43853, - "total_gz": 20092, + "total_gz": 20153, "sent": [ "__syscall_stat64", "emscripten_resize_heap", diff --git a/test/codesize/test_codesize_hello_dylink_all.json b/test/codesize/test_codesize_hello_dylink_all.json index 50b862122bb1a..c46d7869829e7 100644 --- a/test/codesize/test_codesize_hello_dylink_all.json +++ b/test/codesize/test_codesize_hello_dylink_all.json @@ -1,7 +1,7 @@ { - "a.out.js": 244300, + "a.out.js": 244343, "a.out.nodebug.wasm": 577451, - "total": 821751, + "total": 821794, "sent": [ "IMG_Init", "IMG_Load", diff --git a/test/codesize/test_codesize_mem_O3.json b/test/codesize/test_codesize_mem_O3.json index f75a6347c61d7..972df758ffde9 100644 --- a/test/codesize/test_codesize_mem_O3.json +++ b/test/codesize/test_codesize_mem_O3.json @@ -2,9 +2,9 @@ "a.out.js": 4354, "a.out.js.gz": 2091, "a.out.nodebug.wasm": 5260, - "a.out.nodebug.wasm.gz": 2419, + "a.out.nodebug.wasm.gz": 2420, "total": 9614, - "total_gz": 4510, + "total_gz": 4511, "sent": [ "a (emscripten_resize_heap)" ], diff --git a/test/codesize/test_codesize_mem_O3_grow.json b/test/codesize/test_codesize_mem_O3_grow.json index 527a3ce581a7a..6681518c6692e 100644 --- a/test/codesize/test_codesize_mem_O3_grow.json +++ b/test/codesize/test_codesize_mem_O3_grow.json @@ -1,10 +1,10 @@ { "a.out.js": 4639, - "a.out.js.gz": 2244, + "a.out.js.gz": 2245, "a.out.nodebug.wasm": 5261, - "a.out.nodebug.wasm.gz": 2419, + "a.out.nodebug.wasm.gz": 2420, "total": 9900, - "total_gz": 4663, + "total_gz": 4665, "sent": [ "a (emscripten_resize_heap)" ], diff --git a/test/codesize/test_codesize_minimal_O0.json b/test/codesize/test_codesize_minimal_O0.json index 8d4cc47adfaba..d4802eafa0265 100644 --- a/test/codesize/test_codesize_minimal_O0.json +++ b/test/codesize/test_codesize_minimal_O0.json @@ -1,10 +1,10 @@ { "a.out.js": 19452, - "a.out.js.gz": 6998, + "a.out.js.gz": 7017, "a.out.nodebug.wasm": 1015, "a.out.nodebug.wasm.gz": 602, "total": 20467, - "total_gz": 7600, + "total_gz": 7619, "sent": [], "imports": [], "exports": [ diff --git a/test/codesize/test_codesize_minimal_pthreads.json b/test/codesize/test_codesize_minimal_pthreads.json index 75383a2ac05a7..18b5ad2efdd0a 100644 --- a/test/codesize/test_codesize_minimal_pthreads.json +++ b/test/codesize/test_codesize_minimal_pthreads.json @@ -1,10 +1,10 @@ { "a.out.js": 7363, - "a.out.js.gz": 3604, + "a.out.js.gz": 3609, "a.out.nodebug.wasm": 19046, - "a.out.nodebug.wasm.gz": 8822, + "a.out.nodebug.wasm.gz": 8816, "total": 26409, - "total_gz": 12426, + "total_gz": 12425, "sent": [ "a (memory)", "b (exit)", diff --git a/test/codesize/test_codesize_minimal_pthreads_memgrowth.json b/test/codesize/test_codesize_minimal_pthreads_memgrowth.json index 4d941efd39106..2b8739216b7a9 100644 --- a/test/codesize/test_codesize_minimal_pthreads_memgrowth.json +++ b/test/codesize/test_codesize_minimal_pthreads_memgrowth.json @@ -1,10 +1,10 @@ { "a.out.js": 7765, - "a.out.js.gz": 3810, + "a.out.js.gz": 3815, "a.out.nodebug.wasm": 19047, - "a.out.nodebug.wasm.gz": 8823, + "a.out.nodebug.wasm.gz": 8817, "total": 26812, - "total_gz": 12633, + "total_gz": 12632, "sent": [ "a (memory)", "b (exit)", diff --git a/test/codesize/test_minimal_runtime_code_size_hello_embind.json b/test/codesize/test_minimal_runtime_code_size_hello_embind.json index 6f8026cfbadb0..ca20f7b60f9dc 100644 --- a/test/codesize/test_minimal_runtime_code_size_hello_embind.json +++ b/test/codesize/test_minimal_runtime_code_size_hello_embind.json @@ -2,9 +2,9 @@ "a.html": 548, "a.html.gz": 371, "a.js": 7262, - "a.js.gz": 3324, + "a.js.gz": 3326, "a.wasm": 7099, - "a.wasm.gz": 3257, + "a.wasm.gz": 3259, "total": 14909, - "total_gz": 6952 + "total_gz": 6956 } diff --git a/test/codesize/test_minimal_runtime_code_size_hello_embind_val.json b/test/codesize/test_minimal_runtime_code_size_hello_embind_val.json index 1140b98f22baa..ff9dfc10dd1a2 100644 --- a/test/codesize/test_minimal_runtime_code_size_hello_embind_val.json +++ b/test/codesize/test_minimal_runtime_code_size_hello_embind_val.json @@ -2,9 +2,9 @@ "a.html": 548, "a.html.gz": 371, "a.js": 5353, - "a.js.gz": 2524, + "a.js.gz": 2525, "a.wasm": 5741, - "a.wasm.gz": 2690, + "a.wasm.gz": 2693, "total": 11642, - "total_gz": 5585 + "total_gz": 5589 } diff --git a/test/codesize/test_minimal_runtime_code_size_hello_webgl2_wasm.json b/test/codesize/test_minimal_runtime_code_size_hello_webgl2_wasm.json index f74de1ab6a6f7..211ff7fe1a505 100644 --- a/test/codesize/test_minimal_runtime_code_size_hello_webgl2_wasm.json +++ b/test/codesize/test_minimal_runtime_code_size_hello_webgl2_wasm.json @@ -4,7 +4,7 @@ "a.js": 4437, "a.js.gz": 2281, "a.wasm": 8313, - "a.wasm.gz": 5648, + "a.wasm.gz": 5649, "total": 13200, - "total_gz": 8247 + "total_gz": 8248 } diff --git a/test/codesize/test_minimal_runtime_code_size_hello_webgl2_wasm2js.json b/test/codesize/test_minimal_runtime_code_size_hello_webgl2_wasm2js.json index 09d11b0682f79..4fb3b87c6d1f1 100644 --- a/test/codesize/test_minimal_runtime_code_size_hello_webgl2_wasm2js.json +++ b/test/codesize/test_minimal_runtime_code_size_hello_webgl2_wasm2js.json @@ -2,7 +2,7 @@ "a.html": 342, "a.html.gz": 252, "a.js": 18192, - "a.js.gz": 9826, + "a.js.gz": 9855, "total": 18534, - "total_gz": 10078 + "total_gz": 10107 } diff --git a/test/codesize/test_minimal_runtime_code_size_hello_webgl2_wasm_singlefile.json b/test/codesize/test_minimal_runtime_code_size_hello_webgl2_wasm_singlefile.json index aa2b65b9fa344..f6a534b7947e9 100644 --- a/test/codesize/test_minimal_runtime_code_size_hello_webgl2_wasm_singlefile.json +++ b/test/codesize/test_minimal_runtime_code_size_hello_webgl2_wasm_singlefile.json @@ -1,4 +1,4 @@ { "a.html": 15046, - "a.html.gz": 9012 + "a.html.gz": 9032 } diff --git a/test/codesize/test_minimal_runtime_code_size_hello_webgl_wasm.json b/test/codesize/test_minimal_runtime_code_size_hello_webgl_wasm.json index 61816037cdae4..c795e3b8629f1 100644 --- a/test/codesize/test_minimal_runtime_code_size_hello_webgl_wasm.json +++ b/test/codesize/test_minimal_runtime_code_size_hello_webgl_wasm.json @@ -4,7 +4,7 @@ "a.js": 3975, "a.js.gz": 2123, "a.wasm": 8313, - "a.wasm.gz": 5648, + "a.wasm.gz": 5649, "total": 12738, - "total_gz": 8089 + "total_gz": 8090 } diff --git a/test/codesize/test_minimal_runtime_code_size_hello_webgl_wasm2js.json b/test/codesize/test_minimal_runtime_code_size_hello_webgl_wasm2js.json index 3ea609d71d2e8..0d0118e3c9b05 100644 --- a/test/codesize/test_minimal_runtime_code_size_hello_webgl_wasm2js.json +++ b/test/codesize/test_minimal_runtime_code_size_hello_webgl_wasm2js.json @@ -2,7 +2,7 @@ "a.html": 342, "a.html.gz": 252, "a.js": 17718, - "a.js.gz": 9662, + "a.js.gz": 9691, "total": 18060, - "total_gz": 9914 + "total_gz": 9943 } diff --git a/test/codesize/test_minimal_runtime_code_size_random_printf_wasm.json b/test/codesize/test_minimal_runtime_code_size_random_printf_wasm.json index 2d6f52c4ad1e9..312d0b71d6c41 100644 --- a/test/codesize/test_minimal_runtime_code_size_random_printf_wasm.json +++ b/test/codesize/test_minimal_runtime_code_size_random_printf_wasm.json @@ -1,4 +1,4 @@ { "a.html": 10815, - "a.html.gz": 5649 + "a.html.gz": 5656 } diff --git a/test/codesize/test_minimal_runtime_code_size_random_printf_wasm2js.json b/test/codesize/test_minimal_runtime_code_size_random_printf_wasm2js.json index abb290e68d76b..cd8bd30c625c9 100644 --- a/test/codesize/test_minimal_runtime_code_size_random_printf_wasm2js.json +++ b/test/codesize/test_minimal_runtime_code_size_random_printf_wasm2js.json @@ -1,4 +1,4 @@ { "a.html": 17114, - "a.html.gz": 7478 + "a.html.gz": 7504 } diff --git a/test/codesize/test_unoptimized_code_size.json b/test/codesize/test_unoptimized_code_size.json index 88de96a2eb7d5..a194e22a5fa6c 100644 --- a/test/codesize/test_unoptimized_code_size.json +++ b/test/codesize/test_unoptimized_code_size.json @@ -1,16 +1,16 @@ { "hello_world.js": 57042, - "hello_world.js.gz": 17743, + "hello_world.js.gz": 17780, "hello_world.wasm": 14850, - "hello_world.wasm.gz": 7311, + "hello_world.wasm.gz": 7306, "no_asserts.js": 26618, - "no_asserts.js.gz": 8888, + "no_asserts.js.gz": 8904, "no_asserts.wasm": 12010, - "no_asserts.wasm.gz": 5880, + "no_asserts.wasm.gz": 5876, "strict.js": 54860, - "strict.js.gz": 17049, + "strict.js.gz": 17086, "strict.wasm": 14850, - "strict.wasm.gz": 7311, + "strict.wasm.gz": 7306, "total": 180230, - "total_gz": 64182 + "total_gz": 64258 } diff --git a/test/unistd/misc.c b/test/unistd/misc.c index 3efcbad477a63..190582957f200 100644 --- a/test/unistd/misc.c +++ b/test/unistd/misc.c @@ -86,6 +86,14 @@ int main() { printf("pipe2(bad): %d", pipe2(0, 0)); printf(", errno: %d\n", errno); errno = 0; + printf("pipe2(O_NONBLOCK): %d", pipe2(pipe_arg, O_NONBLOCK)); + printf(", errno: %d\n", errno); + printf("pipe2(O_NONBLOCK) read flags: %d\n", (fcntl(pipe_arg[0], F_GETFL) & O_NONBLOCK) != 0); + printf("pipe2(O_NONBLOCK) write flags: %d\n", (fcntl(pipe_arg[1], F_GETFL) & O_NONBLOCK) != 0); + errno = 0; + printf("pipe2(O_CLOEXEC|O_NONBLOCK): %d", pipe2(pipe_arg, O_CLOEXEC | O_NONBLOCK)); + printf(", errno: %d\n", errno); + errno = 0; char* exec_argv[] = {"arg", 0}; char* exec_env[] = {"a=b", 0}; diff --git a/test/unistd/misc.out b/test/unistd/misc.out index 17e5b17ffa0e5..4ed4b37a3b5fd 100644 --- a/test/unistd/misc.out +++ b/test/unistd/misc.out @@ -15,6 +15,10 @@ pipe(good): 0, errno: 0 pipe(bad): -1, errno: 21 pipe2(good): 0, errno: 0 pipe2(bad): -1, errno: 21 +pipe2(O_NONBLOCK): 0, errno: 0 +pipe2(O_NONBLOCK) read flags: 1 +pipe2(O_NONBLOCK) write flags: 1 +pipe2(O_CLOEXEC|O_NONBLOCK): 0, errno: 0 execl: -1, errno: 45 execle: -1, errno: 45 execlp: -1, errno: 45