-
Notifications
You must be signed in to change notification settings - Fork 1.1k
add tmpnam and pthread_exit #527
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
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
@alexcrichton the build failed for no apparent reason (iOS build said |
Thanks for the PR! Unfortunately this is a breaking change though, so could the change to the function pointer be backed out? |
@alexcrichton Can you shed some light on what is breaking? I left out the |
@philippkeller I believe that was added in a very recent version of Rust (coercion from safe to unsafe) but historical versions of Rust didn't support such a feature. |
@bors: r+ |
📌 Commit 437c54c has been approved by |
pthread_create expects unsafe fn pointer, add tmpnam, move readdir to unix level tmpnam and readdir are trivial IMO. About the `pthread_create` change: It needs `unsafe` for passing `C` functions to pthread_create (with rust functions the omission of `unsafe` is working of course). `bindgen` produces this function definition: ``` pub fn pthread_create(arg1: *mut pthread_t, arg2: *const pthread_attr_t, arg3: Option<unsafe extern "C" fn(arg1: *mut c_void) -> *mut c_void>, arg4: *mut c_void) -> c_int; ``` So it would add an additional `Option` around the function. But that would break existing code which uses `libc::pthread_create` and what use is it to call pthread_create without any function pointer, so I left `Option` out. For reference: I also opened a [stackoverflow question](http://stackoverflow.com/questions/42284562) where the answers were also suggesting adding `unsafe` to the function definition.
I see, it only got introduced lately, I think it is only available as from rustc 1.15 |
💔 Test failed - status-travis |
@bors: r+ |
📌 Commit cbdf43b has been approved by |
add tmpnam and pthread_exit tmpnam and readdir are trivial IMO. About the `pthread_create` change: It needs `unsafe` for passing `C` functions to pthread_create (with rust functions the omission of `unsafe` is working of course). `bindgen` produces this function definition: ``` pub fn pthread_create(arg1: *mut pthread_t, arg2: *const pthread_attr_t, arg3: Option<unsafe extern "C" fn(arg1: *mut c_void) -> *mut c_void>, arg4: *mut c_void) -> c_int; ``` So it would add an additional `Option` around the function. But that would break existing code which uses `libc::pthread_create` and what use is it to call pthread_create without any function pointer, so I left `Option` out. For reference: I also opened a [stackoverflow question](http://stackoverflow.com/questions/42284562) where the answers were also suggesting adding `unsafe` to the function definition.
💔 Test failed - status-travis |
@bors: retry
…On Thu, Feb 23, 2017 at 9:48 AM, bors ***@***.***> wrote:
💔 Test failed - status-travis
<https://travis-ci.org/rust-lang/libc/builds/204626304>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#527 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAD95CQ7lyJX9iDgtfZYMLMBkhdiAi4hks5rfao_gaJpZM4MFFa5>
.
|
add tmpnam and pthread_exit tmpnam and readdir are trivial IMO. About the `pthread_create` change: It needs `unsafe` for passing `C` functions to pthread_create (with rust functions the omission of `unsafe` is working of course). `bindgen` produces this function definition: ``` pub fn pthread_create(arg1: *mut pthread_t, arg2: *const pthread_attr_t, arg3: Option<unsafe extern "C" fn(arg1: *mut c_void) -> *mut c_void>, arg4: *mut c_void) -> c_int; ``` So it would add an additional `Option` around the function. But that would break existing code which uses `libc::pthread_create` and what use is it to call pthread_create without any function pointer, so I left `Option` out. For reference: I also opened a [stackoverflow question](http://stackoverflow.com/questions/42284562) where the answers were also suggesting adding `unsafe` to the function definition.
☀️ Test successful - status-appveyor, status-travis |
The `proc_macro` feature has stabilized in the compiler and usage of it largely needs to switch to `use_extern_macros` now.
tmpnam and readdir are trivial IMO.
About the
pthread_create
change: It needsunsafe
for passingC
functions to pthread_create (with rust functions the omission ofunsafe
is working of course).bindgen
produces this function definition:So it would add an additional
Option
around the function. But that would break existing code which useslibc::pthread_create
and what use is it to call pthread_create without any function pointer, so I leftOption
out.For reference: I also opened a stackoverflow question where the answers were also suggesting adding
unsafe
to the function definition.