-
Notifications
You must be signed in to change notification settings - Fork 18k
syscall: add SyscallN #46552
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
Comments
Any idea where we should stop? |
If you have a syscall with 21 parameters, you probably missed some. (With apologies to Alan Perlis) |
I think that MSVC allows at most 256 parameters in a function definition, so we probably shouldn't need more than that. |
Can you provide some reference, please. Thank you. Alex |
For example a SDK for LED matrix display controller. One of the functions is: |
This is going to be sufficient, since 24 is the highest number. https://www.youtube.com/watch?v=RkP_OGDCLY0 |
It's not theoretical. It's from SDK for these controllers: |
This proposal has been added to the active column of the proposals project |
Just so we're clear: this isn't actually to call any Windows system API or something, but just to call some arbitrary C functions with tons of arguments from that SDK, correct? (Not that that's necessarily a bad thing.) |
We could add a variadic function and then we'd be done, even when NTv6 extends the max syscall list to 640KB. We already support variadic syscalls for Proc.Call and LazyProc.Call. Edit: By which I mean, we support the API, and the compiler supports the unsafe.Pointer-safety-rules magic required to make it work. Those functions in turn currently rely on calling the SyscallNN functions. However, it also looks like the SyscallNN functions then eventually trampoline back into a common, variadic cgo stub anyway. So it seems like the fundamentals are all in place already. We just need to cleanup the implementation, and maybe expose an extra primitive. (I don't know if Windows users care about directly issuing syscall.Syscall21, or if this only affects users indirectly via Proc.Call/LazyProc.Call.) |
I agree with Jason sentiment, that this is pretty rare. And since 24 is the Highest Number, Syscall24 should be the last API we will ever need. It shouldn't be difficult to add these APIs. We should also adjust runtime.TestSyscall18 to verify the change.
Adding Syscall21 and Syscall24 is easy comparing to adding and implementing new API. And there is only 1 Syscall21 user so far. So we should not invest too much effort here. Alternatively we can say no to Syscall21 and Syscall24. We would loose users of those controllers. Alex |
If we're already trampolining back to a varidac sub, we should just make the primary API into this varadic, and cut out all the middle pieces. We can then rework mksyscall and that codegen around the more direct varadic route. The SyscallXX helpers will then be left around for backwards compat. That would address the concerns of this proposal, and also clean up the API considerably. |
Good point, writing a varargs version seems clearly preferable. The signature would presumably be something like
I think we can do that safely using the |
OK, so it sounds like we should do SyscallN. |
We could limit this to Windows, but it seems like we should just implement it for all systems. |
Based on the discussion above, this proposal seems like a likely accept. |
No change in consensus, so accepted. 🎉 |
Change https://golang.org/cl/336550 mentions this issue: |
Any info about performance changes? 👀 |
I wouldn't expect any performance changes from this, but I think it would be great if someone wanted to measure and report back. |
Currently Go supports calling up to 18 arguments when calling function from a Windows DLL. But there are some SDKs that have functions with 22 and more parameters. It seems there is no workaround for this issue.
The text was updated successfully, but these errors were encountered: