cechew@bruce.OZ (Earl Chew) (09/04/89)
#! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh <file", e.g.. If this archive is complete, you # will see the following message at the end: # "End of archive 1 (of 7)." # Contents: Makefile.dos Makefile.unx Readme bitset.h proto.h stdio.h # Wrapped by cechew@bruce on Mon Sep 4 12:50:12 1989 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f 'Makefile.dos' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'Makefile.dos'\" else echo shar: Extracting \"'Makefile.dos'\" \(1658 characters\) sed "s/^X//" >'Makefile.dos' <<'END_OF_FILE' X# NdMakefile for TurboC X# XOBJ= _allocbu.obj _cleanup.obj _filbuf.obj _file.obj \ X _flsbuf.obj _fopen.obj _slot.obj fclose.obj \ X fdopen.obj fflush.obj fgetc.obj fgets.obj \ X fopen.obj fprintf.obj fputc.obj fputs.obj \ X fread.obj freopen.obj fscanf.obj fseek.obj \ X ftell.obj fwrite.obj gets.obj getw.obj \ X printf.obj puts.obj putw.obj rewind.obj \ X scanf.obj setbuf.obj setvbuf.obj sprintf.obj \ X sscanf.obj stdio.obj ungetc.obj vfprintf.obj \ X vfscanf.obj vprintf.obj vscanf.obj vsprintf.obj \ X vsscanf.obj X# X.SUFFIXES: .obj .c X.c.obj: X tcc -c $< X# Xexercise.out: exercise.obj $(OBJ) X link /st:4096/m/noi/f \minix\lib\tc\sepi&d+\minix\lib\tc\c0+exercise.obj+$(OBJ),exercise,,\minix\lib\mxtc+\tc\lib\cs X /minix/tools/dos2out -d exercise.exe X /minix/tools/chmem =64000 exercise.out X# Xall: exercise.out tputc.out tprintf.out tfwrite.out Xtiming: tputc.out tprintf.out tfwrite.out X# Xtputc.out: tputc.obj $(OBJ) X link /st:4096/m/noi/f \minix\lib\tc\sepi&d+\minix\lib\tc\c0+tputc.obj+$(OBJ),tputc,,\minix\lib\mxtc+\tc\lib\cs X /minix/tools/dos2out -d tputc.exe X /minix/tools/chmem =64000 tputc.out X# Xtprintf.out: tprintf.obj $(OBJ) X link /st:4096/m/noi/f \minix\lib\tc\sepi&d+\minix\lib\tc\c0+tprintf.obj+$(OBJ),tprintf,,\minix\lib\mxtc+\tc\lib\cs X /minix/tools/dos2out -d tprintf.exe X /minix/tools/chmem =64000 tprintf.out X# Xtfwrite.out: tfwrite.obj $(OBJ) X link /st:4096/m/noi/f \minix\lib\tc\sepi&d+\minix\lib\tc\c0+tfwrite.obj+$(OBJ),tfwrite,,\minix\lib\mxtc+\tc\lib\cs X /minix/tools/dos2out -d tfwrite.exe X /minix/tools/chmem =64000 tfwrite.out X# Xexercise.obj: stdio.h Xtfwrite.obj: stdio.h Xtprintf.obj: stdio.h Xtputc.obj: stdio.h X$(OBJ): stdiolib.h stdio.h END_OF_FILE if test 1658 -ne `wc -c <'Makefile.dos'`; then echo shar: \"'Makefile.dos'\" unpacked with wrong size! fi # end of 'Makefile.dos' fi if test -f 'Makefile.unx' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'Makefile.unx'\" else echo shar: Extracting \"'Makefile.unx'\" \(868 characters\) sed "s/^X//" >'Makefile.unx' <<'END_OF_FILE' X# Makefile for BSD X# XCFLAGS= -I. -I/usr/include -DBSD X# XOBJ= _allocbu.o _cleanup.o _filbuf.o _file.o \ X _flsbuf.o _fopen.o _slot.o fclose.o \ X fdopen.o fflush.o fgetc.o fgets.o \ X fopen.o fprintf.o fputc.o fputs.o \ X fread.o freopen.o fscanf.o fseek.o \ X ftell.o fwrite.o gets.o getw.o \ X printf.o puts.o putw.o rewind.o \ X scanf.o setbuf.o setvbuf.o sprintf.o \ X sscanf.o stdio.o ungetc.o vfprintf.o \ X vfscanf.o vprintf.o vscanf.o vsprintf.o \ X vsscanf.o X# Xexercise: exercise.o $(OBJ) X cc -o exercise exercise.o $(OBJ) X# Xall: exercise tputc tprintf tfwrite Xtiming: tputc tprintf tfwrite X# Xtputc: tputc.o $(OBJ) X cc -o tputc tputc.o $(OBJ) X# Xtprintf: tprintf.o $(OBJ) X cc -o tprintf tprintf.o $(OBJ) X# Xtfwrite: tfwrite.o $(OBJ) X cc -o tfwrite tfwrite.o $(OBJ) X# Xexercise.o: stdio.h Xtfwrite.o: stdio.h Xtprintf.o: stdio.h Xtputc.o: stdio.h X$(OBJ): stdiolib.h stdio.h END_OF_FILE if test 868 -ne `wc -c <'Makefile.unx'`; then echo shar: \"'Makefile.unx'\" unpacked with wrong size! fi # end of 'Makefile.unx' fi if test -f 'Readme' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'Readme'\" else echo shar: Extracting \"'Readme'\" \(3739 characters\) sed "s/^X//" >'Readme' <<'END_OF_FILE' XThis package contains a complete replacement for the current Minix Xstdio package. The advantages offered by this replacement are: X Xo speed Xo full support for unbuffered, line buffered and fully buffered X modes of operation Xo support for update modes (r+, w+ and a+) Xo full varargs support X XHere are some results when running the t*.c timing programs using the new Xstdio and the older Minix stdio: X X real user sys output Xold tprintf 43.0 41.0 1.9 /dev/null Xnew tprintf 20.0 18.3 2.0 /dev/null Xold tprintf 1:17.0 40.8 5.3 /dev/tty Xnew tprintf 1:01.0 18.4 20.5 /dev/tty X Xold tfwrite 21.0 19.6 1.3 /dev/null Xnew tfwrite 5.0 2.6 0.8 /dev/null Xold tfwrite 32.0 19.4 3.5 /dev/tty Xnew tfwrite 15.0 2.7 2.1 /dev/tty X Xold tputc 4.0 3.1 0.1 /dev/null Xnew tputc 2.0 1.0 0.7 /dev/null Xold tputc 8.0 3.1 1.0 /dev/tty * Xnew tputc 16.0 4.8 11.0 /dev/tty * X XThe only anomaly is in the last two lines with the new stdio lagging far behind XMinix stdio. This is due to the fact that the Minix version of putc() (or at Xleast the version that I have) does not support line buffered operation so Xputc() does not flush on receipt of '\n'. This means that the older stdio is Xoperating in a fully buffered mode (compare the user times) whereas the new Xone is line buffering the data. Thus the comparison is not really valid. X XHere are some comparisons with the stdio provided on this Un*x system: X X real user sys Xnew tputc 0.4 0.2 0.0 Xpyr tputc 0.3 0.2 0.0 Xnew tprintf 12.4 2.6 0.6 Xpyr tprintf 2.0 1.4 0.1 Xnew tfwrite 1.2 0.1 0.2 Xpyr tfwrite 0.3 0.1 0.0 X XAs can be seen, the only real difference is in the printf test. X XThe following files are provided: X X_allocbu.c stdio library X_cleanup.c stdio library X_filbuf.c stdio library X_file.c stdio library X_flsbuf.c stdio library X_fopen.c stdio library X_slot.c stdio library Xexercise.c exercise stdio Xfclose.c stdio library Xfdopen.c stdio library Xfflush.c stdio library Xfgetc.c stdio library Xfgets.c stdio library Xfopen.c stdio library Xfprintf.c stdio library Xfputc.c stdio library Xfputs.c stdio library Xfread.c stdio library Xfreopen.c stdio library Xfscanf.c stdio library Xfseek.c stdio library Xftell.c stdio library Xfwrite.c stdio library Xgets.c stdio library Xgetw.c stdio library Xprintf.c stdio library Xputs.c stdio library Xputw.c stdio library Xrewind.c stdio library Xscanf.c stdio library Xsetbuf.c stdio library Xsetvbuf.c stdio library Xsprintf.c stdio library Xsscanf.c stdio library Xstdio.c stdio library Xtfwrite.c timing stdio Xtprintf.c timing stdio Xtputc.c timing stdio Xungetc.c stdio library Xvfprintf.c stdio library Xvfscanf.c stdio library Xvprintf.c stdio library Xvscanf.c stdio library Xvsprintf.c stdio library Xvsscanf.c stdio library Xbitset.h stdio internals Xprototype.h stdio internals Xstdio.h stdio library Xstdiolib.h stdio internals X XThese files supersede all the stdio related files in the Minix library. Only Xstdio.h should be placed in the include directory. You can put proto.h in Xthere too if you like. All other .h files are internal. X XThere are two makefiles provided but they're both site specific (mine :-). You Xshould be able to cobble one up. Basically all you need to do is to compile all Xthe library modules and stick them in the library. You will also have to remove Xthe old Minix stdio modules from the library (best to do this first). X XTo compile the test programs, just compile and link them either with all the Xstdio modules if you haven't updated the library yet, or just with the library Xif you have updated it. You can also try linking them with the old Minix stdio Xmodules if you want to compare the two. X XMake sure that MINIX is defined when you compile. (I'm not quite sure if that's Xpredefined in Minix cc). X XEnjoy! X XEarl END_OF_FILE if test 3739 -ne `wc -c <'Readme'`; then echo shar: \"'Readme'\" unpacked with wrong size! fi # end of 'Readme' fi if test -f 'bitset.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'bitset.h'\" else echo shar: Extracting \"'bitset.h'\" \(2555 characters\) sed "s/^X//" >'bitset.h' <<'END_OF_FILE' X/* X * Bitset Macros X * X * This implements a set of operators to manipulate bitsets X * is a machine independent way. It may be necessary for other X * machines to set up the constants at the front (such as the X * width of int, etc). X * X * To avoid double evaluation of the argument in some of the X * macros, define the data structure as follows: X * X * 1. the bitset is int [] X * 2. the first int will be used as scratch int [0] X * 3. all the following elements will be used for the bitset proper X */ X X#if defined(BSD) X# include <values.h> X# define CHAR_BIT (BITSPERBYTE) X extern void bzero Prototype((char *, int)); X# define _BITEMPTY(a,n) (bzero((a), (n))) X# define _BITFILL(a,n) {char *p=(a); int c=(n); for ( ; c--; *p++ = ~0) ; } X#endif X X#if defined(MINIX) || defined(__MSDOS__) || defined(MSDOS) X# include <limits.h> X# include <memory.h> X# define _BITEMPTY(a,n) (memset((a), 0, (n))) X# define _BITFILL(a,n) (memset((a), ~0, (n))) X#endif X X/* Declare the relative sizing of the components */ X X#define _BITELEMENT unsigned int X#define _BITSINCHAR CHAR_BIT X X/* Determine how many bits there are in an elemental bitset */ X X#define _BITS (sizeof(_BITELEMENT)*_BITSINCHAR) X X/* Declare the relative offsets of the pieces in the structure */ X X#define _BIT_SCRATCH_ 0 X#define _BIT_SET_ 1 X X/* Define how to find a bit within a bitset */ X X#define _BITSIZE_(n) (((n)+_BITS-1)/_BITS) X#define _BITGROUP_(n) ((n)/_BITS) X#define _BITMASK_(n) (1<<((n)%_BITS)) X X/* Define how to find a bit within the data structure */ X X#define _BITSIZE(n) (_BITSIZE_(n)+_BIT_SET_) X#define _BITGROUP(n) (_BITGROUP_(n)+_BIT_SET_) X#define _BITMASK(n) (_BITMASK_(n)) X X/* X * Declare a bitset of length n bits X */ X X#define bitstring(name, n) _BITELEMENT name[_BITSIZE(n)] X X/* X * Clear all elements of the bitset X */ X X#define bitempty(name, n) (_BITEMPTY(&name[_BIT_SET_], \ X _BITSIZE_(n)*sizeof(_BITELEMENT))) X X/* X * Set all elements of the bitset X */ X X#define bitfill(name, n) (_BITFILL(&name[_BIT_SET_], \ X _BITSIZE_(n)*sizeof(_BITELEMENT))) X X/* X * Set one bit in the bitset X */ X X#define bitset(name, n) (name[_BIT_SCRATCH_]=(n), \ X name[_BITGROUP(name[_BIT_SCRATCH_])] |= \ X _BITMASK(name[_BIT_SCRATCH_])) X X/* X * Clear one bit in the bitset X */ X X#define bitclear(name, n) (name[_BIT_SCRATCH_]=(n), \ X name[_BITGROUP(name[_BIT_SCRATCH_])] &= \ X ~_BITMASK(name[_BIT_SCRATCH_])) X X/* X * Test one bit in the bitset X */ X X#define bittest(name, n) (name[_BIT_SCRATCH_]=(n), \ X name[_BITGROUP(name[_BIT_SCRATCH_])] & \ X _BITMASK(name[_BIT_SCRATCH_])) END_OF_FILE if test 2555 -ne `wc -c <'bitset.h'`; then echo shar: \"'bitset.h'\" unpacked with wrong size! fi # end of 'bitset.h' fi if test -f 'proto.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'proto.h'\" else echo shar: Extracting \"'proto.h'\" \(382 characters\) sed "s/^X//" >'proto.h' <<'END_OF_FILE' X/* X * ANSI Prototyping X * X * This file declares macros that are useful for conditionally X * providing ANSI function prototypes. X */ X X#ifndef __PROTOTYPE_H__ X# define __PROTOTYPE_H__ X# ifdef __STDC__ X# define Prototype(x) x X# define Type(x,y) x X# define Declare(x) X# else X# define Prototype(x) () X# define Type(x,y) y X# define Declare(x) x; X# endif X#endif END_OF_FILE if test 382 -ne `wc -c <'proto.h'`; then echo shar: \"'proto.h'\" unpacked with wrong size! fi # end of 'proto.h' fi if test -f 'stdio.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'stdio.h'\" else echo shar: Extracting \"'stdio.h'\" \(3703 characters\) sed "s/^X//" >'stdio.h' <<'END_OF_FILE' X/* s t d i o X * X * Author: C. E. Chew X * Date: August 1989 X * X * Definitions and user interface for the stream io package. X * X * Edit History: X * 04-Sep-1989 Undo change to putc() since it makes it so much X * more complicated and makes so little difference X * to the speed. X * 03-Sep-1989 Alter putc() to cope with line buffered streams. X * This makes processing of line buffered streams X * faster since no calls to _flsbuf is required X * unless the buffer fills. X * 31-Aug-1989 Change to use _end as suggested by Bruce Evans X * many moons ago. X */ X X#include <proto.h> X#include <varargs.h> X X#define BUFSIZ 1024 X#define _NFILE 20 X Xextern struct _iobuf { X unsigned char *_end; /* point at end of buffer */ X unsigned char *_ptr; /* pointer into buffer */ X unsigned char *_base; /* base of buffer */ X int _bufsiz; /* size of buffer */ X short _flag; /* flags */ X char _file; /* channel number */ X unsigned char _buf; /* small buffer */ X} *_iop[_NFILE]; X X#define _IOFBF 0000 /* fully buffered io */ X#define _IOREAD 0001 /* opened for reading */ X#define _IOWRITE 0002 /* opened for writing */ X#define _IONBF 0004 /* unbuffered */ X#define _IOMYBUF 0010 /* allocated buffer */ X#define _IOEOF 0020 /* eof encountered */ X#define _IOERR 0040 /* error encountered */ X#define _IOSTRING 0100 /* strings */ X#define _IOLBF 0200 /* line buffered */ X#define _IORW 0400 /* opened for reading and writing */ X X#define SEEK_SET 0 /* seek from beginning */ X#define SEEK_CUR 1 /* seek from here */ X#define SEEK_END 2 /* seek from end */ X X#define NULL (0) /* null pointer */ X#define FILE struct _iobuf /* FILE structure */ X#define EOF (-1) /* eof flag */ X X#define stdin (_iop[0]) X#define stdout (_iop[1]) X#define stderr (_iop[2]) X X#define getc(p) ((p)->_ptr<(p)->_end?*(p)->_ptr++\ X :_filbuf(p)) X#define getchar() getc(stdin) X X#define putc(x,p) ((p)->_ptr<(p)->_end?*(p)->_ptr++=(unsigned char)(x)\ X :_flsbuf((x),(p))) X#define putchar(x) putc(x,stdout) X X#define fileno(p) ((p)->_file) X X#define feof(p) (((p)->_flag&_IOEOF)!=0) X#define ferror(p) (((p)->_flag&_IOERR)!=0) X#define clearerr(p) ((p)->_flag&=~(_IOEOF|_IOERR)) X Xint _filbuf Prototype((FILE *)); Xint _flsbuf Prototype((int, FILE *)); X XFILE *fopen Prototype((char *, char *)); XFILE *fdopen Prototype((int, char *)); XFILE *freopen Prototype((char *, char *, FILE *)); Xint fflush Prototype((FILE *)); Xint fclose Prototype((FILE *)); X Xlong ftell Prototype((FILE *)); Xint fseek Prototype((FILE *, long, int)); Xvoid rewind Prototype((FILE *)); X Xint fgetc Prototype((FILE *)); Xint fputc Prototype((int, FILE *)); Xint fread Prototype((void *, unsigned int, unsigned int, FILE *)); Xint fwrite Prototype((void *, unsigned int, unsigned int, FILE *)); Xint getw Prototype((FILE *)); Xint putw Prototype((int, FILE *)); Xchar *gets Prototype((char *)); Xchar *fgets Prototype((char *, int, FILE *)); Xint puts Prototype((char *)); Xint fputs Prototype((char *, FILE *)); X Xint ungetc Prototype((int, FILE *)); X Xint printf Prototype((char *, ...)); Xint fprintf Prototype((FILE *, char *, ...)); Xint sprintf Prototype((char *, char *, ...)); Xint vprintf Prototype((char *, va_list)); Xint vfprintf Prototype((FILE *, char *, va_list)); Xint vsprintf Prototype((char *, char *, va_list)); Xint scanf Prototype((char *, ...)); Xint fscanf Prototype((FILE *, char *, ...)); Xint sscanf Prototype((char *, char *, ...)); Xint vscanf Prototype((char *, va_list)); Xint vfscanf Prototype((FILE *, char *, va_list)); Xint vsscanf Prototype((char *, char *, va_list)); X Xvoid setbuf Prototype((FILE *, char *)); Xint setvbuf Prototype((FILE *, char *, int, unsigned int)); END_OF_FILE if test 3703 -ne `wc -c <'stdio.h'`; then echo shar: \"'stdio.h'\" unpacked with wrong size! fi # end of 'stdio.h' fi echo shar: End of archive 1 \(of 7\). cp /dev/null ark1isdone MISSING="" for I in 1 2 3 4 5 6 7 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have unpacked all 7 archives. rm -f ark[1-9]isdone else echo You still need to unpack the following archives: echo " " ${MISSING} fi ## End of shell archive. exit 0