Skip to content

Commit 2918100

Browse files
authored
Merge pull request #3678 from rust-lang/revert-3602-posix_spawn
Revert "Support posix_spawn on Android"
2 parents 73efe14 + 03e47e6 commit 2918100

File tree

3 files changed

+110
-147
lines changed

3 files changed

+110
-147
lines changed

libc-test/build.rs

+5-31
Original file line numberDiff line numberDiff line change
@@ -1613,7 +1613,6 @@ fn test_android(target: &str) {
16131613
"sched.h",
16141614
"semaphore.h",
16151615
"signal.h",
1616-
"spawn.h",
16171616
"stddef.h",
16181617
"stdint.h",
16191618
"stdio.h",
@@ -1980,30 +1979,14 @@ fn test_android(target: &str) {
19801979

19811980
// Added in API level 28, but some tests use level 24.
19821981
"getrandom" => true,
1982+
1983+
// Added in API level 28, but some tests use level 24.
19831984
"syncfs" => true,
1985+
1986+
// Added in API level 28, but some tests use level 24.
19841987
"pthread_attr_getinheritsched" | "pthread_attr_setinheritsched" => true,
1988+
// Added in API level 28, but some tests use level 24.
19851989
"fread_unlocked" | "fwrite_unlocked" | "fgets_unlocked" | "fflush_unlocked" => true,
1986-
"posix_spawn"
1987-
| "posix_spawnp"
1988-
| "posix_spawnattr_init"
1989-
| "posix_spawnattr_destroy"
1990-
| "posix_spawnattr_getsigdefault"
1991-
| "posix_spawnattr_setsigdefault"
1992-
| "posix_spawnattr_getsigmask"
1993-
| "posix_spawnattr_setsigmask"
1994-
| "posix_spawnattr_getflags"
1995-
| "posix_spawnattr_setflags"
1996-
| "posix_spawnattr_getpgroup"
1997-
| "posix_spawnattr_setpgroup"
1998-
| "posix_spawnattr_getschedpolicy"
1999-
| "posix_spawnattr_setschedpolicy"
2000-
| "posix_spawnattr_getschedparam"
2001-
| "posix_spawnattr_setschedparam"
2002-
| "posix_spawn_file_actions_init"
2003-
| "posix_spawn_file_actions_destroy"
2004-
| "posix_spawn_file_actions_addopen"
2005-
| "posix_spawn_file_actions_addclose"
2006-
| "posix_spawn_file_actions_adddup2" => true,
20071990

20081991
// FIXME: bad function pointers:
20091992
"isalnum" | "isalpha" | "iscntrl" | "isdigit" | "isgraph" | "islower" | "isprint"
@@ -2726,7 +2709,6 @@ fn test_emscripten(target: &str) {
27262709
"semaphore.h",
27272710
"shadow.h",
27282711
"signal.h",
2729-
"spawn.h",
27302712
"stddef.h",
27312713
"stdint.h",
27322714
"stdio.h",
@@ -3620,10 +3602,6 @@ fn test_linux(target: &str) {
36203602
"priority_t" if musl => true,
36213603
"name_t" if musl => true,
36223604

3623-
// These are intended to be opaque, but glibc and musl define them.
3624-
"posix_spawn_file_actions_t" => true,
3625-
"posix_spawnattr_t" => true,
3626-
36273605
t => {
36283606
if musl {
36293607
// LFS64 types have been removed in musl 1.2.4+
@@ -3772,10 +3750,6 @@ fn test_linux(target: &str) {
37723750
// kernel so we can drop this and test the type once this new version is used in CI.
37733751
"sched_attr" => true,
37743752

3775-
// These are intended to be opaque, but glibc and musl define them.
3776-
"posix_spawn_file_actions_t" => true,
3777-
"posix_spawnattr_t" => true,
3778-
37793753
_ => false,
37803754
}
37813755
});

src/unix/linux_like/linux/mod.rs

+105
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,26 @@ s! {
452452
pub mnt_passno: ::c_int,
453453
}
454454

455+
pub struct posix_spawn_file_actions_t {
456+
__allocated: ::c_int,
457+
__used: ::c_int,
458+
__actions: *mut ::c_int,
459+
__pad: [::c_int; 16],
460+
}
461+
462+
pub struct posix_spawnattr_t {
463+
__flags: ::c_short,
464+
__pgrp: ::pid_t,
465+
__sd: ::sigset_t,
466+
__ss: ::sigset_t,
467+
#[cfg(any(target_env = "musl", target_env = "ohos"))]
468+
__prio: ::c_int,
469+
#[cfg(not(any(target_env = "musl", target_env = "ohos")))]
470+
__sp: ::sched_param,
471+
__policy: ::c_int,
472+
__pad: [::c_int; 16],
473+
}
474+
455475
pub struct genlmsghdr {
456476
pub cmd: u8,
457477
pub version: u8,
@@ -1839,6 +1859,8 @@ pub const POSIX_MADV_NORMAL: ::c_int = 0;
18391859
pub const POSIX_MADV_RANDOM: ::c_int = 1;
18401860
pub const POSIX_MADV_SEQUENTIAL: ::c_int = 2;
18411861
pub const POSIX_MADV_WILLNEED: ::c_int = 3;
1862+
pub const POSIX_SPAWN_USEVFORK: ::c_int = 64;
1863+
pub const POSIX_SPAWN_SETSID: ::c_int = 128;
18421864

18431865
pub const S_IEXEC: mode_t = 64;
18441866
pub const S_IWRITE: mode_t = 128;
@@ -2596,6 +2618,13 @@ pub const ETH_P_PHONET: ::c_int = 0x00F5;
25962618
pub const ETH_P_IEEE802154: ::c_int = 0x00F6;
25972619
pub const ETH_P_CAIF: ::c_int = 0x00F7;
25982620

2621+
pub const POSIX_SPAWN_RESETIDS: ::c_int = 0x01;
2622+
pub const POSIX_SPAWN_SETPGROUP: ::c_int = 0x02;
2623+
pub const POSIX_SPAWN_SETSIGDEF: ::c_int = 0x04;
2624+
pub const POSIX_SPAWN_SETSIGMASK: ::c_int = 0x08;
2625+
pub const POSIX_SPAWN_SETSCHEDPARAM: ::c_int = 0x10;
2626+
pub const POSIX_SPAWN_SETSCHEDULER: ::c_int = 0x20;
2627+
25992628
pub const NLMSG_NOOP: ::c_int = 0x1;
26002629
pub const NLMSG_ERROR: ::c_int = 0x2;
26012630
pub const NLMSG_DONE: ::c_int = 0x3;
@@ -5425,6 +5454,82 @@ extern "C" {
54255454
pub fn endmntent(streamp: *mut ::FILE) -> ::c_int;
54265455
pub fn hasmntopt(mnt: *const ::mntent, opt: *const ::c_char) -> *mut ::c_char;
54275456

5457+
pub fn posix_spawn(
5458+
pid: *mut ::pid_t,
5459+
path: *const ::c_char,
5460+
file_actions: *const ::posix_spawn_file_actions_t,
5461+
attrp: *const ::posix_spawnattr_t,
5462+
argv: *const *mut ::c_char,
5463+
envp: *const *mut ::c_char,
5464+
) -> ::c_int;
5465+
pub fn posix_spawnp(
5466+
pid: *mut ::pid_t,
5467+
file: *const ::c_char,
5468+
file_actions: *const ::posix_spawn_file_actions_t,
5469+
attrp: *const ::posix_spawnattr_t,
5470+
argv: *const *mut ::c_char,
5471+
envp: *const *mut ::c_char,
5472+
) -> ::c_int;
5473+
pub fn posix_spawnattr_init(attr: *mut posix_spawnattr_t) -> ::c_int;
5474+
pub fn posix_spawnattr_destroy(attr: *mut posix_spawnattr_t) -> ::c_int;
5475+
pub fn posix_spawnattr_getsigdefault(
5476+
attr: *const posix_spawnattr_t,
5477+
default: *mut ::sigset_t,
5478+
) -> ::c_int;
5479+
pub fn posix_spawnattr_setsigdefault(
5480+
attr: *mut posix_spawnattr_t,
5481+
default: *const ::sigset_t,
5482+
) -> ::c_int;
5483+
pub fn posix_spawnattr_getsigmask(
5484+
attr: *const posix_spawnattr_t,
5485+
default: *mut ::sigset_t,
5486+
) -> ::c_int;
5487+
pub fn posix_spawnattr_setsigmask(
5488+
attr: *mut posix_spawnattr_t,
5489+
default: *const ::sigset_t,
5490+
) -> ::c_int;
5491+
pub fn posix_spawnattr_getflags(
5492+
attr: *const posix_spawnattr_t,
5493+
flags: *mut ::c_short,
5494+
) -> ::c_int;
5495+
pub fn posix_spawnattr_setflags(attr: *mut posix_spawnattr_t, flags: ::c_short) -> ::c_int;
5496+
pub fn posix_spawnattr_getpgroup(
5497+
attr: *const posix_spawnattr_t,
5498+
flags: *mut ::pid_t,
5499+
) -> ::c_int;
5500+
pub fn posix_spawnattr_setpgroup(attr: *mut posix_spawnattr_t, flags: ::pid_t) -> ::c_int;
5501+
pub fn posix_spawnattr_getschedpolicy(
5502+
attr: *const posix_spawnattr_t,
5503+
flags: *mut ::c_int,
5504+
) -> ::c_int;
5505+
pub fn posix_spawnattr_setschedpolicy(attr: *mut posix_spawnattr_t, flags: ::c_int) -> ::c_int;
5506+
pub fn posix_spawnattr_getschedparam(
5507+
attr: *const posix_spawnattr_t,
5508+
param: *mut ::sched_param,
5509+
) -> ::c_int;
5510+
pub fn posix_spawnattr_setschedparam(
5511+
attr: *mut posix_spawnattr_t,
5512+
param: *const ::sched_param,
5513+
) -> ::c_int;
5514+
5515+
pub fn posix_spawn_file_actions_init(actions: *mut posix_spawn_file_actions_t) -> ::c_int;
5516+
pub fn posix_spawn_file_actions_destroy(actions: *mut posix_spawn_file_actions_t) -> ::c_int;
5517+
pub fn posix_spawn_file_actions_addopen(
5518+
actions: *mut posix_spawn_file_actions_t,
5519+
fd: ::c_int,
5520+
path: *const ::c_char,
5521+
oflag: ::c_int,
5522+
mode: ::mode_t,
5523+
) -> ::c_int;
5524+
pub fn posix_spawn_file_actions_addclose(
5525+
actions: *mut posix_spawn_file_actions_t,
5526+
fd: ::c_int,
5527+
) -> ::c_int;
5528+
pub fn posix_spawn_file_actions_adddup2(
5529+
actions: *mut posix_spawn_file_actions_t,
5530+
fd: ::c_int,
5531+
newfd: ::c_int,
5532+
) -> ::c_int;
54285533
pub fn fread_unlocked(
54295534
buf: *mut ::c_void,
54305535
size: ::size_t,

src/unix/linux_like/mod.rs

-116
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,6 @@ pub type timer_t = *mut ::c_void;
66
pub type key_t = ::c_int;
77
pub type id_t = ::c_uint;
88

9-
cfg_if! {
10-
if #[cfg(not(target_os = "emscripten"))] {
11-
pub type posix_spawn_file_actions_t = *mut ::c_void;
12-
pub type posix_spawnattr_t = *mut ::c_void;
13-
}
14-
}
15-
169
missing! {
1710
#[cfg_attr(feature = "extra_traits", derive(Debug))]
1811
pub enum timezone {}
@@ -1538,19 +1531,6 @@ cfg_if! {
15381531
}
15391532
}
15401533

1541-
cfg_if! {
1542-
if #[cfg(not(target_os = "emscripten"))] {
1543-
pub const POSIX_SPAWN_RESETIDS: ::c_int = 0x01;
1544-
pub const POSIX_SPAWN_SETPGROUP: ::c_int = 0x02;
1545-
pub const POSIX_SPAWN_SETSIGDEF: ::c_int = 0x04;
1546-
pub const POSIX_SPAWN_SETSIGMASK: ::c_int = 0x08;
1547-
pub const POSIX_SPAWN_SETSCHEDPARAM: ::c_int = 0x10;
1548-
pub const POSIX_SPAWN_SETSCHEDULER: ::c_int = 0x20;
1549-
pub const POSIX_SPAWN_USEVFORK: ::c_int = 0x40;
1550-
pub const POSIX_SPAWN_SETSID: ::c_int = 0x80;
1551-
}
1552-
}
1553-
15541534
const_fn! {
15551535
{const} fn CMSG_ALIGN(len: usize) -> usize {
15561536
len + ::mem::size_of::<usize>() - 1 & !(::mem::size_of::<usize>() - 1)
@@ -1915,102 +1895,6 @@ cfg_if! {
19151895
}
19161896
}
19171897

1918-
cfg_if! {
1919-
if #[cfg(not(target_os = "emscripten"))] {
1920-
extern "C" {
1921-
pub fn posix_spawn(
1922-
pid: *mut ::pid_t,
1923-
path: *const ::c_char,
1924-
file_actions: *const ::posix_spawn_file_actions_t,
1925-
attrp: *const ::posix_spawnattr_t,
1926-
argv: *const *mut ::c_char,
1927-
envp: *const *mut ::c_char,
1928-
) -> ::c_int;
1929-
pub fn posix_spawnp(
1930-
pid: *mut ::pid_t,
1931-
file: *const ::c_char,
1932-
file_actions: *const ::posix_spawn_file_actions_t,
1933-
attrp: *const ::posix_spawnattr_t,
1934-
argv: *const *mut ::c_char,
1935-
envp: *const *mut ::c_char,
1936-
) -> ::c_int;
1937-
pub fn posix_spawnattr_init(attr: *mut posix_spawnattr_t) -> ::c_int;
1938-
pub fn posix_spawnattr_destroy(attr: *mut posix_spawnattr_t) -> ::c_int;
1939-
pub fn posix_spawnattr_getsigdefault(
1940-
attr: *const posix_spawnattr_t,
1941-
default: *mut ::sigset_t,
1942-
) -> ::c_int;
1943-
pub fn posix_spawnattr_setsigdefault(
1944-
attr: *mut posix_spawnattr_t,
1945-
default: *const ::sigset_t,
1946-
) -> ::c_int;
1947-
pub fn posix_spawnattr_getsigmask(
1948-
attr: *const posix_spawnattr_t,
1949-
default: *mut ::sigset_t,
1950-
) -> ::c_int;
1951-
pub fn posix_spawnattr_setsigmask(
1952-
attr: *mut posix_spawnattr_t,
1953-
default: *const ::sigset_t,
1954-
) -> ::c_int;
1955-
pub fn posix_spawnattr_getflags(
1956-
attr: *const posix_spawnattr_t,
1957-
flags: *mut ::c_short,
1958-
) -> ::c_int;
1959-
pub fn posix_spawnattr_setflags(
1960-
attr: *mut posix_spawnattr_t,
1961-
flags: ::c_short,
1962-
) -> ::c_int;
1963-
pub fn posix_spawnattr_getpgroup(
1964-
attr: *const posix_spawnattr_t,
1965-
flags: *mut ::pid_t,
1966-
) -> ::c_int;
1967-
pub fn posix_spawnattr_setpgroup(
1968-
attr: *mut posix_spawnattr_t,
1969-
flags: ::pid_t,
1970-
) -> ::c_int;
1971-
pub fn posix_spawnattr_getschedpolicy(
1972-
attr: *const posix_spawnattr_t,
1973-
flags: *mut ::c_int,
1974-
) -> ::c_int;
1975-
pub fn posix_spawnattr_setschedpolicy(
1976-
attr: *mut posix_spawnattr_t,
1977-
flags: ::c_int,
1978-
) -> ::c_int;
1979-
pub fn posix_spawnattr_getschedparam(
1980-
attr: *const posix_spawnattr_t,
1981-
param: *mut ::sched_param,
1982-
) -> ::c_int;
1983-
pub fn posix_spawnattr_setschedparam(
1984-
attr: *mut posix_spawnattr_t,
1985-
param: *const ::sched_param,
1986-
) -> ::c_int;
1987-
1988-
pub fn posix_spawn_file_actions_init(
1989-
actions: *mut posix_spawn_file_actions_t,
1990-
) -> ::c_int;
1991-
pub fn posix_spawn_file_actions_destroy(
1992-
actions: *mut posix_spawn_file_actions_t,
1993-
) -> ::c_int;
1994-
pub fn posix_spawn_file_actions_addopen(
1995-
actions: *mut posix_spawn_file_actions_t,
1996-
fd: ::c_int,
1997-
path: *const ::c_char,
1998-
oflag: ::c_int,
1999-
mode: ::mode_t,
2000-
) -> ::c_int;
2001-
pub fn posix_spawn_file_actions_addclose(
2002-
actions: *mut posix_spawn_file_actions_t,
2003-
fd: ::c_int,
2004-
) -> ::c_int;
2005-
pub fn posix_spawn_file_actions_adddup2(
2006-
actions: *mut posix_spawn_file_actions_t,
2007-
fd: ::c_int,
2008-
newfd: ::c_int,
2009-
) -> ::c_int;
2010-
}
2011-
}
2012-
}
2013-
20141898
cfg_if! {
20151899
if #[cfg(target_os = "emscripten")] {
20161900
mod emscripten;

0 commit comments

Comments
 (0)