-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
makesyscalls: restore support for cpp in input #1575
Open
brooksdavis
wants to merge
5
commits into
freebsd:main
Choose a base branch
from
brooksdavis:makesyscall-cpp
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CC @agge3 |
I suspect we also need ifdefs in syscalls.map, but I wanted to start with replicating what's in the old version. |
This exercises some subset of the preprocessor that would be nice to still support.
Allow patterns like this in syscalls.master: #if 0 91 AUE_NULL RESERVED #else 91 AUE_NULL STD|CAPENABLED { int newsyscall(void); } #endif makesyscalls.lua and it's predecessor makesyscalls.sh (really an awk script with a tiny shell prolog) used a single pass parsing model where lines beginning with `#` were emitted into most generated files as they were read. I belive this was initially there to allow includes to be listed in syscalls.master, but Hyrum's Law[0] applies and people are using it for things like architecture-specific syscall definitions. This use of CPP macro is unsound and there are a number of sharp edges in both the new and old implementations. The macros are unsound because not all the files were generate are run through CPP (or if they are not in the same context) and this will increasingly be true as we generate more things. Sharp edges include the fact that anything before the first syscall would be printed at a different scope (e.g., before an array is declared). In this patch I collect each non-#include CPP directive and attach them to the syscall table or individual entries. All entries before the first syscall and after the last are attached to the prolog and epilog members. Within the syscall table all entries are attached to the next system calls's prolog member. In generators, each prolog entry is printed regardless of the system call's visibiilty which replicates the naive single pass model's behavior (including lots of empty blocks of #if/#else/#endif in the output). Unlike makesyscalls.lua, I discard none #define entries at the top of the file and print a warning as their usefulness appears limited. [0] https://www.hyrumslaw.com Reported by: kevans Sponsored by: DARPA, AFRL
Warn that C preprocessor directives in the config file are deprecated. They are unsound and support has a number of potential pitfalls. They should be replaced by compile-time generation of files plus an overlay framework to allow things like per-arch variation. Sponsored by: DARPA, AFRL
If there are per-platform differences in which syscalls are supported, we should only try to export implemented ones in libc. Fortunately, syscall maps are run though cpp. (This is arguably incomplete as syscall.mk isn't--and can't practically be--supported.) Sponsored by: DARPA, AFRL
The two outer blocks had identical contents and the two inner blocks differed in a single location. Sponsored by: DARPA, AFRL
brooksdavis
force-pushed
the
makesyscall-cpp
branch
from
January 21, 2025 20:00
db67977
to
2cf57ad
Compare
Pulled in @kevans91's test script and updated for main (I should probably MFC the diff reduction changes.) Fixed the way the epilogue is handled. Added syscalls.map cpp support and added an unrelated minor improvement to the syscall.mk code. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Implement functionality largely identical to that in makesyscalls.lua on 14-STABLE. I've excluded prolog and epilogue support as it's not obviously very useful. Could restore the original function if someone is using conditional includes or the like.
Deprecate this functionality (no plan to remove it without replacement, but putting a line in the sand.)