-
-
Notifications
You must be signed in to change notification settings - Fork 537
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
Add intrinsics.syscall_bsd
#3524
base: master
Are you sure you want to change the base?
Conversation
You don't need to save/restore RFLAGS, because the assembly snippet already specifies that it's clobbered, and "Odin's syscall intrinsic will always return -errno on failure" makes preserving CF non-important. Otherwise this looks fine, apologies for being lazy when I dealt with this in the past. |
Hi @Feoramund, I have been working on a NetBSD port of Odin. I'm currently missing |
I found a way to negate the return value without needing to save/reload CF. The
I have an echo server working off of syscalls right now, so hopefully won't be much longer before I can plug it all into an OS-specific file for |
I've hit a snag. While implementing
Based on this, it's possible for In this one instance, if that value never overlaps with any of the possible error values, then it's not a big concern, however I think it'd be better to solve this more cleanly. I may need to re-think this. I'm wondering if a separate FreeBSD-specific implementation of I'll have to figure out how to do that. EDIT: While reading through the source code of the compiler, I had an idea. Perhaps it might be more useful to implement an intrinsic that returns the state of the flags. I was able to write one pretty quickly. |
I figured out how to modify |
Does this make sense to adopt on other platforms as well? I always assumed it never overlapped with error values. |
There is no way to distinguish certain cases of overlap on Linux (depending on architecture), so the workarounds are "Linux-isms at the syscall interface layer" ( Per the documentation:
|
This is a BSD-style syscall that checks for a high Carry Flag as the error state. If the CF is high, the boolean return value is false, and if it is low (no errors) then the boolean return value is true.
It's possible for the return string to be longer than 128 characters these days, so I've increased it to 1024, same as the other BSDs. SYSCTL was otherwise erring out due to lack of buffer space.
53e9628
to
20c32c8
Compare
intrinsics.syscall_bsd
I'm working on porting
core:net
to FreeBSD, and I ran into this predicament wheresyscall
was returning only positive numbers, which isn't too helpful for detecting errors. I know very little about how LLVM works; feedback's appreciated. I used thercx
register to do the negation since it's already clobbered.