From 48798bf2eb93ec3b99720ac2e16093441156653d Mon Sep 17 00:00:00 2001 From: Robert de Bath Date: Sun, 5 Oct 1997 15:05:09 +0200 Subject: Import Dev86src-0.13.0.tar.gz --- libc/Config.dflt | 1 - libc/Config_sh | 20 +- libc/Make.defs | 13 + libc/Makefile | 21 +- libc/bcc/__ldivmod.c | 1 + libc/bcc/bcc_bsw.c | 1 + libc/bcc/bcc_i386.c | 1 + libc/bcc/bcc_int.c | 1 + libc/bcc/bcc_io.c | 1 + libc/bcc/bcc_long.c | 1 + libc/bcc/ldiv.c | 3 + libc/crt0.c | 7 +- libc/gnu_i386/Config | 1 + libc/gnu_i386/Makefile | 59 + libc/gnu_i386/cstartup.s | 85 ++ libc/gnu_i386/dirent.c | 106 ++ libc/gnu_i386/exec.c | 292 ++++ libc/gnu_i386/heap.c | 76 + libc/gnu_i386/mksyscall | 123 ++ libc/gnu_i386/syscall.dat | 155 ++ libc/gnu_i386/syscall.s | 2969 ++++++++++++++++++++++++++++++++++++++ libc/i386fp/README | 5 + libc/i386sys/Makefile | 5 +- libc/i386sys/cstartup.c | 98 ++ libc/i386sys/signal.c | 99 -- libc/i386sys/syslibc.c | 255 ---- libc/include/asm/limits.h | 57 + libc/include/asm/types.h | 34 + libc/include/errno.h | 26 +- libc/include/fcntl.h | 6 +- libc/include/features.h | 21 +- libc/include/generic/errno.h | 130 ++ libc/include/generic/fcntl.h | 73 + libc/include/generic/types.h | 22 + libc/include/limits.h | 50 +- libc/include/linux/errno.h | 127 ++ libc/include/linux/fcntl.h | 70 + libc/include/linux/ioctl.h | 0 libc/include/linux/mman.h | 52 + libc/include/linux/resource.h | 73 + libc/include/linux/stat.h | 76 + libc/include/linux/termios.h | 257 ++++ libc/include/linux/types.h | 26 + libc/include/linux/utsname.h | 15 + libc/include/linux/vm86.h | 125 ++ libc/include/msdos/errno.h | 46 + libc/include/msdos/fcntl.h | 24 + libc/include/msdos/types.h | 22 + libc/include/signal.h | 2 + libc/include/stddef.h | 14 +- libc/include/sys/errno.h | 26 +- libc/include/sys/ioctl.h | 2 +- libc/include/sys/mman.h | 6 + libc/include/sys/resource.h | 75 +- libc/include/sys/socket.h | 6 + libc/include/sys/stat.h | 52 +- libc/include/sys/types.h | 3 +- libc/include/sys/utsname.h | 12 +- libc/include/sys/vm86.h | 126 +- libc/include/termios.h | 2 +- libc/include/unistd.h | 2 + libc/kinclude/Config | 2 +- libc/kinclude/Makefile | 11 +- libc/kinclude/arch/errno.h | 4 +- libc/kinclude/arch/stat.h | 19 + libc/kinclude/arch/types.h | 28 +- libc/kinclude/linuxmt/resource.h | 73 + libc/kinclude/linuxmt/stat.h | 6 +- libc/kinclude/linuxmt/types.h | 12 +- libc/misc/Makefile | 9 +- libc/misc/syslib.c | 181 +++ libc/stdio2/stdio.c | 9 +- libc/syscall/Makefile | 14 +- libc/syscall/TODO | 125 ++ libc/syscall/syslibc.c | 168 --- 75 files changed, 5768 insertions(+), 952 deletions(-) create mode 100644 libc/gnu_i386/Config create mode 100644 libc/gnu_i386/Makefile create mode 100644 libc/gnu_i386/cstartup.s create mode 100644 libc/gnu_i386/dirent.c create mode 100644 libc/gnu_i386/exec.c create mode 100644 libc/gnu_i386/heap.c create mode 100644 libc/gnu_i386/mksyscall create mode 100644 libc/gnu_i386/syscall.dat create mode 100644 libc/gnu_i386/syscall.s create mode 100644 libc/i386fp/README create mode 100644 libc/i386sys/cstartup.c delete mode 100644 libc/i386sys/signal.c delete mode 100644 libc/i386sys/syslibc.c create mode 100644 libc/include/asm/limits.h create mode 100644 libc/include/asm/types.h create mode 100644 libc/include/generic/errno.h create mode 100644 libc/include/generic/fcntl.h create mode 100644 libc/include/generic/types.h create mode 100644 libc/include/linux/errno.h create mode 100644 libc/include/linux/fcntl.h create mode 100644 libc/include/linux/ioctl.h create mode 100644 libc/include/linux/mman.h create mode 100644 libc/include/linux/resource.h create mode 100644 libc/include/linux/stat.h create mode 100644 libc/include/linux/termios.h create mode 100644 libc/include/linux/types.h create mode 100644 libc/include/linux/utsname.h create mode 100644 libc/include/linux/vm86.h create mode 100644 libc/include/msdos/errno.h create mode 100644 libc/include/msdos/fcntl.h create mode 100644 libc/include/msdos/types.h create mode 100644 libc/include/sys/socket.h create mode 100644 libc/kinclude/arch/stat.h create mode 100644 libc/kinclude/linuxmt/resource.h create mode 100644 libc/misc/syslib.c delete mode 100644 libc/syscall/syslibc.c (limited to 'libc') diff --git a/libc/Config.dflt b/libc/Config.dflt index b2a79b0..7444bae 100644 --- a/libc/Config.dflt +++ b/libc/Config.dflt @@ -5,7 +5,6 @@ getent:+: gtermcap:+: i386fp:+: i386sys:+: -kinclude:+: malloc1:+: misc:+: msdos:+: diff --git a/libc/Config_sh b/libc/Config_sh index 0b65992..5b72652 100644 --- a/libc/Config_sh +++ b/libc/Config_sh @@ -15,7 +15,13 @@ main() if [ "$ALLON" = yes -a -f Config.dflt ] then grep '^[^:]*:+:' Config.dflt > .config.tmp - [ -s .config.tmp ] && ALLON=no + [ -s .config.tmp ] && { + ALLON=no + grep -q '^kinclude:' .config.tmp >/dev/null 2>&1 || { + [ -d "$ELKSSRC/include" ] || + echo 'kinclude:+:' >> .config.tmp + } + } fi egrep -v '^#|^$' /dev/null */[Cc]onfig | \ @@ -40,7 +46,7 @@ main() do display echo - echo -n 'Option to flip [or quit] >' + echon 'Option to flip [or quit] >' read n v="" case "$n" in @@ -144,4 +150,14 @@ set_option() unset_dups } +echon() { + [ "$ECHON" = "" ] && { + if echo -n | grep -e -n >/dev/null + then ECHON="echo "; ECHOT='\c' + else ECHON="echo -n"; ECHOT='' + fi + } + $ECHON "$@""$ECHOT" +} + main diff --git a/libc/Make.defs b/libc/Make.defs index 2b1eca6..d411c6a 100644 --- a/libc/Make.defs +++ b/libc/Make.defs @@ -53,6 +53,19 @@ LIB_CPU=i386 LIB_OS=ELKS endif +############################################################################## +# GCC 386. + +ifeq ($(PLATFORM),i386-GCC) +OBJ=crtg.o +LIBC=$(TOP)/libcg.a +ARCH= +LIB_CPU=g386 +LIB_OS=ELKS +CC=gcc +CCFLAGS=-O -g -nostdinc -I$(TOP)/include +endif + ############################################################################## # Anonymous diff --git a/libc/Makefile b/libc/Makefile index 436c3c6..5ddea9a 100644 --- a/libc/Makefile +++ b/libc/Makefile @@ -10,14 +10,19 @@ TOP=$(TOPDIR)/libc endif VERMAJOR=0 -VERMINOR=12 -VERPATCH=4 +VERMINOR=13 +VERPATCH=0 VER=$(VERMAJOR).$(VERMINOR).$(VERPATCH) CC=bcc CCFLAGS=-I -I$(TOP)/include DEFS=-D__LIBC__ +ifeq ($(ELKSSRC),) +ELKSSRC=/usr/src/elks +endif +export ELKSSRC + include Make.defs CFLAGS=$(ARCH) $(CCFLAGS) $(DEFS) @@ -43,6 +48,9 @@ crt3.o: crt0.c Makefile crt0.o: crt0.c Makefile $(CC) -c $(CFLAGS) -D__LIBC_VER__='"$(VER)"' -o $@ crt0.c +crtg.o: crt0.c Makefile + $(CC) -c $(CFLAGS) -D__LIBC_VER__='"$(VER)"' -o $@ crt0.c + crtX.o: @echo "You need to define the 'PLATFORM=...' variable," @echo "Preferably by doing make from `dirname \`pwd\``" @@ -55,8 +63,10 @@ transfer: .config.dir grep -s '^transfer' $$i/Makefile && $(MAKE) -s -C $$i $@ ; \ done ; echo -n @[ -f kinclude/Used ] || \ - { rm -f include/linuxmt ; \ - ln -s $(ELKSSRC)/include/linuxmt include ; } + { rm -f include/linuxmt include/arch ; \ + ln -s $(ELKSSRC)/include/linuxmt include ; \ + ln -s $(ELKSSRC)/include/arch include ; \ + } ############################################################################ @@ -75,8 +85,9 @@ install_incl: cp -pr include $(BCCHOME)/include if [ -f kinclude/Used ] ; \ then cp -pr kinclude/arch $(BCCHOME)/include/arch ; \ - else rm -rf $(BCCHOME)/include/linuxmt ; \ + else rm -rf $(BCCHOME)/include/linuxmt $(BCCHOME)/include/arch ; \ ln -s $(ELKSSRC)/include/linuxmt $(BCCHOME)/include ; \ + ln -s $(ELKSSRC)/include/arch $(BCCHOME)/include ; \ fi -chown -R root:root $(BCCHOME)/include 2>/dev/null -chmod -R u=rwX,og=rX $(BCCHOME)/include diff --git a/libc/bcc/__ldivmod.c b/libc/bcc/__ldivmod.c index 4cb6d77..596d022 100644 --- a/libc/bcc/__ldivmod.c +++ b/libc/bcc/__ldivmod.c @@ -1,5 +1,6 @@ /************************************************************************/ /* This file contains the BCC compiler helper functions */ +/* (C) Copyright Bruce Evans */ /* Function ldivmod */ #ifdef __AS386_16__ diff --git a/libc/bcc/bcc_bsw.c b/libc/bcc/bcc_bsw.c index 4dd0d11..a80a679 100644 --- a/libc/bcc/bcc_bsw.c +++ b/libc/bcc/bcc_bsw.c @@ -1,5 +1,6 @@ /************************************************************************/ /* This file contains the BCC compiler helper functions */ +/* (C) Copyright Bruce Evans */ /* Support for long arithmetic on big-endian (words-swapped) longs * __laddb.o __landb.o __lcmpb.o __lcomb.o __ldecb.o __ldivb.o __ldivub.o * __leorb.o __lincb.o __lmodb.o __lmodub.o __lmulb.o __lnegb.o __lorb.o diff --git a/libc/bcc/bcc_i386.c b/libc/bcc/bcc_i386.c index d994628..fa57513 100644 --- a/libc/bcc/bcc_i386.c +++ b/libc/bcc/bcc_i386.c @@ -1,5 +1,6 @@ /************************************************************************/ /* This file contains the BCC compiler helper functions */ +/* (C) Copyright Bruce Evans */ /* Support for 386 integer arithmetic * __divsi3.o __idiv.o __idivu.o __imod.o __imodu.o __imul.o * __isl.o __isr.o __isru.o diff --git a/libc/bcc/bcc_int.c b/libc/bcc/bcc_int.c index abdb7b4..028a3f1 100644 --- a/libc/bcc/bcc_int.c +++ b/libc/bcc/bcc_int.c @@ -1,5 +1,6 @@ /************************************************************************/ /* This file contains the BCC compiler helper functions */ +/* (C) Copyright Bruce Evans */ /* Support for integer arithmetic * __idiv.o __idivu.o __imod.o __imodu.o __imul.o __isl.o __isr.o __isru.o */ diff --git a/libc/bcc/bcc_io.c b/libc/bcc/bcc_io.c index af5dfd2..d7af86f 100644 --- a/libc/bcc/bcc_io.c +++ b/libc/bcc/bcc_io.c @@ -1,5 +1,6 @@ /************************************************************************/ /* This file contains the BCC compiler helper functions */ +/* (C) Prentice Hall (Minix) http://www.cs.vu.nl/~ast/minix.html */ /* Miscellaneous obsolete junk * __inport.o __inportb.o __outport.o __outportb.o __peekb.o __peekw.o * __pokeb.o __pokew.o diff --git a/libc/bcc/bcc_long.c b/libc/bcc/bcc_long.c index 4b6ceae..4d1f7d8 100644 --- a/libc/bcc/bcc_long.c +++ b/libc/bcc/bcc_long.c @@ -1,5 +1,6 @@ /************************************************************************/ /* This file contains the BCC compiler helper functions */ +/* (C) Copyright Bruce Evans */ /* Support for long arithmetic on little-endian (normal) longs * __laddl.o __landl.o __lcmpl.o __lcoml.o __ldecl.o __ldivl.o __ldivul.o * __leorl.o __lincl.o __lmodl.o __lmodul.o __lmull.o __lnegl.o __lorl.o diff --git a/libc/bcc/ldiv.c b/libc/bcc/ldiv.c index aab0701..b0fabee 100644 --- a/libc/bcc/ldiv.c +++ b/libc/bcc/ldiv.c @@ -1,3 +1,6 @@ +/************************************************************************/ +/* This file contains the BCC compiler helper functions */ +/* (C) Copyright Bruce Evans */ #ifdef __AS386_16__ #asm diff --git a/libc/crt0.c b/libc/crt0.c index bdf1585..819d92f 100644 --- a/libc/crt0.c +++ b/libc/crt0.c @@ -41,14 +41,15 @@ auto_start: #endif /* __AS386_16__ or __AS386_32__ */ #if defined(__GNUC__) && defined(__i386__) -#define CRT0_OK - #ifdef __ELF__ -__asm__(".globl __startup\n__startup:"); +#define CRT0_OK +__asm__(".globl _start\n_start:"); __asm__("jmp __cstartup"); __asm__(".globl __no_op\n__no_op:"); __asm__("ret"); #else + +#error This library is for ELF only, sorry. __asm__(".globl startup\nstartup:"); __asm__("jmp ___cstartup"); __asm__(".globl no_op\nno_op:"); diff --git a/libc/gnu_i386/Config b/libc/gnu_i386/Config new file mode 100644 index 0000000..6b218f4 --- /dev/null +++ b/libc/gnu_i386/Config @@ -0,0 +1 @@ +gnu386: Linux-i386 system call routines GCC diff --git a/libc/gnu_i386/Makefile b/libc/gnu_i386/Makefile new file mode 100644 index 0000000..5ec95b2 --- /dev/null +++ b/libc/gnu_i386/Makefile @@ -0,0 +1,59 @@ +# Copyright (C) 1995,1996 Robert de Bath +# This file is part of the Linux-8086 C library and is distributed +# under the GNU Library General Public License. + +CSRC=cstartup.s +COBJ=cstartup.o + +ESRC=exec.c +EOBJ=execl.o execv.o execle.o execlp.o execvp.o + +DSRC=dirent.c +DOBJ=opendir.o closedir.o readdir.o + +HSRC=heap.c +HOBJ=__brk_addr.o brk.o sbrk.o + +ifeq ($(LIB_CPU)-$(LIB_OS),g386-ELKS) +OBJ=$(COBJ) $(EOBJ) $(DOBJ) $(HOBJ) +SYSCALLS=syscalls + +CFLAGS=$(ARCH) $(CCFLAGS) $(DEFS) + +all: $(SYSCALLS) $(LIBC)($(OBJ)) + @$(RM) $(OBJ) + +syscalls: syscall.mak + $(MAKE) -f syscall.mak LIBC="$(LIBC)" CFLAGS="$(CFLAGS)" + +syscall.mak: mksyscall syscall.dat + sh mksyscall + +$(LIBC)($(LOBJ)): $(LSRC) + $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o + $(AR) $(ARFLAGS) $@ $*.o + +$(LIBC)($(COBJ)): $(CSRC) + $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o + $(AR) $(ARFLAGS) $@ $*.o + +$(LIBC)($(DOBJ)): $(DSRC) + $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o + $(AR) $(ARFLAGS) $@ $*.o + +$(LIBC)($(EOBJ)): $(ESRC) + $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o + $(AR) $(ARFLAGS) $@ $*.o + +$(LIBC)($(HOBJ)): $(HSRC) + $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o + $(AR) $(ARFLAGS) $@ $*.o +else +all: + @: +endif + +clean: + rm -f *.o libc.a + rm -f syscall.c syscall.mak + diff --git a/libc/gnu_i386/cstartup.s b/libc/gnu_i386/cstartup.s new file mode 100644 index 0000000..780d3a4 --- /dev/null +++ b/libc/gnu_i386/cstartup.s @@ -0,0 +1,85 @@ +# +# This is a startup for GCC compiling to an ELF executable. +# +# + .file "cstartup.s" + +# void (*__cleanup)() = 0; + +.globl __cleanup +.data + .align 4 + .type __cleanup,@object + .size __cleanup,4 +__cleanup: + .long 0 + +.globl errno + .align 4 + .type errno,@object + .size errno,4 +errno: + .long 0 + +# char ** environ; + .comm environ,4,4 + +.text + .align 16 +.globl __cstartup +.type __cstartup,@function +__cstartup: # Crt0 startup (Linux style) + cmpl $0,(%esp) + jz call_exit # If argc == 0 this is being called by ldd, exit. + + popl %ecx + movl %esp,%ebx # Points to the arguments + movl %esp,%eax + movl %ecx,%edx + addl %edx,%edx + addl %edx,%edx + addl %edx,%eax + addl $4,%eax # Now points to environ. + + pushl %eax # envp + pushl %ebx # argp + pushl %ecx # argc + + # mov 8(%esp),%eax + mov %eax,environ + + call main + push %eax # Main has returned, +call_exit: + call exit # return val and call exit(); +bad_exit: + jmp bad_exit # Exit returned !! + +# Exit - call __cleanup then _exit + + .align 16 +.globl exit + .type exit,@function +exit: + pushl %ebp + movl %esp,%ebp + pushl %ebx + movl 8(%ebp),%ebx + movl __cleanup,%eax + testl %eax,%eax + je .L8 + pushl %ebx + call *%eax + addl $4,%esp +.L8: + pushl %ebx + call _exit + jmp bad_exit + +# _exit is an alias for __exit + .align 16 +.globl _exit + .type _exit,@function +_exit: + jmp __exit + diff --git a/libc/gnu_i386/dirent.c b/libc/gnu_i386/dirent.c new file mode 100644 index 0000000..8f7574c --- /dev/null +++ b/libc/gnu_i386/dirent.c @@ -0,0 +1,106 @@ + +#include +#include +#include +#include +#include +#include + +#ifdef L_opendir +DIR * +opendir(dname) +const char *dname; +{ + struct stat st; + int fd; + DIR *p; + + if (stat(dname, &st) < 0) + return 0; + + if (!S_ISDIR(st.st_mode)) + { + errno = ENOTDIR; + return 0; + } + if ((fd = open(dname, O_RDONLY)) < 0) + return 0; + + p = malloc(sizeof(DIR)); + if (p == 0) + { + close(fd); + return 0; + } + + p->dd_buf = malloc(sizeof(struct dirent)); + if (p->dd_buf == 0) + { + free(p); + close(fd); + return 0; + } + p->dd_fd = fd; + p->dd_loc = p->dd_size = 0; + + return p; +} +#endif + +#ifdef L_closedir +int +closedir(dirp) +DIR *dirp; +{ + int fd; + fd = dirp->dd_fd; + free(dirp->dd_buf); + free(dirp); + return close(fd); +} +#endif + +#ifdef __AS386_16__ +#ifdef L_readdir +/* + * This currently assumes we see a v. simple diectory structure, it's + * probably faked! + */ +struct dirent * +readdir(dirp) +DIR *dirp; +{ + int cc; + cc = read(dirp->dd_fd, dirp->dd_buf, sizeof(struct dirent)); + + if (cc <= 0) + return 0; + if (cc != sizeof(struct dirent)) + { + errno = EBADF; + return 0; + } + return dirp->dd_buf; +} +#endif +#else + +/* This is for 386 linux */ + +#ifdef L_readdir +struct dirent * +readdir(dirp) +DIR *dirp; +{ + int cc; + + cc = __readdir(dirp->dd_fd, dirp->dd_buf, 1); + if (cc <= 0) + return 0; + if (cc>1) dirp->dd_buf->d_name[cc] = 0; + + return dirp->dd_buf; +} +#endif + +#endif diff --git a/libc/gnu_i386/exec.c b/libc/gnu_i386/exec.c new file mode 100644 index 0000000..411b744 --- /dev/null +++ b/libc/gnu_i386/exec.c @@ -0,0 +1,292 @@ + +#include +#include + +extern char ** environ; + +#ifdef L_execl +int +execl(fname, arg0) +char * fname, *arg0; +{ + return execve(fname, &arg0, environ); +} +#endif + +#ifdef L_execv +int +execv(fname, argv) +char * fname, **argv; +{ + return execve(fname, argv, environ); +} +#endif + +#ifdef L_execle +int +execle(fname, arg0) +char *fname, *arg0; +{ + char ** envp = &arg0; + while(*envp) envp++; + return execve(fname, &arg0, envp+1); +} +#endif + +#ifdef L_execve +int +execve(fname, argv, envp) +char * fname; +char ** argv; +char ** envp; +{ + char **p; + int argv_len=0, argv_count=0; + int envp_len=0, envp_count=0; + int stack_bytes; + unsigned short * pip; + char * pcp, * stk_ptr, *baseoff; + int rv; + + /* How much space for argv */ + for(p=argv; p && *p && argv_len >= 0; p++) + { + argv_count++; argv_len += strlen(*p)+1; + } + + /* How much space for envp */ + for(p=envp; p && *p && envp_len >= 0; p++) + { + envp_count++; envp_len += strlen(*p)+1; + } + + /* tot it all up */ + stack_bytes = 2 /* argc */ + + argv_count * 2 + 2 /* argv */ + + argv_len + + envp_count * 2 + 2 /* envp */ + + envp_len; + + /* Allocate it */ + if( argv_len < 0 || envp_len < 0 || stack_bytes <= 0 + || (int)(stk_ptr = (char*)sbrk(stack_bytes)) == -1) + { + errno = ENOMEM; + return -1; + } + +/* Sanity check + printf("Argv = (%d,%d), Envp=(%d,%d), stack=%d\n", + argv_count, argv_len, envp_count, envp_len, stack_bytes); +*/ + + /* Now copy in the strings */ + pip=(unsigned short *) stk_ptr; + pcp=stk_ptr+2*(1+argv_count+1+envp_count+1); + + /* baseoff = stk_ptr + stack_bytes; */ + baseoff = stk_ptr; + *pip++ = argv_count; + for(p=argv; p && *p; p++) + { + int l; + *pip++ = pcp-baseoff; + l = strlen(*p)+1; + memcpy(pcp, *p, l); + pcp += l; + } + *pip++ = 0; + + for(p=envp; p && *p; p++) + { + int l; + *pip++ = pcp-baseoff; + l = strlen(*p)+1; + memcpy(pcp, *p, l); + pcp += l; + } + *pip++ = 0; + + rv = __exec(fname, stk_ptr, stack_bytes); + /* FIXME: This will probably have to interpret '#!' style exe's */ + sbrk(-stack_bytes); + return rv; +} +#endif + +#ifdef L_execlp +int +execlp(fname, arg0) +char * fname, *arg0; +{ + return execvp(fname, &arg0); +} +#endif + +#ifdef L_execvp +int +execvp(fname, argv) +char * fname, **argv; +{ + char *pname = fname, *path; + int besterr = ENOENT; + int flen, plen; + char * bp = sbrk(0); + + if( *fname != '/' && (path = getenv("PATH")) != 0 ) + { + flen = strlen(fname)+2; + + for(;path;) + { + if( *path == ':' || *path == '\0' ) + { + tryrun(fname, argv); + if( errno == EACCES ) besterr = EACCES; + if( *path ) path++; else break; + } + else + { + char * p = strchr(path, ':'); + if(p) *p = '\0'; + plen = strlen(path); + pname = sbrk(plen+flen); + + strcpy(pname, path); + strcat(pname, "/"); + strcat(pname, fname); + + tryrun(pname, argv); + if( errno == EACCES ) besterr = EACCES; + + brk(pname); + pname = fname; + if(p) *p++ = ':'; + path=p; + } + } + } + + tryrun(pname, argv); + brk(bp); + if( errno == ENOENT || errno == 0 ) errno = besterr; + return -1; +} + +static int tryrun(pname, argv) +char * pname; +char ** argv; +{ +static char *shprog[] = {"/bin/sh", "", 0}; + struct stat st; + + if( stat(pname, &st) < 0 ) return; + if( !S_ISREG(st.st_mode) ) return; + +#ifdef __AS386_16__ + __execvve(pname, (void*)0, argv, environ); + if( errno == ENOEXEC ) + { + shprog[1] = pname; + __execvve(shprog[0], shprog, argv, environ); + } +#else + execve(pname, argv, environ); + /* FIXME - running /bin/sh in 386 mode */ +#endif +} + +#ifdef __AS386_16__ +static int +__execvve(fname, interp, argv, envp) +char * fname; +char ** interp; +char ** argv; +char ** envp; +{ + char **p; + int argv_len=0, argv_count=0; + int envp_len=0, envp_count=0; + int stack_bytes; + unsigned short * pip; + char * pcp, * stk_ptr, *baseoff; + int rv; + + /* How much space for argv */ + for(p=interp; p && *p && argv_len >= 0; p++) + { + argv_count++; argv_len += strlen(*p)+1; + } + for(p=argv; p && *p && argv_len >= 0; p++) + { + argv_count++; argv_len += strlen(*p)+1; + } + + /* How much space for envp */ + for(p=envp; p && *p && envp_len >= 0; p++) + { + envp_count++; envp_len += strlen(*p)+1; + } + + /* tot it all up */ + stack_bytes = 2 /* argc */ + + argv_count * 2 + 2 /* argv */ + + argv_len + + envp_count * 2 + 2 /* envp */ + + envp_len; + + /* Allocate it */ + if( argv_len < 0 || envp_len < 0 || stack_bytes <= 0 + || (int)(stk_ptr = (char*)sbrk(stack_bytes)) == -1) + { + errno = ENOMEM; + return -1; + } + +/* Sanity check + printf("Argv = (%d,%d), Envp=(%d,%d), stack=%d\n", + argv_count, argv_len, envp_count, envp_len, stack_bytes); +*/ + + /* Now copy in the strings */ + pip=(unsigned short *) stk_ptr; + pcp=stk_ptr+2*(1+argv_count+1+envp_count+1); + + /* baseoff = stk_ptr + stack_bytes; */ + baseoff = stk_ptr; + *pip++ = argv_count; + for(p=interp; p && *p; p++) + { + int l; + *pip++ = pcp-baseoff; + l = strlen(*p)+1; + memcpy(pcp, *p, l); + pcp += l; + } + for(p=argv; p && *p; p++) + { + int l; + *pip++ = pcp-baseoff; + l = strlen(*p)+1; + memcpy(pcp, *p, l); + pcp += l; + } + *pip++ = 0; + + for(p=envp; p && *p; p++) + { + int l; + *pip++ = pcp-baseoff; + l = strlen(*p)+1; + memcpy(pcp, *p, l); + pcp += l; + } + *pip++ = 0; + + rv = __exec(fname, stk_ptr, stack_bytes); + /* FIXME: This will probably have to interpret '#!' style exe's */ + sbrk(-stack_bytes); + return rv; +} +#endif +#endif diff --git a/libc/gnu_i386/heap.c b/libc/gnu_i386/heap.c new file mode 100644 index 0000000..bad7e25 --- /dev/null +++ b/libc/gnu_i386/heap.c @@ -0,0 +1,76 @@ +/* Copyright (C) 1995-1997 Robert de Bath + * This file is part of the Linux-8086 C library and is distributed + * under the GNU Library General Public License. + */ + +#include + +/****************************************************************************/ + +#if defined(__GNUC__) && defined(__i386__) +extern char * __brk_addr; +extern char * __brk(); + +#ifdef L___brk_addr +char * __brk_addr = 0; /* This holds the current return for sbrk(0) */ + + /* "mov %ebx,4(%esp),%ebx\n\t" "mov $45,%eax\n\t" */ + +char * +__brk(char * val) +{ + char * retval; + __asm__( + "int $0x80" + : "=a" (retval) + : "0" (45), "b" (val) + ); + return retval; +} + +__brk_addr_init() +{ + if( __brk_addr == 0 && (__brk_addr = __brk(0)) == 0 ) + { + errno = ENOMEM; + return -1; + } + return 0; +} +#endif + +#ifdef L_sbrk +char * +sbrk(brk_off) +int brk_off; +{ + char * new_brk; + if( __brk_addr_init() ) return (char*)-1; + if( brk_off == 0 ) return __brk_addr; + + new_brk = __brk_addr + brk_off; + __brk_addr = __brk(new_brk); + if( __brk_addr != new_brk ) + { + errno = ENOMEM; + return (char*)-1; + } + return __brk_addr - brk_off; +} +#endif + +#ifdef L_brk +int +brk(new_brk) +char * new_brk; +{ + if( __brk_addr_init() ) return -1; + + __brk_addr = __brk(new_brk); + if( __brk_addr == new_brk ) return 0; + errno = ENOMEM; + return -1; +} +#endif + +#endif diff --git a/libc/gnu_i386/mksyscall b/libc/gnu_i386/mksyscall new file mode 100644 index 0000000..b655e9e --- /dev/null +++ b/libc/gnu_i386/mksyscall @@ -0,0 +1,123 @@ +# Copyright (C) 1995-1997 Robert de Bath +# This file is part of the Linux-8086 C library and is distributed +# under the GNU Library General Public License. +# +# This script generates the 'simple' system calls for the 386 +# +# Each call is put into it's own object file, if the semantics of the +# call are not correct UNIX then the 4th field in the dat file has a +# marker and the function is generated with a __ prefix. +# +# +# Different levels of squeeze +# 0 = each is complete +# 1 = Short codes calling common function + +rm -f syscall.c syscall.mak + +tr '[A-Z]' '[a-z]' < syscall.dat | \ +awk 'BEGIN{ + print "# Copyright (C) 1995-1997 Robert de Bath " > "syscall.mak"; + print "# This file is part of the Linux-8086 C library and is distributed" > "syscall.mak"; + print "# under the GNU Library General Public License." > "syscall.mak"; + print "# " > "syscall.mak"; + print "# This file is automatically generated\n" > "syscall.mak" + + print "# Copyright (C) 1995-1997 Robert de Bath "; + print "# This file is part of the Linux-8086 C library and is distributed"; + print "# under the GNU Library General Public License."; + print "# "; + print "# This file is automatically generated */\n" + obj="OBJ="; + + print "# Standard start\n\n" + printf("#ifndef __MSDOS__\n"); + printf("#ifdef __AS386_32__\n"); + printf(" .text\n"); + printf(" .align 16\n"); + + COMPACT=0; +} +/^[ ]*#/ { next; } +/^[ ]*$/ { next; } +{ + if( $2 > max_call ) max_call = $2; + + if( $3 == "x" || $3 == "" ) next; + else if( $4 == "-" ) next; + else if( $4 == "*" ) funcname="__" $1; + else funcname=$1; + + if( length(obj) > 60 ) + { + printf("%s\t\\\n", obj) > "syscall.mak"; + obj=" "; + } + obj=obj funcname ".o "; + + printf "# CALL %s\n\n", $0; + + printf(".ifdef L_%s\n", funcname); + printf(".globl %s\n", funcname); + printf(".type %s,@function\n", funcname); + printf("%s:\n", funcname); + + # Inline assembler max to 5 args (20 bytes) + if( $3 != 4 && $3 != 5 && ( COMPACT || $3 > 5 )) + { + printf(" mov %%eax,#%d\n", $2); + printf(" br sys_call%d\n", $3); + } + else + { + printf(" pushl %%ebp\n"); + printf(" movl %%esp,%%ebp\n"); + printf(" pushl %%ebx\n"); + if( $3 >= 1 ) printf(" mov 8(%%ebp),%%ebx\n"); + if( $3 >= 2 ) printf(" mov 12(%%ebp),%%ecx\n"); + if( $3 >= 3 ) printf(" mov 16(%%ebp),%%edx\n"); + if( $3 >= 4 ) printf(" push %%esi\n"); + if( $3 >= 4 ) printf(" mov 20(%%ebp),%%esi\n"); + if( $3 >= 5 ) printf(" push %%edi\n"); + if( $3 >= 5 ) printf(" mov 24(%%ebp),%%edi\n"); + printf(" mov $%d,%%eax\n", $2); + printf(" int $0x80\n"); + + if( $3 >= 5 ) printf(" pop %%edi\n"); + if( $3 >= 4 ) printf(" pop %%esi\n"); + printf(" pop %%ebx\n"); + + printf(" test %%eax,%%eax\n"); + printf(" jge syscall_ok\n"); + printf(" neg %%eax\n"); + printf(" mov %%eax,errno\n"); + printf(" mov $-1,%%eax\n"); + printf("syscall_ok:\n"); + printf(" movl %%ebp,%%esp\n"); + printf(" popl %%ebp\n"); + printf(" ret\n"); + } + printf(".endif\n\n"); +} +END{ + + printf("#endif /* __AS386_32__ */\n\n"); + printf("#endif /* __MSDOS__ */\n\n"); + printf("%s\n", obj) > "syscall.mak"; + printf "\n" > "syscall.mak"; + +}' > syscall.s + +cat >> syscall.mak <<\! + +CFLAGS=$(ARCH) $(CCFLAGS) $(DEFS) + +all: $(LIBC)($(OBJ)) + @$(RM) $(OBJ) + +$(LIBC)($(OBJ)): syscall.dat mksyscall + $(AS) --defsym L_$*=0 syscall.s -o $*.o + $(AR) $(ARFLAGS) $@ $*.o +! + +exit $? diff --git a/libc/gnu_i386/syscall.dat b/libc/gnu_i386/syscall.dat new file mode 100644 index 0000000..da9ad6c --- /dev/null +++ b/libc/gnu_i386/syscall.dat @@ -0,0 +1,155 @@ + +# +# Name No Args Flag, comment +# +# . = Ok, with comment +# * = Needs libc code (Prefix __) +# - = Obsolete/not required +# +# Name N C +setup 0 X +exit 1 1 * +fork 2 0 +vfork 2 0 . Fake alias of fork +read 3 3 +write 4 3 +open 5 3 +close 6 1 +waitpid 7 3 +creat 8 2 +link 9 2 +unlink 10 1 +execve 11 3 +chdir 12 1 +time 13 1 +dv32_mknod 14 3 * Has correct args for 32bit dev_t +chmod 15 2 +chown 16 3 +break 17 X - This is done in a special function +oldstat 18 X - +lseek 19 3 +getpid 20 0 +mount 21 5 +umount 22 1 +setuid 23 1 +getuid 24 0 +stime 25 1 +ptrace 26 4 +alarm 27 1 +oldfstat 28 X - +pause 29 0 +utime 30 2 +stty 31 X - +gtty 32 X - +access 33 2 +nice 34 1 +ftime 35 1 +sync 36 0 +kill 37 2 +rename 38 2 +mkdir 39 2 +rmdir 40 1 +dup 41 1 +pipe 42 1 +times 43 1 +prof 44 X - +brk 45 1 - need to save brk_addr & -ve is valid return. +setgid 46 1 +getgid 47 0 +signal 48 2 +geteuid 49 0 +getegid 50 0 +acct 51 1 +phys 52 X - +lock 53 X - +ioctl 54 3 +fcntl 55 3 +mpx 56 X - +setpgid 57 2 +ulimit 58 2 +oldolduname 59 X - +umask 60 1 +chroot 61 1 +dv32_ustat 62 2 * Has correct args for 32bit dev_t +dup2 63 2 +getppid 64 0 +getpgrp 65 0 +setsid 66 0 +sigaction 67 3 +siggetmask 68 0 +sigsetmask 69 1 +setreuid 70 2 +setregid 71 2 +sigsuspend 72 1 +sigpending 73 1 +sethostname 74 2 +setrlimit 75 2 +getrlimit 76 2 +getrusage 77 2 +gettimeofday 78 2 +settimeofday 79 2 +getgroups 80 2 +setgroups 81 2 +select 82 1 * select's arg is &arg1 +symlink 83 2 +oldlstat 84 X - +readlink 85 3 +uselib 86 1 +swapon 87 2 +reboot 88 3 +readdir 89 3 * Takes the fd not a ddptr +mmap 90 1 * Is a pointer to a buffer with the 6 args. +munmap 91 2 +truncate 92 2 +ftruncate 93 2 +fchmod 94 2 +fchown 95 2 +getpriority 96 2 +setpriority 97 3 +profil 98 X - glibc has userspace +statfs 99 2 +fstatfs 100 2 +ioperm 101 3 +socketcall 102 2 * This is a lib internal for socket stuff +klog 103 X +setitimer 104 3 +getitimer 105 2 +dv32_stat 106 2 * Has correct args for 32 bit dev_t +dv32_lstat 107 2 * Has correct args for 32 bit dev_t +dv32_fstat 108 2 * Has correct args for 32 bit dev_t +olduname 109 X - +iopl 110 1 +vhangup 111 0 +idle 112 0 - System internal +vm86 113 1 +wait4 114 4 +swapoff 115 1 +sysinfo 116 1 +ipc 117 5 * SYSV ipc entry point +fsync 118 1 +sigreturn 119 1 * Signal internal +clone 120 2 +setdomainname 121 2 +uname 122 1 +modify_ldt 123 X +adjtimex 124 1 +mprotect 125 3 +sigprocmask 126 3 +create_module 127 X - Module handling, NO WAY! +init_module 128 X +delete_module 129 X +get_kernel_syms 130 X +quotactl 131 X +getpgid 132 1 +fchdir 133 1 +bdflush 134 2 +sysfs 135 3 +personality 136 1 * Linux specific. +afs_syscall 137 X +setfsuid 138 1 +setfsgid 139 1 +_llseek 140 X +getdents 141 3 * New style readdir ? +_newselect 142 X +flock 143 2 +syscall_flock 143 X diff --git a/libc/gnu_i386/syscall.s b/libc/gnu_i386/syscall.s new file mode 100644 index 0000000..6180038 --- /dev/null +++ b/libc/gnu_i386/syscall.s @@ -0,0 +1,2969 @@ +# Copyright (C) 1995-1997 Robert de Bath +# This file is part of the Linux-8086 C library and is distributed +# under the GNU Library General Public License. +# +# This file is automatically generated */ + +# Standard start + + +#ifndef __MSDOS__ +#ifdef __AS386_32__ + .text + .align 16 +# CALL exit 1 1 * + +.ifdef L___exit +.globl __exit +.type __exit,@function +__exit: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov $1,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL fork 2 0 + +.ifdef L_fork +.globl fork +.type fork,@function +fork: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov $2,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL vfork 2 0 . fake alias of fork + +.ifdef L_vfork +.globl vfork +.type vfork,@function +vfork: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov $2,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL read 3 3 + +.ifdef L_read +.globl read +.type read,@function +read: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov 16(%ebp),%edx + mov $3,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL write 4 3 + +.ifdef L_write +.globl write +.type write,@function +write: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov 16(%ebp),%edx + mov $4,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL open 5 3 + +.ifdef L_open +.globl open +.type open,@function +open: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov 16(%ebp),%edx + mov $5,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL close 6 1 + +.ifdef L_close +.globl close +.type close,@function +close: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov $6,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL waitpid 7 3 + +.ifdef L_waitpid +.globl waitpid +.type waitpid,@function +waitpid: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov 16(%ebp),%edx + mov $7,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL creat 8 2 + +.ifdef L_creat +.globl creat +.type creat,@function +creat: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $8,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL link 9 2 + +.ifdef L_link +.globl link +.type link,@function +link: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $9,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL unlink 10 1 + +.ifdef L_unlink +.globl unlink +.type unlink,@function +unlink: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov $10,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL execve 11 3 + +.ifdef L_execve +.globl execve +.type execve,@function +execve: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov 16(%ebp),%edx + mov $11,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL chdir 12 1 + +.ifdef L_chdir +.globl chdir +.type chdir,@function +chdir: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov $12,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL time 13 1 + +.ifdef L_time +.globl time +.type time,@function +time: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov $13,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL dv32_mknod 14 3 * has correct args for 32bit dev_t + +.ifdef L___dv32_mknod +.globl __dv32_mknod +.type __dv32_mknod,@function +__dv32_mknod: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov 16(%ebp),%edx + mov $14,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL chmod 15 2 + +.ifdef L_chmod +.globl chmod +.type chmod,@function +chmod: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $15,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL chown 16 3 + +.ifdef L_chown +.globl chown +.type chown,@function +chown: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov 16(%ebp),%edx + mov $16,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL lseek 19 3 + +.ifdef L_lseek +.globl lseek +.type lseek,@function +lseek: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov 16(%ebp),%edx + mov $19,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL getpid 20 0 + +.ifdef L_getpid +.globl getpid +.type getpid,@function +getpid: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov $20,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL mount 21 5 + +.ifdef L_mount +.globl mount +.type mount,@function +mount: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov 16(%ebp),%edx + push %esi + mov 20(%ebp),%esi + push %edi + mov 24(%ebp),%edi + mov $21,%eax + int $0x80 + pop %edi + pop %esi + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL umount 22 1 + +.ifdef L_umount +.globl umount +.type umount,@function +umount: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov $22,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL setuid 23 1 + +.ifdef L_setuid +.globl setuid +.type setuid,@function +setuid: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov $23,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL getuid 24 0 + +.ifdef L_getuid +.globl getuid +.type getuid,@function +getuid: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov $24,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL stime 25 1 + +.ifdef L_stime +.globl stime +.type stime,@function +stime: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov $25,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL ptrace 26 4 + +.ifdef L_ptrace +.globl ptrace +.type ptrace,@function +ptrace: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov 16(%ebp),%edx + push %esi + mov 20(%ebp),%esi + mov $26,%eax + int $0x80 + pop %esi + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL alarm 27 1 + +.ifdef L_alarm +.globl alarm +.type alarm,@function +alarm: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov $27,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL pause 29 0 + +.ifdef L_pause +.globl pause +.type pause,@function +pause: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov $29,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL utime 30 2 + +.ifdef L_utime +.globl utime +.type utime,@function +utime: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $30,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL access 33 2 + +.ifdef L_access +.globl access +.type access,@function +access: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $33,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL nice 34 1 + +.ifdef L_nice +.globl nice +.type nice,@function +nice: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov $34,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL ftime 35 1 + +.ifdef L_ftime +.globl ftime +.type ftime,@function +ftime: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov $35,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL sync 36 0 + +.ifdef L_sync +.globl sync +.type sync,@function +sync: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov $36,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL kill 37 2 + +.ifdef L_kill +.globl kill +.type kill,@function +kill: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $37,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL rename 38 2 + +.ifdef L_rename +.globl rename +.type rename,@function +rename: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $38,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL mkdir 39 2 + +.ifdef L_mkdir +.globl mkdir +.type mkdir,@function +mkdir: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $39,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL rmdir 40 1 + +.ifdef L_rmdir +.globl rmdir +.type rmdir,@function +rmdir: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov $40,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL dup 41 1 + +.ifdef L_dup +.globl dup +.type dup,@function +dup: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov $41,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL pipe 42 1 + +.ifdef L_pipe +.globl pipe +.type pipe,@function +pipe: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov $42,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL times 43 1 + +.ifdef L_times +.globl times +.type times,@function +times: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov $43,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL setgid 46 1 + +.ifdef L_setgid +.globl setgid +.type setgid,@function +setgid: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov $46,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL getgid 47 0 + +.ifdef L_getgid +.globl getgid +.type getgid,@function +getgid: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov $47,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL signal 48 2 + +.ifdef L_signal +.globl signal +.type signal,@function +signal: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $48,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL geteuid 49 0 + +.ifdef L_geteuid +.globl geteuid +.type geteuid,@function +geteuid: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov $49,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL getegid 50 0 + +.ifdef L_getegid +.globl getegid +.type getegid,@function +getegid: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov $50,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL acct 51 1 + +.ifdef L_acct +.globl acct +.type acct,@function +acct: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov $51,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL ioctl 54 3 + +.ifdef L_ioctl +.globl ioctl +.type ioctl,@function +ioctl: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov 16(%ebp),%edx + mov $54,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL fcntl 55 3 + +.ifdef L_fcntl +.globl fcntl +.type fcntl,@function +fcntl: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov 16(%ebp),%edx + mov $55,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL setpgid 57 2 + +.ifdef L_setpgid +.globl setpgid +.type setpgid,@function +setpgid: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $57,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL ulimit 58 2 + +.ifdef L_ulimit +.globl ulimit +.type ulimit,@function +ulimit: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $58,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL umask 60 1 + +.ifdef L_umask +.globl umask +.type umask,@function +umask: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov $60,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL chroot 61 1 + +.ifdef L_chroot +.globl chroot +.type chroot,@function +chroot: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov $61,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL dv32_ustat 62 2 * has correct args for 32bit dev_t + +.ifdef L___dv32_ustat +.globl __dv32_ustat +.type __dv32_ustat,@function +__dv32_ustat: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $62,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL dup2 63 2 + +.ifdef L_dup2 +.globl dup2 +.type dup2,@function +dup2: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $63,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL getppid 64 0 + +.ifdef L_getppid +.globl getppid +.type getppid,@function +getppid: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov $64,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL getpgrp 65 0 + +.ifdef L_getpgrp +.globl getpgrp +.type getpgrp,@function +getpgrp: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov $65,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL setsid 66 0 + +.ifdef L_setsid +.globl setsid +.type setsid,@function +setsid: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov $66,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL sigaction 67 3 + +.ifdef L_sigaction +.globl sigaction +.type sigaction,@function +sigaction: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov 16(%ebp),%edx + mov $67,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL siggetmask 68 0 + +.ifdef L_siggetmask +.globl siggetmask +.type siggetmask,@function +siggetmask: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov $68,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL sigsetmask 69 1 + +.ifdef L_sigsetmask +.globl sigsetmask +.type sigsetmask,@function +sigsetmask: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov $69,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL setreuid 70 2 + +.ifdef L_setreuid +.globl setreuid +.type setreuid,@function +setreuid: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $70,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL setregid 71 2 + +.ifdef L_setregid +.globl setregid +.type setregid,@function +setregid: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $71,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL sigsuspend 72 1 + +.ifdef L_sigsuspend +.globl sigsuspend +.type sigsuspend,@function +sigsuspend: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov $72,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL sigpending 73 1 + +.ifdef L_sigpending +.globl sigpending +.type sigpending,@function +sigpending: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov $73,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL sethostname 74 2 + +.ifdef L_sethostname +.globl sethostname +.type sethostname,@function +sethostname: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $74,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL setrlimit 75 2 + +.ifdef L_setrlimit +.globl setrlimit +.type setrlimit,@function +setrlimit: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $75,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL getrlimit 76 2 + +.ifdef L_getrlimit +.globl getrlimit +.type getrlimit,@function +getrlimit: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $76,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL getrusage 77 2 + +.ifdef L_getrusage +.globl getrusage +.type getrusage,@function +getrusage: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $77,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL gettimeofday 78 2 + +.ifdef L_gettimeofday +.globl gettimeofday +.type gettimeofday,@function +gettimeofday: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $78,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL settimeofday 79 2 + +.ifdef L_settimeofday +.globl settimeofday +.type settimeofday,@function +settimeofday: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $79,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL getgroups 80 2 + +.ifdef L_getgroups +.globl getgroups +.type getgroups,@function +getgroups: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $80,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL setgroups 81 2 + +.ifdef L_setgroups +.globl setgroups +.type setgroups,@function +setgroups: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $81,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL select 82 1 * select's arg is &arg1 + +.ifdef L___select +.globl __select +.type __select,@function +__select: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov $82,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL symlink 83 2 + +.ifdef L_symlink +.globl symlink +.type symlink,@function +symlink: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $83,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL readlink 85 3 + +.ifdef L_readlink +.globl readlink +.type readlink,@function +readlink: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov 16(%ebp),%edx + mov $85,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL uselib 86 1 + +.ifdef L_uselib +.globl uselib +.type uselib,@function +uselib: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov $86,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL swapon 87 2 + +.ifdef L_swapon +.globl swapon +.type swapon,@function +swapon: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $87,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL reboot 88 3 + +.ifdef L_reboot +.globl reboot +.type reboot,@function +reboot: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov 16(%ebp),%edx + mov $88,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL readdir 89 3 * takes the fd not a ddptr + +.ifdef L___readdir +.globl __readdir +.type __readdir,@function +__readdir: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov 16(%ebp),%edx + mov $89,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL mmap 90 1 * is a pointer to a buffer with the 6 args. + +.ifdef L___mmap +.globl __mmap +.type __mmap,@function +__mmap: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov $90,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL munmap 91 2 + +.ifdef L_munmap +.globl munmap +.type munmap,@function +munmap: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $91,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL truncate 92 2 + +.ifdef L_truncate +.globl truncate +.type truncate,@function +truncate: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $92,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL ftruncate 93 2 + +.ifdef L_ftruncate +.globl ftruncate +.type ftruncate,@function +ftruncate: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $93,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL fchmod 94 2 + +.ifdef L_fchmod +.globl fchmod +.type fchmod,@function +fchmod: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $94,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL fchown 95 2 + +.ifdef L_fchown +.globl fchown +.type fchown,@function +fchown: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $95,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL getpriority 96 2 + +.ifdef L_getpriority +.globl getpriority +.type getpriority,@function +getpriority: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $96,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL setpriority 97 3 + +.ifdef L_setpriority +.globl setpriority +.type setpriority,@function +setpriority: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov 16(%ebp),%edx + mov $97,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL statfs 99 2 + +.ifdef L_statfs +.globl statfs +.type statfs,@function +statfs: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $99,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL fstatfs 100 2 + +.ifdef L_fstatfs +.globl fstatfs +.type fstatfs,@function +fstatfs: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $100,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL ioperm 101 3 + +.ifdef L_ioperm +.globl ioperm +.type ioperm,@function +ioperm: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov 16(%ebp),%edx + mov $101,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL socketcall 102 2 * this is a lib internal for socket stuff + +.ifdef L___socketcall +.globl __socketcall +.type __socketcall,@function +__socketcall: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $102,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL setitimer 104 3 + +.ifdef L_setitimer +.globl setitimer +.type setitimer,@function +setitimer: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov 16(%ebp),%edx + mov $104,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL getitimer 105 2 + +.ifdef L_getitimer +.globl getitimer +.type getitimer,@function +getitimer: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $105,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL dv32_stat 106 2 * has correct args for 32 bit dev_t + +.ifdef L___dv32_stat +.globl __dv32_stat +.type __dv32_stat,@function +__dv32_stat: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $106,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL dv32_lstat 107 2 * has correct args for 32 bit dev_t + +.ifdef L___dv32_lstat +.globl __dv32_lstat +.type __dv32_lstat,@function +__dv32_lstat: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $107,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL dv32_fstat 108 2 * has correct args for 32 bit dev_t + +.ifdef L___dv32_fstat +.globl __dv32_fstat +.type __dv32_fstat,@function +__dv32_fstat: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $108,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL iopl 110 1 + +.ifdef L_iopl +.globl iopl +.type iopl,@function +iopl: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov $110,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL vhangup 111 0 + +.ifdef L_vhangup +.globl vhangup +.type vhangup,@function +vhangup: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov $111,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL vm86 113 1 + +.ifdef L_vm86 +.globl vm86 +.type vm86,@function +vm86: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov $113,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL wait4 114 4 + +.ifdef L_wait4 +.globl wait4 +.type wait4,@function +wait4: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov 16(%ebp),%edx + push %esi + mov 20(%ebp),%esi + mov $114,%eax + int $0x80 + pop %esi + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL swapoff 115 1 + +.ifdef L_swapoff +.globl swapoff +.type swapoff,@function +swapoff: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov $115,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL sysinfo 116 1 + +.ifdef L_sysinfo +.globl sysinfo +.type sysinfo,@function +sysinfo: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov $116,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL ipc 117 5 * sysv ipc entry point + +.ifdef L___ipc +.globl __ipc +.type __ipc,@function +__ipc: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov 16(%ebp),%edx + push %esi + mov 20(%ebp),%esi + push %edi + mov 24(%ebp),%edi + mov $117,%eax + int $0x80 + pop %edi + pop %esi + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL fsync 118 1 + +.ifdef L_fsync +.globl fsync +.type fsync,@function +fsync: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov $118,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL sigreturn 119 1 * signal internal + +.ifdef L___sigreturn +.globl __sigreturn +.type __sigreturn,@function +__sigreturn: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov $119,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL clone 120 2 + +.ifdef L_clone +.globl clone +.type clone,@function +clone: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $120,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL setdomainname 121 2 + +.ifdef L_setdomainname +.globl setdomainname +.type setdomainname,@function +setdomainname: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $121,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL uname 122 1 + +.ifdef L_uname +.globl uname +.type uname,@function +uname: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov $122,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL adjtimex 124 1 + +.ifdef L_adjtimex +.globl adjtimex +.type adjtimex,@function +adjtimex: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov $124,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL mprotect 125 3 + +.ifdef L_mprotect +.globl mprotect +.type mprotect,@function +mprotect: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov 16(%ebp),%edx + mov $125,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL sigprocmask 126 3 + +.ifdef L_sigprocmask +.globl sigprocmask +.type sigprocmask,@function +sigprocmask: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov 16(%ebp),%edx + mov $126,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL getpgid 132 1 + +.ifdef L_getpgid +.globl getpgid +.type getpgid,@function +getpgid: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov $132,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL fchdir 133 1 + +.ifdef L_fchdir +.globl fchdir +.type fchdir,@function +fchdir: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov $133,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL bdflush 134 2 + +.ifdef L_bdflush +.globl bdflush +.type bdflush,@function +bdflush: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $134,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL sysfs 135 3 + +.ifdef L_sysfs +.globl sysfs +.type sysfs,@function +sysfs: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov 16(%ebp),%edx + mov $135,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL personality 136 1 * linux specific. + +.ifdef L___personality +.globl __personality +.type __personality,@function +__personality: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov $136,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL setfsuid 138 1 + +.ifdef L_setfsuid +.globl setfsuid +.type setfsuid,@function +setfsuid: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov $138,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL setfsgid 139 1 + +.ifdef L_setfsgid +.globl setfsgid +.type setfsgid,@function +setfsgid: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov $139,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL getdents 141 3 * new style readdir ? + +.ifdef L___getdents +.globl __getdents +.type __getdents,@function +__getdents: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov 16(%ebp),%edx + mov $141,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL flock 143 2 + +.ifdef L_flock +.globl flock +.type flock,@function +flock: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $143,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +#endif /* __AS386_32__ */ + +#endif /* __MSDOS__ */ + diff --git a/libc/i386fp/README b/libc/i386fp/README new file mode 100644 index 0000000..bb49fe4 --- /dev/null +++ b/libc/i386fp/README @@ -0,0 +1,5 @@ +Files in this directory are copyright Bruce Evans or Timothy Murphy +(tim@maths.tcd.ie) as marked. The copyright is not currently LGPL but +does allow free distribution. This may change soon. + +Rob. (Sept 1997) diff --git a/libc/i386sys/Makefile b/libc/i386sys/Makefile index 5110871..756ce43 100644 --- a/libc/i386sys/Makefile +++ b/libc/i386sys/Makefile @@ -2,9 +2,8 @@ # This file is part of the Linux-8086 C library and is distributed # under the GNU Library General Public License. -LSRC=syslibc.c -LOBJ=__cstart3.o time.o abort.o wait.o waitpid.o wait3.o killpg.o setpgrp.o \ - sleep.o usleep.o +LSRC=cstartup.c +LOBJ=__cstart3.o ESRC=exec.c EOBJ=execl.o execv.o execle.o execlp.o execvp.o diff --git a/libc/i386sys/cstartup.c b/libc/i386sys/cstartup.c new file mode 100644 index 0000000..b88d9cb --- /dev/null +++ b/libc/i386sys/cstartup.c @@ -0,0 +1,98 @@ +/* Copyright (C) 1996 Robert de Bath + * This file is part of the Linux-8086 C library and is distributed + * under the GNU Library General Public License. + */ + +#include +#include +#include +#include + +#ifdef __unix__ +#ifdef __AS386_32__ + +/********************** Function __cstartup *******************************/ + +void (*__cleanup)() = 0; +char ** environ; + +#asm + loc 2 +call_main: + .long _main ! Segment 2 is the trailing pointers, main and the + .long call_exit ! routine to call exit. +#if __FIRST_ARG_IN_AX__ + .data +saved_arg1: + .long 0 +#endif + .data +loop_safe: + .long 0 + .text + +export ___mkargv +___mkargv: ! BCC Tells linker to init argv ... none needed. + +export ___cstartup +___cstartup: ! Crt0 startup (Linux style) + mov eax,[esp] + test eax,eax + jz call_exit ! If argc == 0 this is being called by ldd, exit. + mov eax,[esp+8] + mov [_environ],eax +#if __FIRST_ARG_IN_AX__ + pop [saved_arg1] ! Argc will go into eax +#endif + + mov ebx,#auto_start ! Pointer to first autostart function +auto_run: +#if __FIRST_ARG_IN_AX__ + mov eax,[saved_arg1] +#endif + mov [loop_safe],ebx + mov ebx,[ebx] + test ebx,ebx + jz no_func + call ebx ! Call the function +no_func: + mov ebx,[loop_safe] + add ebx,#4 ! next + jmp auto_run ! And round for the next. + +call_exit: ! Last item called by above. + pop ebx ! Be tidy. +#if !__FIRST_ARG_IN_AX__ + push eax ! At the end the last called was main() push it`s +#endif + call _exit ! return val and call exit(); +bad_exit: + jmp bad_exit ! Exit returned !! + +export _exit +export __exit +_exit: ! exit(rv) function +#if __FIRST_ARG_IN_AX__ + mov [saved_arg1],eax +#else + push [esp+4] ! Copy the `rv` for the exit fuctions. +#endif + mov ebx,[___cleanup] ! Call exit, normally this is `__do_exit` + test ebx,ebx + je no_clean ! But it`s default is null + call ebx +no_clean: +#if __FIRST_ARG_IN_AX__ + mov eax,[saved_arg1] +#else + add esp,#4 +#endif +__exit: ! _exit(rv) + br ___exit ! This is just an alias for __exit(); + +#endasm + +/********************** THE END ********************************************/ + +#endif /* __unix__ */ +#endif diff --git a/libc/i386sys/signal.c b/libc/i386sys/signal.c deleted file mode 100644 index dad3389..0000000 --- a/libc/i386sys/signal.c +++ /dev/null @@ -1,99 +0,0 @@ - -#ifndef __MSDOS__ -#ifdef __AS386_16__ - -#include -#include - -typedef __sighandler_t Sig; - -extern int __signal __P((int, __sighandler_t)); -static Sig system_signal(); - -Sig __sigtable[_NSIG-1]; - -/* - * Signal handler. - * - */ - -/* - * KERNEL INTERFACE: - * It is assumed the kernel will never give us a signal we haven't - * _explicitly_ asked for! - * - * The Kernel need only save space for _one_ function pointer - * (to system_signal) and must deal with SIG_DFL and SIG_IGN - * in kernel space. - * - * When a signal is required the kernel must set all the registers as if - * returning from a interrupt normally then push the number of the signal - * to be generated, push the current pc value, then set the pc to the - * address of the 'system_signal' function. - */ - -Sig -signal(number, pointer) -int number; -Sig pointer; -{ - Sig old_sig; - int rv; - if( number < 1 || number >= _NSIG ) { errno=EINVAL; return SIG_ERR; } - - if( pointer == SIG_DFL || pointer == SIG_IGN ) - rv = __signal(number, pointer); - else - rv = __signal(number, (__sighandler_t) system_signal); - - if( rv < 0 ) return SIG_ERR; - - old_sig = __sigtable[number-1]; - __sigtable[number-1] = pointer; - - switch(rv) - { - case 0: return SIG_DFL; - case 1: return SIG_IGN; - return old_sig; - } -} - -#asm - .text -_system_signal: ! When this is called by the kernel the stack contains - pushf ! in order: - push ax ! - push bx ! The signal number, (NOS) - push cx ! The program counter, (TOS) - push dx ! - push si ! It does NOT contain the CS register or the flags. - push di ! This means it cannot be unraveled by an iret. - push bp - push es ! Note also only ES segment register is saved. - mov bx,sp ! Unlike minix the rv from a system call is in AX. - mov bx,[bx+20] -#if __FIRST_ARG_IN_AX__ - mov ax,bx -#else - push bx ! NB this is _unchecked_, do we want to ? -#endif - add bx,bx - mov bx,[bx+___sigtable-2] ! Offset by 2 cause no entry for signal 0 - call bx ! Do we want to check BX for 0 or 1 ? - inc sp - inc sp - pop es - pop bp - pop di - pop si - pop dx - pop cx - pop bx - pop ax - popf - ret #2 ! Get rid of the signum too. -#endasm - -#endif /* __AS386_16__ */ -#endif /* __MSDOS__ */ diff --git a/libc/i386sys/syslibc.c b/libc/i386sys/syslibc.c deleted file mode 100644 index 60dda42..0000000 --- a/libc/i386sys/syslibc.c +++ /dev/null @@ -1,255 +0,0 @@ -/* Copyright (C) 1996 Robert de Bath - * This file is part of the Linux-8086 C library and is distributed - * under the GNU Library General Public License. - */ - -#include -#include -#include -#include - -/* MSDOS has it's own versions */ -#ifndef __MSDOS__ -#ifdef __AS386_32__ - -/********************** Function __cstartup *******************************/ - -#ifdef L___cstart3 - -void (*__cleanup)() = 0; -char ** environ; - -#asm - loc 2 -call_main: - .long _main ! Segment 2 is the trailing pointers, main and the - .long call_exit ! routine to call exit. -#if __FIRST_ARG_IN_AX__ - .data -saved_arg1: - .long 0 -#endif - .data -loop_safe: - .long 0 - .text - -export ___mkargv -___mkargv: ! BCC Tells linker to init argv ... none needed. - -export ___cstartup -___cstartup: ! Crt0 startup (Linux style) - mov eax,[esp] - test eax,eax - jz call_exit ! If argc == 0 this is being called by ldd, exit. - mov eax,[esp+8] - mov [_environ],eax -#if __FIRST_ARG_IN_AX__ - pop [saved_arg1] ! Argc will go into eax -#endif - - mov ebx,#auto_start ! Pointer to first autostart function -auto_run: -#if __FIRST_ARG_IN_AX__ - mov eax,[saved_arg1] -#endif - mov [loop_safe],ebx - mov ebx,[ebx] - test ebx,ebx - jz no_func - call ebx ! Call the function -no_func: - mov ebx,[loop_safe] - add ebx,#4 ! next - jmp auto_run ! And round for the next. - -call_exit: ! Last item called by above. - pop ebx ! Be tidy. -#if !__FIRST_ARG_IN_AX__ - push eax ! At the end the last called was main() push it`s -#endif - call _exit ! return val and call exit(); -bad_exit: - jmp bad_exit ! Exit returned !! - -export _exit -export __exit -_exit: ! exit(rv) function -#if __FIRST_ARG_IN_AX__ - mov [saved_arg1],eax -#else - push [esp+4] ! Copy the `rv` for the exit fuctions. -#endif - mov ebx,[___cleanup] ! Call exit, normally this is `__do_exit` - test ebx,ebx - je no_clean ! But it`s default is null - call ebx -no_clean: -#if __FIRST_ARG_IN_AX__ - mov eax,[saved_arg1] -#else - add esp,#4 -#endif -__exit: ! _exit(rv) - br ___exit ! This is just an alias for __exit(); - -#endasm -#endif - -/********************** Function time ************************************/ - -#ifdef L_time -time_t time(where) -time_t *where; -{ - struct timeval rv; - if( gettimeofday(&rv, (void*)0) < 0 ) return -1; - if(where) *where = rv.tv_sec; - return rv.tv_sec; -} -#endif - -/********************** Function abort ************************************/ - -#ifdef L_abort -#include - -int abort() -{ - signal(SIGABRT, SIG_DFL); - kill(SIGABRT, getpid()); /* Correct one */ - pause(); /* System may just schedule */ - signal(SIGKILL, SIG_DFL); - kill(SIGKILL, getpid()); /* Can't trap this! */ - __exit(255); /* WHAT!! */ -} -#endif - -/********************** Function wait ************************************/ - -#ifdef L_wait -int -wait(status) -int * status; -{ - return wait4(-1, status, 0, (void*)0); -} -#endif - -/********************** Function wait3 **************************************/ - -#ifdef L_wait3 -int -wait3(status, opts, usage) -int * status; -int opts; -struct rusage * usage; -{ - return wait4(-1, status, opts, usage); -} -#endif - -/********************** Function waitpid ************************************/ - -#ifdef L_waitpid -int -waitpid(pid, status, opts) -int pid; -int * status; -int opts; -{ - return wait4(pid, status, opts, (void*)0); -} -#endif - -/********************** Function killpg ************************************/ - -#ifdef L_killpg -int -killpg(pid, sig) -int pid; -int sig; -{ - if(pid == 0) - pid = getpgrp(); - if(pid > 1) - return kill(-pid, sig); - errno = EINVAL; - return -1; -} -#endif - -/********************** Function setpgrp ************************************/ - -#ifdef L_setpgrp -int -setpgrp() -{ - return setpgid(0,0); -} -#endif - -/********************** Function sleep ************************************/ - -#ifdef L_sleep -#include - -/* This uses SIGALRM, it does keep the previous alarm call but will lose - * any alarms that go off during the sleep - */ - -static void alrm() { } - -unsigned int sleep(seconds) -unsigned int seconds; -{ - void (*last_alarm)(); - unsigned int prev_sec; - - prev_sec = alarm(0); - if( prev_sec <= seconds ) prev_sec = 1; else prev_sec -= seconds; - - last_alarm = signal(SIGALRM, alrm); - alarm(seconds); - pause(); - seconds = alarm(prev_sec); - signal(SIGALRM, last_alarm); - return seconds; -} -#if 0 - /* Is this a better way ? If we have select of course :-) */ -#include -unsigned int -sleep(seconds) -unsigned int seconds; -{ - struct timeval timeout; - time_t start = time((void*)0); - timeout.tv_sec = seconds; - timeout.tv_usec = 0; - select(1, NULL, NULL, NULL, &timeout); - return seconds - (time((void*)0) - start); -} -#endif - -#endif - -/********************** Function usleep ************************************/ - -#ifdef L_usleep -#include -void -usleep(useconds) -unsigned long useconds; -{ - struct timeval timeout; - timeout.tv_sec = useconds%1000000L; - timeout.tv_usec = useconds/1000000L; - select(1, NULL, NULL, NULL, &timeout); -} -#endif - -/********************** THE END ********************************************/ - -#endif /* __MSDOS__ */ -#endif diff --git a/libc/include/asm/limits.h b/libc/include/asm/limits.h new file mode 100644 index 0000000..54b48bc --- /dev/null +++ b/libc/include/asm/limits.h @@ -0,0 +1,57 @@ +/* Copyright (C) 1996 Robert de Bath + * This file is part of the Linux-8086 C library and is distributed + * under the GNU Library General Public License. + */ + +#ifndef __ASM_LIMITS_H +#define __ASM_LIMITS_H + +/* Common defines for current processors */ +#define MB_LEN_MAX 1 /* Longest multi-byte character */ +#define CHAR_BIT 8 /* number of bits in a char */ +#define SHRT_MAX 32767 /* maximum (signed) short value */ +#define SHRT_MIN (-32767) /* minimum (signed) short value */ +#define LONG_MAX 2147483647 /* maximum (signed) long value */ +#define LONG_MIN (-2147483647) /* minimum (signed) long value */ +#define UCHAR_MAX 255 /* maximum unsigned char value */ +#define USHRT_MAX 0xffff /* maximum unsigned short value */ +#define ULONG_MAX 0xffffffff /* maximum unsigned long value */ + +#ifdef __BCC__ +#define CHAR_MAX 255 /* maximum char value */ +#define CHAR_MIN (0) /* mimimum char value */ + +#ifdef __AS386_32__ +#define INT_MAX 2147483647 /* maximum (signed) int value */ +#define INT_MIN (-2147483647) /* minimum (signed) int value */ +#define UINT_MAX 0xffffffff /* maximum unsigned int value */ +#else +#define INT_MAX 32767 /* maximum (signed) int value */ +#define INT_MIN (-32767) /* minimum (signed) int value */ +#define UINT_MAX 0xffff /* maximum unsigned int value */ +#endif + +/* BCC doesn't have signed char */ +/* #define SCHAR_MAX 127 /* maximum signed char value */ +/* #define SCHAR_MIN (-127) /* minimum signed char value */ +#endif + +#if defined(__GNUC__) && defined(__i386__) +#define CHAR_MAX 127 /* maximum char value */ +#define CHAR_MIN (-127) /* mimimum char value */ +#define SCHAR_MAX 127 /* maximum signed char value */ +#define SCHAR_MIN (-127) /* minimum signed char value */ +#define INT_MAX 2147483647 /* maximum (signed) int value */ +#define INT_MIN (-2147483647) /* minimum (signed) int value */ +#define UINT_MAX 0xffffffff /* maximum unsigned int value */ +#endif + +#ifndef INT_MAX +#error "Limits.h not fully implemented" +#endif + +#ifndef RAND_MAX +#define RAND_MAX INT_MAX +#endif + +#endif diff --git a/libc/include/asm/types.h b/libc/include/asm/types.h new file mode 100644 index 0000000..f4d9f46 --- /dev/null +++ b/libc/include/asm/types.h @@ -0,0 +1,34 @@ + +/* asm/types.h - Basic sized C data types. */ + +#ifndef __ASM_8086_TYPES +#define __ASM_8086_TYPES + +/* First we define all of the __u and __s types...*/ + +typedef unsigned char __u8; +typedef unsigned char * __pu8; + +#ifndef __BCC__ /* NOTE! BCC does _not_ have a signed char type! */ +typedef char __s8; +typedef char * __ps8; +#endif + +typedef unsigned short __u16; +typedef unsigned short * __pu16; +typedef short __s16; +typedef short * __ps16; + +typedef unsigned long __u32; +typedef unsigned long * __pu32; +typedef long __s32; +typedef long * __ps32; + +/* __uint == 16bit on 8086 32bit on i386 */ + +typedef unsigned int __uint; +typedef int __sint; +typedef unsigned int * __puint; +typedef int * __psint; + +#endif diff --git a/libc/include/errno.h b/libc/include/errno.h index c8d2002..fa8efb7 100644 --- a/libc/include/errno.h +++ b/libc/include/errno.h @@ -1,25 +1 @@ -#ifndef __ERRNO_H -#define __ERRNO_H - -#include -#include - -#ifdef __USE_BSD -extern int sys_nerr; -extern char *sys_errlist[]; -#endif -#ifdef __USE_GNU -extern int _sys_nerr; -extern char *_sys_errlist[]; -#endif - -extern int errno; - -__BEGIN_DECLS - -extern void perror __P ((__const char* __s)); -extern char* strerror __P ((int __errno)); - -__END_DECLS - -#endif +#include diff --git a/libc/include/fcntl.h b/libc/include/fcntl.h index ddd9afc..2cba550 100644 --- a/libc/include/fcntl.h +++ b/libc/include/fcntl.h @@ -1,9 +1,9 @@ -#ifndef __FCNTL_H -#define __FCNTL_H +#ifndef __FCNTL__H +#define __FCNTL__H #include #include -#include +#include __SYSINC__(fcntl.h) #ifndef FNDELAY #define FNDELAY O_NDELAY diff --git a/libc/include/features.h b/libc/include/features.h index 11eb610..1c7da63 100644 --- a/libc/include/features.h +++ b/libc/include/features.h @@ -22,6 +22,26 @@ #endif +/* Pick an OS sysinclude directory */ +/* Use with #include __SYSINC__(errno.h) */ + +#ifdef __ELKS__ +#define __SYSINC__(_h_file_) +#endif + +#ifdef __linux__ +#undef linux /* Eyuk! */ +#define __SYSINC__(_h_file_) +#endif + +#ifdef __MSDOS__ +#define __SYSINC__(_h_file_) +#endif + +#ifndef __SYSINC__ +#define __SYSINC__(_h_file_) +#endif + /* No C++ */ #define __BEGIN_DECLS #define __END_DECLS @@ -33,4 +53,3 @@ #include #endif - diff --git a/libc/include/generic/errno.h b/libc/include/generic/errno.h new file mode 100644 index 0000000..819f086 --- /dev/null +++ b/libc/include/generic/errno.h @@ -0,0 +1,130 @@ +#ifndef _I86_ERRNO_H +#define _I86_ERRNO_H + +#define EPERM 1 /* Operation not permitted */ +#define ENOENT 2 /* No such file or directory */ +#define ESRCH 3 /* No such process */ +#define EINTR 4 /* Interrupted system call */ +#define EIO 5 /* I/O error */ +#define ENXIO 6 /* No such device or address */ +#define E2BIG 7 /* Arg list too long */ +#define ENOEXEC 8 /* Exec format error */ +#define EBADF 9 /* Bad file number */ +#define ECHILD 10 /* No child processes */ +#define EAGAIN 11 /* Try again */ +#define ENOMEM 12 /* Out of memory */ +#define EACCES 13 /* Permission denied */ +#define EFAULT 14 /* Bad address */ +#define ENOTBLK 15 /* Block device required */ +#define EBUSY 16 /* Device or resource busy */ +#define EEXIST 17 /* File exists */ +#define EXDEV 18 /* Cross-device link */ +#define ENODEV 19 /* No such device */ +#define ENOTDIR 20 /* Not a directory */ +#define EISDIR 21 /* Is a directory */ +#define EINVAL 22 /* Invalid argument */ +#define ENFILE 23 /* File table overflow */ +#define EMFILE 24 /* Too many open files */ +#define ENOTTY 25 /* Not a typewriter */ +#define ETXTBSY 26 /* Text file busy */ +#define EFBIG 27 /* File too large */ +#define ENOSPC 28 /* No space left on device */ +#define ESPIPE 29 /* Illegal seek */ +#define EROFS 30 /* Read-only file system */ +#define EMLINK 31 /* Too many links */ +#define EPIPE 32 /* Broken pipe */ +#define EDOM 33 /* Math argument out of domain of func */ +#define ERANGE 34 /* Math result not representable */ +#define EDEADLK 35 /* Resource deadlock would occur */ +#define ENAMETOOLONG 36 /* File name too long */ +#define ENOLCK 37 /* No record locks available */ +#define ENOSYS 38 /* Function not implemented */ +#define ENOTEMPTY 39 /* Directory not empty */ +#define ELOOP 40 /* Too many symbolic links encountered */ +#define EWOULDBLOCK EAGAIN /* Operation would block */ + +#if 0 +#define ENOMSG 42 /* No message of desired type */ +#define EIDRM 43 /* Identifier removed */ +#define ECHRNG 44 /* Channel number out of range */ +#define EL2NSYNC 45 /* Level 2 not synchronized */ +#define EL3HLT 46 /* Level 3 halted */ +#define EL3RST 47 /* Level 3 reset */ +#define ELNRNG 48 /* Link number out of range */ +#define EUNATCH 49 /* Protocol driver not attached */ +#define ENOCSI 50 /* No CSI structure available */ +#define EL2HLT 51 /* Level 2 halted */ +#define EBADE 52 /* Invalid exchange */ +#define EBADR 53 /* Invalid request descriptor */ +#define EXFULL 54 /* Exchange full */ +#define ENOANO 55 /* No anode */ +#define EBADRQC 56 /* Invalid request code */ +#define EBADSLT 57 /* Invalid slot */ +#define EDEADLOCK 58 /* File locking deadlock error */ +#define EBFONT 59 /* Bad font file format */ +#define ENOSTR 60 /* Device not a stream */ +#define ENODATA 61 /* No data available */ +#define ETIME 62 /* Timer expired */ +#define ENOSR 63 /* Out of streams resources */ +#define ENONET 64 /* Machine is not on the network */ +#define ENOPKG 65 /* Package not installed */ +#define EREMOTE 66 /* Object is remote */ +#define ENOLINK 67 /* Link has been severed */ +#define EADV 68 /* Advertise error */ +#define ESRMNT 69 /* Srmount error */ +#define ECOMM 70 /* Communication error on send */ +#define EPROTO 71 /* Protocol error */ +#define EMULTIHOP 72 /* Multihop attempted */ +#define EDOTDOT 73 /* RFS specific error */ +#define EBADMSG 74 /* Not a data message */ +#define EOVERFLOW 75 /* Value too large for defined data type */ +#define ENOTUNIQ 76 /* Name not unique on network */ +#define EBADFD 77 /* File descriptor in bad state */ +#define EREMCHG 78 /* Remote address changed */ +#define ELIBACC 79 /* Can not access a needed shared library */ +#define ELIBBAD 80 /* Accessing a corrupted shared library */ +#define ELIBSCN 81 /* .lib section in a.out corrupted */ +#define ELIBMAX 82 /* Attempting to link in too many shared libraries */ +#define ELIBEXEC 83 /* Cannot exec a shared library directly */ +#define EILSEQ 84 /* Illegal byte sequence */ +#define ERESTART 85 /* Interrupted system call should be restarted */ +#define ESTRPIPE 86 /* Streams pipe error */ +#define EUSERS 87 /* Too many users */ +#define ENOTSOCK 88 /* Socket operation on non-socket */ +#define EDESTADDRREQ 89 /* Destination address required */ +#define EMSGSIZE 90 /* Message too long */ +#define EPROTOTYPE 91 /* Protocol wrong type for socket */ +#define ENOPROTOOPT 92 /* Protocol not available */ +#define EPROTONOSUPPORT 93 /* Protocol not supported */ +#define ESOCKTNOSUPPORT 94 /* Socket type not supported */ +#define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */ +#define EPFNOSUPPORT 96 /* Protocol family not supported */ +#define EAFNOSUPPORT 97 /* Address family not supported by protocol */ +#define EADDRINUSE 98 /* Address already in use */ +#define EADDRNOTAVAIL 99 /* Cannot assign requested address */ +#define ENETDOWN 100 /* Network is down */ +#define ENETUNREACH 101 /* Network is unreachable */ +#define ENETRESET 102 /* Network dropped connection because of reset */ +#define ECONNABORTED 103 /* Software caused connection abort */ +#define ECONNRESET 104 /* Connection reset by peer */ +#define ENOBUFS 105 /* No buffer space available */ +#define EISCONN 106 /* Transport endpoint is already connected */ +#define ENOTCONN 107 /* Transport endpoint is not connected */ +#define ESHUTDOWN 108 /* Cannot send after transport endpoint shutdown */ +#define ETOOMANYREFS 109 /* Too many references: cannot splice */ +#define ETIMEDOUT 110 /* Connection timed out */ +#define ECONNREFUSED 111 /* Connection refused */ +#define EHOSTDOWN 112 /* Host is down */ +#define EHOSTUNREACH 113 /* No route to host */ +#define EALREADY 114 /* Operation already in progress */ +#define EINPROGRESS 115 /* Operation now in progress */ +#define ESTALE 116 /* Stale NFS file handle */ +#define EUCLEAN 117 /* Structure needs cleaning */ +#define ENOTNAM 118 /* Not a XENIX named type file */ +#define ENAVAIL 119 /* No XENIX semaphores available */ +#define EISNAM 120 /* Is a named type file */ +#define EREMOTEIO 121 /* Remote I/O error */ +#define EDQUOT 122 /* Quota exceeded */ +#endif + +#endif diff --git a/libc/include/generic/fcntl.h b/libc/include/generic/fcntl.h new file mode 100644 index 0000000..7e0626d --- /dev/null +++ b/libc/include/generic/fcntl.h @@ -0,0 +1,73 @@ +#ifndef __UNK_FCNTL_H +#define __UNK_FCNTL_H + +/* + * Definitions taken from the i386 Linux kernel. + */ + +/* open/fcntl */ + +#define O_ACCMODE 0003 +#define O_RDONLY 00 +#define O_WRONLY 01 +#define O_RDWR 02 +#define O_CREAT 0100 /* not fcntl */ +#define O_EXCL 0200 /* not fcntl */ +#define O_TRUNC 01000 /* not fcntl */ +#define O_APPEND 02000 + +#if 0 +#define O_NOCTTY 0400 /* not fcntl */ +#define O_NONBLOCK 04000 +#define O_NDELAY O_NONBLOCK +#define O_SYNC 010000 /* Not supported */ +#define FASYNC 020000 /* Not supported */ +#endif + +#define F_DUPFD 0 /* dup */ +#define F_GETFD 1 /* get f_flags */ +#define F_SETFD 2 /* set f_flags */ +#define F_GETFL 3 /* more flags (cloexec) */ +#define F_SETFL 4 +#define F_GETLK 5 +#define F_SETLK 6 +#define F_SETLKW 7 + +#if 0 +#define F_SETOWN 8 /* for sockets. */ +#define F_GETOWN 9 /* for sockets. */ + +/* for F_[GET|SET]FL */ +#define FD_CLOEXEC 1 /* actually anything with low bit set goes */ + +/* for posix fcntl() and lockf() */ +#define F_RDLCK 0 +#define F_WRLCK 1 +#define F_UNLCK 2 + +/* for old implementation of bsd flock () */ +#define F_EXLCK 4 /* or 3 */ +#define F_SHLCK 8 /* or 4 */ + +/* operations for bsd flock(), also used by the kernel implementation */ +#define LOCK_SH 1 /* shared lock */ +#define LOCK_EX 2 /* exclusive lock */ +#define LOCK_NB 4 /* or'd with one of the above to prevent + blocking */ +#define LOCK_UN 8 /* remove lock */ + +#ifdef __KERNEL__ +#define F_POSIX 1 +#define F_FLOCK 2 +#endif /* __KERNEL__ */ + +struct flock { + short l_type; + short l_whence; + off_t l_start; + off_t l_len; + pid_t l_pid; +}; +#endif + +#endif diff --git a/libc/include/generic/types.h b/libc/include/generic/types.h new file mode 100644 index 0000000..5798f79 --- /dev/null +++ b/libc/include/generic/types.h @@ -0,0 +1,22 @@ + +/* arch/i86/include/asm/types.h - Basic Linux/MT data types. */ + +#ifndef __GENERIC_TYPES_H +#define __GENERIC_TYPES_H + +#include + +typedef __u32 off_t; +typedef __u32 time_t; +typedef __u16 mode_t; +typedef __u32 loff_t; +typedef __u32 speed_t; + +typedef __u32 tcflag_t; +typedef __u8 cc_t; + +typedef int ptrdiff_t; +typedef int size_t; + +#endif + diff --git a/libc/include/limits.h b/libc/include/limits.h index 520c1c4..9e091b7 100644 --- a/libc/include/limits.h +++ b/libc/include/limits.h @@ -5,53 +5,5 @@ #ifndef __LIMITS_H #define __LIMITS_H - -#if __AS386_16__ -#define MB_LEN_MAX 1 /* Longest multi-byte character */ -#define CHAR_MAX 127 /* maximum char value */ -#define CHAR_MIN (-127) /* mimimum char value */ -#define SCHAR_MAX 127 /* maximum signed char value */ -#define SCHAR_MIN (-127) /* minimum signed char value */ -#define CHAR_BIT 8 /* number of bits in a char */ -#define SHRT_MAX 32767 /* maximum (signed) short value */ -#define SHRT_MIN (-32767) /* minimum (signed) short value */ -#define INT_MAX 32767 /* maximum (signed) int value */ -#define INT_MIN (-32767) /* minimum (signed) int value */ -#define LONG_MAX 2147483647 /* maximum (signed) long value */ -#define LONG_MIN (-2147483647) /* minimum (signed) long value */ -#define UCHAR_MAX 255 /* maximum unsigned char value */ -#define USHRT_MAX 0xffff /* maximum unsigned short value */ -#define UINT_MAX 0xffff /* maximum unsigned int value */ -#define ULONG_MAX 0xffffffff /* maximum unsigned long value */ -#ifndef RAND_MAX -#define RAND_MAX INT_MAX -#endif -#endif - -#if __AS386_32__ -#define MB_LEN_MAX 1 /* Longest multi-byte character */ -#define CHAR_MAX 127 /* maximum char value */ -#define CHAR_MIN (-127) /* mimimum char value */ -#define SCHAR_MAX 127 /* maximum signed char value */ -#define SCHAR_MIN (-127) /* minimum signed char value */ -#define CHAR_BIT 8 /* number of bits in a char */ -#define SHRT_MAX 32767 /* maximum (signed) short value */ -#define SHRT_MIN (-32767) /* minimum (signed) short value */ -#define INT_MAX 2147483647 /* maximum (signed) int value */ -#define INT_MIN (-2147483647) /* minimum (signed) int value */ -#define LONG_MAX 2147483647 /* maximum (signed) long value */ -#define LONG_MIN (-2147483647) /* minimum (signed) long value */ -#define UCHAR_MAX 255 /* maximum unsigned char value */ -#define USHRT_MAX 0xffff /* maximum unsigned short value */ -#define UINT_MAX 0xffffffff /* maximum unsigned int value */ -#define ULONG_MAX 0xffffffff /* maximum unsigned long value */ -#ifndef RAND_MAX -#define RAND_MAX INT_MAX -#endif -#endif - -#ifndef CHAR_MAX -#error "Limits.h not implemented" -#endif - +#include #endif diff --git a/libc/include/linux/errno.h b/libc/include/linux/errno.h new file mode 100644 index 0000000..ee3fcab --- /dev/null +++ b/libc/include/linux/errno.h @@ -0,0 +1,127 @@ +#ifndef _I86_ERRNO_H +#define _I86_ERRNO_H + +#define EPERM 1 /* Operation not permitted */ +#define ENOENT 2 /* No such file or directory */ +#define ESRCH 3 /* No such process */ +#define EINTR 4 /* Interrupted system call */ +#define EIO 5 /* I/O error */ +#define ENXIO 6 /* No such device or address */ +#define E2BIG 7 /* Arg list too long */ +#define ENOEXEC 8 /* Exec format error */ +#define EBADF 9 /* Bad file number */ +#define ECHILD 10 /* No child processes */ +#define EAGAIN 11 /* Try again */ +#define ENOMEM 12 /* Out of memory */ +#define EACCES 13 /* Permission denied */ +#define EFAULT 14 /* Bad address */ +#define ENOTBLK 15 /* Block device required */ +#define EBUSY 16 /* Device or resource busy */ +#define EEXIST 17 /* File exists */ +#define EXDEV 18 /* Cross-device link */ +#define ENODEV 19 /* No such device */ +#define ENOTDIR 20 /* Not a directory */ +#define EISDIR 21 /* Is a directory */ +#define EINVAL 22 /* Invalid argument */ +#define ENFILE 23 /* File table overflow */ +#define EMFILE 24 /* Too many open files */ +#define ENOTTY 25 /* Not a typewriter */ +#define ETXTBSY 26 /* Text file busy */ +#define EFBIG 27 /* File too large */ +#define ENOSPC 28 /* No space left on device */ +#define ESPIPE 29 /* Illegal seek */ +#define EROFS 30 /* Read-only file system */ +#define EMLINK 31 /* Too many links */ +#define EPIPE 32 /* Broken pipe */ +#define EDOM 33 /* Math argument out of domain of func */ +#define ERANGE 34 /* Math result not representable */ +#define EDEADLK 35 /* Resource deadlock would occur */ +#define ENAMETOOLONG 36 /* File name too long */ +#define ENOLCK 37 /* No record locks available */ +#define ENOSYS 38 /* Function not implemented */ +#define ENOTEMPTY 39 /* Directory not empty */ +#define ELOOP 40 /* Too many symbolic links encountered */ +#define EWOULDBLOCK EAGAIN /* Operation would block */ +#define ENOMSG 42 /* No message of desired type */ +#define EIDRM 43 /* Identifier removed */ +#define ECHRNG 44 /* Channel number out of range */ +#define EL2NSYNC 45 /* Level 2 not synchronized */ +#define EL3HLT 46 /* Level 3 halted */ +#define EL3RST 47 /* Level 3 reset */ +#define ELNRNG 48 /* Link number out of range */ +#define EUNATCH 49 /* Protocol driver not attached */ +#define ENOCSI 50 /* No CSI structure available */ +#define EL2HLT 51 /* Level 2 halted */ +#define EBADE 52 /* Invalid exchange */ +#define EBADR 53 /* Invalid request descriptor */ +#define EXFULL 54 /* Exchange full */ +#define ENOANO 55 /* No anode */ +#define EBADRQC 56 /* Invalid request code */ +#define EBADSLT 57 /* Invalid slot */ +#define EDEADLOCK 58 /* File locking deadlock error */ +#define EBFONT 59 /* Bad font file format */ +#define ENOSTR 60 /* Device not a stream */ +#define ENODATA 61 /* No data available */ +#define ETIME 62 /* Timer expired */ +#define ENOSR 63 /* Out of streams resources */ +#define ENONET 64 /* Machine is not on the network */ +#define ENOPKG 65 /* Package not installed */ +#define EREMOTE 66 /* Object is remote */ +#define ENOLINK 67 /* Link has been severed */ +#define EADV 68 /* Advertise error */ +#define ESRMNT 69 /* Srmount error */ +#define ECOMM 70 /* Communication error on send */ +#define EPROTO 71 /* Protocol error */ +#define EMULTIHOP 72 /* Multihop attempted */ +#define EDOTDOT 73 /* RFS specific error */ +#define EBADMSG 74 /* Not a data message */ +#define EOVERFLOW 75 /* Value too large for defined data type */ +#define ENOTUNIQ 76 /* Name not unique on network */ +#define EBADFD 77 /* File descriptor in bad state */ +#define EREMCHG 78 /* Remote address changed */ +#define ELIBACC 79 /* Can not access a needed shared library */ +#define ELIBBAD 80 /* Accessing a corrupted shared library */ +#define ELIBSCN 81 /* .lib section in a.out corrupted */ +#define ELIBMAX 82 /* Attempting to link in too many shared libraries */ +#define ELIBEXEC 83 /* Cannot exec a shared library directly */ +#define EILSEQ 84 /* Illegal byte sequence */ +#define ERESTART 85 /* Interrupted system call should be restarted */ +#define ESTRPIPE 86 /* Streams pipe error */ +#define EUSERS 87 /* Too many users */ +#define ENOTSOCK 88 /* Socket operation on non-socket */ +#define EDESTADDRREQ 89 /* Destination address required */ +#define EMSGSIZE 90 /* Message too long */ +#define EPROTOTYPE 91 /* Protocol wrong type for socket */ +#define ENOPROTOOPT 92 /* Protocol not available */ +#define EPROTONOSUPPORT 93 /* Protocol not supported */ +#define ESOCKTNOSUPPORT 94 /* Socket type not supported */ +#define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */ +#define EPFNOSUPPORT 96 /* Protocol family not supported */ +#define EAFNOSUPPORT 97 /* Address family not supported by protocol */ +#define EADDRINUSE 98 /* Address already in use */ +#define EADDRNOTAVAIL 99 /* Cannot assign requested address */ +#define ENETDOWN 100 /* Network is down */ +#define ENETUNREACH 101 /* Network is unreachable */ +#define ENETRESET 102 /* Network dropped connection because of reset */ +#define ECONNABORTED 103 /* Software caused connection abort */ +#define ECONNRESET 104 /* Connection reset by peer */ +#define ENOBUFS 105 /* No buffer space available */ +#define EISCONN 106 /* Transport endpoint is already connected */ +#define ENOTCONN 107 /* Transport endpoint is not connected */ +#define ESHUTDOWN 108 /* Cannot send after transport endpoint shutdown */ +#define ETOOMANYREFS 109 /* Too many references: cannot splice */ +#define ETIMEDOUT 110 /* Connection timed out */ +#define ECONNREFUSED 111 /* Connection refused */ +#define EHOSTDOWN 112 /* Host is down */ +#define EHOSTUNREACH 113 /* No route to host */ +#define EALREADY 114 /* Operation already in progress */ +#define EINPROGRESS 115 /* Operation now in progress */ +#define ESTALE 116 /* Stale NFS file handle */ +#define EUCLEAN 117 /* Structure needs cleaning */ +#define ENOTNAM 118 /* Not a XENIX named type file */ +#define ENAVAIL 119 /* No XENIX semaphores available */ +#define EISNAM 120 /* Is a named type file */ +#define EREMOTEIO 121 /* Remote I/O error */ +#define EDQUOT 122 /* Quota exceeded */ + +#endif diff --git a/libc/include/linux/fcntl.h b/libc/include/linux/fcntl.h new file mode 100644 index 0000000..bc2f72a --- /dev/null +++ b/libc/include/linux/fcntl.h @@ -0,0 +1,70 @@ +#ifndef __LINUX_FCNTL_H +#define __LINUX_FCNTL_H + +/* + * Definitions taken from the i386 Linux kernel. + */ + +/* open/fcntl */ + +#define O_ACCMODE 0003 +#define O_RDONLY 00 +#define O_WRONLY 01 +#define O_RDWR 02 +#define O_CREAT 0100 /* not fcntl */ +#define O_EXCL 0200 /* not fcntl */ +#define O_NOCTTY 0400 /* not fcntl */ +#define O_TRUNC 01000 /* not fcntl */ +#define O_APPEND 02000 +#define O_NONBLOCK 04000 +#define O_NDELAY O_NONBLOCK +#if 0 +#define O_SYNC 010000 /* Not supported */ +#define FASYNC 020000 /* Not supported */ +#endif + +#define F_DUPFD 0 /* dup */ +#define F_GETFD 1 /* get f_flags */ +#define F_SETFD 2 /* set f_flags */ +#define F_GETFL 3 /* more flags (cloexec) */ +#define F_SETFL 4 +#define F_GETLK 5 +#define F_SETLK 6 +#define F_SETLKW 7 + +#define F_SETOWN 8 /* for sockets. */ +#define F_GETOWN 9 /* for sockets. */ + +/* for F_[GET|SET]FL */ +#define FD_CLOEXEC 1 /* actually anything with low bit set goes */ + +/* for posix fcntl() and lockf() */ +#define F_RDLCK 0 +#define F_WRLCK 1 +#define F_UNLCK 2 + +/* for old implementation of bsd flock () */ +#define F_EXLCK 4 /* or 3 */ +#define F_SHLCK 8 /* or 4 */ + +/* operations for bsd flock(), also used by the kernel implementation */ +#define LOCK_SH 1 /* shared lock */ +#define LOCK_EX 2 /* exclusive lock */ +#define LOCK_NB 4 /* or'd with one of the above to prevent + blocking */ +#define LOCK_UN 8 /* remove lock */ + +#ifdef __KERNEL__ +#define F_POSIX 1 +#define F_FLOCK 2 +#endif /* __KERNEL__ */ + +struct flock { + short l_type; + short l_whence; + off_t l_start; + off_t l_len; + pid_t l_pid; +}; + +#endif diff --git a/libc/include/linux/ioctl.h b/libc/include/linux/ioctl.h new file mode 100644 index 0000000..e69de29 diff --git a/libc/include/linux/mman.h b/libc/include/linux/mman.h new file mode 100644 index 0000000..a59e802 --- /dev/null +++ b/libc/include/linux/mman.h @@ -0,0 +1,52 @@ +#ifndef _SYS_MMAN_H +#define _SYS_MMAN_H + +#include +#include + +#define PROT_READ 0x1 /* page can be read */ +#define PROT_WRITE 0x2 /* page can be written */ +#define PROT_EXEC 0x4 /* page can be executed */ +#define PROT_NONE 0x0 /* page can not be accessed */ + +#define MAP_SHARED 0x01 /* Share changes */ +#define MAP_PRIVATE 0x02 /* Changes are private */ +#define MAP_TYPE 0x0f /* Mask for type of mapping */ +#define MAP_FIXED 0x10 /* Interpret addr exactly */ +#define MAP_ANONYMOUS 0x20 /* don't use a file */ + +#define MAP_GROWSDOWN 0x0100 /* stack-like segment */ +#define MAP_DENYWRITE 0x0800 /* ETXTBSY */ +#define MAP_EXECUTABLE 0x1000 /* mark it as a executable */ +#define MAP_LOCKED 0x2000 /* pages are locked */ + +#define MS_ASYNC 1 /* sync memory asynchronously */ +#define MS_INVALIDATE 2 /* invalidate the caches */ +#define MS_SYNC 4 /* synchronous memory sync */ + +#define MCL_CURRENT 1 /* lock all current mappings */ +#define MCL_FUTURE 2 /* lock all future mappings */ + +/* compatibility flags */ +#define MAP_ANON MAP_ANONYMOUS +#define MAP_FILE 0 + +#define MREMAP_MAYMOVE 1 + +extern __ptr_t mmap __P((__ptr_t __addr, size_t __len, + int __prot, int __flags, int __fd, off_t __off)); +extern int munmap __P((__ptr_t __addr, size_t __len)); +extern int mprotect __P ((__const __ptr_t __addr, size_t __len, int __prot)); + +extern int msync __P((__ptr_t __addr, size_t __len, int __flags)); + +extern int mlock __P((__const __ptr_t __addr, size_t __len)); +extern int munlock __P((__const __ptr_t __addr, size_t __len)); + +extern int mlockall __P((int __flags)); +extern int munlockall __P((void)); + +extern __ptr_t mremap __P((__ptr_t __addr, size_t __old_len, + size_t __new_len, int __may_move)); + +#endif /* _SYS_MMAN_H */ diff --git a/libc/include/linux/resource.h b/libc/include/linux/resource.h new file mode 100644 index 0000000..905094b --- /dev/null +++ b/libc/include/linux/resource.h @@ -0,0 +1,73 @@ +/* + * Resource control/accounting header file for linux-86 + */ + +#ifndef __LINUX_RESOURCE_H +#define __LINUX_RESOURCE_H + +#include +#include +#include + +#define RUSAGE_SELF 0 +#define RUSAGE_CHILDREN (-1) +#define RUSAGE_BOTH (-2) /* sys_wait4() uses this */ + +struct rusage { + struct timeval ru_utime; /* user time used */ + struct timeval ru_stime; /* system time used */ + long ru_maxrss; /* maximum resident set size */ + long ru_ixrss; /* integral shared memory size */ + long ru_idrss; /* integral unshared data size */ + long ru_isrss; /* integral unshared stack size */ + long ru_minflt; /* page reclaims */ + long ru_majflt; /* page faults */ + long ru_nswap; /* swaps */ + long ru_inblock; /* block input operations */ + long ru_oublock; /* block output operations */ + long ru_msgsnd; /* messages sent */ + long ru_msgrcv; /* messages received */ + long ru_nsignals; /* signals received */ + long ru_nvcsw; /* voluntary context switches */ + long ru_nivcsw; /* involuntary " */ +}; + +#define RLIM_INFINITY ((long)(~0UL>>1)) + +struct rlimit { + long rlim_cur; + long rlim_max; +}; + +#define PRIO_MIN (-20) +#define PRIO_MAX 20 + +#define PRIO_PROCESS 0 +#define PRIO_PGRP 1 +#define PRIO_USER 2 + +#define RLIMIT_CPU 0 /* CPU time in ms */ +#define RLIMIT_FSIZE 1 /* Maximum filesize */ +#define RLIMIT_DATA 2 /* max data size */ +#define RLIMIT_STACK 3 /* max stack size */ +#define RLIMIT_CORE 4 /* max core file size */ +#define RLIMIT_RSS 5 /* max resident set size */ +#define RLIMIT_NPROC 6 /* max number of processes */ +#define RLIMIT_NOFILE 7 /* max number of open files */ +#define RLIMIT_MEMLOCK 8 /* max locked-in-memory address space */ + +#define RLIM_NLIMITS 9 + +extern int getrlimit __P ((int __resource, + struct rlimit *__rlp)); +extern int setrlimit __P ((int __resource, + __const struct rlimit *__rlp)); + +extern int getpriority __P((int __which, int __who)); +extern int setpriority __P((int __which, int __who, + int __prio)); + +extern int __getrusage __P ((int __who, struct rusage *__rusage)); +extern int getrusage __P ((int __who, struct rusage *__rusage)); + +#endif /* __LINUX_RESOURCE_H */ diff --git a/libc/include/linux/stat.h b/libc/include/linux/stat.h new file mode 100644 index 0000000..eccf1e4 --- /dev/null +++ b/libc/include/linux/stat.h @@ -0,0 +1,76 @@ +#ifndef _LINUX_STAT_H +#define _LINUX_STAT_H + +/* This is for Linux-386, ho hum, I wish BCC could compile the proper one */ +#define mknod __dv32_mknod +#define stat __dv32_stat +#define lstat __dv32_lstat +#define fstat __dv32_fstat + +struct stat { + dev_t st_dev; + unsigned short __pad1; + ino_t st_ino; + umode_t st_mode; + nlink_t st_nlink; + uid_t st_uid; + gid_t st_gid; + dev_t st_rdev; + unsigned short __pad2; + off_t st_size; + unsigned long st_blksize; + unsigned long st_blocks; + time_t st_atime; + unsigned long __unused1; + time_t st_mtime; + unsigned long __unused2; + time_t st_ctime; + unsigned long __unused3; + unsigned long __unused4; + unsigned long __unused5; +}; + +#define S_IFMT 00170000 +#define S_IFSOCK 0140000 +#define S_IFLNK 0120000 +#define S_IFREG 0100000 +#define S_IFBLK 0060000 +#define S_IFDIR 0040000 +#define S_IFCHR 0020000 +#define S_IFIFO 0010000 +#define S_ISUID 0004000 +#define S_ISGID 0002000 +#define S_ISVTX 0001000 + +#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) +#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) +#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) +#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR) +#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK) +#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO) +#define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK) + +#define S_IRWXU 00700 +#define S_IRUSR 00400 +#define S_IWUSR 00200 +#define S_IXUSR 00100 + +#define S_IRWXG 00070 +#define S_IRGRP 00040 +#define S_IWGRP 00020 +#define S_IXGRP 00010 + +#define S_IRWXO 00007 +#define S_IROTH 00004 +#define S_IWOTH 00002 +#define S_IXOTH 00001 + +#ifdef __KERNEL__ +#define S_IRWXUGO (S_IRWXU|S_IRWXG|S_IRWXO) +#define S_IALLUGO (S_ISUID|S_ISGID|S_ISVTX|S_IRWXUGO) +#define S_IRUGO (S_IRUSR|S_IRGRP|S_IROTH) +#define S_IWUGO (S_IWUSR|S_IWGRP|S_IWOTH) +#define S_IXUGO (S_IXUSR|S_IXGRP|S_IXOTH) +#endif + +#endif diff --git a/libc/include/linux/termios.h b/libc/include/linux/termios.h new file mode 100644 index 0000000..02fcb68 --- /dev/null +++ b/libc/include/linux/termios.h @@ -0,0 +1,257 @@ +#ifndef __LINUX_TERMIOS_H +#define __LINUX_TERMIOS_H + +/* This is just a magic number to make these relatively unique ('T') */ +#define __TERMIOS_MAJ ('T'<<8) + +#define TCGETS (__TERMIOS_MAJ+0x01) +#define TCSETS (__TERMIOS_MAJ+0x02) +#define TCSETSW (__TERMIOS_MAJ+0x03) +#define TCSETSF (__TERMIOS_MAJ+0x04) +#define TCGETA (__TERMIOS_MAJ+0x05) +#define TCSETA (__TERMIOS_MAJ+0x06) +#define TCSETAW (__TERMIOS_MAJ+0x07) +#define TCSETAF (__TERMIOS_MAJ+0x08) +#define TCSBRK (__TERMIOS_MAJ+0x09) +#define TCXONC (__TERMIOS_MAJ+0x0A) +#define TCFLSH (__TERMIOS_MAJ+0x0B) +#define TIOCEXCL (__TERMIOS_MAJ+0x0C) +#define TIOCNXCL (__TERMIOS_MAJ+0x0D) +#define TIOCSCTTY (__TERMIOS_MAJ+0x0E) +#define TIOCGPGRP (__TERMIOS_MAJ+0x0F) +#define TIOCSPGRP (__TERMIOS_MAJ+0x10) +#define TIOCOUTQ (__TERMIOS_MAJ+0x11) +#define TIOCSTI (__TERMIOS_MAJ+0x12) +#define TIOCGWINSZ (__TERMIOS_MAJ+0x13) +#define TIOCSWINSZ (__TERMIOS_MAJ+0x14) +#define TIOCMGET (__TERMIOS_MAJ+0x15) +#define TIOCMBIS (__TERMIOS_MAJ+0x16) +#define TIOCMBIC (__TERMIOS_MAJ+0x17) +#define TIOCMSET (__TERMIOS_MAJ+0x18) +#define TIOCGSOFTCAR (__TERMIOS_MAJ+0x19) +#define TIOCSSOFTCAR (__TERMIOS_MAJ+0x1A) +#define FIONREAD (__TERMIOS_MAJ+0x1B) +#define TIOCINQ FIONREAD +#define TIOCLINUX (__TERMIOS_MAJ+0x1C) +#define TIOCCONS (__TERMIOS_MAJ+0x1D) +#define TIOCGSERIAL (__TERMIOS_MAJ+0x1E) +#define TIOCSSERIAL (__TERMIOS_MAJ+0x1F) +#define TIOCPKT (__TERMIOS_MAJ+0x20) +#define FIONBIO (__TERMIOS_MAJ+0x21) +#define TIOCNOTTY (__TERMIOS_MAJ+0x22) +#define TIOCSETD (__TERMIOS_MAJ+0x23) +#define TIOCGETD (__TERMIOS_MAJ+0x24) +#define TCSBRKP (__TERMIOS_MAJ+0x25) /* Needed for POSIX tcsendbreak */ +#define TIOCTTYGSTRUCT (__TERMIOS_MAJ+0x26) /* For debugging only */ +#define FIONCLEX (__TERMIOS_MAJ+0x50) /* these numbers need to be adjusted. */ +#define FIOCLEX (__TERMIOS_MAJ+0x51) +#define FIOASYNC (__TERMIOS_MAJ+0x52) +#define TIOCSERCONFIG (__TERMIOS_MAJ+0x53) +#define TIOCSERGWILD (__TERMIOS_MAJ+0x54) +#define TIOCSERSWILD (__TERMIOS_MAJ+0x55) +#define TIOCGLCKTRMIOS (__TERMIOS_MAJ+0x56) +#define TIOCSLCKTRMIOS (__TERMIOS_MAJ+0x57) +#define TIOCSERGSTRUCT (__TERMIOS_MAJ+0x58) /* For debugging only */ +#define TIOCSERGETLSR (__TERMIOS_MAJ+0x59) /* Get line status register */ +#define TIOCSERGETMULTI (__TERMIOS_MAJ+0x5A) /* Get multiport config */ +#define TIOCSERSETMULTI (__TERMIOS_MAJ+0x5B) /* Set multiport config */ + +/* Used for packet mode */ +#define TIOCPKT_DATA 0 +#define TIOCPKT_FLUSHREAD 1 +#define TIOCPKT_FLUSHWRITE 2 +#define TIOCPKT_STOP 4 +#define TIOCPKT_START 8 +#define TIOCPKT_NOSTOP 16 +#define TIOCPKT_DOSTOP 32 + +struct winsize { + unsigned short ws_row; + unsigned short ws_col; + unsigned short ws_xpixel; + unsigned short ws_ypixel; +}; + +#define NCC 8 +struct termio { + unsigned short c_iflag; /* input mode flags */ + unsigned short c_oflag; /* output mode flags */ + unsigned short c_cflag; /* control mode flags */ + unsigned short c_lflag; /* local mode flags */ + unsigned char c_line; /* line discipline */ + unsigned char c_cc[NCC]; /* control characters */ +}; + +#define NCCS 19 +struct termios { + tcflag_t c_iflag; /* input mode flags */ + tcflag_t c_oflag; /* output mode flags */ + tcflag_t c_cflag; /* control mode flags */ + tcflag_t c_lflag; /* local mode flags */ + cc_t c_line; /* line discipline */ + cc_t c_cc[NCCS]; /* control characters */ +}; + +/* c_cc characters */ +#define VINTR 0 +#define VQUIT 1 +#define VERASE 2 +#define VKILL 3 +#define VEOF 4 +#define VTIME 5 +#define VMIN 6 +#define VSWTC 7 +#define VSTART 8 +#define VSTOP 9 +#define VSUSP 10 +#define VEOL 11 +#define VREPRINT 12 +#define VDISCARD 13 +#define VWERASE 14 +#define VLNEXT 15 +#define VEOL2 16 + +/* c_iflag bits */ +#define IGNBRK 0000001 +#define BRKINT 0000002 +#define IGNPAR 0000004 +#define PARMRK 0000010 +#define INPCK 0000020 +#define ISTRIP 0000040 +#define INLCR 0000100 +#define IGNCR 0000200 +#define ICRNL 0000400 +#define IUCLC 0001000 +#define IXON 0002000 +#define IXANY 0004000 +#define IXOFF 0010000 +#define IMAXBEL 0020000 + +/* c_oflag bits */ +#define OPOST 0000001 +#define OLCUC 0000002 +#define ONLCR 0000004 +#define OCRNL 0000010 +#define ONOCR 0000020 +#define ONLRET 0000040 +#define OFILL 0000100 +#define OFDEL 0000200 +#define NLDLY 0000400 +#define NL0 0000000 +#define NL1 0000400 +#define CRDLY 0003000 +#define CR0 0000000 +#define CR1 0001000 +#define CR2 0002000 +#define CR3 0003000 +#define TABDLY 0014000 +#define TAB0 0000000 +#define TAB1 0004000 +#define TAB2 0010000 +#define TAB3 0014000 +#define XTABS 0014000 +#define BSDLY 0020000 +#define BS0 0000000 +#define BS1 0020000 +#define VTDLY 0040000 +#define VT0 0000000 +#define VT1 0040000 +#define FFDLY 0100000 +#define FF0 0000000 +#define FF1 0100000 + +/* c_cflag bit meaning */ +#define CBAUD 0010017 +#define B0 0000000 /* hang up */ +#define B50 0000001 +#define B75 0000002 +#define B110 0000003 +#define B134 0000004 +#define B150 0000005 +#define B200 0000006 +#define B300 0000007 +#define B600 0000010 +#define B1200 0000011 +#define B1800 0000012 +#define B2400 0000013 +#define B4800 0000014 +#define B9600 0000015 +#define B19200 0000016 +#define B38400 0000017 +#define EXTA B19200 +#define EXTB B38400 +#define CSIZE 0000060 +#define CS5 0000000 +#define CS6 0000020 +#define CS7 0000040 +#define CS8 0000060 +#define CSTOPB 0000100 +#define CREAD 0000200 +#define PARENB 0000400 +#define PARODD 0001000 +#define HUPCL 0002000 +#define CLOCAL 0004000 +#define CBAUDEX 0010000 +#define B57600 0010001 +#define B115200 0010002 +#define B230400 0010003 +#define CIBAUD 002003600000 /* input baud rate (not used) */ +#define CRTSCTS 020000000000 /* flow control */ + +/* c_lflag bits */ +#define ISIG 0000001 +#define ICANON 0000002 +#define XCASE 0000004 +#define ECHO 0000010 +#define ECHOE 0000020 +#define ECHOK 0000040 +#define ECHONL 0000100 +#define NOFLSH 0000200 +#define TOSTOP 0000400 +#define ECHOCTL 0001000 +#define ECHOPRT 0002000 +#define ECHOKE 0004000 +#define FLUSHO 0010000 +#define PENDIN 0040000 +#define IEXTEN 0100000 + +/* modem lines */ +#define TIOCM_LE 0x001 +#define TIOCM_DTR 0x002 +#define TIOCM_RTS 0x004 +#define TIOCM_ST 0x008 +#define TIOCM_SR 0x010 +#define TIOCM_CTS 0x020 +#define TIOCM_CAR 0x040 +#define TIOCM_RNG 0x080 +#define TIOCM_DSR 0x100 +#define TIOCM_CD TIOCM_CAR +#define TIOCM_RI TIOCM_RNG + +/* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */ +#define TIOCSER_TEMT 0x01 /* Transmitter physically empty */ + + +/* tcflow() and TCXONC use these */ +#define TCOOFF 0 +#define TCOON 1 +#define TCIOFF 2 +#define TCION 3 + +/* tcflush() and TCFLSH use these */ +#define TCIFLUSH 0 +#define TCOFLUSH 1 +#define TCIOFLUSH 2 + +/* tcsetattr uses these */ +#define TCSANOW 0 +#define TCSADRAIN 1 +#define TCSAFLUSH 2 + +/* line disciplines */ +#define N_TTY 0 +#define N_SLIP 1 +#define N_MOUSE 2 +#define N_PPP 3 + +#endif /* __LINUXMT_TERMIOS_H */ diff --git a/libc/include/linux/types.h b/libc/include/linux/types.h new file mode 100644 index 0000000..c1a6d7e --- /dev/null +++ b/libc/include/linux/types.h @@ -0,0 +1,26 @@ +#ifndef __LINUX_TYPES_H +#define __LINUX_TYPES_H + +#include + +typedef __u32 off_t; +typedef __u16 pid_t; +typedef __u16 uid_t; +typedef __u16 gid_t; +typedef __u32 time_t; +typedef __u16 umode_t; +typedef __u16 nlink_t; +typedef __u16 mode_t; +typedef __u32 loff_t; +typedef __u32 speed_t; + +typedef __u16 dev_t; +typedef __u32 ino_t; +typedef __u32 tcflag_t; +typedef __u8 cc_t; +typedef __u32 size_t; + +typedef int ptrdiff_t; + +#endif + diff --git a/libc/include/linux/utsname.h b/libc/include/linux/utsname.h new file mode 100644 index 0000000..522da0b --- /dev/null +++ b/libc/include/linux/utsname.h @@ -0,0 +1,15 @@ +#ifndef __LINUX_UTSNAME_H +#define __LINUX_UTSNAME_H + +struct utsname { + char sysname[65]; + char nodename[65]; + char release[65]; + char version[65]; + char machine[65]; + char domainname[65]; +}; + +extern int uname __P ((struct utsname * __utsbuf)); + +#endif diff --git a/libc/include/linux/vm86.h b/libc/include/linux/vm86.h new file mode 100644 index 0000000..851814e --- /dev/null +++ b/libc/include/linux/vm86.h @@ -0,0 +1,125 @@ +#if !__AS386_16__ + +#ifndef _SYS_VM86_H +#define _SYS_VM86_H + +#include +#ifndef _LINUX_VM86_H +#define _LINUX_VM86_H + +/* + * I'm guessing at the VIF/VIP flag usage, but hope that this is how + * the Pentium uses them. Linux will return from vm86 mode when both + * VIF and VIP is set. + * + * On a Pentium, we could probably optimize the virtual flags directly + * in the eflags register instead of doing it "by hand" in vflags... + * + * Linus + */ + +#define TF_MASK 0x00000100 +#define IF_MASK 0x00000200 +#define IOPL_MASK 0x00003000 +#define NT_MASK 0x00004000 +#define VM_MASK 0x00020000 +#define AC_MASK 0x00040000 +#define VIF_MASK 0x00080000 /* virtual interrupt flag */ +#define VIP_MASK 0x00100000 /* virtual interrupt pending */ +#define ID_MASK 0x00200000 + +#define BIOSSEG 0x0f000 + +#define CPU_086 0 +#define CPU_186 1 +#define CPU_286 2 +#define CPU_386 3 +#define CPU_486 4 +#define CPU_586 5 + +/* + * Return values for the 'vm86()' system call + */ +#define VM86_TYPE(retval) ((retval) & 0xff) +#define VM86_ARG(retval) ((retval) >> 8) + +#define VM86_SIGNAL 0 /* return due to signal */ +#define VM86_UNKNOWN 1 /* unhandled GP fault - IO-instruction or similar */ +#define VM86_INTx 2 /* int3/int x instruction (ARG = x) */ +#define VM86_STI 3 /* sti/popf/iret instruction enabled virtual interrupts */ + +/* + * This is the stack-layout when we have done a "SAVE_ALL" from vm86 + * mode - the main change is that the old segment descriptors aren't + * useful any more and are forced to be zero by the kernel (and the + * hardware when a trap occurs), and the real segment descriptors are + * at the end of the structure. Look at ptrace.h to see the "normal" + * setup. + */ + +struct vm86_regs { +/* + * normal regs, with special meaning for the segment descriptors.. + */ + long ebx; + long ecx; + long edx; + long esi; + long edi; + long ebp; + long eax; + long __null_ds; + long __null_es; + long __null_fs; + long __null_gs; + long orig_eax; + long eip; + unsigned short cs, __csh; + long eflags; + long esp; + unsigned short ss, __ssh; +/* + * these are specific to v86 mode: + */ + unsigned short es, __esh; + unsigned short ds, __dsh; + unsigned short fs, __fsh; + unsigned short gs, __gsh; +}; + +struct revectored_struct { + unsigned long __map[8]; /* 256 bits */ +}; + +struct vm86_struct { + struct vm86_regs regs; + unsigned long flags; + unsigned long screen_bitmap; + unsigned long cpu_type; + struct revectored_struct int_revectored; + struct revectored_struct int21_revectored; +}; + +/* + * flags masks + */ +#define VM86_SCREEN_BITMAP 0x0001 + +#ifdef __KERNEL__ + +void handle_vm86_fault(struct vm86_regs *, long); +void handle_vm86_debug(struct vm86_regs *, long); + +#endif + +#endif + +__BEGIN_DECLS + +extern vm86(struct vm86_struct * __info); + +__END_DECLS + +#endif /*_SYS_VM86_H */ + +#endif diff --git a/libc/include/msdos/errno.h b/libc/include/msdos/errno.h new file mode 100644 index 0000000..39107eb --- /dev/null +++ b/libc/include/msdos/errno.h @@ -0,0 +1,46 @@ +#ifndef __MSDOS_ERRNO_H +#define __MSDOS_ERRNO_H + +#define EPERM 1 /* Operation not permitted */ +#define ENOENT 2 /* No such file or directory */ +#define ESRCH 3 /* No such process */ +#define EINTR 4 /* Interrupted system call */ +#define EIO 5 /* I/O error */ +#define ENXIO 6 /* No such device or address */ +#define E2BIG 7 /* Arg list too long */ +#define ENOEXEC 8 /* Exec format error */ +#define EBADF 9 /* Bad file number */ +#define ECHILD 10 /* No child processes */ +#define EAGAIN 11 /* Try again */ +#define ENOMEM 12 /* Out of memory */ +#define EACCES 13 /* Permission denied */ +#define EFAULT 14 /* Bad address */ +#define ENOTBLK 15 /* Block device required */ +#define EBUSY 16 /* Device or resource busy */ +#define EEXIST 17 /* File exists */ +#define EXDEV 18 /* Cross-device link */ +#define ENODEV 19 /* No such device */ +#define ENOTDIR 20 /* Not a directory */ +#define EISDIR 21 /* Is a directory */ +#define EINVAL 22 /* Invalid argument */ +#define ENFILE 23 /* File table overflow */ +#define EMFILE 24 /* Too many open files */ +#define ENOTTY 25 /* Not a typewriter */ +#define ETXTBSY 26 /* Text file busy */ +#define EFBIG 27 /* File too large */ +#define ENOSPC 28 /* No space left on device */ +#define ESPIPE 29 /* Illegal seek */ +#define EROFS 30 /* Read-only file system */ +#define EMLINK 31 /* Too many links */ +#define EPIPE 32 /* Broken pipe */ +#define EDOM 33 /* Math argument out of domain of func */ +#define ERANGE 34 /* Math result not representable */ +#define EDEADLK 35 /* Resource deadlock would occur */ +#define ENAMETOOLONG 36 /* File name too long */ +#define ENOLCK 37 /* No record locks available */ +#define ENOSYS 38 /* Function not implemented */ +#define ENOTEMPTY 39 /* Directory not empty */ +#define ELOOP 40 /* Too many symbolic links encountered */ +#define EWOULDBLOCK EAGAIN /* Operation would block */ + +#endif diff --git a/libc/include/msdos/fcntl.h b/libc/include/msdos/fcntl.h new file mode 100644 index 0000000..8cf076c --- /dev/null +++ b/libc/include/msdos/fcntl.h @@ -0,0 +1,24 @@ +#ifndef __MSDOS_FCNTL_H +#define __MSDOS_FCNTL_H + +/* Definitions taken from the i386 Linux kernel. */ + +#define O_ACCMODE 0003 +#define O_RDONLY 00 +#define O_WRONLY 01 +#define O_RDWR 02 +#define O_CREAT 0100 /* not fcntl */ +#define O_EXCL 0200 /* not fcntl */ +#define O_TRUNC 01000 /* not fcntl */ +#define O_APPEND 02000 + +#define F_DUPFD 0 /* dup */ +#define F_GETFD 1 /* get f_flags */ +#define F_SETFD 2 /* set f_flags */ +#define F_GETFL 3 /* more flags (cloexec) */ +#define F_SETFL 4 +#define F_GETLK 5 +#define F_SETLK 6 +#define F_SETLKW 7 + +#endif diff --git a/libc/include/msdos/types.h b/libc/include/msdos/types.h new file mode 100644 index 0000000..b6628bd --- /dev/null +++ b/libc/include/msdos/types.h @@ -0,0 +1,22 @@ + +/* arch/i86/include/asm/types.h - Basic Linux/MT data types. */ + +#ifndef __MSDOS_TYPES +#define __MSDOS_TYPES + +#include + +typedef __u32 off_t; +typedef __u32 time_t; +typedef __u16 mode_t; +typedef __u32 loff_t; +typedef __u32 speed_t; + +typedef __u32 tcflag_t; +typedef __u8 cc_t; +typedef __u16 size_t; + +typedef int ptrdiff_t; + +#endif + diff --git a/libc/include/signal.h b/libc/include/signal.h index 1d54fc3..b40d926 100644 --- a/libc/include/signal.h +++ b/libc/include/signal.h @@ -79,7 +79,9 @@ struct sigaction { }; /* BSDisms */ +#ifdef BSD extern __const char * __const sys_siglist[]; #define sig_t __sighandler_t +#endif #endif diff --git a/libc/include/stddef.h b/libc/include/stddef.h index ce3cf2b..f26997a 100644 --- a/libc/include/stddef.h +++ b/libc/include/stddef.h @@ -4,25 +4,13 @@ */ /* We don't care, ignore GCC's __need hackery */ -#undef __need_wchar_t -#undef __need_size_t -#undef __need_ptrdiff_t -#undef __need_NULL - -/* Fact is these are _normal_ */ -#if 1 /* __BCC__ */ /* Only for Bcc 8086/80386 */ - #ifndef __STDDEF_H #define __STDDEF_H -#ifndef _SIZE_T -#define _SIZE_T -typedef unsigned int size_t; -#endif +#include #ifndef NULL #define NULL 0 #endif #endif /* __STDDEF_H */ -#endif /* __AS386_16__ */ diff --git a/libc/include/sys/errno.h b/libc/include/sys/errno.h index 339f4fc..a7b7d7b 100644 --- a/libc/include/sys/errno.h +++ b/libc/include/sys/errno.h @@ -1 +1,25 @@ -#include +#ifndef __ERRNO_H +#define __ERRNO_H + +#include +#include __SYSINC__(errno.h) + +#ifdef __USE_BSD +extern int sys_nerr; +extern char *sys_errlist[]; +#endif +#ifdef __USE_GNU +extern int _sys_nerr; +extern char *_sys_errlist[]; +#endif + +extern int errno; + +__BEGIN_DECLS + +extern void perror __P ((__const char* __s)); +extern char* strerror __P ((int __errno)); + +__END_DECLS + +#endif diff --git a/libc/include/sys/ioctl.h b/libc/include/sys/ioctl.h index 55e5882..198d578 100644 --- a/libc/include/sys/ioctl.h +++ b/libc/include/sys/ioctl.h @@ -2,7 +2,7 @@ #ifndef _SYS_IOCTL_H #define _SYS_IOCTL_H #include -#include +#include __SYSINC__(ioctl.h) extern int ioctl __P((int __fildes, int __cmd, ...)); diff --git a/libc/include/sys/mman.h b/libc/include/sys/mman.h index e69de29..abdb413 100644 --- a/libc/include/sys/mman.h +++ b/libc/include/sys/mman.h @@ -0,0 +1,6 @@ + +#ifndef __SYS_MMAN_H +#define __SYS_MMAN_H +#include +#include __SYSINC__(mman.h) +#endif diff --git a/libc/include/sys/resource.h b/libc/include/sys/resource.h index 19ed06f..41b932c 100644 --- a/libc/include/sys/resource.h +++ b/libc/include/sys/resource.h @@ -1,73 +1,6 @@ -/* - * Resource control/accounting header file for linux-86 - */ - -#ifndef _SYS_RESOURCE_H -#define _SYS_RESOURCE_H +#ifndef __SYS_RESOURCE_H +#define __SYS_RESOURCE_H #include -#include -#include - -#define RUSAGE_SELF 0 -#define RUSAGE_CHILDREN (-1) -#define RUSAGE_BOTH (-2) /* sys_wait4() uses this */ - -struct rusage { - struct timeval ru_utime; /* user time used */ - struct timeval ru_stime; /* system time used */ - long ru_maxrss; /* maximum resident set size */ - long ru_ixrss; /* integral shared memory size */ - long ru_idrss; /* integral unshared data size */ - long ru_isrss; /* integral unshared stack size */ - long ru_minflt; /* page reclaims */ - long ru_majflt; /* page faults */ - long ru_nswap; /* swaps */ - long ru_inblock; /* block input operations */ - long ru_oublock; /* block output operations */ - long ru_msgsnd; /* messages sent */ - long ru_msgrcv; /* messages received */ - long ru_nsignals; /* signals received */ - long ru_nvcsw; /* voluntary context switches */ - long ru_nivcsw; /* involuntary " */ -}; - -#define RLIM_INFINITY ((long)(~0UL>>1)) - -struct rlimit { - long rlim_cur; - long rlim_max; -}; - -#define PRIO_MIN (-20) -#define PRIO_MAX 20 - -#define PRIO_PROCESS 0 -#define PRIO_PGRP 1 -#define PRIO_USER 2 - -#define RLIMIT_CPU 0 /* CPU time in ms */ -#define RLIMIT_FSIZE 1 /* Maximum filesize */ -#define RLIMIT_DATA 2 /* max data size */ -#define RLIMIT_STACK 3 /* max stack size */ -#define RLIMIT_CORE 4 /* max core file size */ -#define RLIMIT_RSS 5 /* max resident set size */ -#define RLIMIT_NPROC 6 /* max number of processes */ -#define RLIMIT_NOFILE 7 /* max number of open files */ -#define RLIMIT_MEMLOCK 8 /* max locked-in-memory address space */ - -#define RLIM_NLIMITS 9 - -extern int getrlimit __P ((int __resource, - struct rlimit *__rlp)); -extern int setrlimit __P ((int __resource, - __const struct rlimit *__rlp)); - -extern int getpriority __P((int __which, int __who)); -extern int setpriority __P((int __which, int __who, - int __prio)); - -extern int __getrusage __P ((int __who, struct rusage *__rusage)); -extern int getrusage __P ((int __who, struct rusage *__rusage)); - -#endif /* _SYS_RESOURCE_H */ +#include __SYSINC__(resource.h) +#endif diff --git a/libc/include/sys/socket.h b/libc/include/sys/socket.h new file mode 100644 index 0000000..0029f72 --- /dev/null +++ b/libc/include/sys/socket.h @@ -0,0 +1,6 @@ + +#ifndef __SYS_SOCKET_H +#define __SYS_SOCKET_H +#include +#include __SYSINC__(socket.h) +#endif diff --git a/libc/include/sys/stat.h b/libc/include/sys/stat.h index b1cf558..7e468f3 100644 --- a/libc/include/sys/stat.h +++ b/libc/include/sys/stat.h @@ -1,57 +1,9 @@ #ifndef _SYS_STAT_H #define _SYS_STAT_H -#include -#include #include - -#ifdef __AS386_32__ -/* This is for Linux-386, ho hum, I wish BCC could compile the proper one */ -#define mknod __dv32_mknod -#define stat __dv32_stat -#define lstat __dv32_lstat -#define fstat __dv32_fstat - -struct stat { - dev_t st_dev; - unsigned short __pad1; - ino_t st_ino; - umode_t st_mode; - nlink_t st_nlink; - uid_t st_uid; - gid_t st_gid; - dev_t st_rdev; - unsigned short __pad2; - off_t st_size; - unsigned long st_blksize; - unsigned long st_blocks; - time_t st_atime; - unsigned long __unused1; - time_t st_mtime; - unsigned long __unused2; - time_t st_ctime; - unsigned long __unused3; - unsigned long __unused4; - unsigned long __unused5; -}; -#endif - -#ifdef __AS386_16__ -struct stat -{ - dev_t st_dev; - ino_t st_ino; - mode_t st_mode; - nlink_t st_nlink; - uid_t st_uid; - gid_t st_gid; - dev_t st_rdev; - off_t st_size; - time_t st_atime; - time_t st_mtime; - time_t st_ctime; -}; -#endif +#include +#include __SYSINC__(stat.h) int stat __P((__const char * __path, struct stat * __statbuf)); int lstat __P((__const char * __path, struct stat * __statbuf)); diff --git a/libc/include/sys/types.h b/libc/include/sys/types.h index 7b7de09..273b56b 100644 --- a/libc/include/sys/types.h +++ b/libc/include/sys/types.h @@ -1,2 +1,3 @@ +#include #include -#include +#include __SYSINC__(types.h) diff --git a/libc/include/sys/utsname.h b/libc/include/sys/utsname.h index 0cbc37f..6244ace 100644 --- a/libc/include/sys/utsname.h +++ b/libc/include/sys/utsname.h @@ -3,16 +3,6 @@ #include #include - -struct utsname { - char sysname[65]; - char nodename[65]; - char release[65]; - char version[65]; - char machine[65]; - char domainname[65]; -}; - -extern int uname __P ((struct utsname * __utsbuf)); +#include __SYSINC__(utsname.h) #endif diff --git a/libc/include/sys/vm86.h b/libc/include/sys/vm86.h index 851814e..15ac6cd 100644 --- a/libc/include/sys/vm86.h +++ b/libc/include/sys/vm86.h @@ -1,125 +1,5 @@ -#if !__AS386_16__ - -#ifndef _SYS_VM86_H -#define _SYS_VM86_H - +#ifndef __SYS_VM86_H +#define __SYS_VM86_H #include -#ifndef _LINUX_VM86_H -#define _LINUX_VM86_H - -/* - * I'm guessing at the VIF/VIP flag usage, but hope that this is how - * the Pentium uses them. Linux will return from vm86 mode when both - * VIF and VIP is set. - * - * On a Pentium, we could probably optimize the virtual flags directly - * in the eflags register instead of doing it "by hand" in vflags... - * - * Linus - */ - -#define TF_MASK 0x00000100 -#define IF_MASK 0x00000200 -#define IOPL_MASK 0x00003000 -#define NT_MASK 0x00004000 -#define VM_MASK 0x00020000 -#define AC_MASK 0x00040000 -#define VIF_MASK 0x00080000 /* virtual interrupt flag */ -#define VIP_MASK 0x00100000 /* virtual interrupt pending */ -#define ID_MASK 0x00200000 - -#define BIOSSEG 0x0f000 - -#define CPU_086 0 -#define CPU_186 1 -#define CPU_286 2 -#define CPU_386 3 -#define CPU_486 4 -#define CPU_586 5 - -/* - * Return values for the 'vm86()' system call - */ -#define VM86_TYPE(retval) ((retval) & 0xff) -#define VM86_ARG(retval) ((retval) >> 8) - -#define VM86_SIGNAL 0 /* return due to signal */ -#define VM86_UNKNOWN 1 /* unhandled GP fault - IO-instruction or similar */ -#define VM86_INTx 2 /* int3/int x instruction (ARG = x) */ -#define VM86_STI 3 /* sti/popf/iret instruction enabled virtual interrupts */ - -/* - * This is the stack-layout when we have done a "SAVE_ALL" from vm86 - * mode - the main change is that the old segment descriptors aren't - * useful any more and are forced to be zero by the kernel (and the - * hardware when a trap occurs), and the real segment descriptors are - * at the end of the structure. Look at ptrace.h to see the "normal" - * setup. - */ - -struct vm86_regs { -/* - * normal regs, with special meaning for the segment descriptors.. - */ - long ebx; - long ecx; - long edx; - long esi; - long edi; - long ebp; - long eax; - long __null_ds; - long __null_es; - long __null_fs; - long __null_gs; - long orig_eax; - long eip; - unsigned short cs, __csh; - long eflags; - long esp; - unsigned short ss, __ssh; -/* - * these are specific to v86 mode: - */ - unsigned short es, __esh; - unsigned short ds, __dsh; - unsigned short fs, __fsh; - unsigned short gs, __gsh; -}; - -struct revectored_struct { - unsigned long __map[8]; /* 256 bits */ -}; - -struct vm86_struct { - struct vm86_regs regs; - unsigned long flags; - unsigned long screen_bitmap; - unsigned long cpu_type; - struct revectored_struct int_revectored; - struct revectored_struct int21_revectored; -}; - -/* - * flags masks - */ -#define VM86_SCREEN_BITMAP 0x0001 - -#ifdef __KERNEL__ - -void handle_vm86_fault(struct vm86_regs *, long); -void handle_vm86_debug(struct vm86_regs *, long); - -#endif - -#endif - -__BEGIN_DECLS - -extern vm86(struct vm86_struct * __info); - -__END_DECLS - -#endif /*_SYS_VM86_H */ - +#include __SYSINC__(vm86.h) #endif diff --git a/libc/include/termios.h b/libc/include/termios.h index 604e654..b2d0cc6 100644 --- a/libc/include/termios.h +++ b/libc/include/termios.h @@ -3,7 +3,7 @@ #include #include -#include +#include __SYSINC__(termios.h) extern speed_t cfgetispeed __P ((struct termios *__termios_p)); extern speed_t cfgetospeed __P ((struct termios *__termios_p)); diff --git a/libc/include/unistd.h b/libc/include/unistd.h index c96f710..99faccc 100644 --- a/libc/include/unistd.h +++ b/libc/include/unistd.h @@ -32,6 +32,8 @@ extern char* crypt __P((__const char *__key, __const char *__salt)); #define F_OK 0 /* Test for existence. */ #endif +#define _POSIX_VDISABLE '\0' + #endif /* __UNISTD_H */ diff --git a/libc/kinclude/Config b/libc/kinclude/Config index f3d064f..6c9970d 100644 --- a/libc/kinclude/Config +++ b/libc/kinclude/Config @@ -1 +1 @@ -kinc: The kernel include files +kinc: Example kernel include files diff --git a/libc/kinclude/Makefile b/libc/kinclude/Makefile index aa4ef72..7722d68 100644 --- a/libc/kinclude/Makefile +++ b/libc/kinclude/Makefile @@ -6,16 +6,11 @@ all: @: transfer: - -@rm -f ../include/linuxmt + -@rm -f ../include/linuxmt ../include/arch ln -s ../kinclude/linuxmt ../include + ln -s ../kinclude/arch ../include @touch Used -# This is for use once linuxmt's syscall interface really gets working. -# beware the arch directory must be removed when you do this. -real_transfer: - -@rm -f ../include/linuxmt - cd ../include ; ln -s ../../linuxmt/include/linuxmt . - clean: - -@rm -f ../include/linuxmt + -@rm -f ../include/linuxmt ../include/arch -@rm -f Used diff --git a/libc/kinclude/arch/errno.h b/libc/kinclude/arch/errno.h index ee3fcab..8cee74b 100644 --- a/libc/kinclude/arch/errno.h +++ b/libc/kinclude/arch/errno.h @@ -1,5 +1,5 @@ -#ifndef _I86_ERRNO_H -#define _I86_ERRNO_H +#ifndef __ARCH_ERRNO_H +#define __ARCH_ERRNO_H #define EPERM 1 /* Operation not permitted */ #define ENOENT 2 /* No such file or directory */ diff --git a/libc/kinclude/arch/stat.h b/libc/kinclude/arch/stat.h new file mode 100644 index 0000000..fd77f62 --- /dev/null +++ b/libc/kinclude/arch/stat.h @@ -0,0 +1,19 @@ + +#ifndef _ARCH_STAT_H +#define _ARCH_STAT_H + +struct stat +{ + dev_t st_dev; + ino_t st_ino; + mode_t st_mode; + nlink_t st_nlink; + uid_t st_uid; + gid_t st_gid; + dev_t st_rdev; + off_t st_size; + time_t st_atime; + time_t st_mtime; + time_t st_ctime; +}; +#endif diff --git a/libc/kinclude/arch/types.h b/libc/kinclude/arch/types.h index 00afeed..f59faf6 100644 --- a/libc/kinclude/arch/types.h +++ b/libc/kinclude/arch/types.h @@ -2,33 +2,9 @@ #ifndef __LINUXMT_8086_TYPES #define __LINUXMT_8086_TYPES - -/* First we define all of the __u and __s types...*/ - -typedef unsigned char __u8; -typedef unsigned char * __pu8; -typedef char __s8; -typedef char * __ps8; - -typedef unsigned short __u16; -typedef unsigned short * __pu16; -typedef short __s16; -typedef short * __ps16; - -typedef unsigned long __u32; -typedef unsigned long * __pu32; -typedef long __s32; -typedef long * __ps32; - -/* __uint == 16bit here */ - -typedef unsigned int __uint; -typedef int __sint; -typedef unsigned int * __puint; -typedef int * __psint; - -/* Then we define registers, etc... */ +#include + struct _registers { __u16 ksp, sp, ss, ax, bx, cx, dx, di, si, ds, es, bp, ip, cs, flags; }; diff --git a/libc/kinclude/linuxmt/resource.h b/libc/kinclude/linuxmt/resource.h new file mode 100644 index 0000000..061570a --- /dev/null +++ b/libc/kinclude/linuxmt/resource.h @@ -0,0 +1,73 @@ +/* + * Resource control/accounting header file for linux-86 + */ + +#ifndef __LINUXMT_RESOURCE_H +#define __LINUXMT_RESOURCE_H + +#include +#include +#include + +#define RUSAGE_SELF 0 +#define RUSAGE_CHILDREN (-1) +#define RUSAGE_BOTH (-2) /* sys_wait4() uses this */ + +struct rusage { + struct timeval ru_utime; /* user time used */ + struct timeval ru_stime; /* system time used */ + long ru_maxrss; /* maximum resident set size */ + long ru_ixrss; /* integral shared memory size */ + long ru_idrss; /* integral unshared data size */ + long ru_isrss; /* integral unshared stack size */ + long ru_minflt; /* page reclaims */ + long ru_majflt; /* page faults */ + long ru_nswap; /* swaps */ + long ru_inblock; /* block input operations */ + long ru_oublock; /* block output operations */ + long ru_msgsnd; /* messages sent */ + long ru_msgrcv; /* messages received */ + long ru_nsignals; /* signals received */ + long ru_nvcsw; /* voluntary context switches */ + long ru_nivcsw; /* involuntary " */ +}; + +#define RLIM_INFINITY ((long)(~0UL>>1)) + +struct rlimit { + long rlim_cur; + long rlim_max; +}; + +#define PRIO_MIN (-20) +#define PRIO_MAX 20 + +#define PRIO_PROCESS 0 +#define PRIO_PGRP 1 +#define PRIO_USER 2 + +#define RLIMIT_CPU 0 /* CPU time in ms */ +#define RLIMIT_FSIZE 1 /* Maximum filesize */ +#define RLIMIT_DATA 2 /* max data size */ +#define RLIMIT_STACK 3 /* max stack size */ +#define RLIMIT_CORE 4 /* max core file size */ +#define RLIMIT_RSS 5 /* max resident set size */ +#define RLIMIT_NPROC 6 /* max number of processes */ +#define RLIMIT_NOFILE 7 /* max number of open files */ +#define RLIMIT_MEMLOCK 8 /* max locked-in-memory address space */ + +#define RLIM_NLIMITS 9 + +extern int getrlimit __P ((int __resource, + struct rlimit *__rlp)); +extern int setrlimit __P ((int __resource, + __const struct rlimit *__rlp)); + +extern int getpriority __P((int __which, int __who)); +extern int setpriority __P((int __which, int __who, + int __prio)); + +extern int __getrusage __P ((int __who, struct rusage *__rusage)); +extern int getrusage __P ((int __who, struct rusage *__rusage)); + +#endif /* __LINUXMT_RESOURCE_H */ diff --git a/libc/kinclude/linuxmt/stat.h b/libc/kinclude/linuxmt/stat.h index 9fbd191..a600583 100644 --- a/libc/kinclude/linuxmt/stat.h +++ b/libc/kinclude/linuxmt/stat.h @@ -1,11 +1,7 @@ #ifndef __LINUXMT_STAT_H #define __LINUXMT_STAT_H -#ifdef __KERNEL__ - -#include "../arch/stat.h" - -#endif +#include #define S_IFMT 00170000 #ifdef __LINUXMT_NETWORK__ diff --git a/libc/kinclude/linuxmt/types.h b/libc/kinclude/linuxmt/types.h index 8e5236a..3d32320 100644 --- a/libc/kinclude/linuxmt/types.h +++ b/libc/kinclude/linuxmt/types.h @@ -1,16 +1,7 @@ #ifndef __LINUXMT_TYPES_H #define __LINUXMT_TYPES_H -#include "../arch/types.h" - -/* Throw away _FUNCTION parameters - the syntax is ripped off of Minix's - _PROTOTYPE. Considering Borland did the same thing to MFC on a bigger - scale, I don't think PH will mind :) */ - -/* Yes, this should be in arch/types.h too */ - -#define _FUNCTION(function, params) function() -#define _VFUNCTION(functiom, params) (*function) () +#include typedef __u32 off_t; typedef __u16 pid_t; @@ -22,6 +13,7 @@ typedef __u16 nlink_t; typedef __u16 mode_t; typedef __u32 loff_t; typedef __u32 speed_t; +typedef __u16 size_t; typedef __u16 dev_t; typedef __uint ino_t; diff --git a/libc/misc/Makefile b/libc/misc/Makefile index 56fe043..50d31b7 100644 --- a/libc/misc/Makefile +++ b/libc/misc/Makefile @@ -14,9 +14,12 @@ GOBJ=atoi.o atol.o ltoa.o ltostr.o \ UOBJ=getenv.o putenv.o popen.o system.o setenv.o getcwd.o +SSRC=syslib.c +SOBJ=time.o abort.o wait.o wait3.o waitpid.o killpg.o setpgrp.o sleep.o \ + usleep.o mkfifo.o ifeq ($(LIB_OS),ELKS) -OBJ=$(MOBJ) $(EOBJ) $(GOBJ) $(UOBJ) +OBJ=$(MOBJ) $(EOBJ) $(GOBJ) $(UOBJ) $(SOBJ) else OBJ=$(MOBJ) $(EOBJ) $(GOBJ) endif @@ -41,6 +44,10 @@ $(LIBC)($(EOBJ)): $(ESRC) $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o $(AR) $(ARFLAGS) $@ $*.o +$(LIBC)($(SOBJ)): $(SSRC) + $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o + $(AR) $(ARFLAGS) $@ $*.o + clean: rm -f *.o libc.a diff --git a/libc/misc/syslib.c b/libc/misc/syslib.c new file mode 100644 index 0000000..3aa5963 --- /dev/null +++ b/libc/misc/syslib.c @@ -0,0 +1,181 @@ +/* Copyright (C) 1995,1996 Robert de Bath + * This file is part of the Linux-8086 C library and is distributed + * under the GNU Library General Public License. + */ + +#include +#include +#include +#include +#include +#include + +/* This only for the various unix version */ +#ifdef __unix__ + +/********************** Function time ************************************/ + +#ifdef L_time +time_t time(where) +time_t *where; +{ + struct timeval rv; + if( gettimeofday(&rv, (void*)0) < 0 ) return -1; + if(where) *where = rv.tv_sec; + return rv.tv_sec; +} +#endif + +/********************** Function abort ************************************/ + +#ifdef L_abort + +int abort() +{ + signal(SIGABRT, SIG_DFL); + kill(SIGABRT, getpid()); /* Correct one */ + pause(); /* System may just schedule */ + signal(SIGKILL, SIG_DFL); + kill(SIGKILL, getpid()); /* Can't trap this! */ + __exit(255); /* WHAT!! */ +} +#endif + +/********************** Function wait ************************************/ + +#ifdef L_wait +int +wait(status) +int * status; +{ + return wait4(-1, status, 0, (void*)0); +} +#endif + +/********************** Function wait3 **************************************/ + +#ifdef L_wait3 +int +wait3(status, opts, usage) +int * status; +int opts; +struct rusage * usage; +{ + return wait4(-1, status, opts, usage); +} +#endif + +/********************** Function waitpid ************************************/ + +#ifdef L_waitpid +int +waitpid(pid, status, opts) +int pid; +int * status; +int opts; +{ + return wait4(pid, status, opts, (void*)0); +} +#endif + +/********************** Function killpg ************************************/ + +#ifdef L_killpg +int +killpg(pid, sig) +int pid; +int sig; +{ + if(pid == 0) + pid = getpgrp(); + if(pid > 1) + return kill(-pid, sig); + errno = EINVAL; + return -1; +} +#endif + +/********************** Function setpgrp ************************************/ + +#ifdef L_setpgrp +int +setpgrp() +{ + return setpgid(0,0); +} +#endif + +/********************** Function sleep ************************************/ + +#ifdef L_sleep + +#ifdef __ELKS__ +/* This uses SIGALRM, it does keep the previous alarm call but will lose + * any alarms that go off during the sleep + */ + +static void alrm() { } + +unsigned int sleep(seconds) +unsigned int seconds; +{ + void (*last_alarm)(); + unsigned int prev_sec; + + prev_sec = alarm(0); + if( prev_sec <= seconds ) prev_sec = 1; else prev_sec -= seconds; + + last_alarm = signal(SIGALRM, alrm); + alarm(seconds); + pause(); + seconds = alarm(prev_sec); + signal(SIGALRM, last_alarm); + return seconds; +} + +#else + /* Is this a better way ? If we have select of course :-) */ +unsigned int +sleep(seconds) +unsigned int seconds; +{ + struct timeval timeout; + time_t start = time((void*)0); + timeout.tv_sec = seconds; + timeout.tv_usec = 0; + select(1, NULL, NULL, NULL, &timeout); + return seconds - (time((void*)0) - start); +} +#endif + +#endif + +/********************** Function usleep ************************************/ + +#ifdef L_usleep +void +usleep(useconds) +unsigned long useconds; +{ + struct timeval timeout; + timeout.tv_sec = useconds%1000000L; + timeout.tv_usec = useconds/1000000L; + select(1, NULL, NULL, NULL, &timeout); +} +#endif + +/********************** Function mkfifo ************************************/ + +#ifdef L_mkfifo +int +mkfifo(path, mode) +char * path; +int mode; +{ + return mknod(path, mode | S_IFIFO, 0); +} +#endif + +/********************** THE END ********************************************/ + +#endif /* __unix__ */ diff --git a/libc/stdio2/stdio.c b/libc/stdio2/stdio.c index 210c41f..4bada7e 100644 --- a/libc/stdio2/stdio.c +++ b/libc/stdio2/stdio.c @@ -107,7 +107,8 @@ __io_init_vars() #ifndef __AS386_16__ #ifndef __AS386_32__ static int first_time = 1; - if( !first_time ) return ; first_time = 1; + if( !first_time ) return ; + first_time = 0; #endif #endif if (isatty(1)) @@ -182,6 +183,10 @@ FILE *fp; /* Nothing in the buffer - fill it up */ if (fp->bufpos >= fp->bufread) { + /* Bind stdin to stdout if it's open and line buffered */ + if( fp == stdin && stdout->fd >= 0 && (stdout->mode & _IOLBF )) + fflush(stdout); + fp->bufpos = fp->bufread = fp->bufstart; ch = fread(fp->bufpos, 1, fp->bufend - fp->bufstart, fp); if (ch == 0) @@ -244,7 +249,7 @@ FILE *fp; bstart+=cc; len-=cc; } } - while ( cc>0 || (cc == -1 && errno == EINTR)); + while ( len>0 && (cc>0 || (cc == -1 && errno == EINTR))); /* * If we get here with len!=0 there was an error, exactly what to * do about it is another matter ... diff --git a/libc/syscall/Makefile b/libc/syscall/Makefile index a064c3f..07b1428 100644 --- a/libc/syscall/Makefile +++ b/libc/syscall/Makefile @@ -2,12 +2,8 @@ # This file is part of the Linux-8086 C library and is distributed # under the GNU Library General Public License. -LSRC=syslibc.c -LOBJ=time.o abort.o wait.o waitpid.o wait3.o killpg.o setpgrp.o sleep.o \ - usleep.o - -LSRC0=syslib0.c -LOBJ0=__cstartup.o lseek.o getpid.o getppid.o getuid.o geteuid.o getgid.o \ +LSRC=syslib0.c +LOBJ=__cstartup.o lseek.o getpid.o getppid.o getuid.o geteuid.o getgid.o \ getegid.o dup2.o dup.o getpgrp.o times.o ESRC=exec.c @@ -17,7 +13,7 @@ DSRC=dirent.c DOBJ=opendir.o closedir.o readdir.o ifeq ($(LIB_CPU)-$(LIB_OS),i86-ELKS) -OBJ=$(LOBJ0) $(LOBJ) $(DOBJ) $(EOBJ) signal.o setjmp.o +OBJ=$(LOBJ) $(LOBJ) $(DOBJ) $(EOBJ) signal.o setjmp.o SYSCALLS=call_i86 endif @@ -50,10 +46,6 @@ $(LIBC)($(EOBJ)): $(ESRC) $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o $(AR) $(ARFLAGS) $@ $*.o -$(LIBC)($(LOBJ0)): $(LSRC0) - $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o - $(AR) $(ARFLAGS) $@ $*.o - clean: rm -f *.o libc.a rm -f syscall.c syscall.mak diff --git a/libc/syscall/TODO b/libc/syscall/TODO index b178a96..f396897 100644 --- a/libc/syscall/TODO +++ b/libc/syscall/TODO @@ -3,3 +3,128 @@ semaphores. Idea, for RPC syscall, seperate all the FD related calls from the system ones IIRC all the single FD related ones have the FD in arg0 + +-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +Subject: 8086 Shared Libs and local RPC. + +True shared libs are impossible with the 8086 in small model. +BUT we can use RPC type links to provide a similar system. + +Client side +----------- + +shl_open("socket", 0x81); + Open the shared lib called '/lib/socket.shl' on irq 0x81 + + The kernel starts the server daemon from /lib and binds it to the interrupt. + + If the server is already loaded and has flag 'Multi_access' it will not + be reloaded; note the daemon can be loaded by init or similar. + + The binding may be global or process specific depending on if we are + running in real mode or protected and the options the server starts + with. If the interrupt is busy or the program cannot be run an error + is returned. + + Note also the server has the option to reject the connection even if the + kernel is happy. + + If the server does a shl_open() on itself it is registering a request to + be known on the given interrupt by any process without prior registration. + +int + The must be the interrupt previously accepted by the kernel. + The registers AX,BX,CX,DX,DI,SI are passed to the server in the + structure for shl_accept in the vars: rtype, arg1, ... arg5. + Also the DS register is saved for access by the server. + If the server has died or doesn't respond after a (long) timeout an error + should be returned. + Note: A server that is not present may be respawned if it's stateless. + + Note this is _very_ similar to the system call interrupt and it's possible + the system call server can be a model for a multi-threaded server. + +Server side +----------- + +shl_register("socket", flags); + + Flags: + Multi_access: Server can accept accesses from multiple clients. + Stateless: If server dies it can be restarted in some manner + without the clients being aware. + Non-block: Calls to shl_accept do not block, return error. + + Another possibility is to register to a device (major/minor pair) + when a client attempts to access this device messages the open + syscall is passed to the server like the syscalls for fds opened + by shl_popen(). The server can then do a shl_popen to allow the + client access to a channel. + + This has the advantage that the client doesn't need to know anything + special about the server. + +shl_accept(struct shl_message *); + A client has just made an INT call. + + If pid == 0 this is a shl_open request passed via the kernel, arg1 is + pid, arg2 is euid and arg3 is the egid. The reply will be the return + from the shl_open syscall. + +struct shl_message { + int pid; + int rtype; /* AX register */ + int arg1, arg2, arg3, arg4, arg5; /* BX,CX,DX,DI,SI registers */ + int dseg; /* DS register */ +} + buffer; Structure for 'accept' and 'reply' calls. + +shl_reply(struct shl_message *); + The rtype, arg1..3 values are copied back to the registers in the calling + program. + +shl_notify(int flag); + Allow asychronus notification of the arrival of shl_accept requests. + Perhaps a signal, SIGURG ? + The flag could be a ms time between signals while there are pending items. + (0=none, -1=1 per item, >0=time) + (If this used fds this could be done via select but as we ain't got it ...) + +shl_popen(int pid); + Open a file descriptor on the given process, return the FD number. + + THIS WILL ONLY WORK IF THE PROCESS IS CURRENTLY WAITING FOR A REPLY. + + This FD when accessed will send messages to the server process, + + These messages will be identical in form to the normal messages + except that the value 0x8000 will be ored with the syscall number + in AX. + + Beware also the semantics of fork and exec which can give a server + FD to a process that either knows nothing about the server or will + later register with the server in it's own right. + + (This will probably need a 'dup3(fd, oldpid, newpid)' style call) + +shl_force(struct shl_message *); + This forces the remote process to execute a syscall + + THIS WILL ONLY WORK IF THE PROCESS IS CURRENTLY WAITING FOR A REPLY. + + This would be useful for: shl_open("minix", 0x20); or if an error + causes a forced closure of an FD. + +shl_copy(int io, char * localbuf, int pid, char * remotebuf); + Copies data between the address space of the client process and the + server. (Could be shl_read and shl_write) + + THIS WILL ONLY WORK IF THE PROCESS IS CURRENTLY WAITING FOR A REPLY. + + On Linux-8086 this will just be a far memcpy, in protected mode the + segment descriptor will have to be setup, either specially or previously. + + This will be complicated slightly by the problem that a multi-threaded + server may have many clients waiting at the same time. + + Also the kernel is able to change the segment that a given program resides. diff --git a/libc/syscall/syslibc.c b/libc/syscall/syslibc.c deleted file mode 100644 index 3486ef6..0000000 --- a/libc/syscall/syslibc.c +++ /dev/null @@ -1,168 +0,0 @@ -/* Copyright (C) 1995,1996 Robert de Bath - * This file is part of the Linux-8086 C library and is distributed - * under the GNU Library General Public License. - */ - -#include -#include -#include - -/* MSDOS has it's own versions */ -#ifndef __MSDOS__ - -/********************** Function time ************************************/ - -#ifdef L_time -time_t time(where) -time_t *where; -{ - struct timeval rv; - if( gettimeofday(&rv, (void*)0) < 0 ) return -1; - if(where) *where = rv.tv_sec; - return rv.tv_sec; -} -#endif - -/********************** Function abort ************************************/ - -#ifdef L_abort -#include - -int abort() -{ - signal(SIGABRT, SIG_DFL); - kill(SIGABRT, getpid()); /* Correct one */ - pause(); /* System may just schedule */ - signal(SIGKILL, SIG_DFL); - kill(SIGKILL, getpid()); /* Can't trap this! */ - __exit(255); /* WHAT!! */ -} -#endif - -/********************** Function wait ************************************/ - -#ifdef L_wait -int -wait(status) -int * status; -{ - return wait4(-1, status, 0, (void*)0); -} -#endif - -/********************** Function wait3 **************************************/ - -#ifdef L_wait3 -int -wait3(status, opts, usage) -int * status; -int opts; -struct rusage * usage; -{ - return wait4(-1, status, opts, usage); -} -#endif - -/********************** Function waitpid ************************************/ - -#ifdef L_waitpid -int -waitpid(pid, status, opts) -int pid; -int * status; -int opts; -{ - return wait4(pid, status, opts, (void*)0); -} -#endif - -/********************** Function killpg ************************************/ - -#ifdef L_killpg -int -killpg(pid, sig) -int pid; -int sig; -{ - if(pid == 0) - pid = getpgrp(); - if(pid > 1) - return kill(-pid, sig); - errno = EINVAL; - return -1; -} -#endif - -/********************** Function setpgrp ************************************/ - -#ifdef L_setpgrp -int -setpgrp() -{ - return setpgid(0,0); -} -#endif - -/********************** Function sleep ************************************/ - -#ifdef L_sleep -#include - -/* This uses SIGALRM, it does keep the previous alarm call but will lose - * any alarms that go off during the sleep - */ - -static void alrm() { } - -unsigned int sleep(seconds) -unsigned int seconds; -{ - void (*last_alarm)(); - unsigned int prev_sec; - - prev_sec = alarm(0); - if( prev_sec <= seconds ) prev_sec = 1; else prev_sec -= seconds; - - last_alarm = signal(SIGALRM, alrm); - alarm(seconds); - pause(); - seconds = alarm(prev_sec); - signal(SIGALRM, last_alarm); - return seconds; -} -#if 0 - /* Is this a better way ? If we have select of course :-) */ -#include -unsigned int -sleep(seconds) -unsigned int seconds; -{ - struct timeval timeout; - time_t start = time((void*)0); - timeout.tv_sec = seconds; - timeout.tv_usec = 0; - select(1, NULL, NULL, NULL, &timeout); - return seconds - (time((void*)0) - start); -} -#endif - -#endif - -/********************** Function usleep ************************************/ - -#ifdef L_usleep -#include -void -usleep(useconds) -unsigned long useconds; -{ - struct timeval timeout; - timeout.tv_sec = useconds%1000000L; - timeout.tv_usec = useconds/1000000L; - select(1, NULL, NULL, NULL, &timeout); -} -#endif - -/********************** THE END ********************************************/ - -#endif /* __MSDOS__ */ -- cgit v1.2.1