cechew@bruce.OZ (Earl Chew) (09/05/89)
The following files are provided in this patch: Makefile.dos new TurboC makefile (not very useful) Makefile.unx new Un*x makefile _cleanup.c.cdif delete _cleanup.c (no longer used) _fakfls.c.cdif new fake flush function _filbuf.c.cdif patch _flsbuf.c.cdif patch _fopen.c.cdif patch atexit.c.cdif new atexit function bitset.h.cdif patch exercise.c.cdif patch exit.c.cdif new exit function fputs.c.cdif patch fread.c.cdif patch fwrite.c.cdif patch proto.h.cdif delete proto.h (no longer used) stdio.c.cdif patch stdio.h.cdif patch stdiolib.h.cdif patch texit.c.cdif new test vfscanf.c.cdif patch The new files will be created automatically by patch from the cdifs. The old files to be deleted will be crunched to zero size by patch. You will have to rm them yourself (_cleanup.c and proto.h). Most of the changes are patches to fix certain lint and compile problems to do with void * and unsigned char *. The need to #define MINIX is done away with. The package should compile under a Minix environment without any further #defines. atexit(), exit() and _ioflush() are new functions provided in this patch kit. The older _cleanup() has been done away with. Buffer flushing proceeds as follows. The dependencies in the function calls are: exit() -> _ioflush() putc() -> _flsbuf() -> _ioexit() fwrite() -> _ioexit() etc _flsbuf.o contains _ioexit(), _ioflush() and _flsbuf() _fakfls.o contains _ioflush() Thus, the order for the modules to be put into the library should be: `lorder "everything except exit.o and _fakfls.o" | tsort` exit.o _fakfls.o which is the order that is specified in Makefile.unx. Thus programs which make use of any writing function will cause _ioexit() to be called and thus haul in _flsbuf.o. _fakfls.o will be left out since it occurs last in the library. Programs which don't use stdio will eventually haul exit.o into the executable, and finally _fakfls.o. A new atexit.c is provided which interfaces with the exit.c that is provided. These replace the ones provided by Minix. Note that _exit.c will have to be split from exit.c --- that's the way it should have been from the start. I'm sure that you can manage that yourselves. The new test file texit.c allows you to check whether the linker has left out stdio. Under Un*x use nm to see what's been hauled in. You should see _fakfls.o. If you see the kitchen sink you know that the ld trick hasn't worked. I trashed the old __cleanup thing since, as Bruce Evans pointed out, it wasn't particularly clean and seemed to be Minix specific. This method follows what Bruce suggested to me (as far as I could follow what he said). atexit() seemed like a good way to go, but it appears that some systems don't have it (like the BSD system here). Thus I have provided exit.c and atexit.c. For those systems which already have an atexit.c don't want to replace their exit.c, look at the MSDOS code in stdiolib.h for the SETIOFLUSH macro. I have also placed a copyright notice in the .h files. I don't particularly mind how you use the software so long as you give credit where credit is due. Earl