mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-03-15 05:16:30 +00:00
Explore comfort level with posix_spawn
Justine says nay for the time being. Only XNU implements this. It's not clear what ABI XNU is using but it's obviously not the one in the POSIX documentation link below. Since all platforms implement vfork, it might be better to empirically gauge the intersection of consensus which will have better performance than this interface. https://pubs.opengroup.org/onlinepubs/009696699/xrat/xsh_chap03.html
This commit is contained in:
parent
b2260c2278
commit
f7c7b949fd
13 changed files with 30 additions and 56 deletions
14
libc/calls/scheduler.h
Normal file
14
libc/calls/scheduler.h
Normal file
|
@ -0,0 +1,14 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_CALLS_SCHED_H_
|
||||
#define COSMOPOLITAN_LIBC_CALLS_SCHED_H_
|
||||
#include "libc/calls/struct/sched_param.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
int sched_setscheduler(int, int, const struct sched_param *);
|
||||
int sched_getscheduler(int);
|
||||
int sched_setparam(int, const struct sched_param *);
|
||||
int sched_getparam(int, struct sched_param *);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_CALLS_SCHED_H_ */
|
2
libc/sysv/calls/posix_spawn-sysv.s
Normal file
2
libc/sysv/calls/posix_spawn-sysv.s
Normal file
|
@ -0,0 +1,2 @@
|
|||
.include "o/libc/sysv/macros.internal.inc"
|
||||
.scall posix_spawn$sysv 0xffffffff20f4ffff globl hidden
|
|
@ -1,2 +0,0 @@
|
|||
.include "o/libc/sysv/macros.internal.inc"
|
||||
.scall posix_spawn 0xffffffff20f4ffff globl hidden
|
|
@ -280,18 +280,6 @@ syscon madv MADV_HWPOISON 100 0 0 0 0 # TODO(jart): what is it?
|
|||
syscon madv MADV_REMOVE 9 0 0 0 0 # TODO(jart): what is it?
|
||||
syscon fadv POSIX_FADV_NOREUSE 5 0 5 0 0 # wut
|
||||
|
||||
# posix_spawn()
|
||||
# only native on xnu
|
||||
#
|
||||
# group name GNU/Systemd XNU's Not UNIX FreeBSD OpenBSD XENIX Commentary
|
||||
syscon spawn POSIX_SPAWN_RESETIDS 1 1 1 1 0 # unix consensus
|
||||
syscon spawn POSIX_SPAWN_SETPGROUP 2 2 2 2 0 # unix consensus
|
||||
syscon spawn POSIX_SPAWN_SETSIGDEF 4 4 0x10 0x10 0
|
||||
syscon spawn POSIX_SPAWN_SETSIGMASK 8 8 0x20 0x20 0
|
||||
syscon spawn POSIX_SPAWN_SETSCHEDPARAM 0x10 0 4 4 0
|
||||
syscon spawn POSIX_SPAWN_SETSCHEDULER 0x20 0 8 8 0
|
||||
syscon spawn POSIX_SPAWN_USEVFORK 0x40 0 0 0 0
|
||||
|
||||
# mmap(), mprotect(), etc.
|
||||
# digital restrictions management for the people
|
||||
#
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
.include "libc/sysv/consts/syscon.inc"
|
||||
.syscon spawn POSIX_SPAWN_RESETIDS 1 1 1 1 0
|
|
@ -1,2 +0,0 @@
|
|||
.include "libc/sysv/consts/syscon.inc"
|
||||
.syscon spawn POSIX_SPAWN_SETPGROUP 2 2 2 2 0
|
|
@ -1,2 +0,0 @@
|
|||
.include "libc/sysv/consts/syscon.inc"
|
||||
.syscon spawn POSIX_SPAWN_SETSCHEDPARAM 0x10 0 4 4 0
|
|
@ -1,2 +0,0 @@
|
|||
.include "libc/sysv/consts/syscon.inc"
|
||||
.syscon spawn POSIX_SPAWN_SETSCHEDULER 0x20 0 8 8 0
|
|
@ -1,2 +0,0 @@
|
|||
.include "libc/sysv/consts/syscon.inc"
|
||||
.syscon spawn POSIX_SPAWN_SETSIGDEF 4 4 0x10 0x10 0
|
|
@ -1,2 +0,0 @@
|
|||
.include "libc/sysv/consts/syscon.inc"
|
||||
.syscon spawn POSIX_SPAWN_SETSIGMASK 8 8 0x20 0x20 0
|
|
@ -1,2 +0,0 @@
|
|||
.include "libc/sysv/consts/syscon.inc"
|
||||
.syscon spawn POSIX_SPAWN_USEVFORK 0x40 0 0 0 0
|
|
@ -1,26 +1,6 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_SYSV_CONSTS_POSIX_H_
|
||||
#define COSMOPOLITAN_LIBC_SYSV_CONSTS_POSIX_H_
|
||||
#include "libc/runtime/symbolic.h"
|
||||
|
||||
#define POSIX_FADV_DONTNEED SYMBOLIC(POSIX_FADV_DONTNEED)
|
||||
#define POSIX_FADV_NOREUSE SYMBOLIC(POSIX_FADV_NOREUSE)
|
||||
#define POSIX_FADV_NORMAL SYMBOLIC(POSIX_FADV_NORMAL)
|
||||
#define POSIX_FADV_RANDOM SYMBOLIC(POSIX_FADV_RANDOM)
|
||||
#define POSIX_FADV_SEQUENTIAL SYMBOLIC(POSIX_FADV_SEQUENTIAL)
|
||||
#define POSIX_FADV_WILLNEED SYMBOLIC(POSIX_FADV_WILLNEED)
|
||||
#define POSIX_MADV_DONTNEED SYMBOLIC(POSIX_MADV_DONTNEED)
|
||||
#define POSIX_MADV_NORMAL SYMBOLIC(POSIX_MADV_NORMAL)
|
||||
#define POSIX_MADV_RANDOM SYMBOLIC(POSIX_MADV_RANDOM)
|
||||
#define POSIX_MADV_SEQUENTIAL SYMBOLIC(POSIX_MADV_SEQUENTIAL)
|
||||
#define POSIX_MADV_WILLNEED SYMBOLIC(POSIX_MADV_WILLNEED)
|
||||
#define POSIX_SPAWN_RESETIDS SYMBOLIC(POSIX_SPAWN_RESETIDS)
|
||||
#define POSIX_SPAWN_SETPGROUP SYMBOLIC(POSIX_SPAWN_SETPGROUP)
|
||||
#define POSIX_SPAWN_SETSCHEDPARAM SYMBOLIC(POSIX_SPAWN_SETSCHEDPARAM)
|
||||
#define POSIX_SPAWN_SETSCHEDULER SYMBOLIC(POSIX_SPAWN_SETSCHEDULER)
|
||||
#define POSIX_SPAWN_SETSIGDEF SYMBOLIC(POSIX_SPAWN_SETSIGDEF)
|
||||
#define POSIX_SPAWN_SETSIGMASK SYMBOLIC(POSIX_SPAWN_SETSIGMASK)
|
||||
#define POSIX_SPAWN_USEVFORK SYMBOLIC(POSIX_SPAWN_USEVFORK)
|
||||
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
|
@ -35,14 +15,20 @@ hidden extern const long POSIX_MADV_NORMAL;
|
|||
hidden extern const long POSIX_MADV_RANDOM;
|
||||
hidden extern const long POSIX_MADV_SEQUENTIAL;
|
||||
hidden extern const long POSIX_MADV_WILLNEED;
|
||||
hidden extern const long POSIX_SPAWN_RESETIDS;
|
||||
hidden extern const long POSIX_SPAWN_SETPGROUP;
|
||||
hidden extern const long POSIX_SPAWN_SETSCHEDPARAM;
|
||||
hidden extern const long POSIX_SPAWN_SETSCHEDULER;
|
||||
hidden extern const long POSIX_SPAWN_SETSIGDEF;
|
||||
hidden extern const long POSIX_SPAWN_SETSIGMASK;
|
||||
hidden extern const long POSIX_SPAWN_USEVFORK;
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
|
||||
#define POSIX_FADV_DONTNEED SYMBOLIC(POSIX_FADV_DONTNEED)
|
||||
#define POSIX_FADV_NOREUSE SYMBOLIC(POSIX_FADV_NOREUSE)
|
||||
#define POSIX_FADV_NORMAL SYMBOLIC(POSIX_FADV_NORMAL)
|
||||
#define POSIX_FADV_RANDOM SYMBOLIC(POSIX_FADV_RANDOM)
|
||||
#define POSIX_FADV_SEQUENTIAL SYMBOLIC(POSIX_FADV_SEQUENTIAL)
|
||||
#define POSIX_FADV_WILLNEED SYMBOLIC(POSIX_FADV_WILLNEED)
|
||||
#define POSIX_MADV_DONTNEED SYMBOLIC(POSIX_MADV_DONTNEED)
|
||||
#define POSIX_MADV_NORMAL SYMBOLIC(POSIX_MADV_NORMAL)
|
||||
#define POSIX_MADV_RANDOM SYMBOLIC(POSIX_MADV_RANDOM)
|
||||
#define POSIX_MADV_SEQUENTIAL SYMBOLIC(POSIX_MADV_SEQUENTIAL)
|
||||
#define POSIX_MADV_WILLNEED SYMBOLIC(POSIX_MADV_WILLNEED)
|
||||
|
||||
#endif /* COSMOPOLITAN_LIBC_SYSV_CONSTS_POSIX_H_ */
|
||||
|
|
|
@ -91,7 +91,7 @@ scall 'setsockopt$sysv' 0x0069006920690036 globl hidden
|
|||
scall 'getsockopt$sysv' 0x0076007620760037 globl hidden
|
||||
scall '__fork$sysv' 0x0002000220020039 globl hidden # xnu needs eax=~-edx b/c eax always holds pid and edx is 0 for parent and 1 for child
|
||||
#scall vfork 0x004200422042003a globl # this syscall is from the moon so we implement it by hand in libc/calls/hefty/vfork.S
|
||||
scall posix_spawn 0xffffffff20f4ffff globl hidden # TODO: put in spawnve()
|
||||
scall 'posix_spawn$sysv' 0xffffffff20f4ffff globl hidden # good luck figuring out how xnu defines this
|
||||
scall '__execve$sysv' 0x003b003b203b003b globl hidden
|
||||
scall 'wait4$sysv' 0x000b00072007003d globl hidden
|
||||
scall 'kill$sysv' 0x007a00252025003e globl hidden # kill(pid, sig, 1) b/c xnu
|
||||
|
|
Loading…
Add table
Reference in a new issue