Skip to content

Use correct data types in syscall layer. NFC#27108

Open
kleisauke wants to merge 3 commits into
emscripten-core:mainfrom
kleisauke:correct-syscall-data-types
Open

Use correct data types in syscall layer. NFC#27108
kleisauke wants to merge 3 commits into
emscripten-core:mainfrom
kleisauke:correct-syscall-data-types

Conversation

@kleisauke

Copy link
Copy Markdown
Collaborator

Split out from #19559.

This is an automatic change generated by tools/maint/gen_sig_info.py.
This is an automatic change generated by tools/maint/rebaseline_tests.py.

The following (1) test expectation files were updated by
running the tests with `--rebaseline`:

```
codesize/test_codesize_hello_dylink_all.json: 855675 => 855705 [+30 bytes / +0.00%]

Average change: +0.00% (+0.00% - +0.00%)
```
"a.out.js": 268089,
"a.out.nodebug.wasm": 587586,
"total": 855675,
"a.out.nodebug.wasm": 587616,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know why that wasm gets bigger here? aren't these types all the same size as before?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why this gets bigger. Perhaps due to the same thing as noticed in https://github.com/emscripten-core/emscripten/pull/26482/changes#r2966436130?

Note that test_codesize_hello_dylink_all.json‎ has a rather low signal-to-noise ratio. 😅

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, the $wait and $waitpid symbols are now included as well, but I'm not sure whether that accounts for +30 bytes.

UNIMPLEMENTED(sendmmsg, (int sockfd, intptr_t msgvec, unsigned int vlen, unsigned int flags, ...))
UNIMPLEMENTED(shutdown, (int sockfd, int how, int dummy, int dummy2, int dummy3, int dummy4))
UNIMPLEMENTED(socketpair, (int domain, int type, int protocol, intptr_t fds, int dummy, int dummy2))
UNIMPLEMENTED(wait4,(int pid, intptr_t wstatus, int options, int rusage))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why change this?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The UNIMPLEMENTED marco currently always returns an int, but the wait4 syscall requires a return type of pid_t.

Comment thread src/lib/libsigs.js
__syscall_chdir__sig: 'ip',
__syscall_chmod__sig: 'ipi',
__syscall_connect__sig: 'iippiii',
__syscall_connect__sig: 'iipiiii',

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How did these syscalls work under wasm64 before if the type of arg 3 was not p?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh wait.. I see socklet_t is acually smaller than size_t.. that is good. One less pointer conversion.

Comment thread src/lib/libsigs.js
__syscall_openat__sig: 'iipip',
__syscall_pipe2__sig: 'ipi',
__syscall_poll__sig: 'ipii',
__syscall_poll__sig: 'ippi',

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should define nfds_t to int instead of long to avoid this extra p conversion here?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. That would match with llvm-libc as well. See e.g.:


versus:
typedef unsigned long nfds_t;

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... this likely also needs to be updated to include || SANITIZER_EMSCRIPTEN.

# if SANITIZER_ANDROID || SANITIZER_APPLE
typedef unsigned __sanitizer_nfds_t;
# else
typedef unsigned long __sanitizer_nfds_t;
# endif

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants