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

Fix build on FreeBSD #815

Merged
merged 3 commits into from Mar 22, 2019
Merged

Fix build on FreeBSD #815

merged 3 commits into from Mar 22, 2019

Conversation

ghost
Copy link

@ghost ghost commented Mar 17, 2019

error[E0432]: unresolved import `libc::__errno_location`
  --> src/platform/linux/x11/mod.rs:22:85
   |
22 | use libc::{select, fd_set, FD_SET, FD_ZERO, FD_ISSET, EINTR, EINVAL, ENOMEM, EBADF, __errno_location};
   |                                                                                     ^^^^^^^^^^^^^^^^ no `__errno_location` in the root

__errno_location is called __error on FreeBSD and __errno on Open- and NetBSD.

Note that I only tested on FreeBSD. The OpenBSD and NetBSD bits are a pure guess on my part based on libc documentation and their errno.h [2,3,4,5].

[1] FreeBSD: https://rust-lang.github.io/libc/x86_64-unknown-freebsd/libc/fn.__error.html
[2] NetBSD: https://rust-lang.github.io/libc/x86_64-unknown-netbsd/libc/fn.__errno.html
[3] NetBSD: https://github.com/NetBSD/src/blob/trunk/include/errno.h
[4] OpenBSD: https://rust-lang.github.io/libc/x86_64-unknown-openbsd/libc/fn.__errno.html
[5] OpenBSD: https://github.com/OpenBSD/src/blob/master/include/errno.h

@ghost
Copy link
Author

ghost commented Mar 17, 2019

An alternative solution might be to use the errno crate to access errno in a cross-platform way.

https://crates.io/crates/errno

@elinorbgr
Copy link
Contributor

Hi, thanks for the PR!

Just as a stylistic nitpick, maybe it'd be better to just rename the imports, to avoid littering #[cfg()] markers all over the source, given this is apparently just a name change.

I'm thinking something like:

#[cfg(target_os = "linux")]
use libc::__errno_location;
#[cfg(target_os = "freebsd")]
use libc::__error as __errno_location;
#[cfg(any(target_os = "netbsd", target_os = "openbsd"))]
use libc::__errno as __errno_location;

Do we have any strong stylistic constraints wrt to this ? @francesca64 @Osspial ?

@ghost
Copy link
Author

ghost commented Mar 20, 2019

I've changed it as you've suggested. Anything else I can to do to get this merged?

@Osspial
Copy link
Contributor

Osspial commented Mar 21, 2019

The only thing I can see blocking this is a lack of changelog entry. We should be able to merge this once that's added in.

@ghost
Copy link
Author

ghost commented Mar 21, 2019

Added one.

Tobias Kortkamp added 3 commits March 21, 2019 19:13
error[E0432]: unresolved import `libc::__errno_location`
  --> src/platform/linux/x11/mod.rs:22:85
   |
22 | use libc::{select, fd_set, FD_SET, FD_ZERO, FD_ISSET, EINTR, EINVAL, ENOMEM, EBADF, __errno_location};
   |                                                                                     ^^^^^^^^^^^^^^^^ no `__errno_location` in the root

__errno_location is called __error on FreeBSD and __errno on Open- and NetBSD.

Signed-off-by: Tobias Kortkamp <[email protected]>
Signed-off-by: Tobias Kortkamp <[email protected]>
@Osspial Osspial merged commit 0019ff2 into rust-windowing:master Mar 22, 2019
elinorbgr pushed a commit to elinorbgr/winit that referenced this pull request Apr 7, 2019
* Fix build on FreeBSD

error[E0432]: unresolved import `libc::__errno_location`
  --> src/platform/linux/x11/mod.rs:22:85
   |
22 | use libc::{select, fd_set, FD_SET, FD_ZERO, FD_ISSET, EINTR, EINVAL, ENOMEM, EBADF, __errno_location};
   |                                                                                     ^^^^^^^^^^^^^^^^ no `__errno_location` in the root

__errno_location is called __error on FreeBSD and __errno on Open- and NetBSD.

Signed-off-by: Tobias Kortkamp <[email protected]>

* Import __error / __errno on *BSD as __errno_location

Signed-off-by: Tobias Kortkamp <[email protected]>

* Add changelog entry

Signed-off-by: Tobias Kortkamp <[email protected]>
elinorbgr pushed a commit to elinorbgr/winit that referenced this pull request Apr 7, 2019
* Fix build on FreeBSD

error[E0432]: unresolved import `libc::__errno_location`
  --> src/platform/linux/x11/mod.rs:22:85
   |
22 | use libc::{select, fd_set, FD_SET, FD_ZERO, FD_ISSET, EINTR, EINVAL, ENOMEM, EBADF, __errno_location};
   |                                                                                     ^^^^^^^^^^^^^^^^ no `__errno_location` in the root

__errno_location is called __error on FreeBSD and __errno on Open- and NetBSD.

Signed-off-by: Tobias Kortkamp <[email protected]>

* Import __error / __errno on *BSD as __errno_location

Signed-off-by: Tobias Kortkamp <[email protected]>

* Add changelog entry

Signed-off-by: Tobias Kortkamp <[email protected]>
felixrabe pushed a commit to felixrabe/winit that referenced this pull request Jun 30, 2019
* Fix build on FreeBSD

error[E0432]: unresolved import `libc::__errno_location`
  --> src/platform/linux/x11/mod.rs:22:85
   |
22 | use libc::{select, fd_set, FD_SET, FD_ZERO, FD_ISSET, EINTR, EINVAL, ENOMEM, EBADF, __errno_location};
   |                                                                                     ^^^^^^^^^^^^^^^^ no `__errno_location` in the root

__errno_location is called __error on FreeBSD and __errno on Open- and NetBSD.

Signed-off-by: Tobias Kortkamp <[email protected]>

* Import __error / __errno on *BSD as __errno_location

Signed-off-by: Tobias Kortkamp <[email protected]>

* Add changelog entry

Signed-off-by: Tobias Kortkamp <[email protected]>
kosyak pushed a commit to kosyak/winit that referenced this pull request Jul 10, 2019
* Fix build on FreeBSD

error[E0432]: unresolved import `libc::__errno_location`
  --> src/platform/linux/x11/mod.rs:22:85
   |
22 | use libc::{select, fd_set, FD_SET, FD_ZERO, FD_ISSET, EINTR, EINVAL, ENOMEM, EBADF, __errno_location};
   |                                                                                     ^^^^^^^^^^^^^^^^ no `__errno_location` in the root

__errno_location is called __error on FreeBSD and __errno on Open- and NetBSD.

Signed-off-by: Tobias Kortkamp <[email protected]>

* Import __error / __errno on *BSD as __errno_location

Signed-off-by: Tobias Kortkamp <[email protected]>

* Add changelog entry

Signed-off-by: Tobias Kortkamp <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants