rust/src/libstd/sys/unix/c.rs

390 lines
12 KiB
Rust
Raw Normal View History

// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
//! C definitions used by libnative that don't belong in liblibc
#![allow(dead_code)]
#![allow(non_camel_case_types)]
pub use self::select::fd_set;
pub use self::signal::{sigaction, siginfo, sigset_t};
pub use self::signal::{SA_ONSTACK, SA_RESTART, SA_RESETHAND, SA_NOCLDSTOP};
pub use self::signal::{SA_NODEFER, SA_NOCLDWAIT, SA_SIGINFO, SIGCHLD};
use libc;
2014-09-29 07:28:50 +00:00
#[cfg(any(target_os = "macos",
target_os = "ios",
target_os = "freebsd",
2015-01-29 07:19:28 +00:00
target_os = "dragonfly",
2015-01-17 07:51:04 +00:00
target_os = "bitrig",
2015-01-29 07:19:28 +00:00
target_os = "openbsd"))]
mod consts {
use libc;
pub const FIONBIO: libc::c_ulong = 0x8004667e;
pub const FIOCLEX: libc::c_ulong = 0x20006601;
pub const FIONCLEX: libc::c_ulong = 0x20006602;
}
2014-09-29 07:28:50 +00:00
#[cfg(any(all(target_os = "linux",
any(target_arch = "x86",
target_arch = "x86_64",
target_arch = "arm",
target_arch = "aarch64")),
2014-09-29 07:28:50 +00:00
target_os = "android"))]
mod consts {
use libc;
pub const FIONBIO: libc::c_ulong = 0x5421;
pub const FIOCLEX: libc::c_ulong = 0x5451;
pub const FIONCLEX: libc::c_ulong = 0x5450;
}
2014-09-29 07:28:50 +00:00
#[cfg(all(target_os = "linux",
any(target_arch = "mips",
target_arch = "mipsel",
target_arch = "powerpc")))]
mod consts {
use libc;
pub const FIONBIO: libc::c_ulong = 0x667e;
pub const FIOCLEX: libc::c_ulong = 0x6601;
pub const FIONCLEX: libc::c_ulong = 0x6600;
}
pub use self::consts::*;
2014-09-29 07:28:50 +00:00
#[cfg(any(target_os = "macos",
target_os = "ios",
target_os = "freebsd",
2015-01-29 07:19:28 +00:00
target_os = "dragonfly",
2015-01-17 07:51:04 +00:00
target_os = "bitrig",
2015-01-29 07:19:28 +00:00
target_os = "openbsd"))]
2014-10-06 23:33:29 +00:00
pub const MSG_DONTWAIT: libc::c_int = 0x80;
2014-09-29 07:28:50 +00:00
#[cfg(any(target_os = "linux", target_os = "android"))]
2014-10-06 23:33:29 +00:00
pub const MSG_DONTWAIT: libc::c_int = 0x40;
2014-10-06 23:33:29 +00:00
pub const WNOHANG: libc::c_int = 1;
std: Add a new `env` module This is an implementation of [RFC 578][rfc] which adds a new `std::env` module to replace most of the functionality in the current `std::os` module. More details can be found in the RFC itself, but as a summary the following methods have all been deprecated: [rfc]: https://github.com/rust-lang/rfcs/pull/578 * `os::args_as_bytes` => `env::args` * `os::args` => `env::args` * `os::consts` => `env::consts` * `os::dll_filename` => no replacement, use `env::consts` directly * `os::page_size` => `env::page_size` * `os::make_absolute` => use `env::current_dir` + `join` instead * `os::getcwd` => `env::current_dir` * `os::change_dir` => `env::set_current_dir` * `os::homedir` => `env::home_dir` * `os::tmpdir` => `env::temp_dir` * `os::join_paths` => `env::join_paths` * `os::split_paths` => `env::split_paths` * `os::self_exe_name` => `env::current_exe` * `os::self_exe_path` => use `env::current_exe` + `pop` * `os::set_exit_status` => `env::set_exit_status` * `os::get_exit_status` => `env::get_exit_status` * `os::env` => `env::vars` * `os::env_as_bytes` => `env::vars` * `os::getenv` => `env::var` or `env::var_string` * `os::getenv_as_bytes` => `env::var` * `os::setenv` => `env::set_var` * `os::unsetenv` => `env::remove_var` Many function signatures have also been tweaked for various purposes, but the main changes were: * `Vec`-returning APIs now all return iterators instead * All APIs are now centered around `OsString` instead of `Vec<u8>` or `String`. There is currently on convenience API, `env::var_string`, which can be used to get the value of an environment variable as a unicode `String`. All old APIs are `#[deprecated]` in-place and will remain for some time to allow for migrations. The semantics of the APIs have been tweaked slightly with regard to dealing with invalid unicode (panic instead of replacement). The new `std::env` module is all contained within the `env` feature, so crates must add the following to access the new APIs: #![feature(env)] [breaking-change]
2015-01-27 20:20:58 +00:00
#[cfg(target_os = "linux")]
pub const _SC_GETPW_R_SIZE_MAX: libc::c_int = 70;
#[cfg(any(target_os = "macos",
target_os = "freebsd",
target_os = "dragonfly"))]
std: Add a new `env` module This is an implementation of [RFC 578][rfc] which adds a new `std::env` module to replace most of the functionality in the current `std::os` module. More details can be found in the RFC itself, but as a summary the following methods have all been deprecated: [rfc]: https://github.com/rust-lang/rfcs/pull/578 * `os::args_as_bytes` => `env::args` * `os::args` => `env::args` * `os::consts` => `env::consts` * `os::dll_filename` => no replacement, use `env::consts` directly * `os::page_size` => `env::page_size` * `os::make_absolute` => use `env::current_dir` + `join` instead * `os::getcwd` => `env::current_dir` * `os::change_dir` => `env::set_current_dir` * `os::homedir` => `env::home_dir` * `os::tmpdir` => `env::temp_dir` * `os::join_paths` => `env::join_paths` * `os::split_paths` => `env::split_paths` * `os::self_exe_name` => `env::current_exe` * `os::self_exe_path` => use `env::current_exe` + `pop` * `os::set_exit_status` => `env::set_exit_status` * `os::get_exit_status` => `env::get_exit_status` * `os::env` => `env::vars` * `os::env_as_bytes` => `env::vars` * `os::getenv` => `env::var` or `env::var_string` * `os::getenv_as_bytes` => `env::var` * `os::setenv` => `env::set_var` * `os::unsetenv` => `env::remove_var` Many function signatures have also been tweaked for various purposes, but the main changes were: * `Vec`-returning APIs now all return iterators instead * All APIs are now centered around `OsString` instead of `Vec<u8>` or `String`. There is currently on convenience API, `env::var_string`, which can be used to get the value of an environment variable as a unicode `String`. All old APIs are `#[deprecated]` in-place and will remain for some time to allow for migrations. The semantics of the APIs have been tweaked slightly with regard to dealing with invalid unicode (panic instead of replacement). The new `std::env` module is all contained within the `env` feature, so crates must add the following to access the new APIs: #![feature(env)] [breaking-change]
2015-01-27 20:20:58 +00:00
pub const _SC_GETPW_R_SIZE_MAX: libc::c_int = 71;
2015-01-17 07:51:04 +00:00
#[cfg(any(target_os = "bitrig",
target_os = "openbsd"))]
pub const _SC_GETPW_R_SIZE_MAX: libc::c_int = 101;
std: Add a new `env` module This is an implementation of [RFC 578][rfc] which adds a new `std::env` module to replace most of the functionality in the current `std::os` module. More details can be found in the RFC itself, but as a summary the following methods have all been deprecated: [rfc]: https://github.com/rust-lang/rfcs/pull/578 * `os::args_as_bytes` => `env::args` * `os::args` => `env::args` * `os::consts` => `env::consts` * `os::dll_filename` => no replacement, use `env::consts` directly * `os::page_size` => `env::page_size` * `os::make_absolute` => use `env::current_dir` + `join` instead * `os::getcwd` => `env::current_dir` * `os::change_dir` => `env::set_current_dir` * `os::homedir` => `env::home_dir` * `os::tmpdir` => `env::temp_dir` * `os::join_paths` => `env::join_paths` * `os::split_paths` => `env::split_paths` * `os::self_exe_name` => `env::current_exe` * `os::self_exe_path` => use `env::current_exe` + `pop` * `os::set_exit_status` => `env::set_exit_status` * `os::get_exit_status` => `env::get_exit_status` * `os::env` => `env::vars` * `os::env_as_bytes` => `env::vars` * `os::getenv` => `env::var` or `env::var_string` * `os::getenv_as_bytes` => `env::var` * `os::setenv` => `env::set_var` * `os::unsetenv` => `env::remove_var` Many function signatures have also been tweaked for various purposes, but the main changes were: * `Vec`-returning APIs now all return iterators instead * All APIs are now centered around `OsString` instead of `Vec<u8>` or `String`. There is currently on convenience API, `env::var_string`, which can be used to get the value of an environment variable as a unicode `String`. All old APIs are `#[deprecated]` in-place and will remain for some time to allow for migrations. The semantics of the APIs have been tweaked slightly with regard to dealing with invalid unicode (panic instead of replacement). The new `std::env` module is all contained within the `env` feature, so crates must add the following to access the new APIs: #![feature(env)] [breaking-change]
2015-01-27 20:20:58 +00:00
#[cfg(target_os = "android")]
pub const _SC_GETPW_R_SIZE_MAX: libc::c_int = 0x0048;
#[repr(C)]
#[cfg(target_os = "linux")]
pub struct passwd {
pub pw_name: *mut libc::c_char,
pub pw_passwd: *mut libc::c_char,
pub pw_uid: libc::uid_t,
pub pw_gid: libc::gid_t,
pub pw_gecos: *mut libc::c_char,
pub pw_dir: *mut libc::c_char,
pub pw_shell: *mut libc::c_char,
}
#[repr(C)]
#[cfg(any(target_os = "macos",
target_os = "freebsd",
target_os = "dragonfly",
2015-01-17 07:51:04 +00:00
target_os = "bitrig",
target_os = "openbsd"))]
std: Add a new `env` module This is an implementation of [RFC 578][rfc] which adds a new `std::env` module to replace most of the functionality in the current `std::os` module. More details can be found in the RFC itself, but as a summary the following methods have all been deprecated: [rfc]: https://github.com/rust-lang/rfcs/pull/578 * `os::args_as_bytes` => `env::args` * `os::args` => `env::args` * `os::consts` => `env::consts` * `os::dll_filename` => no replacement, use `env::consts` directly * `os::page_size` => `env::page_size` * `os::make_absolute` => use `env::current_dir` + `join` instead * `os::getcwd` => `env::current_dir` * `os::change_dir` => `env::set_current_dir` * `os::homedir` => `env::home_dir` * `os::tmpdir` => `env::temp_dir` * `os::join_paths` => `env::join_paths` * `os::split_paths` => `env::split_paths` * `os::self_exe_name` => `env::current_exe` * `os::self_exe_path` => use `env::current_exe` + `pop` * `os::set_exit_status` => `env::set_exit_status` * `os::get_exit_status` => `env::get_exit_status` * `os::env` => `env::vars` * `os::env_as_bytes` => `env::vars` * `os::getenv` => `env::var` or `env::var_string` * `os::getenv_as_bytes` => `env::var` * `os::setenv` => `env::set_var` * `os::unsetenv` => `env::remove_var` Many function signatures have also been tweaked for various purposes, but the main changes were: * `Vec`-returning APIs now all return iterators instead * All APIs are now centered around `OsString` instead of `Vec<u8>` or `String`. There is currently on convenience API, `env::var_string`, which can be used to get the value of an environment variable as a unicode `String`. All old APIs are `#[deprecated]` in-place and will remain for some time to allow for migrations. The semantics of the APIs have been tweaked slightly with regard to dealing with invalid unicode (panic instead of replacement). The new `std::env` module is all contained within the `env` feature, so crates must add the following to access the new APIs: #![feature(env)] [breaking-change]
2015-01-27 20:20:58 +00:00
pub struct passwd {
pub pw_name: *mut libc::c_char,
pub pw_passwd: *mut libc::c_char,
pub pw_uid: libc::uid_t,
pub pw_gid: libc::gid_t,
pub pw_change: libc::time_t,
pub pw_class: *mut libc::c_char,
pub pw_gecos: *mut libc::c_char,
pub pw_dir: *mut libc::c_char,
pub pw_shell: *mut libc::c_char,
pub pw_expire: libc::time_t,
}
#[repr(C)]
#[cfg(target_os = "android")]
pub struct passwd {
pub pw_name: *mut libc::c_char,
pub pw_passwd: *mut libc::c_char,
pub pw_uid: libc::uid_t,
pub pw_gid: libc::gid_t,
pub pw_dir: *mut libc::c_char,
pub pw_shell: *mut libc::c_char,
}
extern {
pub fn gettimeofday(timeval: *mut libc::timeval,
2014-06-25 19:47:34 +00:00
tzp: *mut libc::c_void) -> libc::c_int;
pub fn select(nfds: libc::c_int,
2014-06-25 19:47:34 +00:00
readfds: *mut fd_set,
writefds: *mut fd_set,
errorfds: *mut fd_set,
timeout: *mut libc::timeval) -> libc::c_int;
pub fn getsockopt(sockfd: libc::c_int,
level: libc::c_int,
optname: libc::c_int,
optval: *mut libc::c_void,
optlen: *mut libc::socklen_t) -> libc::c_int;
pub fn ioctl(fd: libc::c_int, req: libc::c_ulong, ...) -> libc::c_int;
pub fn waitpid(pid: libc::pid_t, status: *mut libc::c_int,
options: libc::c_int) -> libc::pid_t;
pub fn sigaction(signum: libc::c_int,
2014-06-25 19:47:34 +00:00
act: *const sigaction,
oldact: *mut sigaction) -> libc::c_int;
pub fn sigaddset(set: *mut sigset_t, signum: libc::c_int) -> libc::c_int;
pub fn sigdelset(set: *mut sigset_t, signum: libc::c_int) -> libc::c_int;
pub fn sigemptyset(set: *mut sigset_t) -> libc::c_int;
std: Add a new `env` module This is an implementation of [RFC 578][rfc] which adds a new `std::env` module to replace most of the functionality in the current `std::os` module. More details can be found in the RFC itself, but as a summary the following methods have all been deprecated: [rfc]: https://github.com/rust-lang/rfcs/pull/578 * `os::args_as_bytes` => `env::args` * `os::args` => `env::args` * `os::consts` => `env::consts` * `os::dll_filename` => no replacement, use `env::consts` directly * `os::page_size` => `env::page_size` * `os::make_absolute` => use `env::current_dir` + `join` instead * `os::getcwd` => `env::current_dir` * `os::change_dir` => `env::set_current_dir` * `os::homedir` => `env::home_dir` * `os::tmpdir` => `env::temp_dir` * `os::join_paths` => `env::join_paths` * `os::split_paths` => `env::split_paths` * `os::self_exe_name` => `env::current_exe` * `os::self_exe_path` => use `env::current_exe` + `pop` * `os::set_exit_status` => `env::set_exit_status` * `os::get_exit_status` => `env::get_exit_status` * `os::env` => `env::vars` * `os::env_as_bytes` => `env::vars` * `os::getenv` => `env::var` or `env::var_string` * `os::getenv_as_bytes` => `env::var` * `os::setenv` => `env::set_var` * `os::unsetenv` => `env::remove_var` Many function signatures have also been tweaked for various purposes, but the main changes were: * `Vec`-returning APIs now all return iterators instead * All APIs are now centered around `OsString` instead of `Vec<u8>` or `String`. There is currently on convenience API, `env::var_string`, which can be used to get the value of an environment variable as a unicode `String`. All old APIs are `#[deprecated]` in-place and will remain for some time to allow for migrations. The semantics of the APIs have been tweaked slightly with regard to dealing with invalid unicode (panic instead of replacement). The new `std::env` module is all contained within the `env` feature, so crates must add the following to access the new APIs: #![feature(env)] [breaking-change]
2015-01-27 20:20:58 +00:00
2015-02-03 13:30:10 +00:00
#[cfg(not(target_os = "ios"))]
std: Add a new `env` module This is an implementation of [RFC 578][rfc] which adds a new `std::env` module to replace most of the functionality in the current `std::os` module. More details can be found in the RFC itself, but as a summary the following methods have all been deprecated: [rfc]: https://github.com/rust-lang/rfcs/pull/578 * `os::args_as_bytes` => `env::args` * `os::args` => `env::args` * `os::consts` => `env::consts` * `os::dll_filename` => no replacement, use `env::consts` directly * `os::page_size` => `env::page_size` * `os::make_absolute` => use `env::current_dir` + `join` instead * `os::getcwd` => `env::current_dir` * `os::change_dir` => `env::set_current_dir` * `os::homedir` => `env::home_dir` * `os::tmpdir` => `env::temp_dir` * `os::join_paths` => `env::join_paths` * `os::split_paths` => `env::split_paths` * `os::self_exe_name` => `env::current_exe` * `os::self_exe_path` => use `env::current_exe` + `pop` * `os::set_exit_status` => `env::set_exit_status` * `os::get_exit_status` => `env::get_exit_status` * `os::env` => `env::vars` * `os::env_as_bytes` => `env::vars` * `os::getenv` => `env::var` or `env::var_string` * `os::getenv_as_bytes` => `env::var` * `os::setenv` => `env::set_var` * `os::unsetenv` => `env::remove_var` Many function signatures have also been tweaked for various purposes, but the main changes were: * `Vec`-returning APIs now all return iterators instead * All APIs are now centered around `OsString` instead of `Vec<u8>` or `String`. There is currently on convenience API, `env::var_string`, which can be used to get the value of an environment variable as a unicode `String`. All old APIs are `#[deprecated]` in-place and will remain for some time to allow for migrations. The semantics of the APIs have been tweaked slightly with regard to dealing with invalid unicode (panic instead of replacement). The new `std::env` module is all contained within the `env` feature, so crates must add the following to access the new APIs: #![feature(env)] [breaking-change]
2015-01-27 20:20:58 +00:00
pub fn getpwuid_r(uid: libc::uid_t,
pwd: *mut passwd,
buf: *mut libc::c_char,
buflen: libc::size_t,
result: *mut *mut passwd) -> libc::c_int;
pub fn utimes(filename: *const libc::c_char,
times: *const libc::timeval) -> libc::c_int;
pub fn gai_strerror(errcode: libc::c_int) -> *const libc::c_char;
pub fn setgroups(ngroups: libc::c_int,
ptr: *const libc::c_void) -> libc::c_int;
std: Expand the area of std::fs This commit is an implementation of [RFC 1044][rfc] which adds additional surface area to the `std::fs` module. All new APIs are `#[unstable]` behind assorted feature names for each one. [rfc]: https://github.com/rust-lang/rfcs/pull/1044 The new APIs added are: * `fs::canonicalize` - bindings to `realpath` on unix and `GetFinalPathNameByHandle` on windows. * `fs::symlink_metadata` - similar to `lstat` on unix * `fs::FileType` and accessor methods as `is_{file,dir,symlink}` * `fs::Metadata::file_type` - accessor for the raw file type * `fs::DirEntry::metadata` - acquisition of metadata which is free on Windows but requires a syscall on unix. * `fs::DirEntry::file_type` - access the file type which may not require a syscall on most platforms. * `fs::DirEntry::file_name` - access just the file name without leading components. * `fs::PathExt::symlink_metadata` - convenience method for the top-level function. * `fs::PathExt::canonicalize` - convenience method for the top-level function. * `fs::PathExt::read_link` - convenience method for the top-level function. * `fs::PathExt::read_dir` - convenience method for the top-level function. * `std::os::raw` - type definitions for raw OS/C types available on all platforms. * `std::os::$platform` - new modules have been added for all currently supported platforms (e.g. those more specific than just `unix`). * `std::os::$platform::raw` - platform-specific type definitions. These modules are populated with the bare essentials necessary for lowing I/O types into their raw representations, and currently largely consist of the `stat` definition for unix platforms. This commit also deprecates `Metadata::{modified, accessed}` in favor of inspecting the raw representations via the lowering methods of `Metadata`.
2015-04-16 06:21:13 +00:00
pub fn realpath(pathname: *const libc::c_char, resolved: *mut libc::c_char)
-> *mut libc::c_char;
}
2014-09-29 07:28:50 +00:00
#[cfg(any(target_os = "macos", target_os = "ios"))]
mod select {
pub const FD_SETSIZE: usize = 1024;
2014-05-28 01:37:49 +00:00
#[repr(C)]
pub struct fd_set {
2015-01-01 04:40:24 +00:00
fds_bits: [i32; (FD_SETSIZE / 32)]
}
pub fn fd_set(set: &mut fd_set, fd: i32) {
set.fds_bits[(fd / 32) as usize] |= 1 << ((fd % 32) as usize);
}
}
2014-09-29 07:28:50 +00:00
#[cfg(any(target_os = "android",
target_os = "freebsd",
target_os = "dragonfly",
2015-01-17 07:51:04 +00:00
target_os = "bitrig",
2015-01-29 07:19:28 +00:00
target_os = "openbsd",
2014-09-29 07:28:50 +00:00
target_os = "linux"))]
mod select {
use usize;
2014-08-14 19:49:26 +00:00
use libc;
pub const FD_SETSIZE: usize = 1024;
2014-05-28 01:37:49 +00:00
#[repr(C)]
pub struct fd_set {
// FIXME: shouldn't this be a c_ulong?
2015-03-28 13:07:25 +00:00
fds_bits: [libc::uintptr_t; (FD_SETSIZE / usize::BITS)]
}
pub fn fd_set(set: &mut fd_set, fd: i32) {
let fd = fd as usize;
2015-03-28 13:07:25 +00:00
set.fds_bits[fd / usize::BITS] |= 1 << (fd % usize::BITS);
}
}
2014-09-29 07:28:50 +00:00
#[cfg(any(all(target_os = "linux",
any(target_arch = "x86",
target_arch = "x86_64",
target_arch = "arm",
target_arch = "aarch64")),
2014-09-29 07:28:50 +00:00
target_os = "android"))]
mod signal {
use libc;
2014-10-06 23:33:29 +00:00
pub const SA_NOCLDSTOP: libc::c_ulong = 0x00000001;
pub const SA_NOCLDWAIT: libc::c_ulong = 0x00000002;
pub const SA_NODEFER: libc::c_ulong = 0x40000000;
pub const SA_ONSTACK: libc::c_ulong = 0x08000000;
pub const SA_RESETHAND: libc::c_ulong = 0x80000000;
pub const SA_RESTART: libc::c_ulong = 0x10000000;
pub const SA_SIGINFO: libc::c_ulong = 0x00000004;
pub const SIGCHLD: libc::c_int = 17;
// This definition is not as accurate as it could be, {pid, uid, status} is
// actually a giant union. Currently we're only interested in these fields,
// however.
2014-05-28 01:37:49 +00:00
#[repr(C)]
pub struct siginfo {
si_signo: libc::c_int,
si_errno: libc::c_int,
si_code: libc::c_int,
pub pid: libc::pid_t,
pub uid: libc::uid_t,
pub status: libc::c_int,
}
2014-05-28 01:37:49 +00:00
#[repr(C)]
pub struct sigaction {
pub sa_handler: extern fn(libc::c_int),
pub sa_mask: sigset_t,
pub sa_flags: libc::c_ulong,
sa_restorer: *mut libc::c_void,
}
2015-01-06 22:33:42 +00:00
unsafe impl ::marker::Send for sigaction { }
unsafe impl ::marker::Sync for sigaction { }
2014-12-06 16:39:25 +00:00
2014-05-28 01:37:49 +00:00
#[repr(C)]
2015-01-16 15:01:02 +00:00
#[cfg(target_pointer_width = "32")]
pub struct sigset_t {
__val: [libc::c_ulong; 32],
}
2014-05-28 01:37:49 +00:00
#[repr(C)]
2015-01-16 15:01:02 +00:00
#[cfg(target_pointer_width = "64")]
pub struct sigset_t {
__val: [libc::c_ulong; 16],
}
}
2014-09-29 07:28:50 +00:00
#[cfg(all(target_os = "linux",
any(target_arch = "mips",
target_arch = "mipsel",
target_arch = "powerpc")))]
2014-05-27 09:00:50 +00:00
mod signal {
use libc;
2014-10-06 23:33:29 +00:00
pub const SA_NOCLDSTOP: libc::c_ulong = 0x00000001;
pub const SA_NOCLDWAIT: libc::c_ulong = 0x00010000;
pub const SA_NODEFER: libc::c_ulong = 0x40000000;
pub const SA_ONSTACK: libc::c_ulong = 0x08000000;
pub const SA_RESETHAND: libc::c_ulong = 0x80000000;
pub const SA_RESTART: libc::c_ulong = 0x10000000;
pub const SA_SIGINFO: libc::c_ulong = 0x00000008;
pub const SIGCHLD: libc::c_int = 18;
2014-05-27 09:00:50 +00:00
// This definition is not as accurate as it could be, {pid, uid, status} is
// actually a giant union. Currently we're only interested in these fields,
// however.
2014-05-28 01:37:49 +00:00
#[repr(C)]
2014-05-27 09:00:50 +00:00
pub struct siginfo {
si_signo: libc::c_int,
si_code: libc::c_int,
si_errno: libc::c_int,
pub pid: libc::pid_t,
pub uid: libc::uid_t,
pub status: libc::c_int,
}
2014-05-28 01:37:49 +00:00
#[repr(C)]
2014-05-27 09:00:50 +00:00
pub struct sigaction {
pub sa_flags: libc::c_uint,
pub sa_handler: extern fn(libc::c_int),
pub sa_mask: sigset_t,
sa_restorer: *mut libc::c_void,
sa_resv: [libc::c_int; 1],
2014-05-27 09:00:50 +00:00
}
2015-01-06 22:33:42 +00:00
unsafe impl ::marker::Send for sigaction { }
unsafe impl ::marker::Sync for sigaction { }
2014-12-06 16:39:25 +00:00
2014-05-28 01:37:49 +00:00
#[repr(C)]
2014-05-27 09:00:50 +00:00
pub struct sigset_t {
__val: [libc::c_ulong; 32],
2014-05-27 09:00:50 +00:00
}
}
2014-09-29 07:28:50 +00:00
#[cfg(any(target_os = "macos",
target_os = "ios",
target_os = "freebsd",
2015-02-07 01:59:35 +00:00
target_os = "dragonfly"))]
mod signal {
use libc;
2014-10-06 23:33:29 +00:00
pub const SA_ONSTACK: libc::c_int = 0x0001;
pub const SA_RESTART: libc::c_int = 0x0002;
pub const SA_RESETHAND: libc::c_int = 0x0004;
pub const SA_NOCLDSTOP: libc::c_int = 0x0008;
pub const SA_NODEFER: libc::c_int = 0x0010;
pub const SA_NOCLDWAIT: libc::c_int = 0x0020;
pub const SA_SIGINFO: libc::c_int = 0x0040;
pub const SIGCHLD: libc::c_int = 20;
2015-01-29 07:19:28 +00:00
#[cfg(any(target_os = "macos",
2015-02-07 01:59:35 +00:00
target_os = "ios"))]
pub type sigset_t = u32;
2014-10-05 16:30:04 +00:00
#[cfg(any(target_os = "freebsd", target_os = "dragonfly"))]
#[repr(C)]
pub struct sigset_t {
bits: [u32; 4],
}
// This structure has more fields, but we're not all that interested in
// them.
2014-05-28 01:37:49 +00:00
#[repr(C)]
pub struct siginfo {
pub si_signo: libc::c_int,
pub si_errno: libc::c_int,
pub si_code: libc::c_int,
pub pid: libc::pid_t,
pub uid: libc::uid_t,
pub status: libc::c_int,
}
2014-05-28 01:37:49 +00:00
#[repr(C)]
pub struct sigaction {
pub sa_handler: extern fn(libc::c_int),
pub sa_flags: libc::c_int,
pub sa_mask: sigset_t,
}
}
2015-01-17 07:51:04 +00:00
2015-02-07 01:59:35 +00:00
#[cfg(any(target_os = "bitrig", target_os = "openbsd"))]
2015-01-17 07:51:04 +00:00
mod signal {
use libc;
pub const SA_ONSTACK: libc::c_int = 0x0001;
pub const SA_RESTART: libc::c_int = 0x0002;
pub const SA_RESETHAND: libc::c_int = 0x0004;
pub const SA_NOCLDSTOP: libc::c_int = 0x0008;
pub const SA_NODEFER: libc::c_int = 0x0010;
pub const SA_NOCLDWAIT: libc::c_int = 0x0020;
pub const SA_SIGINFO: libc::c_int = 0x0040;
pub const SIGCHLD: libc::c_int = 20;
pub type sigset_t = libc::c_uint;
// This structure has more fields, but we're not all that interested in
// them.
#[repr(C)]
pub struct siginfo {
pub si_signo: libc::c_int,
pub si_code: libc::c_int,
pub si_errno: libc::c_int,
// FIXME: Bitrig has a crazy union here in the siginfo, I think this
// layout will still work tho. The status might be off by the size of
// a clock_t by my reading, but we can fix this later.
pub pid: libc::pid_t,
pub uid: libc::uid_t,
pub status: libc::c_int,
}
#[repr(C)]
pub struct sigaction {
pub sa_handler: extern fn(libc::c_int),
pub sa_mask: sigset_t,
pub sa_flags: libc::c_int,
}
}