Add posix_spawn bindings

This commit is contained in:
Alex Crichton 2018-01-25 16:19:35 -08:00
parent ac4afe746f
commit 4621a34864
3 changed files with 160 additions and 0 deletions

View File

@ -162,6 +162,7 @@ fn main() {
}
if apple {
cfg.header("spawn.h");
cfg.header("mach-o/dyld.h");
cfg.header("mach/mach_time.h");
cfg.header("malloc/malloc.h");
@ -276,6 +277,7 @@ fn main() {
cfg.header("elf.h");
cfg.header("link.h");
cfg.header("linux/if_tun.h");
cfg.header("spawn.h");
}
if freebsd {
@ -442,6 +444,10 @@ fn main() {
// mqd_t is a pointer on FreeBSD and DragonFly
"mqd_t" if freebsd || dragonfly => true,
// Just some typedefs on osx, no need to check their sign
"posix_spawnattr_t" |
"posix_spawn_file_actions_t" => true,
// windows-isms
n if n.starts_with("P") => true,
n if n.starts_with("H") => true,

View File

@ -28,6 +28,8 @@ pub type integer_t = ::c_int;
pub type cpu_type_t = integer_t;
pub type cpu_subtype_t = integer_t;
pub type vm_prot_t = ::c_int;
pub type posix_spawnattr_t = *mut ::c_void;
pub type posix_spawn_file_actions_t = *mut ::c_void;
pub enum timezone {}
@ -2196,6 +2198,11 @@ pub const DLT_LOOP: ::c_uint = 108;
// sizeof(int32_t)
pub const BPF_ALIGNMENT: ::c_int = 4;
pub const POSIX_SPAWN_RESETIDS: ::c_int = 0x01;
pub const POSIX_SPAWN_SETPGROUP: ::c_int = 0x02;
pub const POSIX_SPAWN_SETSIGDEF: ::c_int = 0x04;
pub const POSIX_SPAWN_SETSIGMASK: ::c_int = 0x08;
f! {
pub fn WSTOPSIG(status: ::c_int) -> ::c_int {
status >> 8
@ -2391,6 +2398,60 @@ extern {
pub fn _dyld_get_image_header(image_index: u32) -> *const mach_header;
pub fn _dyld_get_image_vmaddr_slide(image_index: u32) -> ::intptr_t;
pub fn _dyld_get_image_name(image_index: u32) -> *const ::c_char;
pub fn posix_spawn(pid: *mut ::pid_t,
path: *const ::c_char,
file_actions: *const ::posix_spawn_file_actions_t,
attrp: *const ::posix_spawnattr_t,
argv: *const *mut ::c_char,
envp: *const *mut ::c_char) -> ::c_int;
pub fn posix_spawnp(pid: *mut ::pid_t,
file: *const ::c_char,
file_actions: *const ::posix_spawn_file_actions_t,
attrp: *const ::posix_spawnattr_t,
argv: *const *mut ::c_char,
envp: *const *mut ::c_char) -> ::c_int;
pub fn posix_spawnattr_init(attr: *mut posix_spawnattr_t) -> ::c_int;
pub fn posix_spawnattr_destroy(attr: *mut posix_spawnattr_t) -> ::c_int;
pub fn posix_spawnattr_getsigdefault(attr: *const posix_spawnattr_t,
default: *mut ::sigset_t) -> ::c_int;
pub fn posix_spawnattr_setsigdefault(attr: *mut posix_spawnattr_t,
default: *const ::sigset_t) -> ::c_int;
pub fn posix_spawnattr_getsigmask(attr: *const posix_spawnattr_t,
default: *mut ::sigset_t) -> ::c_int;
pub fn posix_spawnattr_setsigmask(attr: *mut posix_spawnattr_t,
default: *const ::sigset_t) -> ::c_int;
pub fn posix_spawnattr_getflags(attr: *const posix_spawnattr_t,
flags: *mut ::c_short) -> ::c_int;
pub fn posix_spawnattr_setflags(attr: *mut posix_spawnattr_t,
flags: ::c_short) -> ::c_int;
pub fn posix_spawnattr_getpgroup(attr: *const posix_spawnattr_t,
flags: *mut ::pid_t) -> ::c_int;
pub fn posix_spawnattr_setpgroup(attr: *mut posix_spawnattr_t,
flags: ::pid_t) -> ::c_int;
pub fn posix_spawn_file_actions_init(
actions: *mut posix_spawn_file_actions_t,
) -> ::c_int;
pub fn posix_spawn_file_actions_destroy(
actions: *mut posix_spawn_file_actions_t,
) -> ::c_int;
pub fn posix_spawn_file_actions_addopen(
actions: *mut posix_spawn_file_actions_t,
fd: ::c_int,
path: *const ::c_char,
oflag: ::c_int,
mode: ::mode_t,
) -> ::c_int;
pub fn posix_spawn_file_actions_addclose(
actions: *mut posix_spawn_file_actions_t,
fd: ::c_int,
) -> ::c_int;
pub fn posix_spawn_file_actions_adddup2(
actions: *mut posix_spawn_file_actions_t,
fd: ::c_int,
newfd: ::c_int,
) -> ::c_int;
}
cfg_if! {

View File

@ -463,6 +463,26 @@ s! {
pub mnt_freq: ::c_int,
pub mnt_passno: ::c_int,
}
pub struct posix_spawn_file_actions_t {
__allocated: ::c_int,
__used: ::c_int,
__actions: *mut ::c_int,
__pad: [::c_int; 16],
}
pub struct posix_spawnattr_t {
__flags: ::c_short,
__pgrp: ::pid_t,
__sd: ::sigset_t,
__ss: ::sigset_t,
#[cfg(target_env = "musl")]
__prio: ::c_int,
#[cfg(not(target_env = "musl"))]
__sp: ::sched_param,
__policy: ::c_int,
__pad: [::c_int; 16],
}
}
pub const ABDAY_1: ::nl_item = 0x20000;
@ -1238,6 +1258,13 @@ pub const ETH_P_PHONET: ::c_int = 0x00F5;
pub const ETH_P_IEEE802154: ::c_int = 0x00F6;
pub const ETH_P_CAIF: ::c_int = 0x00F7;
pub const POSIX_SPAWN_RESETIDS: ::c_int = 0x01;
pub const POSIX_SPAWN_SETPGROUP: ::c_int = 0x02;
pub const POSIX_SPAWN_SETSIGDEF: ::c_int = 0x04;
pub const POSIX_SPAWN_SETSIGMASK: ::c_int = 0x08;
pub const POSIX_SPAWN_SETSCHEDPARAM: ::c_int = 0x10;
pub const POSIX_SPAWN_SETSCHEDULER: ::c_int = 0x20;
f! {
pub fn CPU_ZERO(cpuset: &mut cpu_set_t) -> () {
for slot in cpuset.bits.iter_mut() {
@ -1711,6 +1738,72 @@ extern {
pub fn endmntent(streamp: *mut ::FILE) -> ::c_int;
pub fn hasmntopt(mnt: *const ::mntent,
opt: *const ::c_char) -> *mut ::c_char;
pub fn posix_spawn(pid: *mut ::pid_t,
path: *const ::c_char,
file_actions: *const ::posix_spawn_file_actions_t,
attrp: *const ::posix_spawnattr_t,
argv: *const *mut ::c_char,
envp: *const *mut ::c_char) -> ::c_int;
pub fn posix_spawnp(pid: *mut ::pid_t,
file: *const ::c_char,
file_actions: *const ::posix_spawn_file_actions_t,
attrp: *const ::posix_spawnattr_t,
argv: *const *mut ::c_char,
envp: *const *mut ::c_char) -> ::c_int;
pub fn posix_spawnattr_init(attr: *mut posix_spawnattr_t) -> ::c_int;
pub fn posix_spawnattr_destroy(attr: *mut posix_spawnattr_t) -> ::c_int;
pub fn posix_spawnattr_getsigdefault(attr: *const posix_spawnattr_t,
default: *mut ::sigset_t) -> ::c_int;
pub fn posix_spawnattr_setsigdefault(attr: *mut posix_spawnattr_t,
default: *const ::sigset_t) -> ::c_int;
pub fn posix_spawnattr_getsigmask(attr: *const posix_spawnattr_t,
default: *mut ::sigset_t) -> ::c_int;
pub fn posix_spawnattr_setsigmask(attr: *mut posix_spawnattr_t,
default: *const ::sigset_t) -> ::c_int;
pub fn posix_spawnattr_getflags(attr: *const posix_spawnattr_t,
flags: *mut ::c_short) -> ::c_int;
pub fn posix_spawnattr_setflags(attr: *mut posix_spawnattr_t,
flags: ::c_short) -> ::c_int;
pub fn posix_spawnattr_getpgroup(attr: *const posix_spawnattr_t,
flags: *mut ::pid_t) -> ::c_int;
pub fn posix_spawnattr_setpgroup(attr: *mut posix_spawnattr_t,
flags: ::pid_t) -> ::c_int;
pub fn posix_spawnattr_getschedpolicy(attr: *const posix_spawnattr_t,
flags: *mut ::c_int) -> ::c_int;
pub fn posix_spawnattr_setschedpolicy(attr: *mut posix_spawnattr_t,
flags: ::c_int) -> ::c_int;
pub fn posix_spawnattr_getschedparam(
attr: *const posix_spawnattr_t,
param: *mut ::sched_param,
) -> ::c_int;
pub fn posix_spawnattr_setschedparam(
attr: *mut posix_spawnattr_t,
param: *const ::sched_param,
) -> ::c_int;
pub fn posix_spawn_file_actions_init(
actions: *mut posix_spawn_file_actions_t,
) -> ::c_int;
pub fn posix_spawn_file_actions_destroy(
actions: *mut posix_spawn_file_actions_t,
) -> ::c_int;
pub fn posix_spawn_file_actions_addopen(
actions: *mut posix_spawn_file_actions_t,
fd: ::c_int,
path: *const ::c_char,
oflag: ::c_int,
mode: ::mode_t,
) -> ::c_int;
pub fn posix_spawn_file_actions_addclose(
actions: *mut posix_spawn_file_actions_t,
fd: ::c_int,
) -> ::c_int;
pub fn posix_spawn_file_actions_adddup2(
actions: *mut posix_spawn_file_actions_t,
fd: ::c_int,
newfd: ::c_int,
) -> ::c_int;
}
cfg_if! {