From ec5f28e3f1400b5dacb88eda2d9db472a20b4349 Mon Sep 17 00:00:00 2001 From: Robert de Bath Date: Wed, 1 Jul 1998 01:00:00 +0200 Subject: Import Dev86src-0.14.3.tar.gz --- libc/Makefile | 6 +- libc/i386fp/README | 5 - libc/kinclude/arch/errno.h | 4 +- libc/kinclude/arch/ioctl.h | 6 +- libc/kinclude/arch/stat.h | 9 +- libc/kinclude/arch/types.h | 4 +- libc/kinclude/linuxmt/errno.h | 2 +- libc/kinclude/linuxmt/ioctl.h | 2 +- libc/misc/qsort.c | 18 ++- libc/msdos/Makefile | 9 +- libc/msdos/TODO | 1 + libc/msdos/conio.c | 23 +++ libc/msdos/dirent.c | 8 + libc/msdos/dosound.c | 10 ++ libc/msdos/msdos.c | 96 ++++++++++-- libc/msdos/mslib.c | 333 ++++++++++++++++++++++++++++++++++++++++++ libc/msdos/new86.c | 69 +++++++++ libc/syscall/syslib0.c | 5 +- libc/termios/ttyname.c | 4 +- 19 files changed, 572 insertions(+), 42 deletions(-) delete mode 100644 libc/i386fp/README create mode 100644 libc/msdos/TODO create mode 100644 libc/msdos/conio.c create mode 100644 libc/msdos/dirent.c create mode 100644 libc/msdos/dosound.c create mode 100644 libc/msdos/mslib.c create mode 100644 libc/msdos/new86.c (limited to 'libc') diff --git a/libc/Makefile b/libc/Makefile index f437a0c..0494400 100644 --- a/libc/Makefile +++ b/libc/Makefile @@ -11,7 +11,7 @@ endif VERMAJOR=0 VERMINOR=14 -VERPATCH=0 +VERPATCH=3 VER=$(VERMAJOR).$(VERMINOR).$(VERPATCH) CC=bcc @@ -76,10 +76,12 @@ clean: ############################################################################ install_incl: - rm -rf $(BCCHOME)/include + # rm -rf $(BCCHOME)/include + rm -rf $(BCCHOME)/include/linuxmt $(BCCHOME)/include/arch cp -pr include $(BCCHOME)/include if [ -f kinclude/Used ] ; \ then cp -pr kinclude/arch $(BCCHOME)/include/arch ; \ + cp -pr kinclude/linuxmt $(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 ; \ diff --git a/libc/i386fp/README b/libc/i386fp/README deleted file mode 100644 index bb49fe4..0000000 --- a/libc/i386fp/README +++ /dev/null @@ -1,5 +0,0 @@ -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/kinclude/arch/errno.h b/libc/kinclude/arch/errno.h index 8cee74b..0a8f840 100644 --- a/libc/kinclude/arch/errno.h +++ b/libc/kinclude/arch/errno.h @@ -1,5 +1,5 @@ -#ifndef __ARCH_ERRNO_H -#define __ARCH_ERRNO_H +#ifndef __ARCH_8086_ERRNO_H +#define __ARCH_8086_ERRNO_H #define EPERM 1 /* Operation not permitted */ #define ENOENT 2 /* No such file or directory */ diff --git a/libc/kinclude/arch/ioctl.h b/libc/kinclude/arch/ioctl.h index 55b276b..0e4459f 100644 --- a/libc/kinclude/arch/ioctl.h +++ b/libc/kinclude/arch/ioctl.h @@ -2,8 +2,8 @@ * Nothing here yet. */ -#ifndef _ASMI86_IOCTL_H -#define _ASMI86_IOCTL_H +#ifndef __ARCH_8086_IOCTL_H +#define __ARCH_8086_IOCTL_H -#endif /* _ASMI86_IOCTL_H */ +#endif /* __ARCH_8086_IOCTL_H */ diff --git a/libc/kinclude/arch/stat.h b/libc/kinclude/arch/stat.h index fd77f62..98d77e1 100644 --- a/libc/kinclude/arch/stat.h +++ b/libc/kinclude/arch/stat.h @@ -1,9 +1,7 @@ +#ifndef __ARCH_8086_STAT_H +#define __ARCH_8086_STAT_H -#ifndef _ARCH_STAT_H -#define _ARCH_STAT_H - -struct stat -{ +struct stat { dev_t st_dev; ino_t st_ino; mode_t st_mode; @@ -16,4 +14,5 @@ struct stat time_t st_mtime; time_t st_ctime; }; + #endif diff --git a/libc/kinclude/arch/types.h b/libc/kinclude/arch/types.h index f59faf6..1f766a5 100644 --- a/libc/kinclude/arch/types.h +++ b/libc/kinclude/arch/types.h @@ -1,7 +1,7 @@ /* arch/i86/include/asm/types.h - Basic Linux/MT data types. */ -#ifndef __LINUXMT_8086_TYPES -#define __LINUXMT_8086_TYPES +#ifndef __ARCH_8086_TYPES +#define __ARCH_8086_TYPES #include diff --git a/libc/kinclude/linuxmt/errno.h b/libc/kinclude/linuxmt/errno.h index b4c07a3..691fd47 100644 --- a/libc/kinclude/linuxmt/errno.h +++ b/libc/kinclude/linuxmt/errno.h @@ -1 +1 @@ -#include "../arch/errno.h" +#include diff --git a/libc/kinclude/linuxmt/ioctl.h b/libc/kinclude/linuxmt/ioctl.h index 20f5ac6..ce1136a 100644 --- a/libc/kinclude/linuxmt/ioctl.h +++ b/libc/kinclude/linuxmt/ioctl.h @@ -1 +1 @@ -#include "../arch/ioctl.h" +#include diff --git a/libc/misc/qsort.c b/libc/misc/qsort.c index cee53c3..a4a98b7 100644 --- a/libc/misc/qsort.c +++ b/libc/misc/qsort.c @@ -7,6 +7,12 @@ * dal@syntel.UUCP United States of America * "It's not reality that's important, but how you perceive things." */ + +/* + * Sun Feb 8 21:02:15 EST 1998 claudio@pos.inf.ufpr.br (Claudio Matsuoka) + * Changed sort direction + */ + #include char *_qbuf = 0; /* pointer to storage for qsort() */ @@ -35,10 +41,10 @@ register int (*cmp) (); base[i] = *p; while (i < j) { - while (((*cmp) ((base + j), p)) > 0) + while (((*cmp) ((base + j), p)) <= 0) --j; base[i] = base[j]; - while ((i < j) && (((*cmp) ((base + i), p)) <= 0)) + while ((i < j) && (((*cmp) ((base + i), p)) > 0)) ++i; base[j] = base[i]; } @@ -77,10 +83,10 @@ register int (*cmp) (); base[i] = *p; while (i < j) { - while (((*cmp) ((base + j), p)) > 0) + while (((*cmp) ((base + j), p)) <= 0) --j; base[i] = base[j]; - while ((i < j) && (((*cmp) ((base + i), p)) <= 0)) + while ((i < j) && (((*cmp) ((base + i), p)) > 0)) ++i; base[j] = base[i]; } @@ -120,10 +126,10 @@ register int (*cmp) (); p = _qbuf; while (i < j) { - while (((*cmp) ((base + size * j), p)) > 0) + while (((*cmp) ((base + size * j), p)) <= 0) --j; moveitem((base + size * i), (base + size * j), size); - while ((i < j) && (((*cmp) ((base + size * i), p)) <= 0)) + while ((i < j) && (((*cmp) ((base + size * i), p)) > 0)) ++i; moveitem((base + size * j), (base + size * i), size); } diff --git a/libc/msdos/Makefile b/libc/msdos/Makefile index d4bc49a..06d999a 100644 --- a/libc/msdos/Makefile +++ b/libc/msdos/Makefile @@ -3,10 +3,11 @@ # under the GNU Library General Public License. ASRC=msdos.c -AOBJ= dos_start.o __mkargv.o __mkenvp.o dos__fconv.o dos_read.o \ - dos_write.o dos_open.o dos_close.o dos_unlink.o dos_lseek.o \ - dos_segalloc.o dos_segfree.o dos_setvect.o dos_getvect.o \ - dos_isatty.o dos_getmod.o dos_stat.o +AOBJ= \ + dos_start.o __exterror.o __mkargv.o __mkenvp.o bdos.o \ + dos__fconv.o dos_abort.o dos_close.o dos_getmod.o dos_getvect.o \ + dos_isatty.o dos_lseek.o dos_open.o dos_read.o dos_segalloc.o \ + dos_segfree.o dos_setvect.o dos_stat.o dos_unlink.o dos_write.o BSRC=i86.c BOBJ= __seg_regs.o __peek_es.o __poke_es.o __deek_es.o __doke_es.o \ diff --git a/libc/msdos/TODO b/libc/msdos/TODO new file mode 100644 index 0000000..7d3eb12 --- /dev/null +++ b/libc/msdos/TODO @@ -0,0 +1 @@ +#define remove(x) unlink(x) diff --git a/libc/msdos/conio.c b/libc/msdos/conio.c new file mode 100644 index 0000000..3c51c92 --- /dev/null +++ b/libc/msdos/conio.c @@ -0,0 +1,23 @@ +/* Is this BIOS keyboard io ? */ + +cgets() + +cputs() + +getch() + +getche() + +cprintf() + +cscanf() + +getpass() + +gotoxy() + +kbhit() + +putch() + + diff --git a/libc/msdos/dirent.c b/libc/msdos/dirent.c new file mode 100644 index 0000000..00d774e --- /dev/null +++ b/libc/msdos/dirent.c @@ -0,0 +1,8 @@ + +opendir + +closedir + +readdir + +rewinddir diff --git a/libc/msdos/dosound.c b/libc/msdos/dosound.c new file mode 100644 index 0000000..80f49d6 --- /dev/null +++ b/libc/msdos/dosound.c @@ -0,0 +1,10 @@ + + +nosound() +{ +} + +sound(freq) +int freq +{ +} diff --git a/libc/msdos/msdos.c b/libc/msdos/msdos.c index 2d23374..99e8835 100644 --- a/libc/msdos/msdos.c +++ b/libc/msdos/msdos.c @@ -11,6 +11,7 @@ #include #include int errno; +unsigned _doserrno; #ifdef L_dos_start @@ -279,6 +280,52 @@ static char buf1[66], buf2[66], *str = 0; } #endif +#ifdef L___exterror + +static char errno_xlate[] = { + 0, EINVAL, ENOENT, ENOENT, EMFILE, EACCES, EBADF, EFAULT, ENOMEM, + EFAULT, ENOMEM, EINVAL, EINVAL, EINVAL, EINVAL, ENODEV, EPERM, EXDEV, + ENFILE, EROFS, ENODEV, ENXIO, EINVAL, EIO, EINVAL, ESPIPE, EIO, EIO, + EAGAIN, EIO, EIO, EIO, EBUSY, EBUSY, ENODEV, EFAULT, ENOLCK, EFAULT, + EFAULT, ENOSPC +}; + +__exterror() +{ +#asm +export exterror +exterror: + push ds + push es + push di + push si + push bp + xor bx,bx + mov ah,#$59 + int $21 + pop bp + pop si + pop di + pop es + pop ds + mov __doserrno,ax +#endasm + { + int nerrno; + extern unsigned _doserrno; + + if( _doserrno == 0 ) + /* No error? No change. */; + else if( _doserrno >= sizeof(errno_xlate) + || errno_xlate[_doserrno] == EFAULT ) + errno = 16384+_doserrno; + else + errno = errno_xlate[_doserrno]; + } + return -1; +} +#endif + #ifdef L_dos_read int read(fd, ptr, len) @@ -294,7 +341,7 @@ unsigned len; mov ah,#$3f int #$21 jnc readok - mov ax,#-1 + br exterror readok: #endasm } @@ -315,7 +362,7 @@ unsigned len; mov ah,#$40 int #$21 jnc writeok - mov ax,#-1 + br exterror writeok: #endasm } @@ -342,7 +389,6 @@ int cmode; else /* Warn, this assumes the standard vals for O_RDWR, O_RDONLY, O_WRONLY */ rv = __dos_open(nname, type&O_ACCMODE); - if( rv < 0 ) errno=ENOENT; return rv; } @@ -355,7 +401,7 @@ __dos_open(fname, mode) mov ah,#$3d ;ask for a open int #$21 jnc openok ;return handle if no error - mov ax,#-1 ;return -1 if error + br exterror openok: #endasm } @@ -370,7 +416,7 @@ char * fname; mov ah,#$3c ;ask for a create int #$21 jnc creok ;return handle if no error - mov ax,#-1 ;return -1 if error + br exterror creok: #endasm } @@ -386,7 +432,7 @@ close(fd) int #$21 mov ax,0 ;return 0 if no error jnc closeok - mov ax,#-1 ;return -1 if error + br exterror closeok: #endasm } @@ -407,7 +453,7 @@ char * fname; int #$21 mov ax,0 ;assume no errors jnc unlok - mov ax,#-1 ;return -1 if error + br exterror unlok: #endasm } @@ -428,7 +474,7 @@ long offset; mov ah,#$42 int #$21 ;do the lseek jnc seekok - mov ax,#-1 ;return -1 if error + call exterror mov dx,ax seekok: #endasm @@ -527,7 +573,7 @@ __dos_getmod(fname) mov ax,#$4300 int #$21 jnc statok - mov cx,#-1 + br exterror statok: mov ax,cx #endasm @@ -588,6 +634,38 @@ not_tty: } #endif +#ifdef L_dos_abort +abort() +{ + write(2, "Abnormal program termination\r\n", 30); + _exit(3); +} +#endif + +#ifdef L_bdos +bdos(dosfn, dosdx, dosal) +int dosfn; +unsigned dosdx, dosal; +{ +#asm +_bdosptr = _bdos + mov bx,sp + push si + push di + + mov dx,_bdos.dosdx[bx] + mov cx,_bdos.dosfn[bx] + mov ax,_bdos.dosal[bx] + mov ah,cl + + int $21 + + pop di + pop si +#endasm +} +#endif + #endif /* __MSDOS__ */ #endif /* __AS386_16__ */ #endif /* !__FIRST_ARG_IN_AX__ */ diff --git a/libc/msdos/mslib.c b/libc/msdos/mslib.c new file mode 100644 index 0000000..c1dfb30 --- /dev/null +++ b/libc/msdos/mslib.c @@ -0,0 +1,333 @@ +/* Copyright (C) 1998 Robert de Bath + * This file is part of the Linux-8086 C library and is distributed + * under the GNU Library General Public License. + */ + +#if !__FIRST_ARG_IN_AX__ +#ifdef __AS386_16__ +#ifdef __MSDOS__ + +#include +#include +#include +int errno; + +#ifdef L_dos_chdir +chdir(path) +char * path; +{ +#asm + mov bx,sp + mov bx,_chdir.path[bx] + cmp [bx+1],': + jnz do_chdir + mov dl,[bx] + and dl,#$3F + dec dl + mov ah,#$0E + int $21 +do_chdir: + mov ah,#$3B + mov dx,bx +do_dxop: + int $21 + jnc op_ok + br exterror +op_ok: + xor ax,ax +#endasm +} +#endif + +#ifdef L_mkdir +mkdir(path) +char * path; +{ +#asm + mov bx,sp + mov dx,_mkdir.path[bx] + mov ah,#$39 + j do_dxop +#endasm +} +#endif + +#ifdef L_rmdir +rmdir(path) +char * path; +{ +#asm + mov bx,sp + mov dx,_rmdir.path[bx] + mov ah,#$3A + j do_dxop +#endasm +} +#endif + +#ifdef L_unlink +unlink(path) +char * path; +{ +#asm + mov bx,sp + mov dx,_unlink.path[bx] + mov ah,#$41 + xor cx,cx ! Attrib 0 for servers. + j do_dxop +#endasm +} +#endif + +#ifdef L_dos_access +access(filename, amode) +char * filename; +int amode; +{ + XXX; +} +#endif + +#ifdef L__dos_allocmem +_dos_allocmem(size + +} +#endif + +#ifdef L__chmod +_chmod(path, func, attrib) +char * path; +int func, attrib; +{ + XXX; +} +#endif + +#ifdef L_chmod +chmod(path, mode) +char * path; +int mode; +{ + XXX; +} +#endif + +#ifdef L_clock +clock_t clock() +{ + XXX; +} +#endif + +#ifdef L_ctrlbrk +ctrlbrk(func) +int (*func)(); +{ + XXX; +} +#endif + +#ifdef L_delay +delay(millis) +unsigned millis; +{ + XXX; +} +#endif + +#ifdef L_dosexterr +dosexterr(ptr) +struct DOSERROR * ptr; +{ + XXX; +} +#endif + +/* +#ifdef __dos_getdiskfree +*/ + +#ifdef L_dup +dup(fd) +int fd; +{ + XXX; +} +#endif + +#ifdef L_dup2 +dup2(ofd, nfd) +int ofd, nfd; +{ + XXX; +} +#endif + +#ifdef L_filelength +long +filelength(fd) +int fd; +{ + XXX; +} +#endif + +#ifdef L_findfirst +findfirst(path, fcb, attrib) +char * path; +void * fcb; +int attrib; +{ + XXX; +} +#endif + +#ifdef L_findnext +findnext(fcb) +void * fcb; +{ + XXX; +} +#endif + +#ifdef L_stat +stat(path, st) +char * path; +struct stat * st; +{ + XXX; +} +#endif + +#ifdef L_fstat +fstat(fd, st) +int fd; +struct stat * st; +{ + XXX; +} +#endif + +#ifdef L_getcbrk +getcbrk() +{ + XXX int 0x21/33; +} +#endif + +#ifdef L_setcbrk +setcbrk(mode) +int mode; +{ + XXX int 0x21/33; +} +#endif + +#ifdef L_getcwd +getcwd(buf, buflen) +char * buf; +int buflen; +{ + XXX; +} +#endif + +#ifdef L__getdrive +_getdrive() +{ + XXX; +} +#endif + +#ifdef L_getenv +char * +getenv(varname) +char * varname; +{ + XXX; +} +#endif + +#ifdef L_putenv +putenv(varname) +char * varname; +{ + XXX; +} +#endif + +#ifdef L_getpid +getpid() +{ + XXX; +} +#endif + +#ifdef L_int86 + XXX; +#endif + +#ifdef L_int86x + XXX; +#endif + +#ifdef L_rename +rename(oldname, newpath) +char *oldpath, *newpath; +{ + XXX; +} +#endif + +#ifdef L_segread +segread(segp) +struct SREGS * segp; +{ + XXX; +} +#endif + +#ifdef L_setmode +setmode(fd, amode) +int fd, amode; +{ + XXX; +} +#endif + +#ifdef L_sleep +sleep(secs) +unsigned secs; +{ + XXX; +} +#endif + +#ifdef L_system +system(cmd) +char * cmd; +{ + XXX; +} +#endif + +#ifdef L_umask +umask(mode) +int mode; +{ + XXX; +} +#endif + +#ifdef L_utime +utime(path, times) +char * path; +stuct utimbuf * times; +{ + XXX; +} +#endif + +#endif /* __MSDOS__ */ +#endif /* __AS386_16__ */ +#endif /* !__FIRST_ARG_IN_AX__ */ diff --git a/libc/msdos/new86.c b/libc/msdos/new86.c new file mode 100644 index 0000000..cc139bb --- /dev/null +++ b/libc/msdos/new86.c @@ -0,0 +1,69 @@ + +#define disable() _disable() +#define enable() _enable() + +_enable() +{ +#asm + sti +#endasm +} + +_disable() +{ +#asm + cli +#endasm +} + +geninterrupt(intr) +int intr; +{ +} + +inp(portno) +int portno; +{ +} + +inpw(portno) +int portno; +{ +} + +outp( +{ +} + +outpw( +{ +} + +peek(segment, offset) +unsigned segment, offset; +{ +} + +peekb(segment, offset) +unsigned segment, offset; +{ +} + +poke(segment, offset, value) +unsigned segment, offset, value; +{ +} + +pokeb(segment, offset, value) +unsigned segment, offset, value; +{ +} + + + + + + + + + diff --git a/libc/syscall/syslib0.c b/libc/syscall/syslib0.c index 1a92179..24fdbf0 100644 --- a/libc/syscall/syslib0.c +++ b/libc/syscall/syslib0.c @@ -22,7 +22,7 @@ char ** environ; #asm loc 2 call_main: - .word _main ! Segment 2 is the trailing pointers, main and the + .word run_main ! Segment 2 is the trailing pointers, main and the .word call_exit ! routine to call exit. #if __FIRST_ARG_IN_AX__ .data @@ -71,6 +71,9 @@ no_entry: inc bx jmp auto_run ! And round for the next. +run_main: + br _main + call_exit: ! Last item called by above. pop bx ! Be tidy. #if !__FIRST_ARG_IN_AX__ diff --git a/libc/termios/ttyname.c b/libc/termios/ttyname.c index d777ab3..5993a2a 100644 --- a/libc/termios/ttyname.c +++ b/libc/termios/ttyname.c @@ -11,7 +11,7 @@ int fd; struct stat st, dst; DIR *fp; struct dirent *d; - static char name[MAXNAMLEN]; + static char name[16]; /* should be MAXNAMLEN but that's overkill */ int noerr = errno; if (fstat(fd, &st) < 0) @@ -30,6 +30,8 @@ int fd; while ((d = readdir(fp)) != 0) { + if( strlen(d->d_name) > sizeof(name) - sizeof(dev) - 1); + continue; strcpy(name + sizeof(dev), d->d_name); if (stat(name, &dst) == 0 && st.st_dev == dst.st_dev && st.st_ino == dst.st_ino) -- cgit v1.2.1