Skip to content

Commit 2461a6e

Browse files
authored
Fix __sys_fallocate with WASM_BIGINT (#12004)
I ran the full test suite with WASM_BIGINT to look for any issues. It found just this one. The code assumed that the i64 was an actual i64, but this uses the musl linux syscall convention, where the i64 is always in two i32 values. Add testing for that, and also a comment on another test that fails with WASM_BIGINT but in an expected way.
1 parent cdf99a4 commit 2461a6e

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

src/library_syscall.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1387,9 +1387,7 @@ var SyscallsLibrary = {
13871387
FS.utime(path, atime, mtime);
13881388
return 0;
13891389
},
1390-
__sys_fallocate: function(fd, mode, {{{ defineI64Param('off') }}}, {{{ defineI64Param('len') }}}) {
1391-
{{{ receiveI64ParamAsI32s('off') }}}
1392-
{{{ receiveI64ParamAsI32s('len') }}}
1390+
__sys_fallocate: function(fd, mode, off_low, off_high, len_low, len_high) {
13931391
var stream = SYSCALLS.getStreamFromFD(fd)
13941392
var offset = SYSCALLS.get64(off_low, off_high);
13951393
var len = SYSCALLS.get64(len_low, len_high);

tests/core/dyncall_specific.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ void waka(int w, long long xy, int z) {
2020

2121
int main() {
2222
EM_ASM({
23+
// Note that these would need to use BigInts if the file were built with
24+
// -s WASM_BIGINT
2325
#if DIRECT
2426
dynCall_viji($0, 1, 4, 0xffffffff, 9);
2527
return;

tests/test_core.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5104,6 +5104,7 @@ def test_fcntl(self):
51045104
def test_fcntl_open(self):
51055105
self.do_run_in_out_file_test('tests', 'fcntl', 'test_fcntl_open.c')
51065106

5107+
@also_with_wasm_bigint
51075108
def test_fcntl_misc(self):
51085109
self.add_pre_run("FS.createDataFile('/', 'test', 'abcdef', true, true, false);")
51095110
self.do_run_in_out_file_test('tests', 'fcntl', 'test_fcntl_misc.c')

0 commit comments

Comments
 (0)