From: Alan Cox Date: Fri, 2 Oct 2015 12:17:08 +0000 (+0100) Subject: fork(): flag day time - add flags, pointer argument as _fork and wrap it X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=442fd50a41a293a133aa165b102ca4ae7eb2570c;p=FUZIX.git fork(): flag day time - add flags, pointer argument as _fork and wrap it Ready for doing faster/cleverer forky things --- diff --git a/Kernel/include/syscall_name.h b/Kernel/include/syscall_name.h index 4853f08b..ba575c68 100644 --- a/Kernel/include/syscall_name.h +++ b/Kernel/include/syscall_name.h @@ -35,7 +35,7 @@ char *syscall_name[NR_SYSCALL] = { "ioctl", "brk", "sbrk", - "fork", + "_fork", "mount", "umount", "signal", @@ -101,7 +101,7 @@ int syscall_args[NR_SYSCALL] = { VARARGS, //ioctl 1, //brk 1, //sbrk - 0, //fork + 2, //_fork 3, //mount 1, //umount 2, //signal diff --git a/Kernel/syscall_proc.c b/Kernel/syscall_proc.c index 19e92b35..e56081e5 100644 --- a/Kernel/syscall_proc.c +++ b/Kernel/syscall_proc.c @@ -349,8 +349,10 @@ arg_t __exit(void) #undef val /******************************************* -fork () Function 32 +_fork (flags, addr) Function 32 ********************************************/ +#define flags (int16_t)udata.u_argn +#define addr (uaddr_t)udata.u_argn1 arg_t _fork(void) { @@ -359,6 +361,13 @@ arg_t _fork(void) arg_t r; irqflags_t irq; + if (flags) { + /* Brief period of grace... */ +// udata.u_error = EINVAL; +// return -1; + kputs("warning: rebuild libc\n"); + } + new_process = ptab_alloc(); if (!new_process) return -1; @@ -390,6 +399,7 @@ arg_t _fork(void) return r; } +#undef flags /******************************************* diff --git a/Library/include/syscalls.h b/Library/include/syscalls.h index 5944a527..04002c97 100644 --- a/Library/include/syscalls.h +++ b/Library/include/syscalls.h @@ -117,7 +117,7 @@ extern int setgid(gid_t gid); extern int ioctl(int fd, int request,...); extern int brk(void *addr); extern void *sbrk(intptr_t increment); -extern pid_t fork(void); +extern pid_t _fork(uint16_t flags, void *addr); extern int mount(const char *dev, const char *path, int flags); extern int umount(const char *dev); extern sighandler_t signal(int signum, sighandler_t sighandler); diff --git a/Library/libs/Makefile b/Library/libs/Makefile index 860207f4..d5953e9e 100644 --- a/Library/libs/Makefile +++ b/Library/libs/Makefile @@ -25,8 +25,8 @@ SRC_C += clock_gettime.c clock_getres.c clock_settime.c SRC_C += creat.c crypt.c ctime.c difftime.c err.c errno.c error.c SRC_C += execl.c execv.c execvp.c exit.c SRC_C += fclose.c fflush.c fgetc.c fgetgrent.c fgetpwent.c -SRC_C += fgetpos.c fgets.c fopen.c fprintf.c fputc.c fputs.c fread.c free.c -SRC_C += fsetpos.c ftell.c fwrite.c getcwd.c +SRC_C += fgetpos.c fgets.c fopen.c fork.c fprintf.c fputc.c fputs.c fread.c +SRC_C += free.c fsetpos.c ftell.c fwrite.c getcwd.c SRC_C += getenv.c __getgrent.c getgrgid.c getgrnam.c getloadavg.c getopt.c SRC_C += getpw.c __getpwent.c getpwnam.c getpwuid.c gets.c gettimeofday.c SRC_C += gmtime.c gmtime_r.c grent.c index.c isatty.c killpg.c diff --git a/Library/libs/Makefile.6502 b/Library/libs/Makefile.6502 index ad37ab4d..3a2ddf06 100644 --- a/Library/libs/Makefile.6502 +++ b/Library/libs/Makefile.6502 @@ -17,8 +17,8 @@ OBJ_ASM = $(SRC_ASM:.s=.o) # Fix me there pmemalign and a couple of other standard funcs we # don't have. Calling these will result in a mess but once we've fixed # our library to cover them it should be fine. There are also some we -# have through the cc65 lib but need in other ports (strxfrm, strftime, -# snprintf, vsnprintf etc) +# have through the cc65 lib but need in other ports (strxfrm, strftime +# etc) # # FIXME: # Due to ctype differences we can't use the stricmp/strcasecmp and @@ -36,8 +36,8 @@ SRC_C += clock_gettime.c clock_getres.c clock_settime.c SRC_C += creat.c crypt.c ctime.c difftime.c err.c errno.c error.c SRC_C += execl.c execv.c execvp.c exit.c SRC_C += fclose.c fflush.c fgetc.c fgetgrent.c fgetpwent.c -SRC_C += fgetpos.c fgets.c fopen.c fprintf.c fputc.c fputs.c fread.c free.c -SRC_C += fsetpos.c ftell.c fwrite.c getcwd.c +SRC_C += fgetpos.c fgets.c fopen.c fork.c fprintf.c fputc.c fputs.c fread.c +SRC_C += free.c fsetpos.c ftell.c fwrite.c getcwd.c SRC_C += getenv.c __getgrent.c getgrgid.c getgrnam.c getloadavg.c getopt.c SRC_C += getpw.c __getpwent.c getpwnam.c getpwuid.c gets.c gettimeofday.c SRC_C += gmtime.c gmtime_r.c grent.c index.c isatty.c killpg.c diff --git a/Library/libs/Makefile.6809 b/Library/libs/Makefile.6809 index 6f3ab527..0db97604 100644 --- a/Library/libs/Makefile.6809 +++ b/Library/libs/Makefile.6809 @@ -17,8 +17,8 @@ SRC_C += clock_gettime.c clock_getres.c clock_settime.c SRC_C += creat.c crypt.c ctime.c difftime.c err.c errno.c error.c SRC_C += execl.c execv.c execvp.c exit.c SRC_C += fclose.c fflush.c fgetc.c fgetgrent.c fgetpwent.c -SRC_C += fgetpos.c fgets.c fopen.c fprintf.c fputc.c fputs.c fread.c free.c -SRC_C += fsetpos.c ftell.c fwrite.c getcwd.c +SRC_C += fgetpos.c fgets.c fopen.c fork.c fprintf.c fputc.c fputs.c fread.c +SRC_C += free.c fsetpos.c ftell.c fwrite.c getcwd.c SRC_C += getenv.c __getgrent.c getgrgid.c getgrnam.c getloadavg.c getopt.c SRC_C += getpw.c __getpwent.c getpwnam.c getpwuid.c gets.c gettimeofday.c SRC_C += gmtime.c gmtime_r.c grent.c index.c isatty.c killpg.c diff --git a/Library/libs/fork.c b/Library/libs/fork.c new file mode 100644 index 00000000..9044081b --- /dev/null +++ b/Library/libs/fork.c @@ -0,0 +1,10 @@ +#include +#include + +/* + * Wrap the kernel _fork() call + */ +pid_t fork(void) +{ + return _fork(0, NULL); +} diff --git a/Library/libs/fuzix/Makefile b/Library/libs/fuzix/Makefile index 79568d84..9935cf5f 100644 --- a/Library/libs/fuzix/Makefile +++ b/Library/libs/fuzix/Makefile @@ -37,7 +37,7 @@ ASRCS += syscall__stime.s ASRCS += syscall_ioctl.s ASRCS += syscall_brk.s ASRCS += syscall_sbrk.s -ASRCS += syscall_fork.s +ASRCS += syscall__fork.s ASRCS += syscall_mount.s ASRCS += syscall_umount.s ASRCS += syscall_signal.s