ref: 3c6c5a02710e4d7a3da6121e9bfb8d2bc0d786dd
parent: 82527a897297f87c627cd3c7a0f783a39bb0a2bd
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Tue May 17 15:32:18 EDT 2022
libc: Add _fork() syscall This syscall is needed to implement system() in posix systems.
--- a/include/bits/darwin/sys.h
+++ b/include/bits/darwin/sys.h
@@ -20,6 +20,7 @@
struct sigaction;
+extern int _fork(void);
extern pid_t _getpid(void);
extern int _kill(pid_t, int);
extern int _sigaction(int, struct sigaction *, struct sigaction *);
--- a/include/bits/dragonfly/sys.h
+++ b/include/bits/dragonfly/sys.h
@@ -18,6 +18,7 @@
typedef int pid_t;
+extern int _fork(void);
extern pid_t _getpid(void);
extern int _kill(pid_t, int);
extern int _sigaction(int, struct sigaction *, struct sigaction *);
--- a/include/bits/linux/sys.h
+++ b/include/bits/linux/sys.h
@@ -20,6 +20,7 @@
struct sigaction;
+extern int _fork(void);
extern pid_t _getpid(void);
extern int _kill(pid_t, int);
extern int _sigaction(int, struct sigaction *, struct sigaction *);
--- a/include/bits/netbsd/sys.h
+++ b/include/bits/netbsd/sys.h
@@ -18,6 +18,7 @@
typedef int pid_t;
+extern int _fork(void);
extern pid_t _getpid(void);
extern int _kill(pid_t, int);
extern int _sigaction(int, struct sigaction *, struct sigaction *);
--- a/include/bits/openbsd/sys.h
+++ b/include/bits/openbsd/sys.h
@@ -20,6 +20,7 @@
struct sigaction;
+extern int _fork(void);
extern pid_t _getpid(void);
extern int _kill(pid_t, int);
extern int _sigaction(int, struct sigaction *, struct sigaction *);
--- a/src/libc/arch/amd64/darwin/.gitignore
+++ b/src/libc/arch/amd64/darwin/.gitignore
@@ -1,5 +1,6 @@
__close.s
__exit.s
+__fork.s
__getpid.s
__kill.s
__lseek.s
--- a/src/libc/arch/amd64/darwin/Makefile
+++ b/src/libc/arch/amd64/darwin/Makefile
@@ -7,6 +7,7 @@
GENOBJS =\
__close.$O\
__exit.$O\
+ __fork.$O\
__getpid.$O\
__kill.$O\
__lseek.$O\
--- a/src/libc/arch/amd64/darwin/syscall.lst
+++ b/src/libc/arch/amd64/darwin/syscall.lst
@@ -1,6 +1,7 @@
#Tab 15
#number name nargs
1 __exit 1
+2 __fork 0
3 __read 3
4 __write 3
5 __open 3
--- a/src/libc/arch/amd64/dragonfly/.gitignore
+++ b/src/libc/arch/amd64/dragonfly/.gitignore
@@ -1,6 +1,7 @@
_brk.s
_close.s
_exit.s
+_fork.s
_getpid.s
_kill.s
_lseek.s
--- a/src/libc/arch/amd64/dragonfly/Makefile
+++ b/src/libc/arch/amd64/dragonfly/Makefile
@@ -8,6 +8,7 @@
_brk.$O\
_close.$O\
_exit.$O\
+ _fork.$O\
_getpid.$O\
_kill.$O\
_lseek.$O\
--- a/src/libc/arch/amd64/dragonfly/syscall.lst
+++ b/src/libc/arch/amd64/dragonfly/syscall.lst
@@ -1,6 +1,7 @@
#Tab 15
#number name nargs
1 _exit 1
+2 _fork 0
3 _read 3
4 _write 3
5 _open 3
--- a/src/libc/arch/amd64/linux/.gitignore
+++ b/src/libc/arch/amd64/linux/.gitignore
@@ -1,6 +1,7 @@
__sigaction.s
_close.s
_exit.s
+_fork.s
_getpid.s
_getrusage.s
_gettimeofday.s
--- a/src/libc/arch/amd64/linux/Makefile
+++ b/src/libc/arch/amd64/linux/Makefile
@@ -9,6 +9,7 @@
__sigaction.$O\
_close.$O\
_exit.$O\
+ _fork.$O\
_getpid.$O\
_getrusage.$O\
_gettimeofday.$O\
--- a/src/libc/arch/amd64/linux/syscall.lst
+++ b/src/libc/arch/amd64/linux/syscall.lst
@@ -9,6 +9,7 @@
13 __sigaction 4
15 _sigreturn 0
39 _getpid 0
+57 _fork 0
60 _exit 1
62 _kill 2
87 _unlink 1
--- a/src/libc/arch/amd64/netbsd/.gitignore
+++ b/src/libc/arch/amd64/netbsd/.gitignore
@@ -1,6 +1,7 @@
_brk.s
_close.s
_exit.s
+_fork.s
_getpid.s
_gettimeofday.s
_kill.s
--- a/src/libc/arch/amd64/netbsd/Makefile
+++ b/src/libc/arch/amd64/netbsd/Makefile
@@ -8,6 +8,7 @@
_brk.$O\
_close.$O\
_exit.$O\
+ _fork.$O\
_getpid.$O\
_gettimeofday.$O\
_kill.$O\
--- a/src/libc/arch/amd64/netbsd/syscall.lst
+++ b/src/libc/arch/amd64/netbsd/syscall.lst
@@ -1,6 +1,7 @@
#Tab 15
#number name nargs
1 _exit 1
+2 _fork 0
3 _read 3
4 _write 3
5 _open 3
--- a/src/libc/arch/amd64/openbsd/.gitignore
+++ b/src/libc/arch/amd64/openbsd/.gitignore
@@ -1,6 +1,7 @@
_brk.s
_close.s
_exit.s
+_fork.s
_getpid.s
_gettimeofday.s
_kill.s
--- a/src/libc/arch/amd64/openbsd/Makefile
+++ b/src/libc/arch/amd64/openbsd/Makefile
@@ -8,6 +8,7 @@
_brk.$O\
_close.$O\
_exit.$O\
+ _fork.$O\
_getpid.$O\
_gettimeofday.$O\
_kill.$O\
--- a/src/libc/arch/amd64/openbsd/syscall.lst
+++ b/src/libc/arch/amd64/openbsd/syscall.lst
@@ -1,6 +1,7 @@
#Tab 15
#number name nargs
1 _exit 1
+2 _fork 0
3 _read 3
4 _write 3
5 _open 3
--- a/src/libc/arch/arm/linux/.gitignore
+++ b/src/libc/arch/arm/linux/.gitignore
@@ -1,6 +1,7 @@
_Exit.s
_brk.s
_close.s
+_fork.s
_getpid.s
_kill.s
_lseek.s
--- a/src/libc/arch/arm/linux/Makefile
+++ b/src/libc/arch/arm/linux/Makefile
@@ -7,6 +7,7 @@
GENOBJS =\
_close.$O\
_exit.$O\
+ _fork.$O\
_getpid.$O\
_kill.$O\
_lseek.$O\
--- a/src/libc/arch/arm/linux/syscall.lst
+++ b/src/libc/arch/arm/linux/syscall.lst
@@ -1,5 +1,6 @@
#number name
322 _openat
+2 _fork
6 _close
3 _read
4 _write
--- a/src/libc/arch/i386/linux/.gitignore
+++ b/src/libc/arch/i386/linux/.gitignore
@@ -1,5 +1,6 @@
_close.s
_exit.s
+_fork.s
_getpid.s
_kill.s
_lseek.s
--- a/src/libc/arch/i386/linux/Makefile
+++ b/src/libc/arch/i386/linux/Makefile
@@ -7,6 +7,7 @@
GENOBJS =\
_close.$O\
_exit.$O\
+ _fork.$O\
_getpid.$O\
_kill.$O\
_lseek.$O\
--- a/src/libc/arch/i386/linux/syscall.lst
+++ b/src/libc/arch/i386/linux/syscall.lst
@@ -1,5 +1,6 @@
#number name num_of_op
1 _exit 1
+2 _fork 0
3 _read 3
4 _write 3
5 _open 2
--- a/src/libc/arch/ppc/linux/.gitignore
+++ b/src/libc/arch/ppc/linux/.gitignore
@@ -1,6 +1,7 @@
_close.s
_creat.s
_exit.s
+_fork.s
_getpid.s
_kill.s
_link.s
--- a/src/libc/arch/ppc/linux/Makefile
+++ b/src/libc/arch/ppc/linux/Makefile
@@ -10,6 +10,7 @@
_close.$O\
_creat.$O\
_exit.$O\
+ _fork.$O\
_getpid.$O\
_kill.$O\
_link.$O\
--- a/src/libc/arch/ppc/linux/syscall.lst
+++ b/src/libc/arch/ppc/linux/syscall.lst
@@ -1,5 +1,6 @@
#number name
1 _exit
+2 _fork
3 _read
4 _write
5 _open