Skip to content

Haiku: add the posix_spawn functions and constants #2839

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

Merged
merged 1 commit into from
Jul 7, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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