refactor syscall into an array and move number into arch depend files #189
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
anddo_SYSCALL_NAME
. The first one is also implemented and just calldo_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.