From 0936b9aeab611665645a4e6bafaded7ca76dd189 Mon Sep 17 00:00:00 2001 From: Robert de Bath Date: Tue, 3 Sep 1996 22:06:58 +0200 Subject: Import Dev86-0.0.7.tar.gz --- libc/MAGIC | 8 +++--- libc/Make.defs | 2 +- libc/Makefile | 2 +- libc/New_subdir | 2 +- libc/TODO | 48 ------------------------------- libc/bcc/ldiv.c | 27 ++++++++++++++++++ libc/include/stdlib.h | 16 +++++++++++ libc/include/sys/cdefs.h | 3 ++ libc/include/sys/times.h | 21 ++++++++++++++ libc/include/time.h | 7 +++++ libc/kinclude/linuxmt/types.h | 2 ++ libc/libc.a | Bin 78644 -> 82366 bytes libc/misc/Makefile | 17 +++++++---- libc/string/string.c | 2 ++ libc/syscall/Makefile | 2 +- libc/syscall/syscall.dat | 4 +-- libc/syscall/syslibc.c | 29 +++++++++++++++++++ libc/time/Config | 1 + libc/time/Makefile | 17 +++++++++++ libc/time/README | 7 +++++ libc/time/asc_conv.c | 46 ++++++++++++++++++++++++++++++ libc/time/asctime.c | 15 ++++++++++ libc/time/ctime.c | 26 +++++++++++++++++ libc/time/gmtime.c | 15 ++++++++++ libc/time/localtime.c | 22 +++++++++++++++ libc/time/tm_conv.c | 64 ++++++++++++++++++++++++++++++++++++++++++ 26 files changed, 342 insertions(+), 63 deletions(-) delete mode 100644 libc/TODO create mode 100644 libc/bcc/ldiv.c create mode 100644 libc/include/sys/times.h create mode 100644 libc/time/Config create mode 100644 libc/time/Makefile create mode 100644 libc/time/README create mode 100644 libc/time/asc_conv.c create mode 100644 libc/time/asctime.c create mode 100644 libc/time/ctime.c create mode 100644 libc/time/gmtime.c create mode 100644 libc/time/localtime.c create mode 100644 libc/time/tm_conv.c (limited to 'libc') diff --git a/libc/MAGIC b/libc/MAGIC index 69c9c2d..319751e 100644 --- a/libc/MAGIC +++ b/libc/MAGIC @@ -8,16 +8,16 @@ Useful bits for /etc/magic: # text if readable, executable if runnable binary, data if unreadable. # 0 string \01\03\020\04 Linux-8086 impure executable ->16 long !0 not stripped +>28 long !0 not stripped 0 string \01\03\040\04 Linux-8086 executable ->16 long !0 not stripped +>28 long !0 not stripped # 0 string \243\206\001\0 Linux-8086 object file # There is _no_ difference between 16 and 32 bit .o files # 0 string \01\03\020\20 Minix-386 impure executable ->16 long !0 not stripped +>28 long !0 not stripped 0 string \01\03\040\20 Minix-386 executable ->16 long !0 not stripped +>28 long !0 not stripped # #------------------------------------------------------------------------------ diff --git a/libc/Make.defs b/libc/Make.defs index 1cf9b30..6744899 100644 --- a/libc/Make.defs +++ b/libc/Make.defs @@ -18,7 +18,7 @@ endif VERMAJOR=0 VERMINOR=0 -VERPATCH=6 +VERPATCH=7 VER=$(VERMAJOR).$(VERMINOR).$(VERPATCH) LIBDEFS=-D__LIBC__ diff --git a/libc/Makefile b/libc/Makefile index 0076f8b..a88ffb2 100644 --- a/libc/Makefile +++ b/libc/Makefile @@ -9,7 +9,7 @@ SRC=crt0.c OBJ=crt0.o TARGETS=$(OBJ) $(LIBC) -TXT=Makefile Make.defs README TODO KERNEL COPYING Contributors MAGIC \ +TXT=Makefile Make.defs README KERNEL COPYING Contributors MAGIC \ New_subdir Pre_main Config_sh all: .config.lst $(TARGETS) diff --git a/libc/New_subdir b/libc/New_subdir index 92f523d..a28a5ec 100755 --- a/libc/New_subdir +++ b/libc/New_subdir @@ -36,7 +36,7 @@ OBJ=$1.o all: \$(OBJ) libc.a: \$(OBJ) - ar r ../$(LIBC) \$(OBJ) + ar r ../\$(LIBC) \$(OBJ) @touch libc.a clean: diff --git a/libc/TODO b/libc/TODO deleted file mode 100644 index f6baaa0..0000000 --- a/libc/TODO +++ /dev/null @@ -1,48 +0,0 @@ -Here's a short list of bits that are required. If you want to do one of -these it's probably best to post to the list . - -Add more to this todo list! - - -TODO for libc-8086: -Item Notes ---------------------------------------------------------------------------- -Header Files - This will take some time, also some files should - be kernel. -Floating Point - Bruce is on this (Yes that one) Initially it'll - assume an FPU is available. "int" version soon - after. -dirent &co - Directory listing - Partial. -hsearch &co - -tsearch &co - -locale processing - multi national, unicode (string stuff has a couple - of stubs) -rpc - -time calcs - mktime gmtime localtime etc, Nat -timezone - Probably V simplistic, List of UTC's - offsets & STDvDST -i386 support - For both GCC and BCC-386. - -shadow password - Do we need ? Do we want :-) [No! Ick! ;) -Nat] -curses - What does ncurses need ? (150kb!!) -crypt - TEA version, first cut. -signal stuff - Got a basic 'signal' appears to work correctly. -getenv/setenv - Done -bsearch - Grabbed (Public Domain) -lsearch - Grabbed (Public Domain) -random numbers - Got ZX81 version (better than some) (And 2nd now) -Build environment - Good first cut is now available. - -Other projects: -Project Notes ---------------------------------------------------------------------------- -Optimiser for BCC - A lot of work, but lucrative. - (assembler level one started, by?) -Tiny vi editor - Use 'ae' ? -Shells: Bourne, Csh, -menu, silly - ash now compiles, Rob. -Tiny Perl - :-) :-) You first ;) -User commands - Everything in /bin /usr/bin - will existing PD/GPL - compile in 16 bit ? Or do smaller ones exist, - need to be written ? - diff --git a/libc/bcc/ldiv.c b/libc/bcc/ldiv.c new file mode 100644 index 0000000..6bfef0a --- /dev/null +++ b/libc/bcc/ldiv.c @@ -0,0 +1,27 @@ +#asm +.text +export _ldiv +_ldiv: + push bp + mov bp,sp + push di + push si + mov ax,[bp+6] + mov bx,[bp+8] + mov cx,[bp+10] + mov di,[bp+12] + call ldivmod + mov si,[bp+4] + mov [si],cx + mov [si+2],di + mov [si+4],ax + mov [si+6],bx + mov ax,si + pop si + pop di + pop bp + ret +.data +.bss +#endasm + diff --git a/libc/include/stdlib.h b/libc/include/stdlib.h index f67984a..7831424 100644 --- a/libc/include/stdlib.h +++ b/libc/include/stdlib.h @@ -25,6 +25,22 @@ extern void srand __P ((unsigned int seed)); extern long strtol __P ((const char * nptr, char ** endptr, int base)); extern unsigned long strtoul __P ((const char * nptr, char ** endptr, int base)); +#ifndef __HAS_NO_FLOATS__ extern double strtod __P ((const char * nptr, char ** endptr)); +#endif + +/* Returned by `div'. */ +typedef struct + { + int quot; /* Quotient. */ + int rem; /* Remainder. */ + } div_t; + +/* Returned by `ldiv'. */ +typedef struct + { + long int quot; /* Quotient. */ + long int rem; /* Remainder. */ + } ldiv_t; #endif /* __STDLIB_H */ diff --git a/libc/include/sys/cdefs.h b/libc/include/sys/cdefs.h index 366b0c6..0afc883 100644 --- a/libc/include/sys/cdefs.h +++ b/libc/include/sys/cdefs.h @@ -18,7 +18,10 @@ typedef long double __long_double_t; #define __STRING(x) "x" #define __ptr_t char * + +#ifndef __HAS_NO_FLOATS__ typedef double __long_double_t; +#endif #endif diff --git a/libc/include/sys/times.h b/libc/include/sys/times.h new file mode 100644 index 0000000..b6defa8 --- /dev/null +++ b/libc/include/sys/times.h @@ -0,0 +1,21 @@ +#ifndef _SYS_TIMES_H +#define _SYS_TIMES_H + +#include +#include +#include + +struct tms { + clock_t tms_utime; + clock_t tms_stime; + clock_t tms_cutime; + clock_t tms_cstime; +}; + +__BEGIN_DECLS + +extern clock_t times __P ((struct tms * __tp)); + +__END_DECLS + +#endif diff --git a/libc/include/time.h b/libc/include/time.h index b9eb87c..30ae4bc 100644 --- a/libc/include/time.h +++ b/libc/include/time.h @@ -30,6 +30,11 @@ struct tm { int tm_isdst; }; +struct timezone { + int tz_minuteswest; /* minutes west of Greenwich */ + int tz_dsttime; /* type of dst correction */ +}; + #define __isleap(year) \ ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0)) @@ -43,8 +48,10 @@ extern int stime __P ((time_t* __tptr)); extern clock_t clock __P ((void)); extern time_t time __P ((time_t * __tp)); +#ifndef __HAS_NO_FLOATS__ extern __CONSTVALUE double difftime __P ((time_t __time2, time_t __time1)) __CONSTVALUE2; +#endif extern time_t mktime __P ((struct tm * __tp)); extern char * asctime __P ((__const struct tm * __tp)); diff --git a/libc/kinclude/linuxmt/types.h b/libc/kinclude/linuxmt/types.h index 785d250..1450d25 100644 --- a/libc/kinclude/linuxmt/types.h +++ b/libc/kinclude/linuxmt/types.h @@ -28,5 +28,7 @@ typedef __u16 ino_t; typedef __u32 tcflag_t; typedef __u8 cc_t; +typedef int ptrdiff_t; + #endif diff --git a/libc/libc.a b/libc/libc.a index 5f92616..be7499f 100644 Binary files a/libc/libc.a and b/libc/libc.a differ diff --git a/libc/misc/Makefile b/libc/misc/Makefile index 87ad1e5..01092bb 100644 --- a/libc/misc/Makefile +++ b/libc/misc/Makefile @@ -11,11 +11,18 @@ MOBJ=abs.o raise.o bcopy.o bzero.o bcmp.o index.o rindex.o remove.o creat.o ESRC=atexit.c EOBJ=on_exit.o atexit.o __do_exit.o -OBJ=$(MOBJ) $(EOBJ) \ - atoi.o atol.o ltoa.o ltostr.o \ - ctype.o qsort.o bsearch.o rand.o lsearch.o getopt.o \ - getenv.o putenv.o itoa.o cputype.o \ - strtol.o popen.o system.o crypt.o +GOBJ=atoi.o atol.o ltoa.o ltostr.o \ + ctype.o qsort.o bsearch.o rand.o lsearch.o getopt.o \ + itoa.o cputype.o strtol.o crypt.o + +UOBJ=getenv.o putenv.o popen.o system.o + + +ifeq ($(PLATFORM),i86-DOS) +OBJ=$(MOBJ) $(EOBJ) $(GOBJ) +else +OBJ=$(MOBJ) $(EOBJ) $(GOBJ) $(UOBJ) +endif # No ELKS strtod() until BCC does 16 bit FP... ifeq ($(PLATFORM),i386-Linux) diff --git a/libc/string/string.c b/libc/string/string.c index fad6690..50b7145 100644 --- a/libc/string/string.c +++ b/libc/string/string.c @@ -120,6 +120,7 @@ const char * s; push es push ds ; Im not sure if this is needed, so just in case. pop es + cld #endif #if __FIRST_ARG_IN_AX__ @@ -367,6 +368,7 @@ size_t l; push es push ds ; Im not sure if this is needed, so just in case. pop es + cld #endif #if __FIRST_ARG_IN_AX__ diff --git a/libc/syscall/Makefile b/libc/syscall/Makefile index 21991ee..fd2f1bc 100644 --- a/libc/syscall/Makefile +++ b/libc/syscall/Makefile @@ -9,7 +9,7 @@ LSRC=syslibc.c LOBJ=__cstartup.o time.o lseek.o getpid.o getppid.o \ getuid.o geteuid.o getgid.o getegid.o \ dup2.o dup.o abort.o wait.o waitpid.o sleep.o \ - killpg.o setpgrp.o getpgrp.o + killpg.o setpgrp.o getpgrp.o times.o usleep.o ESRC=execve.c EOBJ=execve.o execl.o execv.o execle.o diff --git a/libc/syscall/syscall.dat b/libc/syscall/syscall.dat index df61a4f..de5ed9b 100644 --- a/libc/syscall/syscall.dat +++ b/libc/syscall/syscall.dat @@ -67,7 +67,7 @@ RENAME 38 2 MKDIR 39 2 RMDIR 40 1 PIPE 42 1 -TIMES 43 1 +TIMES 43 2 * 2nd arg is pointer for long ret val. SETGID 46 1 GETGID 47 1 * This gets both gid and egid SIGNAL 48 2 * Have put the despatch table in user space. @@ -78,7 +78,7 @@ UMASK 60 1 CHROOT 61 1 USTAT 62 2 GETPGRP 65 0 - use getpgid(0) -SETSID 66 X +SETSID 66 0 SIGACTION 67 X SGETMASK 68 X SSETMASK 69 X diff --git a/libc/syscall/syslibc.c b/libc/syscall/syslibc.c index 1dcb013..e6d58eb 100644 --- a/libc/syscall/syslibc.c +++ b/libc/syscall/syslibc.c @@ -6,6 +6,7 @@ #include #include #include +#include /* MSDOS has it's own versions */ #ifndef __MSDOS__ @@ -117,6 +118,18 @@ time_t *where; } #endif +/********************** Function times ************************************/ + +#ifdef L_times +clock_t times(buf) +struct tms* buf; +{ + long rv; + __times(buf, &rv); + return rv; +} +#endif + /********************** Function lseek ************************************/ #ifdef L_lseek @@ -359,6 +372,22 @@ unsigned int seconds; 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 ********************************************/ diff --git a/libc/time/Config b/libc/time/Config new file mode 100644 index 0000000..053ab81 --- /dev/null +++ b/libc/time/Config @@ -0,0 +1 @@ +time: Unix time manipulation functions. diff --git a/libc/time/Makefile b/libc/time/Makefile new file mode 100644 index 0000000..d04e5f4 --- /dev/null +++ b/libc/time/Makefile @@ -0,0 +1,17 @@ +# 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. + +TOP=.. +include $(TOP)/Make.defs + +OBJ=localtime.o gmtime.o asctime.o ctime.o asc_conv.o tm_conv.o + +all: $(OBJ) + +libc.a: $(OBJ) + ar r ../$(LIBC) $(OBJ) + @touch libc.a + +clean: + rm -f *.o libc.a diff --git a/libc/time/README b/libc/time/README new file mode 100644 index 0000000..0d50401 --- /dev/null +++ b/libc/time/README @@ -0,0 +1,7 @@ +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. + +There's currently nothing special about time. + +-Robert diff --git a/libc/time/asc_conv.c b/libc/time/asc_conv.c new file mode 100644 index 0000000..0ba48f1 --- /dev/null +++ b/libc/time/asc_conv.c @@ -0,0 +1,46 @@ + +#include +#include +/* + * Internal ascii conversion routine, avoid use of printf, it's a bit big! + */ + +static hit(buf, val) +char * buf; +int val; +{ + *buf = '0' + val%10; +} + +void +__asctime(buffer, ptm) +char * buffer; +struct tm * ptm; +{ +static days[] = "SunMonTueWedThuFriSat"; +static mons[] = "JanFebMarAprMayJunJulAugSepOctNovDec"; + int year; + + /* 012345678901234567890123456 */ + strcpy(buffer, "Err Err .. ..:..:.. ....\n"); + if( ptm->tm_wday >= 0 && ptm->tm_wday <= 6 ) + memcpy(buffer, days+3*ptm->tm_wday, 3); + + if( ptm->tm_mon >= 1 && ptm->tm_mon <= 12 ) + memcpy(buffer+4, mons+3*ptm->tm_mon-3, 3); + + hit(buffer+ 8, ptm->tm_mday/10); + hit(buffer+ 9, ptm->tm_mday ); + hit(buffer+11, ptm->tm_hour/10); + hit(buffer+12, ptm->tm_hour ); + hit(buffer+14, ptm->tm_min/10); + hit(buffer+15, ptm->tm_min ); + hit(buffer+17, ptm->tm_sec/10); + hit(buffer+18, ptm->tm_sec ); + + year = ptm->tm_year + 1900; + hit(buffer+20, year/1000); + hit(buffer+21, year/100); + hit(buffer+22, year/10); + hit(buffer+23, year); +} diff --git a/libc/time/asctime.c b/libc/time/asctime.c new file mode 100644 index 0000000..b66cd37 --- /dev/null +++ b/libc/time/asctime.c @@ -0,0 +1,15 @@ + +#include + +extern void __asctime(); + +char * +asctime(timeptr) +struct tm * timeptr; +{ +static char timebuf[26]; + + if( timeptr == 0 ) return 0; + __asctime(timebuf, timeptr); + return timebuf; +} diff --git a/libc/time/ctime.c b/libc/time/ctime.c new file mode 100644 index 0000000..bc7283d --- /dev/null +++ b/libc/time/ctime.c @@ -0,0 +1,26 @@ + +#include + +extern void __tm_conv(); +extern void __asc_conv(); + +char * +ctime(timep) +time_t * timep; +{ +static char cbuf[26]; + struct tm tmb; + struct timezone tz; + time_t offt; + + gettimeofday((void*)0, &tz); + + offt = -tz.tz_minuteswest*60L; + + /* tmb.tm_isdst = ? */ + __tm_conv(&tmb, &timep, offt); + + __asc_conv(cbuf, &tmb); + + return cbuf; +} diff --git a/libc/time/gmtime.c b/libc/time/gmtime.c new file mode 100644 index 0000000..29907d0 --- /dev/null +++ b/libc/time/gmtime.c @@ -0,0 +1,15 @@ + +#include + +extern void __tm_conv(); + +struct tm * +gmtime(timep) +time_t * timep; +{ + static struct tm tmb; + + __tm_conv(&tmb, &timep, 0L); + + return &tmb; +} diff --git a/libc/time/localtime.c b/libc/time/localtime.c new file mode 100644 index 0000000..b0b729c --- /dev/null +++ b/libc/time/localtime.c @@ -0,0 +1,22 @@ + +#include + +extern void __tm_conv(); + +struct tm * +localtime(timep) +time_t * timep; +{ + static struct tm tmb; + struct timezone tz; + time_t offt; + + gettimeofday((void*)0, &tz); + + offt = -tz.tz_minuteswest*60L; + + /* tmb.tm_isdst = ? */ + __tm_conv(&tmb, &timep, offt); + + return &tmb; +} diff --git a/libc/time/tm_conv.c b/libc/time/tm_conv.c new file mode 100644 index 0000000..96f4735 --- /dev/null +++ b/libc/time/tm_conv.c @@ -0,0 +1,64 @@ + +#include + +/* This is a translation from ALGOL in Collected Algorithms of CACM. */ +/* Copied from Algorithm 199, Author: Robert G. Tantzen */ + +void +__tm_conv(tmbuf, timep, offset) +struct tm *tmbuf; +time_t *timep; +time_t offset; +{ +static int moffset[] = + {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334}; + + long s; + long j, d, m, y; + + offset += *timep; + + tmbuf->tm_isdst = 0; /* Someone else can set this */ + + j = offset / 86400L + 719469; + s = offset % 86400L; + + if( s < 0 ) { s += 86400L; j--; } + + tmbuf->tm_sec = s % 60; + tmbuf->tm_min = (s / 60) % 60; + tmbuf->tm_hour = s / 3600; + + tmbuf->tm_wday = (j+2) % 7; + + /* + * Julian date converter. Takes a julian date (the number of days since + * some distant epoch or other), and fills tmbuf. + */ + + y = (4L * j - 1L) / 146097L; + j = 4L * j - 1L - 146097L * y; + d = j / 4L; + j = (4L * d + 3L) / 1461L; + d = 4L * d + 3L - 1461L * j; + d = (d + 4L) / 4L; + m = (5L * d - 3L) / 153L; + d = 5L * d - 3 - 153L * m; + d = (d + 5L) / 5L; + y = 100L * y + j; + if (m < 10) + m += 2; + else + { + m -= 10; + ++y; + } + + tmbuf->tm_year = y - 1900; + tmbuf->tm_mon = m; + tmbuf->tm_mday = d; + + tmbuf->tm_yday = d + moffset[m]; + if (m > 1 && ((y) % 4 == 0 && ((y) % 100 != 0 || (y) % 400 == 0))) + tmbuf->tm_yday++; +} -- cgit v1.2.1