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
x/sys/unix: add System V shared memory functions #46084
Comments
It appears the solaris cgo implementation is required because an ... I don't actually care about solaris and would be happy if this were able to go forward without it. :-D |
/cc @jayconrod in case fuzzing has run into this as well |
This proposal has been added to the active column of the proposals project |
I think this would be good to have. I looked for this before deciding how to build our fuzzing shared memory implementation and was sad not to find it. Ultimately, I went with a memory mapped file to minimize platform differences, but it would be nice not to have to write anything to disk. |
Keeping in mind Ian's feedback on my initial PR:
If this were to be accepted + implemented, there are probably several ways this could be implemented. I vote to follow gen2brain/shm's approach instead of my original PR, as it's more of a mechanical expression of the underlying API. For reference, here's the original C functions copied from linux glibc:
shmget/shmdt
shmat
I prefer 1 or 3. Converting to a byte slice is likely the common case, and follows how mmap works. shmctl
I lean towards 1 as I don't think the struct argument is used all that often. helper functions in gen2brain/shmThere are two really useful helper functions that gen2brain added in addition to the standard sysv API
Given Ian's initial comment, I imagine these two functions would not be adapted to x/sys/unix as they're straightforward to implement if you know how the shm API works. |
It would be nice to have a more standard API that hides some of the per-OS variation, like syscall.Mmap and syscall.Munmap. The gen2brain/shm API is:
For x/sys we would need more prefixes, like:
The Thoughts? |
The proposed API seems mostly fine to me, with two caveats. The It seems like most other API in sys follow the unix names pretty closely, so using the Answering my final question then:
Your API is option number 1. I think it will be the easiest to implement, so I agree. |
Based on the discussion above, this proposal seems like a likely accept. |
No change in consensus, so accepted. 🎉 |
Awesome. This should be a pretty straightforward modification of my earlier PR, I can probably make the modifications this weekend. |
Initial PR @ golang/sys#110, feedback welcome. I chose SysvShmDesc as stated in my objection since nobody objected to my objection, and it's a clearer name than SysvShm. |
It would be good if someone with the various OS/arch combinations that golang supports were able to run the build scripts to autogenerate the various z* files. I only have OSX and Linux setup locally. I tried adding linux support by running |
Change https://golang.org/cl/327830 mentions this issue: |
Implements proposed API from https://golang.org/issue/46084. I chose `SysvShmDesc` since it's a clearer name than `SysvShm`. Initially supports Darwin and Linux. Solaris support has a blocker (https://golang.org/issue/46084#issuecomment-836980018) For golang/go#46084 Change-Id: Ied0f768a74c448254adc3315348417825a7ec63e GitHub-Last-Rev: befbd7a GitHub-Pull-Request: #110 Reviewed-on: https://go-review.googlesource.com/c/sys/+/327830 Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Go Bot <gobot@golang.org>
This has been implemented for Darwin and Linux, so I think that counts as implemented and this proposal can be closed? I'd do the other OS also, but I don't have a good way to test it locally. |
Thanks, people can open specific issues for specific platforms (or just send a patch). |
Change https://golang.org/cl/353509 mentions this issue: |
Keep it disabled on ios though. For golang/go#45696 For golang/go#46084 Change-Id: I3d551227a4ebc0eebabdd16b175aa6a75ea9de19 Reviewed-on: https://go-review.googlesource.com/c/sys/+/353509 Trust: Tobias Klauser <tobias.klauser@gmail.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Update, June 2 2021: The current proposed API is in #46084 (comment). - rsc
What did you expect to see?
It would be mildly useful to have
shmget/shmat/shmdt/shmctl
available in pure go. System V shared memory isn't very common in modern applications, but there are still uses for it that can't be accomplished otherwise. Usages I'm aware of:I think the primary question I'd like to have answered is whether inclusion is appropriate for x/sys/unix and how likely it would be for it to be accepted, given that its usage is fairly esoteric.
Prior art
There are several cgo implementations I had found previously, but my google-fu is failing me at the moment. I had proposed an initial API at golang/sys#108 , but hadn't noticed the other pure go prior art in my initial search. There are several mostly pure go implementations:
cc @gen2brain
The text was updated successfully, but these errors were encountered: