summaryrefslogtreecommitdiff
path: root/libc
diff options
context:
space:
mode:
authorRobert de Bath <rdebath@poboxes.com>2002-01-12 20:42:42 +0100
committerLubomir Rintel <lkundrak@v3.sk>2013-10-23 23:48:46 +0200
commitd91fa39567f5659e3931cf61517d62fddcd87570 (patch)
tree20583acd4f345a4f5c9a7772870ef972cb8a3b14 /libc
parentbff547eabb6678ec8e71ffbcfbf9a4f05c94d949 (diff)
downloaddev86-d91fa39567f5659e3931cf61517d62fddcd87570.tar.gz
Import Dev86src-0.16.1.tar.gzv0.16.1
Diffstat (limited to 'libc')
-rw-r--r--libc/Config.dflt1
-rw-r--r--libc/Makefile2
-rw-r--r--libc/bios/bios.c22
-rw-r--r--libc/bios/cprintf.c132
-rw-r--r--libc/conio/Config1
-rw-r--r--libc/conio/Makefile36
-rw-r--r--libc/conio/conio.c (renamed from libc/msdos/conio.c)28
-rw-r--r--libc/conio/cprintf.c221
-rw-r--r--libc/include/conio.h26
-rw-r--r--libc/syscall/syscall.dev8626
-rw-r--r--libc/syscall/syscall.dev86.old160
11 files changed, 502 insertions, 153 deletions
diff --git a/libc/Config.dflt b/libc/Config.dflt
index 1927f1e..5056bf7 100644
--- a/libc/Config.dflt
+++ b/libc/Config.dflt
@@ -1,5 +1,6 @@
bcc:+:
bios:+:
+conio:+:
error:+:
getent:+:
gtermcap:+:
diff --git a/libc/Makefile b/libc/Makefile
index 21c3a30..6d6c5bb 100644
--- a/libc/Makefile
+++ b/libc/Makefile
@@ -11,7 +11,7 @@ endif
VERMAJOR=0
VERMINOR=16
-VERPATCH=0
+VERPATCH=1
VER=$(VERMAJOR).$(VERMINOR).$(VERPATCH)
CC=bcc
diff --git a/libc/bios/bios.c b/libc/bios/bios.c
index 402f689..e0e5c23 100644
--- a/libc/bios/bios.c
+++ b/libc/bios/bios.c
@@ -33,12 +33,22 @@ loop_save:
.text
export ___cstartup ! Crt0 startup
___cstartup:
- mov ___argr+0,ax
- mov ___argr+2,bx
- mov ___argr+4,cx
- mov ___argr+6,dx
- mov ___argr+8,si
- mov ___argr+10,di
+ cli
+ mov sp,cs
+ add sp,#__segoff
+ mov ds,sp
+ mov ss,sp
+ mov sp,#___argr+12
+ push di
+ push si
+ push dx
+ push cx
+ push bx
+ push ax
+ xor bp,bp
+ mov sp,bp
+ push bp
+ sti
zap_bss: ! Clear the BSS
mov ax,ds
diff --git a/libc/bios/cprintf.c b/libc/bios/cprintf.c
deleted file mode 100644
index cd5f62b..0000000
--- a/libc/bios/cprintf.c
+++ /dev/null
@@ -1,132 +0,0 @@
-
-#include <stdarg.h>
-#define wchar(ch) putch(ch)
-
-cprintf(char * fmt, va_list ap)
-{
- register int c;
- int count = 0;
- int type, base;
- long val;
- char * cp;
- char padch=' ';
- int minsize = 0;
-
- while(c=*fmt++)
- {
- if(c!='%')
- {
- wchar(c);
- count++;
- }
- else
- {
- type=1;
- do { c=*fmt++; } while( c>='0' && c<='9');
-
- padch = *fmt;
- minsize=0;
- if(padch == '-') fmt++;
-
- for(;;)
- {
- c=*fmt++;
- if( c<'0' || c>'9' ) break;
- minsize*=10; minsize+=c-'0';
- }
-
- while( c=='.' || (c>='0' && c<='9')) { c=*fmt++; }
-
- if( padch == '-' ) minsize = -minsize;
- else
- if( padch == '0' ) padch='0'; else padch=' ';
-
- if( c == 0 ) break;
- if(c=='h')
- {
- c=*fmt++;
- type = 0;
- }
- else if(c=='l')
- {
- c=*fmt++;
- type = 2;
- }
-
- switch(c)
- {
- case 'x': base=16; type|=4; if(0) {
- case 'o': base= 8; type|=4; } if(0) {
- case 'u': base=10; type|=4; } if(0) {
- case 'd': base=10; }
- val=0;
- switch(type)
- {
- case 0: val=va_arg(ap, short); break;
- case 1: val=va_arg(ap, int); break;
- case 2: val=va_arg(ap, long); break;
- case 4: val=va_arg(ap, unsigned short); break;
- case 5: val=va_arg(ap, unsigned int); break;
- case 6: val=va_arg(ap, unsigned long); break;
- }
- cp = __numout(val,base);
- if(0) {
- case 's':
- cp=va_arg(ap, char *);
- }
- if( minsize > 0 )
- {
- minsize -= strlen(cp);
- while(minsize>0) { wchar(padch); minsize--; }
- minsize=0;
- }
- if( minsize < 0 ) minsize= -minsize-strlen(cp);
- while(*cp)
- wchar(*cp++);
- while(minsize>0) { wchar(' '); minsize--; }
- break;
- case 'c':
- wchar(va_arg(ap, int));
- break;
- default:
- wchar(c);
- break;
- }
- }
- }
- return count;
-}
-
-
-
-static char nstring[]="0123456789ABCDEF";
-
-static unsigned char *
-__numout(long i, int base)
-{
- static unsigned char out[16];
- int n;
- int flg = 0;
- unsigned long val;
-
- if (i<0 && base==10)
- {
- flg = 1;
- i = -i;
- }
- val = i;
-
- for (n = 0; n < 15; n++)
- out[n] = ' ';
- out[15] = '\0';
- n = 14;
- do
- {
- out[n] = nstring[val % base];
- n--;
- val /= base;
- }
- while(val);
- if(flg) out[n--] = '-';
- return &out[n+1];
-}
diff --git a/libc/conio/Config b/libc/conio/Config
new file mode 100644
index 0000000..76765c8
--- /dev/null
+++ b/libc/conio/Config
@@ -0,0 +1 @@
+conio: Console io functions for BIOS and DOS.
diff --git a/libc/conio/Makefile b/libc/conio/Makefile
new file mode 100644
index 0000000..bd86b2c
--- /dev/null
+++ b/libc/conio/Makefile
@@ -0,0 +1,36 @@
+# Copyright (C) 1996 Robert de Bath <robert@mayday.compulink.co.uk>
+# This file is part of the Linux-8086 C library and is distributed
+# under the GNU Library General Public License.
+
+ASRC=conio.c
+AOBJ=getch.o getche.o kbhit.o putch.o cputs.o
+
+OBJ=$(AOBJ) cprintf.o
+
+CFLAGS=$(ARCH) $(CCFLAGS) $(DEFS)
+
+ifeq ($(LIB_CPU)-$(LIB_OS),i86-BIOS)
+all: $(LIBC)($(OBJ))
+ @$(RM) $(OBJ)
+else
+ifeq ($(LIB_CPU)-$(LIB_OS),i86-DOS)
+all: $(LIBC)($(OBJ))
+ @$(RM) $(OBJ)
+else
+all:
+ @:
+endif
+endif
+
+$(LIBC)($(AOBJ)): $(ASRC)
+ $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o
+ $(AR) $(ARFLAGS) $@ $*.o
+
+$(LIBC)(cprintf.o): cprintf.c
+ $(CC) -c -ansi $(ARCH) $(CCFLAGS) $(DEFS) $*.c
+ $(AR) $(ARFLAGS) $@ $*.o
+
+
+
+clean:
+ rm -f *.o libc.a
diff --git a/libc/msdos/conio.c b/libc/conio/conio.c
index f6f9105..c0e9cbb 100644
--- a/libc/msdos/conio.c
+++ b/libc/conio/conio.c
@@ -3,11 +3,17 @@
* under the GNU Library General Public License.
*/
+#include <conio.h>
+
/*
* I'm not sure if these should be BIOS or dos calls, so I'll assume they're
* BIOS calls but I may have to do something about Ctrl-C.
+ *
+ * These functions are also compiled for __STANDALONE__ so if ^C or DOS
+ * versions are made this will have to be addressed.
*/
+#ifdef L_getch
getch()
{
#asm
@@ -15,14 +21,18 @@ getch()
int $16
#endasm
}
+#endif
+#ifdef L_getche
getche()
{
int i = getch();
- if( i & 0xFF) putch(i);
+ if( i & 0xFF ) putch(i);
return i;
}
+#endif
+#ifdef L_kbhit
kbhit()
{
#asm
@@ -38,7 +48,9 @@ nokey:
xor ax,ax
#endasm
}
+#endif
+#ifdef L_putch
putch()
{
#asm
@@ -46,17 +58,27 @@ putch()
mov bx,sp
mov ax,[bx+2]
#endif
+ cmp al,#$0A
+ jne not_nl
+ mov ax,#$0E0D
+ mov bx,#7
+ int $10
+ mov al,#$0A
+not_nl:
mov ah,#$0E
mov bx,#7
int $10
#endasm
}
+#endif
+#ifdef L_cputs
cputs(str)
char * str;
{
while(*str) putch(*str++);
}
+#endif
#if 0
@@ -64,10 +86,6 @@ cgets()
{
}
-cprintf()
-{
-}
-
cscanf()
{
}
diff --git a/libc/conio/cprintf.c b/libc/conio/cprintf.c
new file mode 100644
index 0000000..4bc3bac
--- /dev/null
+++ b/libc/conio/cprintf.c
@@ -0,0 +1,221 @@
+#include <stdarg.h>
+#include <conio.h>
+
+static unsigned char * __numout(long i, int base);
+
+int cprintf(char * fmt, ...)
+{
+ register int c;
+ int count = 0;
+ int type, base;
+ long val;
+ char * cp;
+ char padch=' ';
+ int minsize, maxsize;
+ va_list ap;
+
+ va_start(ap, fmt);
+
+ while(c=*fmt++)
+ {
+ count++;
+ if(c!='%')
+ putch(c);
+ else
+ {
+ type=1;
+ padch = *fmt;
+ maxsize=minsize=0;
+ if(padch == '-') fmt++;
+
+ for(;;)
+ {
+ c=*fmt++;
+ if( c<'0' || c>'9' ) break;
+ minsize*=10; minsize+=c-'0';
+ }
+
+ if( c == '.' )
+ for(;;)
+ {
+ c=*fmt++;
+ if( c<'0' || c>'9' ) break;
+ maxsize*=10; maxsize+=c-'0';
+ }
+
+ if( padch == '-' ) minsize = -minsize;
+ else
+ if( padch != '0' ) padch=' ';
+
+ if( c == 0 ) break;
+ if(c=='h')
+ {
+ c=*fmt++;
+ type = 0;
+ }
+ else if(c=='l')
+ {
+ c=*fmt++;
+ type = 2;
+ }
+
+ switch(c)
+ {
+ case 'x': base=16; type |= 4; if(0) {
+ case 'o': base= 8; type |= 4; } if(0) {
+ case 'u': base=10; type |= 4; } if(0) {
+ case 'd': base=-10; }
+ switch(type)
+ {
+ case 0: val=va_arg(ap, short); break;
+ case 1: val=va_arg(ap, int); break;
+ case 2: val=va_arg(ap, long); break;
+ case 4: val=va_arg(ap, unsigned short); break;
+ case 5: val=va_arg(ap, unsigned int); break;
+ case 6: val=va_arg(ap, unsigned long); break;
+ default:val=0; break;
+ }
+ cp = __numout(val,base);
+ if(0) {
+ case 's':
+ cp=va_arg(ap, char *);
+ }
+ count--;
+ c = strlen(cp);
+ if( !maxsize ) maxsize = c;
+ if( minsize > 0 )
+ {
+ minsize -= c;
+ while(minsize>0) { putch(padch); count++; minsize--; }
+ minsize=0;
+ }
+ if( minsize < 0 ) minsize= -minsize-c;
+ while(*cp && maxsize-->0 )
+ {
+ putch(*cp++);
+ count++;
+ }
+ while(minsize>0) { putch(' '); count++; minsize--; }
+ break;
+ case 'c':
+ putch(va_arg(ap, int));
+ break;
+ default:
+ putch(c);
+ break;
+ }
+ }
+ }
+ va_end(ap);
+ return count;
+}
+
+static char nstring[]="0123456789ABCDEF";
+
+#ifndef __AS386_16__
+#define NUMLTH 11
+
+static unsigned char *
+__numout(long i, int base)
+{
+ static unsigned char out[NUMLTH+1];
+ int n;
+ int flg = 0;
+ unsigned long val;
+
+ if (base<0)
+ {
+ base = -base;
+ if (i<0)
+ {
+ flg = 1;
+ i = -i;
+ }
+ }
+ val = i;
+
+ out[NUMLTH] = '\0';
+ n = NUMLTH-1;
+ do
+ {
+ out[n--] = nstring[val % base];
+ val /= base;
+ }
+ while(val);
+ if(flg) out[n--] = '-';
+ return &out[n+1];
+}
+
+#else
+
+#asm
+! numout.s
+!
+.bss
+___out lcomm $C
+
+.text
+___numout:
+push bp
+mov bp,sp
+push di
+push si
+add sp,*-4
+mov byte ptr -8[bp],*$0 ! flg = 0
+mov si,4[bp] ; i or val.lo
+mov di,6[bp] ; i or val.hi
+mov cx,8[bp] ; base
+test cx,cx ! base < 0 ?
+jge .3num
+neg cx ! base = -base
+or di,di ! i < 0 ?
+jns .5num
+mov byte ptr -8[bp],*1 ! flg = 1
+neg di ! i = -i
+neg si
+sbb di,0
+.5num:
+.3num:
+mov byte ptr [___out+$B],*$0 ! out[11] = nul
+mov -6[bp],*$A ! n = 10
+
+.9num:
+!!! out[n--] = nstring[val % base];
+xor dx,dx
+xchg ax,di
+div cx
+xchg ax,di
+xchg ax,si
+div cx
+xchg ax,si ! val(new) = val / base
+
+mov bx,dx ! dx = val % base
+
+mov al,_nstring[bx]
+mov bx,-6[bp]
+dec word ptr -6[bp]
+mov ___out[bx],al
+
+mov ax,si
+or ax,di ! while (val)
+jne .9num
+
+cmp byte ptr -8[bp],*$0 ! flg == 0 ?
+je .Dnum
+
+mov bx,-6[bp]
+dec word ptr -6[bp]
+mov byte ptr ___out[bx],*$2D ! out[n--] = minus
+
+.Dnum:
+mov ax,-6[bp]
+add ax,#___out+1
+
+add sp,*4
+pop si
+pop di
+pop bp
+ret
+#endasm
+
+#endif
diff --git a/libc/include/conio.h b/libc/include/conio.h
new file mode 100644
index 0000000..7219a8f
--- /dev/null
+++ b/libc/include/conio.h
@@ -0,0 +1,26 @@
+
+#ifndef __CONIO_H
+#define __CONIO_H
+#include <features.h>
+
+int cprintf __P((char *, ...));
+int cputs __P((char *));
+int getch __P((void));
+int getche __P((void));
+int kbhit __P((void));
+int putch __P((int));
+
+#if 0 /* Unimplemented as yet */
+char * cgets __P((char *));
+int ungetch __P((int));
+int cscanf __P((char *, ...));
+#endif
+
+#if 0 /* Hummm */
+unsigned outpw __P((unsigned int, unsigned int));
+unsigned inpw __P((unsigned int));
+int outp __P((unsigned int, int));
+int inp __P((unsigned int));
+#endif
+
+#endif
diff --git a/libc/syscall/syscall.dev86 b/libc/syscall/syscall.dev86
index 29e7b5e..2c5384c 100644
--- a/libc/syscall/syscall.dev86
+++ b/libc/syscall/syscall.dev86
@@ -47,25 +47,25 @@ ptrace 26 4 @ adb/sdb/dbx need this.
alarm 27 2
fstat +28 2
pause 29 0
-utime 30 2
+utime +30 2
chroot +31 1
-vfork 32 0
+vfork +32 0
access +33 2
nice 34 1
sleep 35 1
sync +36 0
-kill 37 2
+kill +37 2
rename +38 2
mkdir +39 2
rmdir +40 1
dup +41 1 . There is a fcntl lib function too.
-pipe 42 1
+pipe +42 1
times 43 2 * 2nd arg is pointer for long ret val.
profil 44 4 @
dup2 +45 2
setgid +46 1
getgid 47 1 * this gets both gid and egid
-signal 48 2 * have put the despatch table in user space.
+signal +48 2 * have put the despatch table in user space.
getinfo 49 1 @ possible? gets pid,ppid,uid,euid etc
fcntl +50 3
acct 51 1 @ Accounting to named file (off if null)
@@ -78,11 +78,19 @@ lstat +57 2
symlink +58 2
readlink +59 3
umask +60 1
-settimeofday 61 2
-gettimeofday 62 2
-select 63 5 *
+settimeofday +61 2
+gettimeofday +62 2
+select +63 5 . 5 paramaters is possible
readdir +64 3 *
-
+insmod +65 1
+fchown +66 3
+dlload +67 2
+setsid +68 0
+socket +69 3
+bind +70 3
+listen +71 2
+accept +72 3
+connect +73 3
#
# Name No Args Flag&comment
#
diff --git a/libc/syscall/syscall.dev86.old b/libc/syscall/syscall.dev86.old
new file mode 100644
index 0000000..29e7b5e
--- /dev/null
+++ b/libc/syscall/syscall.dev86.old
@@ -0,0 +1,160 @@
+#
+# WARNING!
+# This file is used to generate the system call lists for Dev86(elks)
+# ELKSemu and elks itself. Changes to this may require changes in
+# all three of those packages.
+#
+# . = Ok, with comment
+# * = Needs libc code (Prefix __)
+# - = Obsolete/not required
+# @ = May be required later
+#
+# An initial plus on the call number specifies that this call is
+# implemented in the kernel.
+#
+# Package versions are matched.
+# Dev86/Elksemu version - 0.13.1
+# Elks version - 0.0.66
+#
+# Name No Args Flag, comment
+#
+exit +1 1 * c exit does stdio, _exit in crt0
+fork +2 0
+read +3 3
+write +4 3
+open +5 3
+close +6 1
+wait4 +7 4
+creat 8 0 - Not needed alias for open
+link +9 2
+unlink +10 1
+execve +11 3 * execve minix style
+chdir +12 1
+time 13 1 - Use settimeofday
+mknod +14 3
+chmod +15 2
+chown +16 3
+brk +17 1 * This is only to tell the system
+stat +18 2
+lseek +19 3 * nb 2nd arg is an io ptr to long not a long.
+getpid +20 1 * this gets both pid & ppid
+mount +21 5
+umount +22 1
+setuid +23 1
+getuid +24 1 * this gets both uid and euid
+stime 25 2 - this must not exist - even as a libc.
+ptrace 26 4 @ adb/sdb/dbx need this.
+alarm 27 2
+fstat +28 2
+pause 29 0
+utime 30 2
+chroot +31 1
+vfork 32 0
+access +33 2
+nice 34 1
+sleep 35 1
+sync +36 0
+kill 37 2
+rename +38 2
+mkdir +39 2
+rmdir +40 1
+dup +41 1 . There is a fcntl lib function too.
+pipe 42 1
+times 43 2 * 2nd arg is pointer for long ret val.
+profil 44 4 @
+dup2 +45 2
+setgid +46 1
+getgid 47 1 * this gets both gid and egid
+signal 48 2 * have put the despatch table in user space.
+getinfo 49 1 @ possible? gets pid,ppid,uid,euid etc
+fcntl +50 3
+acct 51 1 @ Accounting to named file (off if null)
+phys 52 3 - Replaced my mmap()
+lock 53 1 @ Prevent swapping for this proc if flg!=0
+ioctl +54 3 . make this and fcntl the same ?
+reboot +55 3 . the magic number is 0xfee1,0xdead,...
+mpx 56 2 - Replaced by fifos and select.
+lstat +57 2
+symlink +58 2
+readlink +59 3
+umask +60 1
+settimeofday 61 2
+gettimeofday 62 2
+select 63 5 *
+readdir +64 3 *
+
+#
+# Name No Args Flag&comment
+#
+# ( awk '{$2=NR+500;OFS="\t";print ;}'| expand -24,32,40 | unexpand ) <<!
+#
+ADJTIMEX 501 X @
+FCHDIR 502 1 @
+FCHMOD 503 2 @
+FCHOWN 504 3 @
+FDATASYNC 505 X @
+FLOCK 506 2 - Use fcntl
+FSTATFS 507 2 @
+FSYNC 508 1 @
+FTIME 509 1 - Use gettimeofday
+FTRUNCATE 510 3 @
+GETDENTS 511 X @
+GETGROUPS 512 2 @
+GETITIMER 513 2 @
+GETPGID 514 1 @
+GETPGRP 515 0 - Use getpgid(0)
+GETPRIORITY 516 2 @
+GETRLIMIT 517 2 @
+GETRUSAGE 518 2 @
+GETSID 519 X @
+IPC 520 5 @ This is for all SYSV IPC (c/f mpx)
+LLSEEK 521 3 @ 2nd arg is ptr to two longs
+MPROTECT 522 X @
+MSYNC 523 X @
+MUNLOCK 524 X @
+MUNLOCKALL 525 X @
+MUNMAP 526 X @
+PERSONALITY 527 X @
+QUOTACTL 528 X @
+READV 529 3 @
+SCHED_GETPARAM 530 X @
+SCHED_GETSCHEDULER 531 X @
+SCHED_GET_PRIORITY_MAX 532 X @
+SCHED_GET_PRIORITY_MIN 533 X @
+SCHED_RR_GET_INTERVAL 534 X @
+SCHED_SETPARAM 535 X @
+SCHED_SETSCHEDULER 536 X @
+SCHED_YIELD 537 X @
+SETDOMAINNAME 538 X @
+SETFSGID 539 1 @
+SETFSUID 540 1 @
+SETGROUPS 541 2 @
+SETHOSTNAME 542 2 @
+SETITIMER 543 3 @
+SETPGID 544 2 @
+SETPRIORITY 545 3 @
+SETREGID 546 2 @
+SETREUID 547 2 @
+SETRLIMIT 548 2 @
+SETSID 549 0 @
+SGETMASK 550 X @
+SIGACTION 551 X @
+SIGPENDING 552 X @
+SIGPROCMASK 553 X @
+SIGRETURN 554 X @
+SIGSUSPEND 555 X @
+SOCKETCALL 556 X @
+SSETMASK 557 X @
+STATFS 558 2 @
+SWAPOFF 559 X @
+SWAPON 560 X @
+SYSCTL 561 X @
+SYSFS 562 X @
+SYSINFO 563 X - Use /proc
+SYSLOG 564 X @ Poss fifo & libc implementation.
+TRUNCATE 565 3 @
+ULIMIT 566 2 @
+UNAME 567 1 @
+USTAT 568 2 @
+VHANGUP 569 0 @
+WRITEV 570 3 @