Skip to content

Conversation

@clemdiep
Copy link
Contributor

This PR refactor syscall handling to simplify the process of adding new ones. This is in the goal of supporting native musl library.

For that, an array (syscall_table) is used to contains the callback to use for a given syscall number. This remove the need of the switch to select the correct function.

Macros are also added to declare and define syscall function. They declare two functions __sys_SYSCALL_NAME and do_SYSCALL_NAME. The first one is also implemented and just call do_SYSCALL_NAME with casting each arguments to the correct type. They are inspired by Linux one's (see include/linux/syscalls.h in Linux sources).

The syscalls number are also moved into a per arch depend file. For now, the number are the same between the two archs, but to support native musl, different number will be needed (e.g. exit is 1 on arm32 and 93 on aarch64). This will be done futur work.

@clemdiep clemdiep force-pushed the 183-refactor-syscall-handling branch from 6ab3148 to 10f4f5a Compare September 1, 2025 08:44
@daniel-rossier
Copy link
Contributor

Nice job Clément, thank you!

@clemdiep clemdiep merged commit 82ccd1d into main Sep 11, 2025
10 of 11 checks passed
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.

3 participants