2018-08-29 08:21:01 -05:00
|
|
|
#![allow(missing_docs, nonstandard_style)]
|
2014-10-10 10:11:49 -07:00
|
|
|
|
2019-02-11 04:23:21 +09:00
|
|
|
use crate::io::ErrorKind;
|
|
|
|
|
2017-11-01 12:32:13 -07:00
|
|
|
pub use self::rand::hashmap_random_keys;
|
2017-11-01 13:04:03 -07:00
|
|
|
pub use libc::strlen;
|
2017-11-01 12:32:13 -07:00
|
|
|
|
2016-02-04 13:56:59 -08:00
|
|
|
#[macro_use]
|
|
|
|
pub mod weak;
|
|
|
|
|
2018-11-03 11:15:48 -07:00
|
|
|
pub mod alloc;
|
2016-04-25 13:39:05 -07:00
|
|
|
pub mod android;
|
2019-12-22 17:42:04 -05:00
|
|
|
pub mod args;
|
2021-04-24 17:50:40 +02:00
|
|
|
#[path = "../unix/cmath.rs"]
|
2017-11-01 12:59:40 -07:00
|
|
|
pub mod cmath;
|
std: Rewrite the `sync` module
This commit is a reimplementation of `std::sync` to be based on the
system-provided primitives wherever possible. The previous implementation was
fundamentally built on top of channels, and as part of the runtime reform it has
become clear that this is not the level of abstraction that the standard level
should be providing. This rewrite aims to provide as thin of a shim as possible
on top of the system primitives in order to make them safe.
The overall interface of the `std::sync` module has in general not changed, but
there are a few important distinctions, highlighted below:
* The condition variable type, `Condvar`, has been separated out of a `Mutex`.
A condition variable is now an entirely separate type. This separation
benefits users who only use one mutex, and provides a clearer distinction of
who's responsible for managing condition variables (the application).
* All of `Condvar`, `Mutex`, and `RWLock` are now directly built on top of
system primitives rather than using a custom implementation. The `Once`,
`Barrier`, and `Semaphore` types are still built upon these abstractions of
the system primitives.
* The `Condvar`, `Mutex`, and `RWLock` types all have a new static type and
constant initializer corresponding to them. These are provided primarily for C
FFI interoperation, but are often useful to otherwise simply have a global
lock. The types, however, will leak memory unless `destroy()` is called on
them, which is clearly documented.
* The `Condvar` implementation for an `RWLock` write lock has been removed. This
may be added back in the future with a userspace implementation, but this
commit is focused on exposing the system primitives first.
* The fundamental architecture of this design is to provide two separate layers.
The first layer is that exposed by `sys_common` which is a cross-platform
bare-metal abstraction of the system synchronization primitives. No attempt is
made at making this layer safe, and it is quite unsafe to use! It is currently
not exported as part of the API of the standard library, but the stabilization
of the `sys` module will ensure that these will be exposed in time. The
purpose of this layer is to provide the core cross-platform abstractions if
necessary to implementors.
The second layer is the layer provided by `std::sync` which is intended to be
the thinnest possible layer on top of `sys_common` which is entirely safe to
use. There are a few concerns which need to be addressed when making these
system primitives safe:
* Once used, the OS primitives can never be **moved**. This means that they
essentially need to have a stable address. The static primitives use
`&'static self` to enforce this, and the non-static primitives all use a
`Box` to provide this guarantee.
* Poisoning is leveraged to ensure that invalid data is not accessible from
other tasks after one has panicked.
In addition to these overall blanket safety limitations, each primitive has a
few restrictions of its own:
* Mutexes and rwlocks can only be unlocked from the same thread that they
were locked by. This is achieved through RAII lock guards which cannot be
sent across threads.
* Mutexes and rwlocks can only be unlocked if they were previously locked.
This is achieved by not exposing an unlocking method.
* A condition variable can only be waited on with a locked mutex. This is
achieved by requiring a `MutexGuard` in the `wait()` method.
* A condition variable cannot be used concurrently with more than one mutex.
This is guaranteed by dynamically binding a condition variable to
precisely one mutex for its entire lifecycle. This restriction may be able
to be relaxed in the future (a mutex is unbound when no threads are
waiting on the condvar), but for now it is sufficient to guarantee safety.
* Condvars now support timeouts for their blocking operations. The
implementation for these operations is provided by the system.
Due to the modification of the `Condvar` API, removal of the `std::sync::mutex`
API, and reimplementation, this is a breaking change. Most code should be fairly
easy to port using the examples in the documentation of these primitives.
[breaking-change]
Closes #17094
Closes #18003
2014-11-24 11:16:40 -08:00
|
|
|
pub mod condvar;
|
2016-09-21 19:50:30 +00:00
|
|
|
pub mod env;
|
2015-02-02 21:39:14 -08:00
|
|
|
pub mod fd;
|
2015-05-05 16:35:15 -07:00
|
|
|
pub mod fs;
|
2020-09-19 18:03:10 +02:00
|
|
|
pub mod futex;
|
2019-02-08 20:42:34 +01:00
|
|
|
pub mod io;
|
2020-10-07 01:01:12 +02:00
|
|
|
#[cfg(any(target_os = "linux", target_os = "android"))]
|
|
|
|
pub mod kernel_copy;
|
2019-12-22 17:42:04 -05:00
|
|
|
#[cfg(target_os = "l4re")]
|
|
|
|
mod l4re;
|
|
|
|
pub mod memchr;
|
std: Rewrite the `sync` module
This commit is a reimplementation of `std::sync` to be based on the
system-provided primitives wherever possible. The previous implementation was
fundamentally built on top of channels, and as part of the runtime reform it has
become clear that this is not the level of abstraction that the standard level
should be providing. This rewrite aims to provide as thin of a shim as possible
on top of the system primitives in order to make them safe.
The overall interface of the `std::sync` module has in general not changed, but
there are a few important distinctions, highlighted below:
* The condition variable type, `Condvar`, has been separated out of a `Mutex`.
A condition variable is now an entirely separate type. This separation
benefits users who only use one mutex, and provides a clearer distinction of
who's responsible for managing condition variables (the application).
* All of `Condvar`, `Mutex`, and `RWLock` are now directly built on top of
system primitives rather than using a custom implementation. The `Once`,
`Barrier`, and `Semaphore` types are still built upon these abstractions of
the system primitives.
* The `Condvar`, `Mutex`, and `RWLock` types all have a new static type and
constant initializer corresponding to them. These are provided primarily for C
FFI interoperation, but are often useful to otherwise simply have a global
lock. The types, however, will leak memory unless `destroy()` is called on
them, which is clearly documented.
* The `Condvar` implementation for an `RWLock` write lock has been removed. This
may be added back in the future with a userspace implementation, but this
commit is focused on exposing the system primitives first.
* The fundamental architecture of this design is to provide two separate layers.
The first layer is that exposed by `sys_common` which is a cross-platform
bare-metal abstraction of the system synchronization primitives. No attempt is
made at making this layer safe, and it is quite unsafe to use! It is currently
not exported as part of the API of the standard library, but the stabilization
of the `sys` module will ensure that these will be exposed in time. The
purpose of this layer is to provide the core cross-platform abstractions if
necessary to implementors.
The second layer is the layer provided by `std::sync` which is intended to be
the thinnest possible layer on top of `sys_common` which is entirely safe to
use. There are a few concerns which need to be addressed when making these
system primitives safe:
* Once used, the OS primitives can never be **moved**. This means that they
essentially need to have a stable address. The static primitives use
`&'static self` to enforce this, and the non-static primitives all use a
`Box` to provide this guarantee.
* Poisoning is leveraged to ensure that invalid data is not accessible from
other tasks after one has panicked.
In addition to these overall blanket safety limitations, each primitive has a
few restrictions of its own:
* Mutexes and rwlocks can only be unlocked from the same thread that they
were locked by. This is achieved through RAII lock guards which cannot be
sent across threads.
* Mutexes and rwlocks can only be unlocked if they were previously locked.
This is achieved by not exposing an unlocking method.
* A condition variable can only be waited on with a locked mutex. This is
achieved by requiring a `MutexGuard` in the `wait()` method.
* A condition variable cannot be used concurrently with more than one mutex.
This is guaranteed by dynamically binding a condition variable to
precisely one mutex for its entire lifecycle. This restriction may be able
to be relaxed in the future (a mutex is unbound when no threads are
waiting on the condvar), but for now it is sufficient to guarantee safety.
* Condvars now support timeouts for their blocking operations. The
implementation for these operations is provided by the system.
Due to the modification of the `Condvar` API, removal of the `std::sync::mutex`
API, and reimplementation, this is a breaking change. Most code should be fairly
easy to port using the examples in the documentation of these primitives.
[breaking-change]
Closes #17094
Closes #18003
2014-11-24 11:16:40 -08:00
|
|
|
pub mod mutex;
|
2017-08-17 13:23:00 +02:00
|
|
|
#[cfg(not(target_os = "l4re"))]
|
2015-02-05 16:50:11 -08:00
|
|
|
pub mod net;
|
2017-09-06 16:01:51 +02:00
|
|
|
#[cfg(target_os = "l4re")]
|
|
|
|
pub use self::l4re::net;
|
2014-09-30 17:03:56 -07:00
|
|
|
pub mod os;
|
2016-09-21 19:11:39 +00:00
|
|
|
pub mod path;
|
2015-05-05 16:35:15 -07:00
|
|
|
pub mod pipe;
|
|
|
|
pub mod process;
|
2016-02-17 13:56:16 -08:00
|
|
|
pub mod rand;
|
std: Rewrite the `sync` module
This commit is a reimplementation of `std::sync` to be based on the
system-provided primitives wherever possible. The previous implementation was
fundamentally built on top of channels, and as part of the runtime reform it has
become clear that this is not the level of abstraction that the standard level
should be providing. This rewrite aims to provide as thin of a shim as possible
on top of the system primitives in order to make them safe.
The overall interface of the `std::sync` module has in general not changed, but
there are a few important distinctions, highlighted below:
* The condition variable type, `Condvar`, has been separated out of a `Mutex`.
A condition variable is now an entirely separate type. This separation
benefits users who only use one mutex, and provides a clearer distinction of
who's responsible for managing condition variables (the application).
* All of `Condvar`, `Mutex`, and `RWLock` are now directly built on top of
system primitives rather than using a custom implementation. The `Once`,
`Barrier`, and `Semaphore` types are still built upon these abstractions of
the system primitives.
* The `Condvar`, `Mutex`, and `RWLock` types all have a new static type and
constant initializer corresponding to them. These are provided primarily for C
FFI interoperation, but are often useful to otherwise simply have a global
lock. The types, however, will leak memory unless `destroy()` is called on
them, which is clearly documented.
* The `Condvar` implementation for an `RWLock` write lock has been removed. This
may be added back in the future with a userspace implementation, but this
commit is focused on exposing the system primitives first.
* The fundamental architecture of this design is to provide two separate layers.
The first layer is that exposed by `sys_common` which is a cross-platform
bare-metal abstraction of the system synchronization primitives. No attempt is
made at making this layer safe, and it is quite unsafe to use! It is currently
not exported as part of the API of the standard library, but the stabilization
of the `sys` module will ensure that these will be exposed in time. The
purpose of this layer is to provide the core cross-platform abstractions if
necessary to implementors.
The second layer is the layer provided by `std::sync` which is intended to be
the thinnest possible layer on top of `sys_common` which is entirely safe to
use. There are a few concerns which need to be addressed when making these
system primitives safe:
* Once used, the OS primitives can never be **moved**. This means that they
essentially need to have a stable address. The static primitives use
`&'static self` to enforce this, and the non-static primitives all use a
`Box` to provide this guarantee.
* Poisoning is leveraged to ensure that invalid data is not accessible from
other tasks after one has panicked.
In addition to these overall blanket safety limitations, each primitive has a
few restrictions of its own:
* Mutexes and rwlocks can only be unlocked from the same thread that they
were locked by. This is achieved through RAII lock guards which cannot be
sent across threads.
* Mutexes and rwlocks can only be unlocked if they were previously locked.
This is achieved by not exposing an unlocking method.
* A condition variable can only be waited on with a locked mutex. This is
achieved by requiring a `MutexGuard` in the `wait()` method.
* A condition variable cannot be used concurrently with more than one mutex.
This is guaranteed by dynamically binding a condition variable to
precisely one mutex for its entire lifecycle. This restriction may be able
to be relaxed in the future (a mutex is unbound when no threads are
waiting on the condvar), but for now it is sufficient to guarantee safety.
* Condvars now support timeouts for their blocking operations. The
implementation for these operations is provided by the system.
Due to the modification of the `Condvar` API, removal of the `std::sync::mutex`
API, and reimplementation, this is a breaking change. Most code should be fairly
easy to port using the examples in the documentation of these primitives.
[breaking-change]
Closes #17094
Closes #18003
2014-11-24 11:16:40 -08:00
|
|
|
pub mod rwlock;
|
2014-11-23 19:21:17 -08:00
|
|
|
pub mod stack_overflow;
|
2019-12-22 17:42:04 -05:00
|
|
|
pub mod stdio;
|
2014-11-23 19:21:17 -08:00
|
|
|
pub mod thread;
|
2020-07-12 11:37:11 +02:00
|
|
|
pub mod thread_local_dtor;
|
2020-07-12 11:45:04 +02:00
|
|
|
pub mod thread_local_key;
|
2015-01-13 21:24:26 -08:00
|
|
|
pub mod time;
|
2014-10-10 10:11:49 -07:00
|
|
|
|
2019-03-05 15:05:44 -08:00
|
|
|
pub use crate::sys_common::os_str_bytes as os_str;
|
|
|
|
|
2021-04-11 07:05:39 +02:00
|
|
|
// SAFETY: must be called only once during runtime initialization.
|
2021-04-18 07:19:39 +02:00
|
|
|
// NOTE: this is not guaranteed to run, for example when Rust code is called externally.
|
2021-04-11 23:48:10 +02:00
|
|
|
pub unsafe fn init(argc: isize, argv: *const *const u8) {
|
2020-09-27 00:00:00 +00:00
|
|
|
// The standard streams might be closed on application startup. To prevent
|
|
|
|
// std::io::{stdin, stdout,stderr} objects from using other unrelated file
|
|
|
|
// resources opened later, we reopen standards streams when they are closed.
|
2021-04-11 07:05:39 +02:00
|
|
|
sanitize_standard_fds();
|
2020-09-27 00:00:00 +00:00
|
|
|
|
2015-10-07 23:11:25 +01:00
|
|
|
// By default, some platforms will send a *signal* when an EPIPE error
|
2015-09-08 15:53:46 -07:00
|
|
|
// would otherwise be delivered. This runtime doesn't install a SIGPIPE
|
|
|
|
// handler, causing it to kill the program, which isn't exactly what we
|
|
|
|
// want!
|
|
|
|
//
|
|
|
|
// Hence, we set SIGPIPE to ignore when the program starts up in order
|
|
|
|
// to prevent this problem.
|
2021-04-11 07:05:39 +02:00
|
|
|
reset_sigpipe();
|
2016-01-09 18:20:33 +00:00
|
|
|
|
2021-04-11 23:48:10 +02:00
|
|
|
stack_overflow::init();
|
|
|
|
args::init(argc, argv);
|
|
|
|
|
|
|
|
unsafe fn sanitize_standard_fds() {
|
2021-04-18 05:13:53 +02:00
|
|
|
#[cfg(not(miri))]
|
|
|
|
// The standard fds are always available in Miri.
|
2021-04-11 23:48:10 +02:00
|
|
|
cfg_if::cfg_if! {
|
|
|
|
if #[cfg(not(any(
|
|
|
|
target_os = "emscripten",
|
|
|
|
target_os = "fuchsia",
|
|
|
|
target_os = "vxworks",
|
|
|
|
// The poll on Darwin doesn't set POLLNVAL for closed fds.
|
|
|
|
target_os = "macos",
|
|
|
|
target_os = "ios",
|
|
|
|
target_os = "redox",
|
|
|
|
)))] {
|
2020-09-28 10:32:05 +02:00
|
|
|
use crate::sys::os::errno;
|
|
|
|
let pfds: &mut [_] = &mut [
|
|
|
|
libc::pollfd { fd: 0, events: 0, revents: 0 },
|
|
|
|
libc::pollfd { fd: 1, events: 0, revents: 0 },
|
|
|
|
libc::pollfd { fd: 2, events: 0, revents: 0 },
|
|
|
|
];
|
|
|
|
while libc::poll(pfds.as_mut_ptr(), 3, 0) == -1 {
|
|
|
|
if errno() == libc::EINTR {
|
|
|
|
continue;
|
|
|
|
}
|
2020-09-27 00:00:00 +00:00
|
|
|
libc::abort();
|
|
|
|
}
|
2020-09-28 10:32:05 +02:00
|
|
|
for pfd in pfds {
|
|
|
|
if pfd.revents & libc::POLLNVAL == 0 {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if libc::open("/dev/null\0".as_ptr().cast(), libc::O_RDWR, 0) == -1 {
|
|
|
|
// If the stream is closed but we failed to reopen it, abort the
|
|
|
|
// process. Otherwise we wouldn't preserve the safety of
|
|
|
|
// operations on the corresponding Rust object Stdin, Stdout, or
|
|
|
|
// Stderr.
|
|
|
|
libc::abort();
|
|
|
|
}
|
|
|
|
}
|
2021-04-11 23:48:10 +02:00
|
|
|
} else if #[cfg(any(target_os = "macos", target_os = "ios", target_os = "redox"))] {
|
2020-09-28 10:32:05 +02:00
|
|
|
use crate::sys::os::errno;
|
|
|
|
for fd in 0..3 {
|
|
|
|
if libc::fcntl(fd, libc::F_GETFD) == -1 && errno() == libc::EBADF {
|
|
|
|
if libc::open("/dev/null\0".as_ptr().cast(), libc::O_RDWR, 0) == -1 {
|
|
|
|
libc::abort();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-09-27 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-22 23:49:57 -08:00
|
|
|
unsafe fn reset_sigpipe() {
|
2021-04-11 23:48:10 +02:00
|
|
|
#[cfg(not(any(target_os = "emscripten", target_os = "fuchsia")))]
|
2017-04-03 22:41:55 -07:00
|
|
|
assert!(signal(libc::SIGPIPE, libc::SIG_IGN) != libc::SIG_ERR);
|
2016-01-22 23:49:57 -08:00
|
|
|
}
|
2016-01-09 18:20:33 +00:00
|
|
|
}
|
2015-09-08 15:53:46 -07:00
|
|
|
|
2021-04-11 07:05:39 +02:00
|
|
|
// SAFETY: must be called only once during runtime cleanup.
|
2021-04-18 07:19:39 +02:00
|
|
|
// NOTE: this is not guaranteed to run, for example when the program aborts.
|
2021-04-11 23:20:01 +02:00
|
|
|
pub unsafe fn cleanup() {
|
|
|
|
args::cleanup();
|
|
|
|
stack_overflow::cleanup();
|
|
|
|
}
|
2021-04-11 07:05:39 +02:00
|
|
|
|
2016-03-21 16:54:53 -07:00
|
|
|
#[cfg(target_os = "android")]
|
2019-02-11 04:23:21 +09:00
|
|
|
pub use crate::sys::android::signal;
|
2016-03-21 16:54:53 -07:00
|
|
|
#[cfg(not(target_os = "android"))]
|
|
|
|
pub use libc::signal;
|
|
|
|
|
2015-01-31 20:24:36 -08:00
|
|
|
pub fn decode_error_kind(errno: i32) -> ErrorKind {
|
2020-12-03 20:39:33 +00:00
|
|
|
use ErrorKind::*;
|
2015-01-31 20:24:36 -08:00
|
|
|
match errno as libc::c_int {
|
2020-12-03 20:39:33 +00:00
|
|
|
libc::EADDRINUSE => AddrInUse,
|
|
|
|
libc::EADDRNOTAVAIL => AddrNotAvailable,
|
|
|
|
libc::ECONNABORTED => ConnectionAborted,
|
|
|
|
libc::ECONNREFUSED => ConnectionRefused,
|
|
|
|
libc::ECONNRESET => ConnectionReset,
|
|
|
|
libc::EEXIST => AlreadyExists,
|
|
|
|
libc::EINTR => Interrupted,
|
|
|
|
libc::EINVAL => InvalidInput,
|
|
|
|
libc::ENOENT => NotFound,
|
|
|
|
libc::ENOMEM => OutOfMemory,
|
|
|
|
libc::ENOSYS => Unsupported,
|
|
|
|
libc::ENOTCONN => NotConnected,
|
|
|
|
libc::EPIPE => BrokenPipe,
|
|
|
|
libc::ETIMEDOUT => TimedOut,
|
|
|
|
|
2021-06-18 18:46:50 +01:00
|
|
|
libc::EACCES | libc::EPERM => PermissionDenied,
|
2015-01-31 20:24:36 -08:00
|
|
|
|
|
|
|
// These two constants can have the same value on some systems,
|
|
|
|
// but different values on others, so we can't use a match
|
|
|
|
// clause
|
2020-12-03 20:39:33 +00:00
|
|
|
x if x == libc::EAGAIN || x == libc::EWOULDBLOCK => WouldBlock,
|
2015-01-31 20:24:36 -08:00
|
|
|
|
2020-12-03 20:39:33 +00:00
|
|
|
_ => Uncategorized,
|
2015-01-31 20:24:36 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-28 08:56:56 -07:00
|
|
|
#[doc(hidden)]
|
|
|
|
pub trait IsMinusOne {
|
|
|
|
fn is_minus_one(&self) -> bool;
|
|
|
|
}
|
|
|
|
|
|
|
|
macro_rules! impl_is_minus_one {
|
|
|
|
($($t:ident)*) => ($(impl IsMinusOne for $t {
|
|
|
|
fn is_minus_one(&self) -> bool {
|
|
|
|
*self == -1
|
|
|
|
}
|
|
|
|
})*)
|
|
|
|
}
|
|
|
|
|
|
|
|
impl_is_minus_one! { i8 i16 i32 i64 isize }
|
|
|
|
|
2019-02-11 04:23:21 +09:00
|
|
|
pub fn cvt<T: IsMinusOne>(t: T) -> crate::io::Result<T> {
|
2019-12-22 17:42:04 -05:00
|
|
|
if t.is_minus_one() { Err(crate::io::Error::last_os_error()) } else { Ok(t) }
|
2015-02-02 21:39:14 -08:00
|
|
|
}
|
|
|
|
|
2019-02-11 04:23:21 +09:00
|
|
|
pub fn cvt_r<T, F>(mut f: F) -> crate::io::Result<T>
|
2019-12-22 17:42:04 -05:00
|
|
|
where
|
|
|
|
T: IsMinusOne,
|
|
|
|
F: FnMut() -> T,
|
2015-02-02 21:39:14 -08:00
|
|
|
{
|
|
|
|
loop {
|
|
|
|
match cvt(f()) {
|
|
|
|
Err(ref e) if e.kind() == ErrorKind::Interrupted => {}
|
|
|
|
other => return other,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-09-30 23:07:04 +00:00
|
|
|
|
2020-10-20 00:00:00 +00:00
|
|
|
pub fn cvt_nz(error: libc::c_int) -> crate::io::Result<()> {
|
|
|
|
if error == 0 { Ok(()) } else { Err(crate::io::Error::from_raw_os_error(error)) }
|
|
|
|
}
|
|
|
|
|
2016-09-30 23:07:04 +00:00
|
|
|
// On Unix-like platforms, libc::abort will unregister signal handlers
|
|
|
|
// including the SIGABRT handler, preventing the abort from being blocked, and
|
2020-03-06 12:13:55 +01:00
|
|
|
// fclose streams, with the side effect of flushing them so libc buffered
|
2016-09-30 23:07:04 +00:00
|
|
|
// output will be printed. Additionally the shell will generally print a more
|
|
|
|
// understandable error message like "Abort trap" rather than "Illegal
|
|
|
|
// instruction" that intrinsics::abort would cause, as intrinsics::abort is
|
|
|
|
// implemented as an illegal instruction.
|
2020-05-17 19:37:44 +02:00
|
|
|
pub fn abort_internal() -> ! {
|
|
|
|
unsafe { libc::abort() }
|
2016-09-30 23:07:04 +00:00
|
|
|
}
|
2020-11-10 19:01:21 +01:00
|
|
|
|
|
|
|
cfg_if::cfg_if! {
|
|
|
|
if #[cfg(target_os = "android")] {
|
|
|
|
#[link(name = "dl")]
|
|
|
|
#[link(name = "log")]
|
|
|
|
#[link(name = "gcc")]
|
|
|
|
extern "C" {}
|
|
|
|
} else if #[cfg(target_os = "freebsd")] {
|
|
|
|
#[link(name = "execinfo")]
|
|
|
|
#[link(name = "pthread")]
|
|
|
|
extern "C" {}
|
|
|
|
} else if #[cfg(target_os = "netbsd")] {
|
|
|
|
#[link(name = "pthread")]
|
|
|
|
#[link(name = "rt")]
|
|
|
|
extern "C" {}
|
|
|
|
} else if #[cfg(any(target_os = "dragonfly", target_os = "openbsd"))] {
|
|
|
|
#[link(name = "pthread")]
|
|
|
|
extern "C" {}
|
|
|
|
} else if #[cfg(target_os = "solaris")] {
|
|
|
|
#[link(name = "socket")]
|
|
|
|
#[link(name = "posix4")]
|
|
|
|
#[link(name = "pthread")]
|
|
|
|
#[link(name = "resolv")]
|
|
|
|
extern "C" {}
|
|
|
|
} else if #[cfg(target_os = "illumos")] {
|
|
|
|
#[link(name = "socket")]
|
|
|
|
#[link(name = "posix4")]
|
|
|
|
#[link(name = "pthread")]
|
|
|
|
#[link(name = "resolv")]
|
|
|
|
#[link(name = "nsl")]
|
|
|
|
// Use libumem for the (malloc-compatible) allocator
|
|
|
|
#[link(name = "umem")]
|
|
|
|
extern "C" {}
|
|
|
|
} else if #[cfg(target_os = "macos")] {
|
|
|
|
#[link(name = "System")]
|
|
|
|
// res_init and friends require -lresolv on macOS/iOS.
|
|
|
|
// See #41582 and http://blog.achernya.com/2013/03/os-x-has-silly-libsystem.html
|
|
|
|
#[link(name = "resolv")]
|
|
|
|
extern "C" {}
|
|
|
|
} else if #[cfg(target_os = "ios")] {
|
|
|
|
#[link(name = "System")]
|
|
|
|
#[link(name = "objc")]
|
|
|
|
#[link(name = "Security", kind = "framework")]
|
|
|
|
#[link(name = "Foundation", kind = "framework")]
|
|
|
|
#[link(name = "resolv")]
|
|
|
|
extern "C" {}
|
|
|
|
} else if #[cfg(target_os = "fuchsia")] {
|
|
|
|
#[link(name = "zircon")]
|
|
|
|
#[link(name = "fdio")]
|
|
|
|
extern "C" {}
|
|
|
|
}
|
|
|
|
}
|