mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-27 06:48:31 +00:00
Add minor improvements and cleanup
This commit is contained in:
parent
9e3e985ae5
commit
feed0d2b0e
163 changed files with 2286 additions and 2245 deletions
|
@ -1,2 +0,0 @@
|
|||
.include "o/libc/sysv/macros.inc"
|
||||
.scall vfork 0x004200422042003a globl
|
|
@ -293,14 +293,14 @@ 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
|
||||
|
||||
# mprotect(), etc.
|
||||
# mmap(), mprotect(), etc.
|
||||
# digital restrictions management for the people
|
||||
#
|
||||
# group name GNU/Systemd XNU's Not UNIX FreeBSD OpenBSD XENIX Commentary
|
||||
syscon mprot PROT_NONE 0 0 0 0 0 # unix consensus (nt needs special business logic here)
|
||||
syscon mprot PROT_READ 1 1 1 1 1 # unix consensus
|
||||
syscon mprot PROT_WRITE 2 2 2 2 2 # unix consensus
|
||||
syscon mprot PROT_EXEC 4 4 4 4 4 # unix consensus
|
||||
syscon mprot PROT_NONE 0 0 0 0 0 # mmap, mprotect, unix consensus (nt needs special business logic here)
|
||||
syscon mprot PROT_READ 1 1 1 1 1 # mmap, mprotect, unix consensus
|
||||
syscon mprot PROT_WRITE 2 2 2 2 2 # mmap, mprotect, unix consensus
|
||||
syscon mprot PROT_EXEC 4 4 4 4 4 # mmap, mprotect, unix consensus
|
||||
syscon mprot PROT_GROWSDOWN 0x01000000 0 0 0 0 # intended for mprotect; see MAP_GROWSDOWN for mmap() (todo: what was 0x01000000 on nt)
|
||||
syscon mprot PROT_GROWSUP 0x02000000 0 0 0 0 # intended for mprotect; see MAP_GROWSDOWN for mmap()
|
||||
|
||||
|
@ -2798,6 +2798,7 @@ syscon nr __NR_access 0x0015 0x2000021 0x0021 0x0021 -1
|
|||
syscon nr __NR_sched_yield 0x0018 0x100003c 0x014b 0x012a -1
|
||||
syscon nr __NR_sendfile 0x0028 0x2000151 0x0189 0xffff -1
|
||||
syscon nr __NR_fork 0x0039 0x2000002 0x0002 0x0002 -1
|
||||
syscon nr __NR_vfork 0x003a 0x2000042 0x0042 0x0042 -1
|
||||
syscon nr __NR_gettimeofday 0x0060 0x2000074 0x0074 0x0043 -1
|
||||
syscon nr __NR_arch_prctl 0x009e 0x000ffff 0x00a5 0x00a5 -1
|
||||
syscon nr __NR_gettid 0x00ba 0x200011e 0xffff 0xffff -1
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
.include "libc/sysv/consts/syscon.inc"
|
||||
.syscon mmap MAP_FIXED 16 16 16 16 16
|
||||
.syscon mmap MAP_FIXED 0x10 0x10 0x10 0x10 0x10
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
.include "libc/sysv/consts/syscon.inc"
|
||||
.syscon mmap MAP_NONBLOCK 0x010000 0 0 0 0
|
||||
.syscon mmap MAP_NONBLOCK 0x10000 0 0 0 0
|
||||
|
|
2
libc/sysv/consts/__NR_vfork.s
Normal file
2
libc/sysv/consts/__NR_vfork.s
Normal file
|
@ -0,0 +1,2 @@
|
|||
.include "libc/sysv/consts/syscon.inc"
|
||||
.syscon nr __NR_vfork 0x003a 0x2000042 0x0042 0x0042 -1
|
|
@ -91,7 +91,7 @@ scall 'socketpair$sysv' 0x0087008720870035 globl hidden
|
|||
scall 'setsockopt$sysv' 0x0069006920690036 globl hidden
|
||||
scall 'getsockopt$sysv' 0x0076007620760037 globl hidden
|
||||
scall 'fork$sysv' 0x0002000220020039 globl hidden
|
||||
scall vfork 0x004200422042003a globl
|
||||
#scall vfork 0x004200422042003a globl # needs to be called via vfork.S
|
||||
scall posix_spawn 0xffffffff20f4ffff globl hidden # TODO: put in spawnve()
|
||||
scall 'execve$sysv' 0x003b003b203b003b globl hidden
|
||||
scall 'wait4$sysv' 0x000b00072007003d globl hidden
|
||||
|
|
|
@ -107,18 +107,18 @@ systemfive.linux:
|
|||
systemfive.error:
|
||||
neg %eax
|
||||
/ 𝑠𝑙𝑖𝑑𝑒
|
||||
.endfn systemfive.error
|
||||
.endfn systemfive.error,globl,hidden
|
||||
systemfive.errno:
|
||||
mov %eax,errno(%rip)
|
||||
push $-1
|
||||
pop %rax
|
||||
stc
|
||||
ret
|
||||
.endfn systemfive.errno
|
||||
.endfn systemfive.errno,globl,hidden
|
||||
systemfive.enosys:
|
||||
mov ENOSYS(%rip),%eax
|
||||
jmp systemfive.errno
|
||||
.endfn systemfive.enosys
|
||||
.endfn systemfive.enosys,globl,hidden
|
||||
systemfive.openbsd:
|
||||
shr $48,%rax
|
||||
jmp systemfive.bsd
|
||||
|
|
|
@ -34,6 +34,7 @@ LIBC_SYSV_A_FILES := \
|
|||
libc/sysv/restorert.S \
|
||||
libc/sysv/syscall.S \
|
||||
libc/sysv/systemfive.S \
|
||||
libc/sysv/vfork.S \
|
||||
$(wildcard libc/sysv/stubs/*) \
|
||||
$(wildcard libc/sysv/consts/*) \
|
||||
$(wildcard libc/sysv/errfuns/*)
|
||||
|
@ -86,6 +87,7 @@ LIBC_SYSV_CALLS_A_DEPS := \
|
|||
$(call uniq,$(foreach x,$(LIBC_SYSV_CALLS_A_DIRECTDEPS),$($(x))))
|
||||
|
||||
$(LIBC_SYSV_CALLS_A): \
|
||||
libc/sysv/calls/ \
|
||||
$(LIBC_SYSV_CALLS_A).pkg \
|
||||
$(LIBC_SYSV_CALLS_A_OBJS)
|
||||
|
||||
|
|
48
libc/sysv/vfork.S
Normal file
48
libc/sysv/vfork.S
Normal file
|
@ -0,0 +1,48 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/dce.h"
|
||||
#include "libc/macros.h"
|
||||
|
||||
/ Forks process without copying page tables.
|
||||
/
|
||||
/ This is the same as fork() except it's optimized for the case
|
||||
/ where the caller invokes exec() immediately afterwards.
|
||||
/
|
||||
/ @return pid of child process or 0 if forked process
|
||||
/ @returnstwice
|
||||
vfork: mov __NR_vfork(%rip),%eax
|
||||
cmp $-1,%eax
|
||||
je systemfive.enosys
|
||||
pop %rsi
|
||||
testb IsBsd()
|
||||
jnz vfork.bsd
|
||||
syscall
|
||||
push %rsi
|
||||
cmp $-4095,%rax
|
||||
jae systemfive.error
|
||||
ret
|
||||
.endfn vfork,globl
|
||||
|
||||
vfork.bsd:
|
||||
syscall
|
||||
push %rsi
|
||||
jc systemfive.errno
|
||||
ret
|
||||
.endfn vfork.bsd
|
Loading…
Add table
Add a link
Reference in a new issue