Skip to content
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

f! macro makes functions unnecessarily unsafe and extern #1213

Closed
asomers opened this issue Jan 16, 2019 · 2 comments
Closed

f! macro makes functions unnecessarily unsafe and extern #1213

asomers opened this issue Jan 16, 2019 · 2 comments

Comments

@asomers
Copy link
Contributor

asomers commented Jan 16, 2019

The f! macro is used to reimplement C macros and inline functions in libc. It eagerly marks these functions as unsafe and extern. However, most of them don't actually need to be unsafe, and none of them need to be extern. Shall I update the f! macro to eliminate the extern and make the unsafe optional? This would be a backwards-compatible change, though it might generate "unnecessary unsafe" warnings in consumer code.

Here's an example of an f! function that plainly doesn't need to be unsafe:

    pub fn WEXITSTATUS(status: ::c_int) -> ::c_int {
        status >> 8
    }
@alexcrichton
Copy link
Member

I would personally prefer it stays as-is because platforms are often in disagreement about what's a macro, what's an inlined function, and what's an actual symbol. It's not really the place of libc to provide nice to use abstractions and/or make design decisions. The point of this crate is to be as simple as possible to append to.

@asomers
Copy link
Contributor Author

asomers commented Jan 16, 2019

Ok.

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

No branches or pull requests

2 participants