Skip to content

Commit

Permalink
Auto merge of #2839 - nielx:haiku-posix_spawn, r=JohnTitor
Browse files Browse the repository at this point in the history
Haiku: add the posix_spawn functions and constants

Tested with libc-test.
  • Loading branch information
bors committed Jul 7, 2022
2 parents a2f7dac + 8b55add commit 888c473
Showing 1 changed file with 78 additions and 0 deletions.
78 changes: 78 additions & 0 deletions src/unix/haiku/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ pub type Elf64_Xword = u64;
pub type ENTRY = entry;
pub type ACTION = ::c_int;

pub type posix_spawnattr_t = *mut ::c_void;
pub type posix_spawn_file_actions_t = *mut ::c_void;

#[cfg_attr(feature = "extra_traits", derive(Debug))]
pub enum timezone {}
impl ::Copy for timezone {}
Expand Down Expand Up @@ -1438,6 +1441,13 @@ pub const LOG_SERIAL: ::c_int = 16 << 12;
pub const LOG_PERROR: ::c_int = 32 << 12;
pub const LOG_NOWAIT: ::c_int = 64 << 12;

// spawn.h
pub const POSIX_SPAWN_RESETIDS: ::c_int = 0x01;
pub const POSIX_SPAWN_SETPGROUP: ::c_int = 0x02;
pub const POSIX_SPAWN_SETSIGDEF: ::c_int = 0x10;
pub const POSIX_SPAWN_SETSIGMASK: ::c_int = 0x20;
pub const POSIX_SPAWN_SETSID: ::c_int = 0x40;

const_fn! {
{const} fn CMSG_ALIGN(len: usize) -> usize {
len + ::mem::size_of::<usize>() - 1 & !(::mem::size_of::<usize>() - 1)
Expand Down Expand Up @@ -1888,6 +1898,74 @@ extern "C" {

pub fn brk(addr: *mut ::c_void) -> ::c_int;
pub fn sbrk(increment: ::intptr_t) -> *mut ::c_void;

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_spawn_file_actions_init(file_actions: *mut posix_spawn_file_actions_t) -> ::c_int;
pub fn posix_spawn_file_actions_destroy(
file_actions: *mut posix_spawn_file_actions_t,
) -> ::c_int;
pub fn posix_spawn_file_actions_addopen(
file_actions: *mut posix_spawn_file_actions_t,
fildes: ::c_int,
path: *const ::c_char,
oflag: ::c_int,
mode: ::mode_t,
) -> ::c_int;
pub fn posix_spawn_file_actions_addclose(
file_actions: *mut posix_spawn_file_actions_t,
fildes: ::c_int,
) -> ::c_int;
pub fn posix_spawn_file_actions_adddup2(
file_actions: *mut posix_spawn_file_actions_t,
fildes: ::c_int,
newfildes: ::c_int,
) -> ::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_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,
_pgroup: *mut ::pid_t,
) -> ::c_int;
pub fn posix_spawnattr_setpgroup(attr: *mut posix_spawnattr_t, pgroup: ::pid_t) -> ::c_int;
pub fn posix_spawnattr_getsigdefault(
attr: *const posix_spawnattr_t,
sigdefault: *mut ::sigset_t,
) -> ::c_int;
pub fn posix_spawnattr_setsigdefault(
attr: *mut posix_spawnattr_t,
sigdefault: *const ::sigset_t,
) -> ::c_int;
pub fn posix_spawnattr_getsigmask(
attr: *const posix_spawnattr_t,
_sigmask: *mut ::sigset_t,
) -> ::c_int;
pub fn posix_spawnattr_setsigmask(
attr: *mut posix_spawnattr_t,
sigmask: *const ::sigset_t,
) -> ::c_int;

}

#[link(name = "bsd")]
Expand Down

0 comments on commit 888c473

Please sign in to comment.