Skip to content

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

Merged
merged 11 commits into from
Feb 23, 2017
Merged

add tmpnam and pthread_exit #527

merged 11 commits into from
Feb 23, 2017

Conversation

philippkeller
Copy link

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 where the answers were also suggesting adding unsafe to the function definition.

@rust-highfive
Copy link

r? @alexcrichton

(rust_highfive has picked a reviewer for you, use r? to override)

@philippkeller
Copy link
Author

@alexcrichton the build failed for no apparent reason (iOS build said No output has been received in the last 10m0s, this potentially indicates a stalled build or something wrong with the build itself.). What could I do here? Can I retrigger the build somehow?

@alexcrichton
Copy link
Member

Thanks for the PR! Unfortunately this is a breaking change though, so could the change to the function pointer be backed out?

@philippkeller
Copy link
Author

@alexcrichton Can you shed some light on what is breaking?

I left out the Option so everything which is breaking is the change from fn to unsafe fn. I tested with a safe fn and this still works, so I assume this is non-breaking.

@alexcrichton
Copy link
Member

@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.

@alexcrichton
Copy link
Member

@bors: r+

@bors
Copy link
Contributor

bors commented Feb 22, 2017

📌 Commit 437c54c has been approved by alexcrichton

@bors
Copy link
Contributor

bors commented Feb 22, 2017

⌛ Testing commit 437c54c with merge bfe5ac9...

bors added a commit that referenced this pull request Feb 22, 2017
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.
@philippkeller
Copy link
Author

I see, it only got introduced lately, I think it is only available as from rustc 1.15

@bors
Copy link
Contributor

bors commented Feb 22, 2017

💔 Test failed - status-travis

@philippkeller philippkeller changed the title pthread_create expects unsafe fn pointer, add tmpnam, move readdir to unix level add tmpnam and pthread_exit Feb 23, 2017
@alexcrichton
Copy link
Member

@bors: r+

@bors
Copy link
Contributor

bors commented Feb 23, 2017

📌 Commit cbdf43b has been approved by alexcrichton

@bors
Copy link
Contributor

bors commented Feb 23, 2017

⌛ Testing commit cbdf43b with merge db3e67f...

bors added a commit that referenced this pull request Feb 23, 2017
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.
@bors
Copy link
Contributor

bors commented Feb 23, 2017

💔 Test failed - status-travis

@alexcrichton
Copy link
Member

alexcrichton commented Feb 23, 2017 via email

bors added a commit that referenced this pull request Feb 23, 2017
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.
@bors
Copy link
Contributor

bors commented Feb 23, 2017

⌛ Testing commit cbdf43b with merge 684be76...

@bors
Copy link
Contributor

bors commented Feb 23, 2017

☀️ Test successful - status-appveyor, status-travis
Approved by: alexcrichton
Pushing 684be76 to master...

@bors bors merged commit cbdf43b into rust-lang:master Feb 23, 2017
danielverkamp pushed a commit to danielverkamp/libc that referenced this pull request Apr 28, 2020
The `proc_macro` feature has stabilized in the compiler and usage of it largely
needs to switch to `use_extern_macros` now.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants