Skip to content

Relocate <spawn.h> functions to define them to dragonfly. #4294

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
Mar 4, 2025
Merged
Show file tree
Hide file tree
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
31 changes: 31 additions & 0 deletions libc-test/semver/dragonfly.txt
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,12 @@ POSIX_MADV_NORMAL
POSIX_MADV_RANDOM
POSIX_MADV_SEQUENTIAL
POSIX_MADV_WILLNEED
POSIX_SPAWN_RESETIDS
POSIX_SPAWN_SETPGROUP
POSIX_SPAWN_SETSCHEDPARAM
POSIX_SPAWN_SETSCHEDULER
POSIX_SPAWN_SETSIGDEF
POSIX_SPAWN_SETSIGMASK
PPPDISC
PROC_PDEATHSIG_CTL
PROC_PDEATHSIG_STATUS
Expand Down Expand Up @@ -1434,6 +1440,8 @@ mincore
mkdirat
mkfifoat
mknodat
mkostemp
mkostemps
mkstemps
mq_attr
mq_close
Expand Down Expand Up @@ -1468,6 +1476,29 @@ popen
posix_fadvise
posix_fallocate
posix_madvise
posix_spawn
posix_spawn_file_actions_addclose
posix_spawn_file_actions_adddup2
posix_spawn_file_actions_addopen
posix_spawn_file_actions_destroy
posix_spawn_file_actions_init
posix_spawn_file_actions_t
posix_spawnattr_destroy
posix_spawnattr_getflags
posix_spawnattr_getpgroup
posix_spawnattr_getschedparam
posix_spawnattr_getschedpolicy
posix_spawnattr_getsigdefault
posix_spawnattr_getsigmask
posix_spawnattr_init
posix_spawnattr_setflags
posix_spawnattr_setpgroup
posix_spawnattr_setschedparam
posix_spawnattr_setschedpolicy
posix_spawnattr_setsigdefault
posix_spawnattr_setsigmask
posix_spawnattr_t
posix_spawnp
ppoll
preadv
procctl
Expand Down
86 changes: 0 additions & 86 deletions src/unix/bsd/freebsdlike/freebsd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ pub type cpulevel_t = c_int;
pub type cpuwhich_t = c_int;

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

pub type pthread_spinlock_t = *mut __c_anonymous_pthread_spinlock;
pub type pthread_barrierattr_t = *mut __c_anonymous_pthread_barrierattr;
Expand Down Expand Up @@ -3938,13 +3936,6 @@ pub const RTP_PRIO_REALTIME: c_ushort = 2;
pub const RTP_PRIO_NORMAL: c_ushort = 3;
pub const RTP_PRIO_IDLE: c_ushort = 4;

pub const POSIX_SPAWN_RESETIDS: c_short = 0x01;
pub const POSIX_SPAWN_SETPGROUP: c_short = 0x02;
pub const POSIX_SPAWN_SETSCHEDPARAM: c_short = 0x04;
pub const POSIX_SPAWN_SETSCHEDULER: c_short = 0x08;
pub const POSIX_SPAWN_SETSIGDEF: c_short = 0x10;
pub const POSIX_SPAWN_SETSIGMASK: c_short = 0x20;

// Flags for chflags(2)
pub const UF_SYSTEM: c_ulong = 0x00000080;
pub const UF_SPARSE: c_ulong = 0x00000100;
Expand Down Expand Up @@ -5160,9 +5151,6 @@ extern "C" {
sevp: *mut sigevent,
) -> c_int;

pub fn mkostemp(template: *mut c_char, flags: c_int) -> c_int;
pub fn mkostemps(template: *mut c_char, suffixlen: c_int, flags: c_int) -> c_int;

pub fn getutxuser(user: *const c_char) -> *mut utmpx;
pub fn setutxdb(_type: c_int, file: *const c_char) -> c_int;

Expand Down Expand Up @@ -5196,80 +5184,6 @@ extern "C" {

pub fn rtprio_thread(function: c_int, lwpid: crate::lwpid_t, rtp: *mut super::rtprio) -> c_int;

pub fn posix_spawn(
pid: *mut crate::pid_t,
path: *const c_char,
file_actions: *const crate::posix_spawn_file_actions_t,
attrp: *const crate::posix_spawnattr_t,
argv: *const *mut c_char,
envp: *const *mut c_char,
) -> c_int;
pub fn posix_spawnp(
pid: *mut crate::pid_t,
file: *const c_char,
file_actions: *const crate::posix_spawn_file_actions_t,
attrp: *const crate::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 crate::sigset_t,
) -> c_int;
pub fn posix_spawnattr_setsigdefault(
attr: *mut posix_spawnattr_t,
default: *const crate::sigset_t,
) -> c_int;
pub fn posix_spawnattr_getsigmask(
attr: *const posix_spawnattr_t,
default: *mut crate::sigset_t,
) -> c_int;
pub fn posix_spawnattr_setsigmask(
attr: *mut posix_spawnattr_t,
default: *const crate::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 crate::pid_t,
) -> c_int;
pub fn posix_spawnattr_setpgroup(attr: *mut posix_spawnattr_t, flags: crate::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 crate::sched_param,
) -> c_int;
pub fn posix_spawnattr_setschedparam(
attr: *mut posix_spawnattr_t,
param: *const crate::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: crate::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;

pub fn uuidgen(store: *mut uuid, count: c_int) -> c_int;

pub fn thr_kill(id: c_long, sig: c_int) -> c_int;
Expand Down
87 changes: 87 additions & 0 deletions src/unix/bsd/freebsdlike/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ pub type iconv_t = *mut c_void;
// making the type definition system dependent. Better not bind it exactly.
pub type kvm_t = c_void;

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

cfg_if! {
if #[cfg(target_pointer_width = "64")] {
type Elf_Addr = Elf64_Addr;
Expand Down Expand Up @@ -1481,6 +1484,13 @@ pub const GRND_NONBLOCK: c_uint = 0x1;
pub const GRND_RANDOM: c_uint = 0x2;
pub const GRND_INSECURE: c_uint = 0x4;

pub const POSIX_SPAWN_RESETIDS: c_short = 0x01;
pub const POSIX_SPAWN_SETPGROUP: c_short = 0x02;
pub const POSIX_SPAWN_SETSCHEDPARAM: c_short = 0x04;
pub const POSIX_SPAWN_SETSCHEDULER: c_short = 0x08;
pub const POSIX_SPAWN_SETSIGDEF: c_short = 0x10;
pub const POSIX_SPAWN_SETSIGMASK: c_short = 0x20;

safe_f! {
pub {const} fn WIFCONTINUED(status: c_int) -> bool {
status == 0x13
Expand Down Expand Up @@ -1792,6 +1802,83 @@ extern "C" {
search_path: *const c_char,
argv: *const *mut c_char,
) -> c_int;

pub fn mkostemp(template: *mut c_char, flags: c_int) -> c_int;
pub fn mkostemps(template: *mut c_char, suffixlen: c_int, flags: c_int) -> c_int;

pub fn posix_spawn(
pid: *mut crate::pid_t,
path: *const c_char,
file_actions: *const crate::posix_spawn_file_actions_t,
attrp: *const crate::posix_spawnattr_t,
argv: *const *mut c_char,
envp: *const *mut c_char,
) -> c_int;
pub fn posix_spawnp(
pid: *mut crate::pid_t,
file: *const c_char,
file_actions: *const crate::posix_spawn_file_actions_t,
attrp: *const crate::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 crate::sigset_t,
) -> c_int;
pub fn posix_spawnattr_setsigdefault(
attr: *mut posix_spawnattr_t,
default: *const crate::sigset_t,
) -> c_int;
pub fn posix_spawnattr_getsigmask(
attr: *const posix_spawnattr_t,
default: *mut crate::sigset_t,
) -> c_int;
pub fn posix_spawnattr_setsigmask(
attr: *mut posix_spawnattr_t,
default: *const crate::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 crate::pid_t,
) -> c_int;
pub fn posix_spawnattr_setpgroup(attr: *mut posix_spawnattr_t, flags: crate::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 crate::sched_param,
) -> c_int;
pub fn posix_spawnattr_setschedparam(
attr: *mut posix_spawnattr_t,
param: *const crate::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: crate::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;
}

#[link(name = "rt")]
Expand Down
Loading