-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
std.posix
defines non-posix symbols
#20563
Comments
Oh and since this is mentioned in the contributor guidelines to be relevant: I came across this while working on a Zig project https://github.com/arminfriedl/unclog. When using I'm also happy to try to contribute with code. I'd just need some help/pointers if and how to proceed. [1] I figure the same happens with musl and everything other than Solaris too though |
would you feel better if it was named std.unix instead? |
I personally would much prefer Writing |
The event completion framework of Solaris is in some way the Solaris alternative to `kqueue` and `epoll` [1]. It it is, however, specific to Solaris and afaik not implemented anywhere else in that way. Especially, it is not part of POSIX or some libc implementations that I am aware of. Move symbols related to the Solaris event completeion framework (`port_*`) to `solaris.zig` and remove from `posix.zig` and the general `c.zig`. Note that, in case of a Solaris build the respective symbols will be still available by means of `usingnamespace` in `c.zig`. This seems sufficient given that any direct use of the event completion API will anyways only work on Solaris. Especially, in case of `port_t` putting this into `posix.zig` can be considered harmful. It is all to easy to mistake for POSIX's `in_port_t` [2,3], which is semantically wrong. resolves ziglang#20563 [1] Solaris Event Completion: https://web.archive.org/web/20120819060517/http://developers.sun.com/solaris/articles/event_completion.html [2] Not available in `posix.zig` currently. Might be another issue? [3] POSIX standard this is based on: https://pubs.opengroup.org/onlinepubs/9699919799/download/index.html
Not really. For the Added a PR with a suggestion. This only addresses the |
I don't really understand what this issue is trying to accomplish. What is the problem statement? Edit: I think I see a path to resolution. Please see the pattern inside std.c that is used for extern functions. If these APIs are shared with other operating systems, they can use the pattern of switching on native_os. Otherwise they can use the pattern near the bottom of the file to import directly from solaris.zig, and indeed have the definitions live inside that file to indicate where they are from. |
Originally, it was just a symbol in Then it came to the unix layer discussion and maybe I'm just misunderstanding the purpose of these layers. So my understanding of these common layers (posix-y, unix-y,..) was that by using any declarations/definitions there I would be able to compile against any reasonably posix-y/unix-y OS without changes or special-casing in my code. I.e. as long as I stick to only these layers I don't need to bother with OS-specifics too much - same code compiles and runs everywhere basically the same. So the problem then is: For
Maybe I just saw these layers as an intersection of what is common across all the posix-y/unix-y OS, whereas they are more meant as a combination of what that exists in any of the posix-y/unix-y OS - shared (semantically or lexically) to varying degrees.
Yes if I understand this correctly that seems to be a good way to me, making things more explicit 👍 |
It sounds like you understand what the std lib is going for now. Admittedly the naming of Naming aside, I do think the abstraction layer makes sense in a conceptual sense. It's well defined what belongs in there and what does not. |
I know this is borderline-bikeshed, but perhaps
|
WASI seems to be partially Unix-y, though obviously nowhere near full POSIX. Haiku seems to be POSIX-compatible, as far as I can find? If we want to keep
|
What would be the point of regressing the functionality of the standard library that way? I get that it accomplishes punishing users who want to target Windows, does it accomplish anything else? |
Status quo already punishes users who want to target Windows. See #6600. The right way to do this is to have well-designed abstractions in the standard library, probably with the ability to drop down to platform-specific details when necessary (as in e.g. |
Oh, thanks for linking #6600. After the discussion here and how I came to understand things now, at least from my perspective, we can close this issue in favor of #6600. It seems to tackle the underlying issue at a more proper and more general level. Please feel free to re-open if you think otherwise. Just trying to clean up my own mud ;) |
I think there are symbols defined in
std.posix
that are not actually defined (as such) by POSIX. I used the standards documents available at [1] for this.The definition that started this was
zig/lib/std/posix.zig
Line 134 in 854e86c
Should this be renamed to
std.posix.in_port_t
? I couldn't find any mention ofport_t
in the POSIX standard. The closest isin_port_t
which should be defined in thearpa/inet.h
andnetinet/in.h
headers.port_t
itself seems Solaris specific, but not POSIX.In a similar vein there are
zig/lib/std/posix.zig
Lines 135 to 136 in 854e86c
Both of which again seem to be exist somehow in Solaris, however they do not appear to be defined in POSIX.
There might be others too.
I dunno if this was done on purpose or something, but I guess these (and other similar ones) should be renamed/removed from
std.posix
? The straight-forward solution is a breaking change though, obviously.[1] https://pubs.opengroup.org/onlinepubs/9699919799/download/index.html
The text was updated successfully, but these errors were encountered: