-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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 libc::errno and libc::set_errno and use to implement std::os::errno #18642
Conversation
} | ||
} | ||
|
||
_errno_ptr() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder what was the benefit of defining errno_ptr()
on top of _errno_ptr()
which can hide platform-dependency by themselves.
Incidentally, ::{c_int}
isn't beautiful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The question of whether use <...>::{c_int}
is not beautiful is probably a debatable one :-). In either case, the style has been chosen as it matches all of the other single name use ...
statements within this source file.
As to defining errno_ptr()
over _errno_ptr()
. I guess the benefits are that it ensures errno_ptr
is implemented on all target_os
possibilities. If a value of target_os
is not covered by the _errno_ptr
implementations, the function errno_ptr
won't compile, providing a hint that it needs to be implemented for that new platform. (granted, if it wasn't done this way, errno
and set_errno
wouldn't compile, but that is a slightly less specific error)
It also means the function only needs to be documented at this single entrypoint.
But again, the implementation was mostly influenced by what the existing errno
source had been doing.
Can you also update pub fn from_errno(errno: uint, detail: bool) -> IoError { Also, I wonder if adding sth like |
@nodakai Yes, I hadn't initially put in to this PR as I also think there are a few other cleanups required (see my next to last comment in old PR #17265) |
Right now liblibc is in theory purely just declarations of C functions available on the host system rather than providing common abstractions and implementations. Now that we have |
@alexcrichton Presume you mean that |
I don't think wrappers that aren't defined by the C standard library belong in libc. |
@donkopotamus oh I'm sorry this got lost in my inbox! To answer your question, I was referring to |
@alexcrichton I can understand that argument ... I moved it into For myself, I'm just interested in having |
@donkopotamus I agree that it's not so great right now, but currently liblibc is just a wrapper crate with no extra code in it (as much as possible). The story for this will become much clearer over time as we flesh out the story for |
Closing due to inactivity, but feel free to reopen with additions to |
minor: Remove unstable attributes in minicore
This pull request does the following:
libc::errno() -> c_int
andlibc::set_errno(c_int)
std::os::errno
usinglibc::errno
std::os::errno()
, which returnsint
on unix anduint
on windows, in favour of returningint
only.This represents a reopening of previously discussed PR #17265.