diff -Nurd linux-86.old/Changes linux-86/Changes --- linux-86.old/Changes Fri May 9 18:34:21 1997 +++ linux-86/Changes Sun Oct 5 11:17:45 1997 @@ -1,3 +1,62 @@ +For version 0.13.0. + +> Removed too eager 'typeconv.c' warning. + +> Well, I just broken everything! To be exact if Dev86 sees a directory + called ${ELKSSRC:-/usr/src/elks}/include it'll assume that is the + equlivent of libc/kinclude and use that in preference. I've sent off + a patch so that elks-0.0.* should be compatible but meantime there + are bound to be lots of problems caused by shuffling of include files. + (Later: Actually doesn't seem too bad) + +> Added '-g' to gcc options, make sure install has '-s' to strip symbols. + +> Grrrr, missing files in bootblocks directory, I didn't have them all. + OK, as part of the dist script I'll have to do a 'make other' ... + Some other bits there too ... + +> Minor alteration to opening files in ld to fix problem when share.exe + loaded under dos. + +> Added Config.dflt for default libc configuration flags. I can now + re-introduce Joel's standard I/O functions ... but they haven't + been updated in a while ... + +> Addition to minix.c to use allow BB to determine the track size by + trial and error (not intuit from superblock) to allow mis-sized + filesystems on a floppy. Also add some error retries to the floppy + version. + +> Squeeze the minix BB a bit more, DOTS is now working again. + +> Can now do 'use16 8086' in assembler instead of 'use16 86' also + 'use16 80386' + +> Add 'make install-ln', this installs _symbolic_links_ to the dev + directory in the normal directories. This means you don't have + to do a make install after re-compiling. But it also means the + 'install' is dependent on the dev dirs. + +> Add ability to use overrides on the command line of the initial make, + and have them saved, for CC, CFLAGS, LDFLAGS, PREFIX, BINDIR and LIBDIR. + Includes minor alteration to bcc.c and as86_encap. + +> Added in 'objchop' as an option in the ld directory. + +> The cpu type warnings were worrying some people so I've set the + initial value of the '-w' flag to off, use -w- to turn them back on. + The -W flag to bcc now does this too. + +> Added the ELKS_SETUP from Ken Yap to minix.c. + +> Added __ELKS__, __8086__ and __i386__ #defines for relevent bcc configs. + +> Clarified some of the copyrights, esp for Bruce's stuff. + +> Added a few changes to clean up compiles on an AIX/RS6000. It still + needs gnu-make installed and is only tested with gcc though. + (Because of IBM's recent contribution to increasing the popularity of GCC) + For version 0.12.0. > Notice the change in the version numbers, as long as I'm releasing the diff -Nurd linux-86.old/Libc_version linux-86/Libc_version --- linux-86.old/Libc_version Fri May 9 18:35:57 1997 +++ linux-86/Libc_version Sun Oct 5 14:03:03 1997 @@ -1 +1 @@ -0.12.0 +0.13.0 diff -Nurd linux-86.old/Makefile linux-86/Makefile --- linux-86.old/Makefile Thu Apr 24 22:12:43 1997 +++ linux-86/Makefile Sun Oct 5 12:37:34 1997 @@ -2,9 +2,17 @@ # This file is part of the Linux-8086 Development environment and is # distributed under the GNU General Public License. -TARGETS=bcc unproto copt as86 ld86 \ - install install-all install-lib install-lib2 install-other \ - clean tests alt-libs library config other +TARGETS= \ + clean bcc unproto copt as86 ld86 elksemu \ + install install-all install-bcc install-emu install-lib \ + install-lib2 install-ln install-man install-other \ + all-libs alt-libs library lib-386 lib-bsd lib-dos lib-fast lib-stand \ + config other tests dis88 doselks bootblocks ld86r + +PREFIX= /usr/bcc +BINDIR= /usr/bin +LIBDIR= $(PREFIX)/lib/bcc +CFLAGS= -O # Some makes take the last of a list as the default ... all: make.fil @@ -16,59 +24,74 @@ $(TARGETS): phony phony: +ld: ld86 +as: as86 + realclean: - [ ! -f make.fil ] || $(MAKE) -f make.fil TOPDIR=`pwd` $@ - rm -f make.fil ifdef ifdef.o + -[ ! -f make.fil ] || $(MAKE) -f make.fil TOPDIR=`pwd` $@ + -rm -f make.fil ifdef ifdef.o make.fil: ifdef makefile.in ./ifdef -MU makefile.in >tmp.mak - mv -f tmp.mak make.fil + sed -e "s:%PREFIX%:$(PREFIX):" \ + -e "s:%BINDIR%:$(BINDIR):" \ + -e "s:%LIBDIR%:$(LIBDIR):" \ + -e "s:%CC%:$(CC):" \ + -e "s:%CFLAGS%:$(CFLAGS):" \ + -e "s:%LDFLAGS%:$(LDFLAGS):" \ + < tmp.mak > make.tmp + mv -f make.tmp make.fil + @rm -f tmp.mak ifdef: ifdef.o - $(CC) -o ifdef ifdef.o + $(CC) $(LDFLAGS) -o ifdef ifdef.o ifdef.o: ifdef.c $(CC) $(CFLAGS) $(IFDEFFLAGS) -c ifdef.c Uninstall: phony + @# CHECK FROM HERE + @make -n Uninstall @echo 'Are you really sure... have you checked this... ^C to interrupt' @read line rm -rf /usr/bcc - rm -f /usr/bin/bcc /usr/bin/as86_encap /usr/bin/dis88 - rm -f /usr/bin/as86 /usr/bin/ld86 + rm -f $(BINDIR)/bcc $(BINDIR)/as86_encap $(BINDIR)/dis86 + rm -f $(BINDIR)/as86 $(BINDIR)/ld86 rm -f /lib/elksemu rm -f /usr/lib/liberror.txt rm -f /usr/man/man1/elks.1* /usr/man/man1/elksemu.1* - rm -f /usr/man/man1/dis88.1* /usr/man/man1/bcc.1* + rm -f /usr/man/man1/dis86.1* /usr/man/man1/bcc.1* rm -f /usr/man/man1/as86.1* /usr/man/man1/ld86.1* - rm -f /usr/man/man1/dis88.1* + @# TO HERE distribution: @rm -f /tmp/linux-86 || true @[ ! -f Copy_dist ] || sh Copy_dist mkdir -p /tmp/Dist [ -d /tmp/linux-86 ] || ln -s `pwd` /tmp/linux-86 - cd /tmp ;\ - $(MAKE) -C linux-86 realclean || exit 1 ;\ - $(MAKE) -C linux-86/libc Libc_version ;\ - VER=`cat linux-86/Libc_version` ;\ - tar cf Dist/Dev86src-$$VER.tar linux-86/* ;\ - ln -s linux-86/as as86 ;\ - cp -p linux-86/man/as86.1 as86/as86.1 ;\ - tar cf Dist/as86-$$VER.tar `find as86/* -prune -type f` ;\ - rm as86/as86.1 as86 ;\ - ln -s linux-86/libc libc-$$VER ;\ - tar cf Dist/libc-8086-$$VER.tar libc-$$VER/* ;\ - rm libc-$$VER ;\ + cd /tmp &&\ + $(MAKE) -C linux-86 realclean &&\ + $(MAKE) -C linux-86/libc Libc_version &&\ + VER=`cat linux-86/Libc_version` &&\ + tar cf Dist/Dev86src-$$VER.tar linux-86/* &&\ + ln -s linux-86/as as86 &&\ + cp -p linux-86/man/as86.1 as86/as86.1 &&\ + cp -p linux-86/COPYING as86/COPYING &&\ + tar cf Dist/as86-$$VER.tar `find as86/* -prune -type f` &&\ + rm as86/as86.1 as86 &&\ + ln -s linux-86/libc libc-$$VER &&\ + tar cf Dist/libc-8086-$$VER.tar libc-$$VER/* &&\ + rm libc-$$VER &&\ $(MAKE) -C /tmp/linux-86 install \ - ARFLAGS=q DIST=/tmp/linux-86-dist || exit 1 ;\ - tar cf /tmp/Dist/Dev86bin-$$VER.tar -C /tmp/linux-86-dist . ;\ - rm -f /tmp/Dist/Dev86clb-$$VER.zip Bcc ;\ - ln -s /tmp/linux-86 Bcc ;\ + ARFLAGS=q DIST=/tmp/linux-86-dist ELKSSRC=/dev/null &&\ + $(MAKE) -C /tmp/linux-86 other &&\ + tar cf /tmp/Dist/Dev86bin-$$VER.tar -C /tmp/linux-86-dist . &&\ + rm -f /tmp/Dist/Dev86clb-$$VER.zip Bcc &&\ + ln -s /tmp/linux-86 Bcc &&\ zip -9rpk /tmp/Dist/Dev86clb-$$VER.zip \ Bcc/lib/crt0.o Bcc/lib/libc.a Bcc/lib/libbsd.a \ Bcc/lib/libdos.a Bcc/lib/libc_f.a Bcc/lib/libc_s.a \ - Bcc/lib/i386/crt0.o Bcc/lib/i386/libc.a ;\ + Bcc/lib/i386/crt0.o Bcc/lib/i386/libc.a &&\ rm Bcc gzip -v9f /tmp/Dist/*.tar diff -Nurd linux-86.old/README linux-86/README --- linux-86.old/README Sun Mar 23 11:15:54 1997 +++ linux-86/README Thu Aug 21 19:41:43 1997 @@ -1,11 +1,6 @@ This is a development environment for ELKS-86 and standalone 8086 code. -The only hand configuration is to choose one of libc/syscall/syscall.dat.* -to be used as libc/syscall/syscall.dat The '*.chad' one matches the *.50 -elks kernel but you're best to pickup the one in the kernel you're compiling -for. - -All you then need to do then is 'make' from the top directory and the main +All you need to do is 'make' from the top directory and the main parts of the package will be made. These can be tested by use the 'ncc' program from the newly created bin subdirectory. @@ -15,15 +10,20 @@ Some other bits can be built by 'make other' and installed with 'make install-other'. +If you don't want it to install some bits in /usr/bin you can override +the bindir on the first make ie: 'make BINDIR=/usr/local/bin' this +is remembered until 'make.fil' is rebuilt. + The manual pages in the man subdirectory are a start as some pages matched to these programs, there are also some hints for using as86 well. The tests and bootblocks directories give some example code. The bcc command defaults to using /usr/bcc/include and /usr/bcc/lib the libraries _and_ include files are copied to these locations by install. +This can be changed by overriding 'PREFIX=...' on the initial make. -All the versions of the library are built by make; 'normal', 'fast', 'MSDOS', -'standalone' and Linux-i386. +All the versions of the library are built by make; 'normal', 'fast', +'MSDOS', 'standalone' and Linux-i386. You use the other libraries like this: 'FAST' $ bcc -Mf prog.c -o prog @@ -47,17 +47,27 @@ I _strongly_ suggest you install the kernel patch or load the module in the elksemu directory in your Linux-i386 kernel, it makes things _much_ -easier. (They both need the elksemu executable installed correctly) +easier. If you're using a post 2.1.43 kernel the modeule you need is +the binfmt_misc driver as described in elksemu/README. +(All the options need the elksemu executable installed correctly) Copyrights ---------- -This software is for the most part under GPL style copyright, the libc and -libbsd are covered by the 'weaker' library versions of this document. -(See the COPYING files in this and the libc directories for details) +The `bcc', 'as' and `ld' parts of the distribution are now covered by +the GPL. The `bccfp' library now in the libc/i386fp directory is under +the LGPL. (Copyright holder Bruce Evans) -The copyrights of other parts are documented in the relevent files. Some -parts are explicitly PD others like the unproto code have copyrights that -allow free distribution but are otherwise more vague. +The contents of the libc and libbsd subdirectories are under the LGPL +with a few noted exceptions. The programs in 'tests', elksemu, copt and +the bootblocks directory are under the GPL. Dis88 and unproto are freely +distributable if the source is distributed also. + +In libc the regular expression routine and the printf/scanf functions are +not under LGPL, the former is 'freely distributable' the latter is public +domain. + +See the COPYING file in this directory for the GPL and the COPYING file +in the libc directories for the LGPL. -- Rob. (Robert de Bath ) diff -Nurd linux-86.old/as/Makefile linux-86/as/Makefile --- linux-86.old/as/Makefile Thu Apr 24 06:32:02 1997 +++ linux-86/as/Makefile Thu Jun 19 19:57:25 1997 @@ -15,7 +15,8 @@ $(CC) $(LDFLAGS) $(OBJS) -o as86 as86_encap: as86_encap.sh - sed "s:%%LIBDIR%%:$(LIBDIR):" < as86_encap.sh > tmp + sed -e "s:%%LIBDIR%%:$(LIBDIR):" -e "s:%%BINDIR%%:$(BINDIR):" \ + < as86_encap.sh > tmp @mv -f tmp as86_encap chmod +x as86_encap diff -Nurd linux-86.old/as/as.c linux-86/as/as.c --- linux-86.old/as/as.c Sun Apr 13 12:33:32 1997 +++ linux-86/as/as.c Sun Oct 5 11:09:47 1997 @@ -64,6 +64,7 @@ initsource(); /* only nec to init for unsupported mem file */ typeconv_init(INT_BIG_ENDIAN, LONG_BIG_ENDIAN); as_warn.global = TRUE; /* constant */ + as_warn.semaphore = -1; last_pass=1; process_args(argc, argv); initscan(); diff -Nurd linux-86.old/as/as86_encap.sh linux-86/as/as86_encap.sh --- linux-86.old/as/as86_encap.sh Thu Apr 24 06:46:30 1997 +++ linux-86/as/as86_encap.sh Sat Jul 12 16:16:45 1997 @@ -19,9 +19,11 @@ trap "rm -f _$$.* ; exit 99" 1 2 3 15 LIBDIR='%%LIBDIR%%' # Set by make install +BINDIR='%%BINDIR%%' # Set by make install # If the one set by install fails then try a couple of others. [ -x "$LIBDIR/as86" ] || LIBDIR="`dirname $0`" +[ -x "$LIBDIR/as86" ] || LIBDIR="$BINDIR" [ -x "$LIBDIR/as86" ] || LIBDIR="`dirname $0`/../lib" [ -x "$LIBDIR/as86" ] || LIBDIR=/usr/bin @@ -81,7 +83,7 @@ if(NF == 0) next; printf " "; for(i=2;i<=NF;i++) { - if( $i >= 32 && $i <= 127 && $i != 39 && $i != 92 ) + if( $i >= 32 && $i < 127 && $i != 39 && $i != 92 ) printf("\047%c\047,", $i); else printf("%3d,", $i); diff -Nurd linux-86.old/as/as86_to_data linux-86/as/as86_to_data --- linux-86.old/as/as86_to_data Tue Nov 19 21:05:12 1996 +++ linux-86/as/as86_to_data Thu Jun 19 19:59:31 1997 @@ -22,6 +22,7 @@ trap "rm -f _$$.* ; exit 99" 1 2 3 15 LIBDIR='%%LIBDIR%%' # Set by make install +[ -d "$LIBDIR" ] || LIBDIR='%%BINDIR%%' [ -d "$LIBDIR" ] || LIBDIR=/usr/bin IFILE="$1" diff -Nurd linux-86.old/as/pops.c linux-86/as/pops.c --- linux-86.old/as/pops.c Sat Dec 7 08:12:55 1996 +++ linux-86/as/pops.c Sun May 25 11:04:07 1997 @@ -1006,7 +1006,9 @@ absexpres(); if (lastexp.data & UNDBIT) return; - if( lastexp.offset > 15 ) + if( lastexp.offset > 8000 ) + setcpu((int) lastexp.offset / 100 % 10); + else if( lastexp.offset > 15 ) setcpu((int) lastexp.offset / 100); else setcpu((int) lastexp.offset); diff -Nurd linux-86.old/as/syshead.h linux-86/as/syshead.h --- linux-86.old/as/syshead.h Sat Feb 1 09:44:03 1997 +++ linux-86/as/syshead.h Sun Sep 28 10:02:24 1997 @@ -1,15 +1,15 @@ -#ifndef STDC_HEADERS_MISSING -#include -#include -#include -#endif - #ifndef POSIX_HEADERS_MISSING #include #include #include #include +#endif + +#ifndef STDC_HEADERS_MISSING +#include +#include +#include #endif #ifdef MSDOS diff -Nurd linux-86.old/as/typeconv.c linux-86/as/typeconv.c --- linux-86.old/as/typeconv.c Fri Apr 25 21:02:43 1997 +++ linux-86/as/typeconv.c Sat Jun 7 08:38:27 1997 @@ -156,6 +156,8 @@ { switch (count) { + case 0: + return 0; case 1: return buf[0] & 0xFF; case 2: @@ -174,6 +176,8 @@ { switch (count) { + case 0: + return 0; case 1: return buf[0] & 0xFF; case 2: diff -Nurd linux-86.old/as/typeconv.c.old linux-86/as/typeconv.c.old --- linux-86.old/as/typeconv.c.old Sun Apr 13 15:48:04 1997 +++ linux-86/as/typeconv.c.old Thu Jan 1 01:00:00 1970 @@ -1,537 +0,0 @@ -/* typeconv.c - convert between char arrays and unsigneds */ - -/* Copyright (C) 1994 Bruce Evans */ - -/* - c2u2(): 2 byte array to 2 byte unsigned - c4u4(): 4 byte array to 4 byte unsigned - cnu2(): n byte array to 2 byte unsigned - cnu4(): n byte array to 4 byte unsigned - u2c2(): 2 byte unsigned to 2 byte array - u2cn(): 2 byte unsigned to n byte array - u4c4(): 4 byte unsigned to 4 byte array - u4cn(): 4 byte unsigned to n byte array - typeconv_init: (re)initialise for given byte order. - Default is no swapping, but the initialisation should be done - anyway to provide some validity checks (returns FALSE if error). - - Not provided: - c2u4(), c4u2(), u2c4(), u4c2(). - Each of these is best done by truncating or extending a return value - or argument to the appropiate fixed-count function. - c4u2() has too many cases to do in-line conveniently, and the others - are hardly more efficient when done in-line. - - 4 byte orderings for both char arrays and unsigneds are supported: - 0123 - little-endian - 3210 - big-endian - 2301 - little-endian with long words big-endian (pdp11) - 1032 - big-endian with long words little_endian (who knows?) - - The unsigned's byte order is that of the machine on which these - routines are running. - It is determined at run time initialisation since the compiler/ - preprocessor is too dumb to tell us at compile time. -*/ - -#include "syshead.h" -#include "const.h" -#include "type.h" -#include "globvar.h" - -FORWARD u2_pt c2u2_00 P((char *buf)); -FORWARD u4_pt c4u4_00 P((char *buf)); -FORWARD u2_pt c2u2_ss P((char *buf)); -FORWARD u4_pt c4u4_ss P((char *buf)); -FORWARD u4_pt c4u4_s0 P((char *buf)); -FORWARD u4_pt c4u4_0s P((char *buf)); -FORWARD void u2c2_00 P((char *buf, u2_pt offset)); -FORWARD void u4c4_00 P((char *buf, u4_t offset)); -FORWARD void u2c2_ss P((char *buf, u2_pt offset)); -FORWARD void u4c4_ss P((char *buf, u4_t offset)); -FORWARD void u4c4_s0 P((char *buf, u4_t offset)); -FORWARD void u4c4_0s P((char *buf, u4_t offset)); - -PRIVATE u2_pt (*pc2u2) P((char *buf)) = c2u2_00; -PRIVATE u4_pt (*pc4u4) P((char *buf)) = c4u4_00; -PRIVATE void (*pu2c2) P((char *buf, u2_pt offset)) = u2c2_00; -PRIVATE void (*pu4c4) P((char *buf, u4_t offset)) = u4c4_00; - -/* === char arrays to unsigneds === */ - -/* no bytes swapped, longwinded to avoid alignment problems */ - -PRIVATE u2_pt c2u2_00(buf) -register char *buf; -{ - u2_t offset; - - ((char *) &offset)[0] = buf[0]; - ((char *) &offset)[1] = buf[1]; - return offset; -} - -PRIVATE u4_pt c4u4_00(buf) -register char *buf; -{ - u4_t offset; - - ((char *) &offset)[0] = buf[0]; - ((char *) &offset)[1] = buf[1]; - ((char *) &offset)[2] = buf[2]; - ((char *) &offset)[3] = buf[3]; - return offset; -} - -/* straight swapping for little-endian to big-endian and vice versa */ - -PRIVATE u2_pt c2u2_ss(buf) -register char *buf; -{ - u2_t offset; - - ((char *) &offset)[0] = buf[1]; - ((char *) &offset)[1] = buf[0]; - return offset; -} - -PRIVATE u4_pt c4u4_ss(buf) -register char *buf; -{ - u4_t offset; - - ((char *) &offset)[0] = buf[3]; - ((char *) &offset)[1] = buf[2]; - ((char *) &offset)[2] = buf[1]; - ((char *) &offset)[3] = buf[0]; - return offset; -} - -/* wierd swapping for different-endian u2's, same-endian u4's */ - -PRIVATE u4_pt c4u4_s0(buf) -register char *buf; -{ - u4_t offset; - - ((char *) &offset)[0] = buf[1]; - ((char *) &offset)[1] = buf[0]; - ((char *) &offset)[2] = buf[3]; - ((char *) &offset)[3] = buf[2]; - return offset; -} - -/* very wierd swapping for same-endian u2's, different-endian u4's */ - -PRIVATE u4_pt c4u4_0s(buf) -register char *buf; -{ - u4_t offset; - - ((char *) &offset)[0] = buf[2]; - ((char *) &offset)[1] = buf[3]; - ((char *) &offset)[2] = buf[0]; - ((char *) &offset)[3] = buf[1]; - return offset; -} - -/* === entry points === */ - -PUBLIC u2_pt c2u2(buf) -char *buf; -{ - return (*pc2u2) (buf); -} - -PUBLIC u4_t c4u4(buf) -char *buf; -{ - return (*pc4u4) (buf); -} - -PUBLIC u2_pt cnu2(buf, count) -char *buf; -unsigned count; -{ - switch (count) - { - case 1: - return buf[0] & 0xFF; - case 2: - return (*pc2u2) (buf); - case 4: - return (u2_pt) (*pc4u4) (buf); - default: - return 0; - } -} - -PUBLIC u4_t cnu4(buf, count) -char *buf; -unsigned count; -{ - switch (count) - { - case 1: - return buf[0] & 0xFF; - case 2: - return (*pc2u2) (buf); - case 4: - return (*pc4u4) (buf); - default: - return 0; - } -} - -/* === unsigneds to char arrays === */ - -/* no bytes swapped, longwinded to avoid alignment problems */ - -PRIVATE void u2c2_00(buf, offset) -register char *buf; -u2_pt offset; -{ - - buf[0] = ((char *) &offset)[0]; - buf[1] = ((char *) &offset)[1]; -} - -PRIVATE void u4c4_00(buf, offset) -register char *buf; -u4_t offset; -{ - buf[0] = ((char *) &offset)[0]; - buf[1] = ((char *) &offset)[1]; - buf[2] = ((char *) &offset)[2]; - buf[3] = ((char *) &offset)[3]; -} - -/* straight swapping for little-endian to big-endian and vice versa */ - -PRIVATE void u2c2_ss(buf, offset) -register char *buf; -u2_pt offset; -{ - u2_t offset2; - - offset2 = offset; - buf[0] = ((char *) &offset2)[1]; - buf[1] = ((char *) &offset2)[0]; -} - -PRIVATE void u4c4_ss(buf, offset) -register char *buf; -u4_t offset; -{ - buf[0] = ((char *) &offset)[3]; - buf[1] = ((char *) &offset)[2]; - buf[2] = ((char *) &offset)[1]; - buf[3] = ((char *) &offset)[0]; -} - -/* wierd swapping for different-endian u2's, same-endian u4's */ - -PRIVATE void u4c4_s0(buf, offset) -register char *buf; -u4_t offset; -{ - buf[0] = ((char *) &offset)[1]; - buf[1] = ((char *) &offset)[0]; - buf[2] = ((char *) &offset)[3]; - buf[3] = ((char *) &offset)[2]; -} - -/* very wierd swapping for same-endian u2's, different-endian u4's */ - -PRIVATE void u4c4_0s(buf, offset) -register char *buf; -u4_t offset; -{ - buf[0] = ((char *) &offset)[2]; - buf[1] = ((char *) &offset)[3]; - buf[2] = ((char *) &offset)[0]; - buf[3] = ((char *) &offset)[1]; -} - -/* === entry points === */ - -PUBLIC void u2c2(buf, offset) -register char *buf; -u2_pt offset; -{ - (*pu2c2) (buf, offset); -} - -PUBLIC void u4c4(buf, offset) -register char *buf; -u4_t offset; -{ - (*pu4c4) (buf, offset); -} - -PUBLIC void u2cn(buf, offset, count) -register char *buf; -u2_pt offset; -unsigned count; -{ - switch (count) - { - case 1: - buf[0] = (char) offset; - return; - case 2: - (*pu2c2) (buf, offset); - return; - case 4: - (*pu4c4) (buf, (u4_t) offset); - return; - } -} - -PUBLIC void u4cn(buf, offset, count) -register char *buf; -u4_t offset; -unsigned count; -{ - switch (count) - { - case 1: - buf[0] = (char) offset; - return; - case 2: - (*pu2c2) (buf, (u2_pt) (u2_t) offset); - return; - case 4: - (*pu4c4) (buf, offset); - return; - } -} - -/* initialise type conversion, return FALSE if it cannot be handled */ - -PUBLIC bool_pt typeconv_init(big_endian, long_big_endian) -bool_pt big_endian; -bool_pt long_big_endian; -{ - u2_pt conv2; - u4_pt conv4; - char *conv2ptr; - char *conv4ptr; - - if (sizeof(u2_t) != 2 || sizeof(u4_t) != 4) - /* dumb preprocessor's don't accept sizeof in #if expressions */ - return FALSE; - - if (big_endian) - { - conv2ptr = (conv4ptr = "\1\2\3\4") + 2; - if (!long_big_endian) - conv4ptr = "\3\4\1\2"; - } - else - { - conv2ptr = conv4ptr = "\4\3\2\1"; - if (long_big_endian) - conv4ptr = "\2\1\4\3"; - } - conv2 = c2u2_00(conv2ptr); - conv4 = c4u4_00(conv4ptr); - if (conv2 == 0x0304) - { - pc2u2 = c2u2_00; - pc4u4 = c4u4_00; - pu2c2 = u2c2_00; - pu4c4 = u4c4_00; - if (conv4 == 0x03040102L) - { - pc4u4 = c4u4_0s; - pu4c4 = u4c4_0s; - } - else if (conv4 != 0x01020304L) - return FALSE; - } - else if (conv2 == 0x0403) - { - pc2u2 = c2u2_ss; - pc4u4 = c4u4_ss; - pu2c2 = u2c2_ss; - pu4c4 = u4c4_ss; - if (conv4 == 0x02010403L) - { - pc4u4 = c4u4_s0; - pu4c4 = u4c4_s0; - } - else if (conv4 != 0x04030201L) - return FALSE; - } - else - return FALSE; - return TRUE; -} - -#ifdef DEBUG_TYPECONV - -main() -{ - char *source; - char target[4]; - u2_t u2; - u2_t u2a; - u4_t u4; - u4_t u4a; - - printf("%u\n", typeconv_init(FALSE, FALSE)); - printf("%u\n", typeconv_init(FALSE, TRUE)); - printf("%u\n", typeconv_init(TRUE, FALSE)); - printf("%u\n", typeconv_init(TRUE, TRUE)); - - typeconv_init(FALSE, FALSE); - source = "\4\3\2\1"; - - target[0] = 0; - target[1] = 0; - u2 = cnu2(source, 2); - u2cn(target, u2, 2); - if (strncmp(source, target, 2)) - printf("oops9\n"); - - target[0] = 0; - target[1] = 0; - u4a = cnu4(source, 2); - u4cn(target, u4a, 2); - if (strncmp(source, target, 2)) - printf("oops10\n"); - - target[0] = 0; - target[1] = 0; - target[2] = 0; - target[3] = 0; - u2a = cnu2(source, 4); - u2cn(target, u2a, 4); - if (strncmp(target, "\4\3\0\0", 4)) - printf("oops11\n"); - - target[0] = 0; - target[1] = 0; - target[2] = 0; - target[3] = 0; - u4 = cnu4(source, 4); - u4cn(target, u4, 4); - if (strncmp(source, target, 4)) - printf("oops12\n"); - - printf("%04x %04x %08lx %08lx\n", u2, u2a, u4, u4a); - - typeconv_init(FALSE, TRUE); - source = "\2\1\4\3"; - - target[0] = 0; - target[1] = 0; - u2 = cnu2(source + 2, 2); - u2cn(target, u2, 2); - if (strncmp(source + 2, target, 2)) - printf("oops13\n"); - - target[0] = 0; - target[1] = 0; - u4a = cnu4(source + 2, 2); - u4cn(target, u4a, 2); - if (strncmp(source + 2, target, 2)) - printf("oops14\n"); - - target[0] = 0; - target[1] = 0; - target[2] = 0; - target[3] = 0; - u2a = cnu2(source, 4); - u2cn(target, u2a, 4); - if (strncmp(target, "\0\0\4\3", 4)) - printf("oops15\n"); - - target[0] = 0; - target[1] = 0; - target[2] = 0; - target[3] = 0; - u4 = cnu4(source, 4); - u4cn(target, u4, 4); - if (strncmp(source, target, 4)) - printf("oops16\n"); - - printf("%04x %04x %08lx %08lx\n", u2, u2a, u4, u4a); - - typeconv_init(TRUE, FALSE); - source = "\3\4\1\2"; - - target[0] = 0; - target[1] = 0; - u2 = cnu2(source, 2); - u2cn(target, u2, 2); - if (strncmp(source, target, 2)) - printf("oops5\n"); - - target[0] = 0; - target[1] = 0; - u4a = cnu4(source, 2); - u4cn(target, u4a, 2); - if (strncmp(source, target, 2)) - printf("oops6\n"); - - target[0] = 0; - target[1] = 0; - target[2] = 0; - target[3] = 0; - u2a = cnu2(source, 4); - u2cn(target, u2a, 4); - if (strncmp(target, "\3\4\0\0", 4)) - printf("oops7\n"); - - target[0] = 0; - target[1] = 0; - target[2] = 0; - target[3] = 0; - u4 = cnu4(source, 4); - u4cn(target, u4, 4); - if (strncmp(source, target, 4)) - printf("oops8\n"); - - printf("%04x %04x %08lx %08lx\n", u2, u2a, u4, u4a); - - typeconv_init(TRUE, TRUE); - source = "\1\2\3\4"; - - target[0] = 0; - target[1] = 0; - u2 = cnu2(source + 2, 2); - u2cn(target, u2, 2); - if (strncmp(source + 2, target, 2)) - printf("oops1\n"); - - target[0] = 0; - target[1] = 0; - u4a = cnu4(source + 2, 2); - u4cn(target, u4a, 2); - if (strncmp(source + 2, target, 2)) - printf("oops2\n"); - - target[0] = 0; - target[1] = 0; - target[2] = 0; - target[3] = 0; - u2a = cnu2(source, 4); - u2cn(target, u2a, 4); - if (strncmp(target, "\0\0\3\4", 4)) - printf("oops3\n"); - - target[0] = 0; - target[1] = 0; - target[2] = 0; - target[3] = 0; - u4 = cnu4(source, 4); - u4cn(target, u4, 4); - if (strncmp(source, target, 4)) - printf("oops4\n"); - - printf("%04x %04x %08lx %08lx\n", u2, u2a, u4, u4a); -} - -#endif /* DEBUG_TYPECONV */ diff -Nurd linux-86.old/bcc/Makefile linux-86/bcc/Makefile --- linux-86.old/bcc/Makefile Tue Apr 22 20:36:59 1997 +++ linux-86/bcc/Makefile Thu Jul 10 23:54:26 1997 @@ -9,7 +9,7 @@ LDFLAGS =-s BINDIR =/usr/bin LIBDIR =/usr/lib/bcc -BCCDEFS =-DLOCALPREFIX=$(PREFIX) -DDEFARCH=0 +BCCDEFS =-DLOCALPREFIX=$(PREFIX) -DBINDIR=$(BINDIR) -DDEFARCH=0 OBJS = bcc-cc1.o codefrag.o debug.o declare.o express.o exptree.o floatop.o \ function.o gencode.o genloads.o glogcode.o hardop.o input.o label.o \ @@ -37,7 +37,7 @@ $(CC) $(ANSI) $(CFLAGS) -DCCC $(BCCDEFS) $(LDFLAGS) bcc.c -o $@ bcc-cc1: $(OBJS) - $(CC) $(LDFLAGS) $(OBJS) -o bcc-cc1 + $(CC) $(BCCARCH) $(LDFLAGS) $(OBJS) -o bcc-cc1 clean realclean: rm -f bcc bcc-cc1 ncc bcc09 ccc bcc.o $(OBJS) @@ -48,3 +48,6 @@ input.h label.h os.h output.h \ parse.h proto.h reg.h sc.h scan.h \ sizes.h table.h type.h + +.c.o: + $(CC) $(BCCARCH) $(CFLAGS) -c $< diff -Nurd linux-86.old/bcc/bcc.c linux-86/bcc/bcc.c --- linux-86.old/bcc/bcc.c Tue Apr 22 20:36:59 1997 +++ linux-86/bcc/bcc.c Sun Oct 5 11:12:27 1997 @@ -22,7 +22,7 @@ #define PUBLIC #define TRUE 1 -#ifdef __STDC__ +#if __STDC__ == 1 #define P(x) x #define HASHIT(x) #x #define QUOT(x) HASHIT(x) @@ -45,7 +45,7 @@ #define EXESUF #endif -#if defined(__minix) || defined(_AIX) +#if defined(__minix) || defined(_AIX) || defined(__BCC__) #define realpath(x,y) 0 #endif @@ -76,7 +76,11 @@ #define STANDARD_CRT0_0_PREFIX "~/lib/bcc/i86/" #define STANDARD_CRT0_3_PREFIX "~/lib/bcc/i386/" #define STANDARD_EXEC_PREFIX "~/lib/bcc/" +#ifdef BINDIR +#define STANDARD_EXEC_PREFIX_2 QUOT(BINDIR) "/" +#else #define STANDARD_EXEC_PREFIX_2 "/usr/bin/" +#endif #define DEFAULT_INCLUDE "-I~/include" #define DEFAULT_LIBDIR0 "-L~/lib/bcc/i86/" #define DEFAULT_LIBDIR3 "-L~/lib/bcc/i386/" @@ -177,6 +181,7 @@ int main P((int argc, char **argv)); FORWARD void addarg P((struct arg_s *argp, char *arg)); +FORWARD void adddefine P((char *arg)); FORWARD void addprefix P((struct prefix_s *prefix, char *name)); FORWARD char *expand_tilde P((char * str, int canfree)); FORWARD void fatal P((char *message)); @@ -360,11 +365,8 @@ case 'v': ++verbosity; break; - case 'w': - aswarn=FALSE; - break; case 'W': - ++aswarn; + aswarn = TRUE; break; case 'I': add_default_inc = 0; @@ -372,6 +374,7 @@ case 'L': add_default_lib = 0; break; + default: *argdone = FALSE; break; @@ -384,11 +387,8 @@ { ansi_pass=TRUE; cpp_pass=TRUE; -#ifndef CCC /* NOTE I'm setting this to zero, this isn't a _real_ STDC */ - addarg(&ccargs, "-D__STDC__=0"); -#endif - addarg(&cppargs, "-D__STDC__=0"); + adddefine("-D__STDC__=0"); } break; case 'A': @@ -403,10 +403,7 @@ case 'D': case 'I': case 'U': -#ifndef CCC - addarg(&ccargs, arg); -#endif - addarg(&cppargs, arg); + adddefine(arg); break; case 'X': addarg(&ldargs, arg + 2); @@ -481,15 +478,13 @@ exit(1); #ifdef BCC86 + if(!major_mode && !bits32) major_mode='n'; switch(major_mode) { case 'd': /* DOS compile */ bits32 = FALSE; libc= "-ldos"; -#ifndef CCC - addarg(&ccargs, "-D__MSDOS__"); -#endif - addarg(&cppargs, "-D__MSDOS__"); + adddefine("-D__MSDOS__"); addarg(&ldargs, "-d"); addarg(&ldargs, "-s"); addarg(&ldargs, "-T100"); @@ -498,11 +493,15 @@ case 'n': /* Normal Linux-86 */ bits32 = FALSE; libc= "-lc"; + adddefine("-D__ELKS__"); + adddefine("-D__unix__"); break; case 'f': /* Caller saves+ax is first arg */ bits32 = FALSE; libc= "-lc_f"; + adddefine("-D__ELKS__"); + adddefine("-D__unix__"); addarg(&ccargs, "-f"); addarg(&ccargs, "-c"); break; @@ -510,35 +509,37 @@ case 'c': /* Just caller saves, normal C-lib is ok */ bits32 = FALSE; libc= "-lc"; + adddefine("-D__ELKS__"); + adddefine("-D__unix__"); addarg(&ccargs, "-c"); break; case 's': /* Standalone executable */ bits32 = FALSE; libc= "-lc_s"; -#ifndef CCC - addarg(&ccargs, "-D__STANDALONE__"); -#endif - addarg(&cppargs, "-D__STANDALONE__"); + adddefine("-D__STANDALONE__"); break; case 'l': /* Large Linux compile */ bits32 = TRUE; libc= "-lc"; -#ifndef CCC - addarg(&ccargs, "-D__linux__"); -#endif - addarg(&cppargs, "-D__linux__"); + adddefine("-D__linux__"); + adddefine("-D__unix__"); addarg(&ldargs, "-N"); /* Make OMAGIC */ break; + + case '?': case 0: break; + default: fatal("Fatal error: illegal -M option given"); } #endif - if( !aswarn ) + if( aswarn ) + addarg(&asargs, "-w-"); + else addarg(&asargs, "-w"); if( patch_exe ) addarg(&ldargs, "-s"); @@ -554,12 +555,7 @@ if ((temp = getenv("BCC_EXEC_PREFIX")) != NUL_PTR) addprefix(&exec_prefix, temp); if( add_default_inc ) - { -#ifndef CCC - addarg(&ccargs, DEFAULT_INCLUDE); -#endif - addarg(&cppargs, DEFAULT_INCLUDE); - } + adddefine(DEFAULT_INCLUDE); if( add_default_lib ) { #ifdef BCC86 @@ -1026,6 +1022,15 @@ return newstr; } +PRIVATE void adddefine(arg) +char *arg; +{ +#ifndef CCC + addarg(&ccargs, arg); +#endif + addarg(&cppargs, arg); +} + PRIVATE void addarg(argp, arg) register struct arg_s *argp; char *arg; @@ -1094,9 +1099,15 @@ } ppath = expand_tilde(stralloc2(prefix->name, path), 1); if (verbosity > 2) - writesn(ppath); + writes(ppath); if (access(ppath, mode) == 0) + { + if (verbosity > 2) + writesn(" - found."); return ppath; + } + if (verbosity > 2) + writesn(" - nope."); free(ppath); } return path; @@ -1269,27 +1280,14 @@ PRIVATE void set_trap() { -#ifndef NORDB #ifdef SIGINT signal(SIGINT, trap); #endif #ifdef SIGQUIT signal(SIGQUIT, trap); #endif - -#else - /* This is being too trap happy IMO - Rdb */ -#ifndef _NSIG -#define _NSIG NSIG -#endif - int signum; - - for (signum = 0; signum <= _NSIG; ++signum) -#ifdef SIGCHLD - if (signum != SIGCHLD) -#endif - if (signal(signum, SIG_IGN) != SIG_IGN) - signal(signum, trap); +#ifdef SIGTERM + signal(SIGTERM, trap); #endif } diff -Nurd linux-86.old/bcc/bcc.h linux-86/bcc/bcc.h --- linux-86.old/bcc/bcc.h Sun Apr 13 11:29:05 1997 +++ linux-86/bcc/bcc.h Sun Sep 28 09:33:32 1997 @@ -2,6 +2,10 @@ * This file is part of the Linux-8086 Development environment and is * distributed under the GNU General Public License. */ +#ifdef _AIX +#include /* AIX 4.1 + GCC seems to need this */ +#endif + /* Ansi C has certain guarentees ... except under MSdross :-( */ #ifdef __STDC__ diff -Nurd linux-86.old/bcc/codefrag.c linux-86/bcc/codefrag.c --- linux-86.old/bcc/codefrag.c Sun Apr 13 11:15:50 1997 +++ linux-86/bcc/codefrag.c Sun Sep 28 09:57:08 1997 @@ -691,7 +691,7 @@ /* adjust stack ptr by adding a labelled constant less current sp */ PUBLIC void adjsp(label) -label_t label; +label_no label; { outaddsp(); outbyte(LOCALSTARTCHAR); @@ -767,9 +767,9 @@ /* jump to case of switch */ -PUBLIC label_t casejump() +PUBLIC label_no casejump() { - label_t jtablelab; + label_no jtablelab; #ifdef I8088 outlswitch(); @@ -886,13 +886,13 @@ /* define string */ -PUBLIC label_t defstr(sptr, stop, dataflag) +PUBLIC label_no defstr(sptr, stop, dataflag) char *sptr; char *stop; bool_pt dataflag; { int byte; /* promoted char for output */ - label_t strlab; + label_no strlab; seg_t oldsegment; fastin_t count; /* range 0..max(DEFSTR_BYTEMAX,DEFSTR_STRMAX) */ @@ -1043,7 +1043,7 @@ /* equate a local label to a value */ PUBLIC void equlab(label, offset) -label_t label; +label_no label; offset_t offset; { outbyte(LOCALSTARTCHAR); @@ -1087,7 +1087,7 @@ outcwd(); regtransfer(DXREG, reg); #else - label_t exitlab; + label_no exitlab; clr(reg); testhi(); @@ -1106,7 +1106,7 @@ /* define local common storage */ PUBLIC void lcommlab(label) -label_t label; +label_no label; { outlabel(label); outlcommon(); diff -Nurd linux-86.old/bcc/glogcode.c linux-86/bcc/glogcode.c --- linux-86.old/bcc/glogcode.c Sun Apr 13 11:16:29 1997 +++ linux-86/bcc/glogcode.c Sun Sep 28 09:57:09 1997 @@ -40,26 +40,26 @@ FORWARD bool_pt cmpsmallconst P((value_t intconst, struct symstruct *target, ccode_t *pcondtrue)); #endif -FORWARD void comparecond P((struct nodestruct *exp, label_t truelab, - label_t falselab, bool_pt nojump)); -FORWARD void jumpcond P((struct nodestruct *exp, label_t truelab, - label_t falselab, bool_pt nojump)); -FORWARD void loadlogical P((struct symstruct *source, label_t falselab)); -FORWARD void logandcond P((struct nodestruct *exp, label_t truelab, - label_t falselab, bool_pt nojump)); -FORWARD void logorcond P((struct nodestruct *exp, label_t truelab, - label_t falselab, bool_pt nojump)); +FORWARD void comparecond P((struct nodestruct *exp, label_no truelab, + label_no falselab, bool_pt nojump)); +FORWARD void jumpcond P((struct nodestruct *exp, label_no truelab, + label_no falselab, bool_pt nojump)); +FORWARD void loadlogical P((struct symstruct *source, label_no falselab)); +FORWARD void logandcond P((struct nodestruct *exp, label_no truelab, + label_no falselab, bool_pt nojump)); +FORWARD void logorcond P((struct nodestruct *exp, label_no truelab, + label_no falselab, bool_pt nojump)); FORWARD void reduceconst P((struct symstruct *source)); FORWARD void test P((struct symstruct *target, ccode_t *pcondtrue)); -FORWARD void testcond P((struct nodestruct *exp, label_t truelab, - label_t falselab, bool_pt nojump)); +FORWARD void testcond P((struct nodestruct *exp, label_no truelab, + label_no falselab, bool_pt nojump)); PUBLIC void cmp(source, target, pcondtrue) struct symstruct *source; struct symstruct *target; ccode_t *pcondtrue; { - label_t falselab; + label_no falselab; cmplocal(source, target, pcondtrue); #if 0 @@ -230,8 +230,8 @@ PRIVATE void comparecond(exp, truelab, falselab, nojump) struct nodestruct *exp; -label_t truelab; -label_t falselab; +label_no truelab; +label_no falselab; bool_pt nojump; /* NB if nonzero, is ~0 so complement is 0 */ { ccode_t condtrue; @@ -278,11 +278,11 @@ PUBLIC void condop(exp) struct nodestruct *exp; { - label_t exitlab; - label_t falselab; + label_no exitlab; + label_no falselab; struct nodestruct *falsenode; struct symstruct *falsesym; - label_t truelab; + label_no truelab; struct nodestruct *truenode; struct symstruct *truesym; @@ -318,8 +318,8 @@ PRIVATE void jumpcond(exp, truelab, falselab, nojump) struct nodestruct *exp; -label_t truelab; -label_t falselab; +label_no truelab; +label_no falselab; bool_pt nojump; /* NB if nonzero, is ~0 so complement is 0 */ { switch (exp->tag) @@ -349,9 +349,9 @@ PUBLIC void jumpfalse(exp, label) struct nodestruct *exp; -label_t label; +label_no label; { - label_t truelab; + label_no truelab; jumpcond(exp, truelab = getlabel(), label, ~0); deflabel(truelab); @@ -359,9 +359,9 @@ PUBLIC void jumptrue(exp, label) struct nodestruct *exp; -label_t label; +label_no label; { - label_t falselab; + label_no falselab; jumpcond(exp, label, falselab = getlabel(), 0); deflabel(falselab); @@ -369,9 +369,9 @@ PRIVATE void loadlogical(source, falselab) struct symstruct *source; -label_t falselab; +label_no falselab; { - label_t exitlab; + label_no exitlab; struct symstruct *target; target = constsym((value_t) TRUE); @@ -388,11 +388,11 @@ PRIVATE void logandcond(exp, truelab, falselab, nojump) struct nodestruct *exp; -label_t truelab; -label_t falselab; +label_no truelab; +label_no falselab; bool_pt nojump; /* NB if nonzero, is ~0 so complement is 0 */ { - label_t andlab; + label_no andlab; andlab = getlabel(); jumpcond(exp->left.nodeptr, andlab, falselab, ~0); @@ -403,9 +403,9 @@ PUBLIC void logop(exp) struct nodestruct *exp; { - label_t falselab; + label_no falselab; struct symstruct *target; - label_t truelab; + label_no truelab; jumpcond(exp, truelab = getlabel(), falselab = getlabel(), ~0); deflabel(truelab); @@ -418,11 +418,11 @@ PRIVATE void logorcond(exp, truelab, falselab, nojump) struct nodestruct *exp; -label_t truelab; -label_t falselab; +label_no truelab; +label_no falselab; bool_pt nojump; /* NB if nonzero, is ~0 so complement is 0 */ { - label_t orlab; + label_no orlab; orlab = getlabel(); jumpcond(exp->left.nodeptr, truelab, orlab, 0); @@ -532,8 +532,8 @@ PRIVATE void testcond(exp, truelab, falselab, nojump) struct nodestruct *exp; -label_t truelab; -label_t falselab; +label_no truelab; +label_no falselab; bool_pt nojump; /* NB if nonzero, is ~0 so complement is 0 */ { ccode_t condtrue; diff -Nurd linux-86.old/bcc/hardop.c linux-86/bcc/hardop.c --- linux-86.old/bcc/hardop.c Sun Apr 13 11:38:14 1997 +++ linux-86/bcc/hardop.c Sun Sep 28 09:57:09 1997 @@ -428,9 +428,9 @@ struct symstruct *source; struct symstruct *target; { - label_t exitlab; + label_no exitlab; uoffset_t factor; - label_t usignlab; + label_no usignlab; if (source->indcount == 0 && source->storage != CONSTANT) { diff -Nurd linux-86.old/bcc/input.c linux-86/bcc/input.c --- linux-86.old/bcc/input.c Sun Apr 13 11:16:39 1997 +++ linux-86/bcc/input.c Fri Aug 15 19:54:46 1997 @@ -550,10 +550,14 @@ { i386_32 = TRUE; definestring("__AS386_32__"); + definestring("__i386__"); } else #endif + { definestring("__AS386_16__"); + definestring("__8086__"); + } #endif #ifdef MC6809 definestring("__AS09__"); diff -Nurd linux-86.old/bcc/label.c linux-86/bcc/label.c --- linux-86.old/bcc/label.c Sun Apr 13 11:16:43 1997 +++ linux-86/bcc/label.c Sun Sep 28 09:57:10 1997 @@ -25,7 +25,7 @@ struct labdatstruct { - label_t labnum; /* 0 if not active */ + label_no labnum; /* 0 if not active */ offset_t lablc; /* location counter for branch or label */ char *labpatch; /* buffer ptr for branch, NULL for label */ ccode_t labcond; /* condition code for branch */ @@ -55,9 +55,9 @@ }; #endif -PRIVATE label_t lasthighlab = 0xFFFF+1; /* temp & temp init so labels fixed */ +PRIVATE label_no lasthighlab = 0xFFFF+1; /* temp & temp init so labels fixed */ /* lint */ -PRIVATE label_t lastlab; /* bss init to 0 */ +PRIVATE label_no lastlab; /* bss init to 0 */ PRIVATE offset_t lc; /* bss init to 0 */ PRIVATE struct labdatstruct vislab[MAXVISLAB]; /* bss, all labnum's init 0 */ @@ -65,14 +65,14 @@ PRIVATE struct symstruct *namedfirst; /* bss init to NULL */ PRIVATE struct symstruct *namedlast; /* bss init to NULL */ -FORWARD void addlabel P((ccode_pt cond, label_t label, char *patch)); -FORWARD struct labdatstruct *findlabel P((label_t label)); +FORWARD void addlabel P((ccode_pt cond, label_no label, char *patch)); +FORWARD struct labdatstruct *findlabel P((label_no label)); /* add label to circular list */ PRIVATE void addlabel(cond, label, patch) ccode_pt cond; -label_t label; +label_no label; char *patch; { register struct labdatstruct *labptr; @@ -167,7 +167,7 @@ /* define location of label and backpatch references to it */ PUBLIC void deflabel(label) -label_t label; +label_no label; { char *cnameptr; struct labdatstruct *labmin; @@ -241,7 +241,7 @@ } PRIVATE struct labdatstruct *findlabel(label) -label_t label; +label_no label; { register struct labdatstruct *labptr; struct labdatstruct *labtop; @@ -259,14 +259,14 @@ /* reserve a new label, from top down to temp avoid renumbering low labels */ -PUBLIC label_t gethighlabel() +PUBLIC label_no gethighlabel() { return --lasthighlab; } /* reserve a new label */ -PUBLIC label_t getlabel() +PUBLIC label_no getlabel() { return ++lastlab; } @@ -274,7 +274,7 @@ /* jump to label */ PUBLIC void jump(label) -label_t label; +label_no label; { lbranch(RA, label); } @@ -283,7 +283,7 @@ PUBLIC void lbranch(cond, label) ccode_pt cond; -label_t label; +label_no label; { #ifdef I8088 char *cnameptr; @@ -376,7 +376,7 @@ /* print label */ PUBLIC void outlabel(label) -label_t label; +label_no label; { outbyte(LABELSTARTCHAR); outhexdigs((uoffset_t) label); @@ -385,7 +385,7 @@ /* print label and newline */ PUBLIC void outnlabel(label) -label_t label; +label_no label; { outlabel(label); #ifdef LABELENDCHAR @@ -399,7 +399,7 @@ PUBLIC void sbranch(cond, label) ccode_pt cond; -label_t label; +label_no label; { #ifdef I8088 char *cnameptr; diff -Nurd linux-86.old/bcc/proto.h linux-86/bcc/proto.h --- linux-86.old/bcc/proto.h Sun Apr 13 11:18:57 1997 +++ linux-86/bcc/proto.h Sun Sep 28 09:57:11 1997 @@ -8,7 +8,7 @@ void extend P((struct symstruct *target)); /* codefrag.c */ -void adjsp P((label_t label)); +void adjsp P((label_no label)); void clrBreg P((void)); void comment P((void)); void ctoi P((void)); @@ -57,20 +57,20 @@ void adjlc P((offset_t offset, store_pt reg)); void andconst P((offset_t offset)); void bssseg P((void)); -label_t casejump P((void)); +label_no casejump P((void)); void common P((char *name)); void cseg P((void)); void defnulls P((uoffset_t nullcount)); -label_t defstr P((char *sptr, char *stop, bool_pt dataflag)); +label_no defstr P((char *sptr, char *stop, bool_pt dataflag)); bool_pt diveasy P((value_t divisor, bool_pt uflag)); void dpseg P((void)); void dseg P((void)); void equ P((char *name, char *string)); -void equlab P((label_t label, offset_t offset)); +void equlab P((label_no label, offset_t offset)); void globl P((char *name)); void import P((char *name)); void itol P((store_pt reg)); -void lcommlab P((label_t label)); +void lcommlab P((label_no label)); void lcommon P((char *name)); void lea P((offset_t offset, store_pt sourcereg, store_pt targreg)); void loadconst P((offset_t offset, store_pt reg)); @@ -189,8 +189,8 @@ void cmp P((struct symstruct *source, struct symstruct *target, ccode_t *pcondtrue)); void condop P((struct nodestruct *exp)); -void jumpfalse P((struct nodestruct *exp, label_t label)); -void jumptrue P((struct nodestruct *exp, label_t label)); +void jumpfalse P((struct nodestruct *exp, label_no label)); +void jumptrue P((struct nodestruct *exp, label_no label)); void logop P((struct nodestruct *exp)); /* hardop.c */ @@ -220,16 +220,16 @@ void clearlabels P((char *patchbuf, char *patchtop)); void clearswitchlabels P((void)); uoffset_t getlc P((void)); -void deflabel P((label_t label)); -label_t gethighlabel P((void)); -label_t getlabel P((void)); -void jump P((label_t label)); -void lbranch P((ccode_pt cond, label_t label)); +void deflabel P((label_no label)); +label_no gethighlabel P((void)); +label_no getlabel P((void)); +void jump P((label_no label)); +void lbranch P((ccode_pt cond, label_no label)); struct symstruct *namedlabel P((void)); void outcond P((ccode_pt cond)); -void outlabel P((label_t label)); -void outnlabel P((label_t label)); -void sbranch P((ccode_pt cond, label_t label)); +void outlabel P((label_no label)); +void outnlabel P((label_no label)); +void sbranch P((ccode_pt cond, label_no label)); void unbumplc P((void)); /* loadexp.c */ @@ -343,7 +343,7 @@ struct symstruct **gethashptr P((char *sname)); void growheap P((unsigned size)); void *growobject P((void *object, unsigned extra)); -label_t holdstr P((char *sptr, char *stop)); +label_no holdstr P((char *sptr, char *stop)); void newlevel P((void)); void oldlevel P((void)); void ourfree P((void *ptr)); diff -Nurd linux-86.old/bcc/state.c linux-86/bcc/state.c --- linux-86.old/bcc/state.c Sun Apr 13 11:17:08 1997 +++ linux-86/bcc/state.c Sun Sep 28 09:57:11 1997 @@ -22,8 +22,8 @@ struct loopstruct { - label_t breaklab; /* destination for break */ - label_t contlab; /* destination for continue */ + label_no breaklab; /* destination for break */ + label_no contlab; /* destination for continue */ struct nodestruct *etmark; /* expression tree built during loop */ struct symstruct *exprmark; /* expression symbols built during loop */ struct symstruct *locmark; /* local variables built during loop */ @@ -36,12 +36,12 @@ struct casestruct *caseptr; /* current spot in caselist */ struct casestruct *casetop; /* last in caselist + 1 */ bool_t charselector; /* tells if case selector is char */ - label_t dfaultlab; /* destination for default case (0 if none) */ + label_no dfaultlab; /* destination for default case (0 if none) */ struct switchstruct *prevswitch; /* previous active switch */ struct casestruct { value_t casevalue; /* value giving this case */ - label_t caselabel; /* corresponding label */ + label_no caselabel; /* corresponding label */ } caselist[INITIALCASES]; /* perhaps larger */ }; @@ -50,7 +50,7 @@ /* depends on NULL init */ PRIVATE bool_t returnflag; /* set if last effective statement */ /* was a return */ -PRIVATE label_t swstacklab; /* label giving stack for switch statement */ +PRIVATE label_no swstacklab; /* label giving stack for switch statement */ FORWARD void addloop P((struct loopstruct *newloop)); FORWARD void badloop P((void)); @@ -364,7 +364,7 @@ PRIVATE void dodowhile() { struct loopstruct dwhileloop; - label_t dolab; + label_no dolab; addloop(&dwhileloop); deflabel(dolab = getlabel()); @@ -385,8 +385,8 @@ PRIVATE void dofor() { struct loopstruct forloop; - label_t forstatlab; - label_t fortestlab = 0; /* for -Wall */ + label_no forstatlab; + label_no fortestlab = 0; /* for -Wall */ struct nodestruct *testexp; struct nodestruct *loopexp; @@ -446,8 +446,8 @@ PRIVATE void doif() { struct nodestruct *etmark; - label_t elselab; - label_t exitlab; + label_no elselab; + label_no exitlab; struct symstruct *exprmark; lparen(); @@ -486,7 +486,7 @@ struct switchstruct *sw; struct loopstruct switchloop; offset_t spmark = 0; /* for -Wall */ - label_t sdecidelab; + label_no sdecidelab; sw = (struct switchstruct *) ourmalloc(sizeof *sw); #ifdef TS @@ -532,7 +532,7 @@ { struct loopstruct whileloop; struct nodestruct *testexp; - label_t wstatlab; + label_no wstatlab; lparen(); addloop(&whileloop); @@ -557,11 +557,11 @@ value_t caseval; bool_t charselector; bool_t dfaultflag; - label_t dfaultlab; - label_t jtablelab; + label_no dfaultlab; + label_no jtablelab; ccode_t lowcondition; store_pt targreg; - label_t zjtablelab; + label_no zjtablelab; caseptr = switchnow->caselist; casetop = switchnow->caseptr; diff -Nurd linux-86.old/bcc/table.c linux-86/bcc/table.c --- linux-86.old/bcc/table.c Sun Apr 13 11:17:11 1997 +++ linux-86/bcc/table.c Sun Sep 28 09:57:11 1997 @@ -50,7 +50,7 @@ struct string *snext; char *sptr; char *stop; - label_t slabel; + label_no slabel; }; #endif @@ -495,7 +495,7 @@ /* hold string for dumping at end, to avoid mixing it with other data */ -PUBLIC label_t holdstr(sptr, stop) +PUBLIC label_no holdstr(sptr, stop) char *sptr; char *stop; { diff -Nurd linux-86.old/bcc/types.h linux-86/bcc/types.h --- linux-86.old/bcc/types.h Sun Apr 13 11:18:23 1997 +++ linux-86/bcc/types.h Sun Sep 28 09:57:12 1997 @@ -92,7 +92,7 @@ typedef smalu_t constr_t; /* type constructor flags */ typedef smalu_pt indn_pt; /* promoted indn_t */ typedef smalu_t indn_t; /* storage indirection count */ -typedef unsigned label_t; /* label number */ +typedef unsigned label_no; /* label number */ typedef smalu_t maclev_t; /* macro expansion level */ typedef smalin_pt op_pt; /* promoted op_t */ typedef smalin_t op_t; /* operator code */ @@ -147,7 +147,7 @@ { double *offd; /* value for double constants */ offset_t offi; /* offset for register or global storage */ - label_t offlabel; /* label number for strings */ + label_no offlabel; /* label number for strings */ char *offp; /* to string for macro definitions */ sym_pt offsym; /* symbol code for keywords */ value_t offv; /* value for integral constants */ @@ -155,7 +155,7 @@ offset; union { - label_t label; /* label number for strings */ + label_no label; /* label number for strings */ char namea[1]; /* variable length array for declarations */ char *namep; /* to constant storage for exprs */ } diff -Nurd linux-86.old/bootblocks/Makefile linux-86/bootblocks/Makefile --- linux-86.old/bootblocks/Makefile Wed May 7 22:50:45 1997 +++ linux-86/bootblocks/Makefile Sun Aug 17 21:01:45 1997 @@ -5,68 +5,84 @@ CC=$(BCC) CFLAGS=-ansi -Ms -H0x10000 -s -ASFLAGS=-0 +ASFLAGS=-0 -w +MDEFS= # LST=-l $*.lst +# CLST=-A-l -A$*.lst default: makeboot makeboot.com monitor.out all: default tgz bin CSRC=minix.c -SSRC=tarboot.s skip.s com_bcc.s tich.s sysboot.s bootlist.s mbr.s msdos.s +SSRC=sysboot.s \ + tarboot.s skip.s com_bcc.s tich.s \ + bootlist.s mbr.s msdos.s noboot.s encap: $(SSRC:s=v) $(CSRC:c=v) minixhd.v bin: $(SSRC:s=bin) $(CSRC:c=bin) minixhd.bin MOBJ=monitor.o i86_funcs.o relocate.o help.o bzimage.o dosfs.o nofs.o MSRC=monitor.c i86_funcs.c relocate.c help.c bzimage.c dosfs.c nofs.c +MINC=i86_funcs.h readfs.h + +EXTRAS=minix.h elf_info.c elf_info.h standalone.c li86.s install: monitor.out: $(MOBJ) $(CC) $(CFLAGS) $(MOBJ) -o monitor.out -monitor: $(MSRC) +$(MOBJ): $(MINC) version.h + +monitor: $(MSRC) $(MINC) @rm -f $(MOBJ) make 'CFLAGS=-ansi' monitor.out mv monitor.out monitor @rm -f $(MOBJ) minix.s: minix.c - $(BCC) -Mc -S minix.c + $(BCC) -Mf -DDOTS -DTRY_FLOPPY $(MDEFS) -S minix.c minixhd.s: minix.c - $(BCC) -Mc -DHARDDISK -S minix.c -o minixhd.s + $(BCC) -Mf -DDOTS -DHARDDISK $(MDEFS) -S minix.c -o minixhd.s -makeboot: makeboot.c sysboot.v skip.v msdos.v tarboot.v +makeboot: makeboot.c sysboot.v noboot.v skip.v msdos.v tarboot.v $(HOSTCC) $(HOSTCCFLAGS) -o makeboot makeboot.c -makeboot.com: makeboot.c sysboot.v skip.v msdos.v tarboot.v +makeboot.com: makeboot.c sysboot.v noboot.v skip.v msdos.v tarboot.v $(BCC) -Md -o makeboot.com makeboot.c +version.h: + head -1 ../Libc_version | \ + sed 's/\(.*\)/#define VERSION "\1"/' > version.h + clean realclean: rm -f monitor makeboot bootblocks.tar.gz - rm -f minix.s *.com *.o *.bin *.out *.lst *.sym *.v + rm -f minix.s minixhd.s version.h + rm -f *.com *.o *.bin *.out *.lst *.sym *.v *.tmp tgz: minix.bin monitor.out makeboot.com makeboot tar cfV bootblocks.tar ENIAC monitor.out \ README Makefile \ - $(MSRC) makeboot.c \ - $(CSRC) $(SSRC) \ - makeboot.com minix.bin + $(MSRC) \ + $(MINC) \ + makeboot.c $(CSRC) \ + $(SSRC) \ + makeboot.com minix.bin \ + $(EXTRAS) makeboot tar bootblocks.tar gzip -f9 bootblocks.tar distribution: - tar czf /tmp/bootblocks.tar.gz README Makefile \ - $(MSRC) makeboot.c \ - $(CSRC) $(SSRC) + tar czf /tmp/bootblocks.tar.gz \ + README Makefile $(MSRC) $(MINC) makeboot.c $(CSRC) $(SSRC) $(EXTRAS) .SUFFIXES: .bin .v .s.bin: - $(BCC) -c $*.s -A-u- -A-b -A/tmp/$*.bin -A-s -A$*.sym -A-l -A$*.lst - -@mv /tmp/$*.bin $*.bin + $(BCC) -W -c $*.s -A-u- -A-b -A$*.tmp -A-s -A$*.sym $(CLST) + mv $*.tmp $*.bin -@rm $*.o .s.v: diff -Nurd linux-86.old/bootblocks/bzimage.c linux-86/bootblocks/bzimage.c --- linux-86.old/bootblocks/bzimage.c Wed Jan 8 21:54:30 1997 +++ linux-86/bootblocks/bzimage.c Fri Jun 20 13:02:08 1997 @@ -227,6 +227,8 @@ for(i=0; i<512; i++) __poke_es(i, buffer[i]); } + else + printf("In EMU can't write to 0x%x\n", address); return 0; } #endif diff -Nurd linux-86.old/bootblocks/dosfs.c linux-86/bootblocks/dosfs.c --- linux-86.old/bootblocks/dosfs.c Wed May 7 22:36:49 1997 +++ linux-86/bootblocks/dosfs.c Fri Jun 20 13:37:43 1997 @@ -298,14 +298,12 @@ pend_h != phy_h || pend_c != phy_c ) { -/* -printf("phy_read(%d,%d,%d,%d,%d,%d);\n", - drive, pend_c, pend_h, pend_s+1, pend_len, buf_start); -*/ if( buf_start ) do { rv = phy_read(drive, pend_c, pend_h, pend_s+1, pend_len, buf_start); tries--; + if( rv ) printf("Error in phy_read(%d,%d,%d,%d,%d,%d);\n", + drive, pend_c, pend_h, pend_s+1, pend_len, buf_start); } while(rv && tries > 0); diff -Nurd linux-86.old/bootblocks/elf_info.c linux-86/bootblocks/elf_info.c --- linux-86.old/bootblocks/elf_info.c Thu Jan 1 01:00:00 1970 +++ linux-86/bootblocks/elf_info.c Sun Jun 30 15:54:07 1996 @@ -0,0 +1,189 @@ + +#include +#include "elf_info.h" + +Elf32_Ehdr elf_head; +Elf32_Phdr *elf_prog; + +#ifdef TEST +FILE *ifd; + +main(argc, argv) +int argc; +char **argv; +{ + ifd = fopen(argv[1], "r"); + if (ifd == 0) + exit(1); + + read_elfprog(); + write_ram("", -1L, 0); + + fclose(ifd); +} + +read_file(buf, offset, len) +void *buf; +long offset; +int len; +{ + fseek(ifd, offset, 0); + return fread(buf, 1, len, ifd); +} + +write_ram(buf, linear, len) +char *buf; +long linear; +int len; +{ +static long llen = 0; +static long lastlin= -1; + + if( llen > 0 && lastlin + llen != linear ) + { + printf("for %8ld bytes\n", llen); + lastlin= -1; + } + if( lastlin == -1 ) + { + lastlin = linear; + llen = 0; + + if( linear != -1 ) + printf("Write %08lx ", linear); + } + llen += len; + return len; +} + +error(str) +char *str; +{ + printf("Error: %s\n", str); + return -1; +} +#endif + +info_elf() +{ + int i; + + printf("ELF-386 executable, entry = 0x%08lx\n", elf_head.e_entry); + printf("\t\toffset paddr vaddr filesz memsz align\n"); + for (i = 0; i < elf_head.e_phnum; i++) + { + printf(" %d: ", i); + switch ((int) elf_prog[i].p_type) + { + case PT_NULL: + printf("PT_NULL"); + break; + case PT_LOAD: + printf("PT_LOAD"); + break; + case PT_DYNAMIC: + printf("PT_DYNAMIC"); + break; + case PT_INTERP: + printf("PT_INTERP"); + break; + case PT_NOTE: + printf("PT_NOTE"); + break; + case PT_SHLIB: + printf("PT_SHLIB"); + break; + case PT_PHDR: + printf("PT_PHDR"); + break; + default: + printf("PT_(%d)", elf_prog[i].p_type); + break; + } + printf("\t%08lx %08lx %08lx %08lx %08lx %08lx", + elf_prog[i].p_offset, + elf_prog[i].p_paddr, + elf_prog[i].p_vaddr, + elf_prog[i].p_filesz, + elf_prog[i].p_memsz, + elf_prog[i].p_align + ); + printf("\n"); + } +} + +read_elfprog() +{ + static unsigned char elf_ok[] = + {ELFMAG0, ELFMAG1, ELFMAG2, ELFMAG3, ELFCLASS32, ELFDATA2LSB, EV_CURRENT}; + + int i; + char page_buf[4096]; + + if (read_file(&elf_head, 0L, sizeof(elf_head)) != sizeof(elf_head)) + return error("Can't read ELF header"); + + if (memcmp(elf_head.e_ident, elf_ok, 7) != 0 || + elf_head.e_type != ET_EXEC || + elf_head.e_machine != EM_386 || + elf_head.e_phnum <= 0 || + elf_head.e_phentsize != sizeof(Elf32_Phdr) + ) + return error("Not a 386 executable ELF program"); + + elf_prog = malloc(i = sizeof(Elf32_Phdr) * elf_head.e_phnum); + if (elf_prog == 0) + return error("Out of memory"); + + if (read_file(elf_prog, elf_head.e_phoff, i) != i) + return error("Can't read ELF program header"); + + info_elf(); + + for (i = 0; i < elf_head.e_phnum; i++) + { + long from, to, length, copied; + int chunk; + + switch ((int) elf_prog[i].p_type) + { + case PT_NULL: + case PT_NOTE: + continue; + default: + return error("ELF: Unusable program segment (Must be static)"); + case PT_LOAD: + break; + } + from=elf_prog[i].p_offset; + to=elf_prog[i].p_vaddr; + length=elf_prog[i].p_filesz; + + for(copied=0; copiedcopied+sizeof(page_buf)) chunk=sizeof(page_buf); + else chunk=length-copied; + + if( (chunk=read_file(page_buf, from, chunk)) <= 0 ) + return error("ELF Cannot read executable"); + if( write_ram(page_buf, to, chunk) < 0 ) + return error("Memory save failed"); + copied+=chunk; from+=chunk; to+=chunk; + } + length=elf_prog[i].p_memsz; + if( length > copied ) + { + write_ram("", -1L, 0); + memset(page_buf, '\0', sizeof(page_buf)); + for(; copiedcopied+sizeof(page_buf)) chunk=sizeof(page_buf); + else chunk=length-copied; + + if( write_ram(page_buf, to, chunk) < 0 ) + return error("Memory zap failed"); + copied+=chunk; to+=chunk; + } + } + } +} diff -Nurd linux-86.old/bootblocks/elf_info.h linux-86/bootblocks/elf_info.h --- linux-86.old/bootblocks/elf_info.h Thu Jan 1 01:00:00 1970 +++ linux-86/bootblocks/elf_info.h Sat Jun 15 12:14:11 1996 @@ -0,0 +1,282 @@ + +/* ELF layout information */ + +/* NOTE: I'm copying the file format information here because the _format_ + * is standard, but the Linux header files are not and may depend on + * headers not available when compiling Linux-86 code. + */ + +#ifndef _LINUX_ELF_H +#define _LINUX_ELF_H + +typedef unsigned long Elf32_Addr; +typedef unsigned short Elf32_Half; +typedef unsigned long Elf32_Off; +typedef long Elf32_Sword; +typedef unsigned long Elf32_Word; + +/* These constants are for the segment types stored in the image headers */ +#define PT_NULL 0 +#define PT_LOAD 1 +#define PT_DYNAMIC 2 +#define PT_INTERP 3 +#define PT_NOTE 4 +#define PT_SHLIB 5 +#define PT_PHDR 6 +#define PT_LOPROC 0x70000000L +#define PT_HIPROC 0x7fffffffL + +/* These constants define the different elf file types */ +#define ET_NONE 0 +#define ET_REL 1 +#define ET_EXEC 2 +#define ET_DYN 3 +#define ET_CORE 4 +#define ET_LOPROC 5 +#define ET_HIPROC 6 + +/* These constants define the various ELF target machines */ +#define EM_NONE 0 +#define EM_M32 1 +#define EM_SPARC 2 +#define EM_386 3 +#define EM_68K 4 +#define EM_88K 5 +#define EM_486 6 /* Perhaps disused */ +#define EM_860 7 + +/* This is the info that is needed to parse the dynamic section of the file */ +#define DT_NULL 0 +#define DT_NEEDED 1 +#define DT_PLTRELSZ 2 +#define DT_PLTGOT 3 +#define DT_HASH 4 +#define DT_STRTAB 5 +#define DT_SYMTAB 6 +#define DT_RELA 7 +#define DT_RELASZ 8 +#define DT_RELAENT 9 +#define DT_STRSZ 10 +#define DT_SYMENT 11 +#define DT_INIT 12 +#define DT_FINI 13 +#define DT_SONAME 14 +#define DT_RPATH 15 +#define DT_SYMBOLIC 16 +#define DT_REL 17 +#define DT_RELSZ 18 +#define DT_RELENT 19 +#define DT_PLTREL 20 +#define DT_DEBUG 21 +#define DT_TEXTREL 22 +#define DT_JMPREL 23 +#define DT_LOPROC 0x70000000L +#define DT_HIPROC 0x7fffffffL + +/* This info is needed when parsing the symbol table */ +#define STB_LOCAL 0 +#define STB_GLOBAL 1 +#define STB_WEAK 2 + +#define STT_NOTYPE 0 +#define STT_OBJECT 1 +#define STT_FUNC 2 +#define STT_SECTION 3 +#define STT_FILE 4 + +#define ELF32_ST_BIND(x) ((x) >> 4) +#define ELF32_ST_TYPE(x) (((unsigned int) x) & 0xf) + +/* Symbolic values for the entries in the auxiliary table + put on the initial stack */ +#define AT_NULL 0 /* end of vector */ +#define AT_IGNORE 1 /* entry should be ignored */ +#define AT_EXECFD 2 /* file descriptor of program */ +#define AT_PHDR 3 /* program headers for program */ +#define AT_PHENT 4 /* size of program header entry */ +#define AT_PHNUM 5 /* number of program headers */ +#define AT_PAGESZ 6 /* system page size */ +#define AT_BASE 7 /* base address of interpreter */ +#define AT_FLAGS 8 /* flags */ +#define AT_ENTRY 9 /* entry point of program */ +#define AT_NOTELF 10 /* program is not ELF */ +#define AT_UID 11 /* real uid */ +#define AT_EUID 12 /* effective uid */ +#define AT_GID 13 /* real gid */ +#define AT_EGID 14 /* effective gid */ + + +typedef struct dynamic{ + Elf32_Sword d_tag; + union{ + Elf32_Sword d_val; + Elf32_Addr d_ptr; + } d_un; +} Elf32_Dyn; + +extern Elf32_Dyn _DYNAMIC []; + +/* The following are used with relocations */ +#define ELF32_R_SYM(x) ((x) >> 8) +#define ELF32_R_TYPE(x) ((x) & 0xff) + +#define R_386_NONE 0 +#define R_386_32 1 +#define R_386_PC32 2 +#define R_386_GOT32 3 +#define R_386_PLT32 4 +#define R_386_COPY 5 +#define R_386_GLOB_DAT 6 +#define R_386_JMP_SLOT 7 +#define R_386_RELATIVE 8 +#define R_386_GOTOFF 9 +#define R_386_GOTPC 10 +#define R_386_NUM 11 + +typedef struct elf32_rel { + Elf32_Addr r_offset; + Elf32_Word r_info; +} Elf32_Rel; + +typedef struct elf32_rela{ + Elf32_Addr r_offset; + Elf32_Word r_info; + Elf32_Sword r_addend; +} Elf32_Rela; + +typedef struct elf32_sym{ + Elf32_Word st_name; + Elf32_Addr st_value; + Elf32_Word st_size; + unsigned char st_info; + unsigned char st_other; + Elf32_Half st_shndx; +} Elf32_Sym; + + +#define EI_NIDENT 16 + +typedef struct elfhdr{ + unsigned char e_ident[EI_NIDENT]; + Elf32_Half e_type; + Elf32_Half e_machine; + Elf32_Word e_version; + Elf32_Addr e_entry; /* Entry point */ + Elf32_Off e_phoff; + Elf32_Off e_shoff; + Elf32_Word e_flags; + Elf32_Half e_ehsize; + Elf32_Half e_phentsize; + Elf32_Half e_phnum; + Elf32_Half e_shentsize; + Elf32_Half e_shnum; + Elf32_Half e_shstrndx; +} Elf32_Ehdr; + +/* These constants define the permissions on sections in the program + header, p_flags. */ +#define PF_R 0x4 +#define PF_W 0x2 +#define PF_X 0x1 + +typedef struct elf_phdr{ + Elf32_Word p_type; + Elf32_Off p_offset; + Elf32_Addr p_vaddr; + Elf32_Addr p_paddr; + Elf32_Word p_filesz; + Elf32_Word p_memsz; + Elf32_Word p_flags; + Elf32_Word p_align; +} Elf32_Phdr; + +/* sh_type */ +#define SHT_NULL 0 +#define SHT_PROGBITS 1 +#define SHT_SYMTAB 2 +#define SHT_STRTAB 3 +#define SHT_RELA 4 +#define SHT_HASH 5 +#define SHT_DYNAMIC 6 +#define SHT_NOTE 7 +#define SHT_NOBITS 8 +#define SHT_REL 9 +#define SHT_SHLIB 10 +#define SHT_DYNSYM 11 +#define SHT_NUM 12 +#define SHT_LOPROC 0x70000000L +#define SHT_HIPROC 0x7fffffffL +#define SHT_LOUSER 0x80000000L +#define SHT_HIUSER 0xffffffffL + +/* sh_flags */ +#define SHF_WRITE 0x1 +#define SHF_ALLOC 0x2 +#define SHF_EXECINSTR 0x4 +#define SHF_MASKPROC 0xf0000000L + +/* special section indexes */ +#define SHN_UNDEF 0 +#define SHN_LORESERVE 0xff00L +#define SHN_LOPROC 0xff00L +#define SHN_HIPROC 0xff1fL +#define SHN_ABS 0xfff1L +#define SHN_COMMON 0xfff2L +#define SHN_HIRESERVE 0xffffL + +typedef struct { + Elf32_Word sh_name; + Elf32_Word sh_type; + Elf32_Word sh_flags; + Elf32_Addr sh_addr; + Elf32_Off sh_offset; + Elf32_Word sh_size; + Elf32_Word sh_link; + Elf32_Word sh_info; + Elf32_Word sh_addralign; + Elf32_Word sh_entsize; +} Elf32_Shdr; + +#define EI_MAG0 0 /* e_ident[] indexes */ +#define EI_MAG1 1 +#define EI_MAG2 2 +#define EI_MAG3 3 +#define EI_CLASS 4 +#define EI_DATA 5 +#define EI_VERSION 6 +#define EI_PAD 7 + +#define ELFMAG0 0x7f /* EI_MAG */ +#define ELFMAG1 'E' +#define ELFMAG2 'L' +#define ELFMAG3 'F' +#define ELFMAG "\177ELF" +#define SELFMAG 4 + +#define ELFCLASSNONE 0 /* EI_CLASS */ +#define ELFCLASS32 1 +#define ELFCLASS64 2 +#define ELFCLASSNUM 3 + +#define ELFDATANONE 0 /* e_ident[EI_DATA] */ +#define ELFDATA2LSB 1 +#define ELFDATA2MSB 2 + +#define EV_NONE 0 /* e_version, EI_VERSION */ +#define EV_CURRENT 1 +#define EV_NUM 2 + +/* Notes used in ET_CORE */ +#define NT_PRSTATUS 1 +#define NT_PRFPREG 2 +#define NT_PRPSINFO 3 +#define NT_TASKSTRUCT 4 + +/* Note header in a PT_NOTE section */ +typedef struct elf_note { + Elf32_Word n_namesz; /* Name size */ + Elf32_Word n_descsz; /* Content size */ + Elf32_Word n_type; /* Content type */ +} Elf32_Nhdr; + +#endif /* _LINUX_ELF_H */ diff -Nurd linux-86.old/bootblocks/i86_funcs.h linux-86/bootblocks/i86_funcs.h --- linux-86.old/bootblocks/i86_funcs.h Thu Jan 1 01:00:00 1970 +++ linux-86/bootblocks/i86_funcs.h Fri Jan 3 08:42:20 1997 @@ -0,0 +1,21 @@ +/* + * These are bios and hardware functions for the 8086 IBM PC + */ + +extern int x86; /* CPU major number (0-3) */ +extern char *x86_name; /* and it's name */ +extern int x86_emu; /* Is this a PC emulator ? */ +extern int x86_a20_closed; /* Is the A20 gate closed ? */ +extern int x86_test; /* In test mode */ +extern int x86_fpu; + +extern unsigned boot_mem_top; /* Top of RAM below 1M */ +extern long main_mem_top; /* Top of RAM above 1M */ + +int a20_closed(); +void open_a20(); +void bios_open_a20(); +void cpu_check(); +void mem_check(); +int ext_put(); +int ext_get(); diff -Nurd linux-86.old/bootblocks/li86.s linux-86/bootblocks/li86.s --- linux-86.old/bootblocks/li86.s Thu Jan 1 01:00:00 1970 +++ linux-86/bootblocks/li86.s Tue Nov 19 21:30:57 1996 @@ -0,0 +1,46 @@ +!---------------------------------------------------------------------------- +! +! This is a skeleton for creating an impure Linux-8086 executable without +! using the linker. The .text and .data areas are correctly positioned. +! +! This file needs to be compiled using the 3 pass mode (-j) +! +!---------------------------------------------------------------------------- +.text +org -32 +.word 0x0301 ! Magic +.word 0x0410 ! Btype +.long 0x20 ! header length +.long _etext ! a_text +.long _edata-_etext ! a_data +.long 0 ! a_bss +.long 0 ! a_entry +.long STACK_SIZE ! a_total +.long 0 ! a_syms +.data +.blkb _etext +.even +.text +!---------------------------------------------------------------------------- + +STACK_SIZE = 0x10000 + +.data +var: +.word $1234 + +.text + int $20 + mov ax,var + mov bx,_edata + push ax + ret + +!---------------------------------------------------------------------------- +! This trailer must be at the end of the file. +.text +_etext: +.data +_edata: +END + diff -Nurd linux-86.old/bootblocks/makeboot.c linux-86/bootblocks/makeboot.c --- linux-86.old/bootblocks/makeboot.c Sat May 3 08:09:11 1997 +++ linux-86/bootblocks/makeboot.c Sat Jun 7 16:28:35 1997 @@ -4,17 +4,18 @@ #include #include "sysboot.v" +#include "noboot.v" #include "msdos.v" #include "skip.v" #include "tarboot.v" char buffer[1024]; -#define FS_NONE 0 -#define FS_ADOS 1 -#define FS_DOS 2 -#define FS_TAR 3 -#define FS_STAT 4 +#define FS_NONE 0 /* Bootsector is complete */ +#define FS_ADOS 1 /* Bootsector needs 'normal' DOS FS */ +#define FS_DOS 2 /* Bootsector needs any DOS FS */ +#define FS_TAR 3 /* Bootsector needs GNU-tar volume label */ +#define FS_STAT 4 /* DOS bootsector is checked */ struct bblist { char * name; @@ -24,7 +25,7 @@ } bblocks[] = { { "tar", tarboot_data, FS_TAR, "Bootable GNU tar volume lable" }, { "dosfs", msdos_data, FS_ADOS, "Boots file BOOTFILE.SYS from dosfs" }, - { "none", sysboot_data, FS_DOS, "No OS bookblock, just message" }, + { "none", noboot_data, FS_DOS, "No OS bookblock, just message" }, { "skip", skip_data, FS_DOS, "Bypasses floppy boot with message" }, { "stat", 0, FS_STAT, "Display dosfs superblock" }, { "copy", 0, FS_STAT, "Copy boot block to makeboot.sav" }, @@ -41,6 +42,8 @@ int disk_head = 256; /* Set to the correct values when an MSDOS disk is */ int disk_trck = 256; /* successfully identified */ +int force = 0; + main(argc, argv) int argc; char ** argv; @@ -51,6 +54,10 @@ progname = argv[0]; + if( argc == 4 && strcmp(argv[1], "-f") == 0 ) + { + argv++; argc--; force++; + } if( argc != 3 ) Usage(); if( (i=strlen(argv[1])) < 2 ) Usage(); @@ -355,12 +362,12 @@ if( csum != osum ) { fprintf(stderr, "TAR file checksum failed, this isn't a tar file.\n"); - exit(9); + if(!force) exit(9); } if( buff_tar.linkflag != 'V' ) { fprintf(stderr, "Tar file doesn't start with a volume label\n"); - exit(8); + if(!force) exit(8); } strcpy(vbuf, boot_tar.name); strcat(vbuf, " Volume 1"); @@ -568,24 +575,26 @@ { disk_sect = dosflds[DOS_SPT].value; disk_head = dosflds[DOS_HEADS].value; - disk_trck = dosflds[DOS_MAXSECT].value/disk_head/disk_sect; + if( disk_sect > 0 && disk_head > 0 ) + disk_trck = dosflds[DOS_MAXSECT].value/disk_head/disk_sect; return; } - exit(2); + if(!force) exit(2); } check_simpledos() { - int numclust; + int numclust = 0xFFFF; char * err = 0; check_msdos(); /* Work out how many real clusters there are */ - numclust = ( dosflds[DOS_MAXSECT].value - - dosflds[DOS_RESV].value - - dosflds[DOS_NFAT].value * dosflds[DOS_FATLEN].value - - ((dosflds[DOS_NROOT].value+15)/16) - ) / dosflds[DOS_MAXSECT].value + 2; + if( dosflds[DOS_MAXSECT].value + 2 > 2 ) + numclust = ( dosflds[DOS_MAXSECT].value + - dosflds[DOS_RESV].value + - dosflds[DOS_NFAT].value * dosflds[DOS_FATLEN].value + - ((dosflds[DOS_NROOT].value+15)/16) + ) / dosflds[DOS_MAXSECT].value + 2; if( dosflds[DOS_NFAT].value > 2 ) err = "Too many fat copies on disk"; @@ -607,7 +616,7 @@ fprintf(stderr, "ERROR: %s\n\n", err); print_super(buffer); - exit(2); + if(!force) exit(2); } /**************************************************************************/ diff -Nurd linux-86.old/bootblocks/minix.c linux-86/bootblocks/minix.c --- linux-86.old/bootblocks/minix.c Wed May 7 22:26:17 1997 +++ linux-86/bootblocks/minix.c Mon Aug 18 21:39:18 1997 @@ -7,25 +7,54 @@ */ #include +#include "minix.h" -#undef DOTS /* define to have dots printed */ -#define zone_shift 0 /* for any < 32M (non-zero not supported yet) */ +/* #define DOTS /* define to have dots printed */ +/* #define ELKS_SETUP /* Assume first SETUPSIZE bytes for SETUPSEG */ +/* #define HARDDISK /* Define for hard disk version */ +/* #define TRY_FLOPPY /* To do trial reads to find floppy size */ +/* #define IMAGE_MAGIC /* Check for elks Image magic nos. */ + +#ifdef IMAGE_MAGIC +/* #undef DOTS */ +#define MIN_SPACE +#endif +#define zone_shift 0 /* for any < 32M (non-zero not supported yet) */ #define seg_at(k) ((k)*64) #define seg_of(p) ((unsigned int)p >>4) #define BOOTSEG (0x07c0) #define LOADSEG (0x1000) +#ifdef ELKS_SETUP +/* Can't do this .. SETUPSEGSIZE isn't in there! */ +/* + * #include + * #define SETUPSEG (DEF_SETUPSEG) + * #define SETUPSIZE (DEF_SETUPSIZE) + * #define ORGADDR (SETUPSEG*16+SETUPSEGSIZE) + */ +#define SETUPSEG (0x0120) +#define SETUPSIZE (4*512/16) +#define ORGADDR (0x0500) +#else +#define ORGADDR (0x0500) +#endif + #ifdef HARDDISK #define get_now() #endif -#asm -! BOOTSEG = 0x07c0 -! LOADSEG = 0x1000 ! This must be sector aligned +#ifdef zone_shift +#if zone_shift == 0 +#define load_zone load_block +#endif +#else +static short zone_shift; +#endif +#asm BOOTADDR = 0x7c00 -ORGADDR = $0500 .text ! Apparently on startup the only things we can assume are that we start at @@ -38,30 +67,34 @@ ! org ORGADDR ! The lowest available address. start: +#ifndef MIN_SPACE include sysboot.s org dos_sysid .ascii "MINIXFS BOOT (C) 1990-1997, Robert de Bath" org codestart +#endif #ifdef HARDDISK mov bx,[si+8] ! Fetch the linear address of part from DS:SI mov dh,[si+10] ! DL is drive number #endif - xor ax,ax + xor ax,ax ! All segments are zero, first 64k of mem. mov ds,ax mov es,ax mov ss,ax mov sp,ax #ifndef HARDDISK +loopy: mov ax,#$0204 ! Read 4 sectors, code + superblock. mov bx,#start ! Where this _should_ be mov cx,#$0001 ! From sector 1 xor dx,dx ! Of the floppy drive head zero int $13 + jc loopy #else mov cx,#$100 ! Move 256 words @@ -87,119 +120,11 @@ #endasm +/* /* */ /****************************************************************************/ -/* Super block table. The root file system and every mounted file system - * has an entry here. The entry holds information about the sizes of the bit - * maps and inodes. The s_ninodes field gives the number of inodes available - * for files and directories, including the root directory. Inode 0 is - * on the disk, but not used. Thus s_ninodes = 4 means that 5 bits will be - * used in the bit map, bit 0, which is always 1 and not used, and bits 1-4 - * for files and directories. The disk layout is: - * - * Item # blocks - * boot block 1 - * super block 1 - * inode map s_imap_blocks - * zone map s_zmap_blocks - * inodes (s_ninodes + 1 + INODES_PER_BLOCK - 1)/INODES_PER_BLOCK - * unused whatever is needed to fill out the current zone - * data zones (s_nzones - s_firstdatazone) << s_log_zone_size - * - * A super_block slot is free if s_dev == NO_DEV. - */ - -#define BLOCK_SIZE 1024 /* # bytes in a disk block */ - -/* Flag bits for i_mode in the inode. */ -#define I_TYPE 0170000 /* this field gives inode type */ -#define I_REGULAR 0100000 /* regular file, not dir or special */ -#define I_BLOCK_SPECIAL 0060000 /* block special file */ -#define I_DIRECTORY 0040000 /* file is a directory */ -#define I_CHAR_SPECIAL 0020000 /* character special file */ -#define I_SET_UID_BIT 0004000 /* set effective uid on exec */ -#define I_SET_GID_BIT 0002000 /* set effective gid on exec */ -#define ALL_MODES 0006777 /* all bits for user, group and others */ -#define RWX_MODES 0000777 /* mode bits for RWX only */ -#define R_BIT 0000004 /* Rwx protection bit */ -#define W_BIT 0000002 /* rWx protection bit */ -#define X_BIT 0000001 /* rwX protection bit */ -#define I_NOT_ALLOC 0000000 /* this inode is free */ - -/* Type definitions */ -typedef unsigned short unshort; /* must be 16-bit unsigned */ -typedef unshort block_nr; /* block number */ -typedef unshort inode_nr; /* inode number */ -typedef unshort zone_nr; /* zone number */ -typedef unshort bit_nr; /* if inode_nr & zone_nr both unshort, - then also unshort, else long */ - -typedef unshort sect_nr; - -typedef long zone_type; /* zone size */ -typedef unshort mask_bits; /* mode bits */ -typedef unshort dev_nr; /* major | minor device number */ -typedef char links; /* number of links to an inode */ -typedef long real_time; /* real time in seconds since Jan 1, 1970 */ -typedef long file_pos; /* position in, or length of, a file */ -typedef short uid; /* user id */ -typedef char gid; /* group id */ - -/* Tables sizes */ -#define NR_ZONE_NUMS 9 /* # zone numbers in an inode */ -#define NAME_SIZE 14 /* # bytes in a directory component */ - -/* Miscellaneous constants */ -#define SUPER_MAGIC 0x137F /* magic number contained in super-block */ - -#define BOOT_BLOCK (block_nr)0 /* block number of boot block */ -#define SUPER_BLOCK (block_nr)1 /* block number of super block */ -#define ROOT_INODE (inode_nr)1 /* inode number for root directory */ - -/* Derived sizes */ -#define NR_DZONE_NUM (NR_ZONE_NUMS-2) /* # zones in inode */ -#define INODES_PER_BLOCK (BLOCK_SIZE/sizeof(d_inode)) /* # inodes/disk blk */ -#define NR_INDIRECTS (BLOCK_SIZE/sizeof(zone_nr)) /* # zones/indir blk */ -#define INTS_PER_BLOCK (BLOCK_SIZE/sizeof(int)) /* # integers/blk */ - -struct super_block { - inode_nr s_ninodes; /* # usable inodes on the minor device */ - zone_nr s_nzones; /* total device size, including bit maps etc */ - unshort s_imap_blocks; /* # of blocks used by inode bit map */ - unshort s_zmap_blocks; /* # of blocks used by zone bit map */ - zone_nr s_firstdatazone; /* number of first data zone */ - short s_log_zone_size; /* log2 of blocks/zone */ - file_pos s_max_size; /* maximum file size on this device */ - short s_magic; /* magic number to recognize super-blocks */ - -} ; - -/* Type definitions local to the File System. */ -typedef struct { /* directory entry */ - inode_nr d_inum; /* inode number */ - char d_name[NAME_SIZE]; /* character string */ -} dir_struct; - -/* Declaration of the disk inode used in rw_inode(). */ -typedef struct { /* disk inode. Memory inode is in "inotab.h" */ - mask_bits i_mode; /* file type, protection, etc. */ - uid i_uid; /* user id of the file's owner */ - file_pos i_size; /* current file size in bytes */ - real_time i_modtime; /* when was file data last changed */ - gid i_gid; /* group number */ - links i_nlinks; /* how many links to this file */ - zone_nr i_zone[NR_ZONE_NUMS]; /* block nums for direct, ind, and dbl ind */ -} d_inode; - +/* Section cdef */ /****************************************************************************/ -#ifdef zone_shift -#if zone_shift == 0 -#define load_zone load_block -#endif -#else -static short zone_shift; -#endif - /* The name of the file and inode to start */ extern char bootfile[]; extern inode_nr inode; @@ -222,31 +147,37 @@ extern dir_struct * dirptr; extern unsigned flength; -/* The 'shape' of the floppy - intuit from superblock */ +#ifndef HARDDISK +/* The 'shape' of the floppy - intuit from superblock or try to read max */ extern unsigned n_sectors; +#endif -/* - * #define b_super (*(struct super_block *) 1024) - * #define b_inode ((d_inode *)2048) - * #define b_zone ((zone_nr *)3072) - */ +#ifdef IMAGE_MAGIC +extern unsigned checkflg; +extern unsigned segend; +#endif extern struct super_block b_super; extern d_inode b_inode[INODES_PER_BLOCK]; extern zone_nr b_zone[NR_INDIRECTS]; extern dir_struct directory[]; +/* /* */ +/****************************************************************************/ +/* Section adef */ /****************************************************************************/ #asm ! A few variables we need to know the positions of for patching, so export ! them and as86_encaps will make some variables. .text -export _inode ! Inode to search +export inode ! Inode to search +inode: _inode: .word 1 ! ROOT_INODE -export _bootfile ! File to boot, make this whatever you like, -_bootfile: ! 'boot' is good too. +export bootfile ! File to boot, make this whatever you like, +bootfile: ! 'boot' is good too. +_bootfile: .ascii "linux" .byte 0,0,0,0,0,0,0,0,0 @@ -259,67 +190,83 @@ _lastsect: .word 0 #endif -code: - call _loadprog - call _runprog - br _nogood + block start+0x400 +_b_super: .blkb 1024 +_b_inode: .blkb 1024 +_b_zone: .blkb 1024 +#ifdef MIN_SPACE +temp_space: .blkb 512 +#endif +probe_buf: +_directory: .blkb 32768 + endb #endasm -#ifdef HARDDISK - +/* /* */ +/****************************************************************************/ +/* Section nogood */ +/****************************************************************************/ +/* #if defined(HARDDISK) && !defined(SKIPBOOT) */ +#ifndef SKIPBOOT +static +nogood() +{ #asm -_load_block: - push bp - mov bp,sp - - ! Fetch load location - mov ax,[bp+4] - mov es,ax - - ! Test for block zero - mov ax,6[bp] - test ax,ax - jne real_block - - ! Iff block zero, zap memory - push di - mov cx,#512 + mov si,#fail_fs +min_nextc: + lodsb + cmp al,#0 + jz min_eos + mov bx,#7 + mov ah,#$E ! Can't use $13 cause that's AT+ only! + int $10 + jmp min_nextc +min_eos: ! Wait for a key then reboot xor ax,ax - mov di,ax - rep - stosw - pop di - -func_exit: - mov sp,bp - pop bp - ret + int $16 + !int $19 ! This should be OK as we haven't touched anything. + jmpi $0,$FFFF ! Wam! Try or die! -real_block: -#ifdef DOTS - mov ax,#$2E - push ax - call _bios_putc - inc sp - inc sp +fail_fs: +#if defined(HARDDISK) && !defined(IMAGE_MAGIC) + .asciz "Initial boot failed, press return to reboot\r\n" +#else + .asciz "Boot failed:" #endif +#endasm +} -! Load a real block. - mov cx,ax - xor dx,dx - shl cx,#1 - rcl dx,#1 - - xor bx,bx - mov al,#2 - call load_sect +#else - j func_exit +static +nogood() +{ +/* This didn't work, chain the boot sector of the HD */ +#asm + push cs + pop es +hcode: + mov ax,#$0201 ! Read 1 sector + mov bx,#BOOTADDR ! In the boot area + mov cx,#$0001 ! From sector 1 + mov dx,#$0080 ! Of the hard drive head zero + int $13 + jc hcode ! Keep trying forever! + jmpi BOOTADDR,0 +#endasm +} +#endif +/* /* */ +/****************************************************************************/ +/* Section hd_sect */ +/****************************************************************************/ +#ifdef HARDDISK +#asm ! ! Load AL sectors from linear sector DX:CX into location ES:BX -! Linear sector zero is a [bootpart] +! Linear sector zero is at [bootpart] ! This loads one sector at a time, but that's OK cause even in the _very_ ! worst case it'll take no more that 5 seconds to load a 16 bit executable. ! @@ -343,7 +290,7 @@ push es ! Load location push bx - push cx ! Drive and sector. + push cx ! Drive and sector again. push dx ! Fetch drive 'shape' @@ -384,10 +331,20 @@ pop bx ! ES:BX for int 1302 pop es + mov di,#5 ! Lots of retries for a hd +retry: mov ax,#$0201 int $13 - jc _nogood + jnc got_hd_sect + + xor ax,ax ! Reset between each try. + int $13 + + dec di + jnz retry + br _nogood +got_hd_sect: pop dx pop cx pop si @@ -400,64 +357,21 @@ add bh,#2 jmp moresect #endasm - -#else -#asm -_set_bpb: -bios_tabl=dosfs_stat ! Temp space. -bios_disk=dosfs_stat+4 ! - -#ifndef __CALLER_SAVES__ - push si - push di -#endif - - mov di,#bios_disk - mov bx,#0x78 -! 0:bx is parameter table address - - push ds - push di - - mov si,[bx] - mov ax,[bx+2] - mov [bios_tabl],si - mov [bios_tabl+2],ax - push ax - - pop ds -! ds:si is source - -! copy 12 bytes - mov cl,#6 - cld - rep - movsw - - pop di - pop ds - mov ax,[_n_sectors] - movb 4[di],al ! patch sector count - - mov [bx],di - mov 2[bx],es - -#ifndef __CALLER_SAVES__ - pop si - pop di #endif - ret - -_unset_bpb: -! 0:0x78 is parameter table address - mov ax,[bios_tabl] - mov [0x78],ax - mov ax,[bios_tabl+2] - mov [0x78+2],ax - ret +/****************************************************************************/ +/* This is the end of the parts that MUST be in the first sector */ +/* From here down the functions can safely be in any order. */ +/****************************************************************************/ -#endasm +/* /* */ +/****************************************************************************/ +/* Section fd */ +/****************************************************************************/ +#ifndef HARDDISK +/*----------------------------------*/ +/* Floppy disk device driver */ +/*----------------------------------*/ static load_block(address, blkno) @@ -466,7 +380,7 @@ register sect_nr sectno; if(blkno == 0) { zero_block(address); return; } #ifdef DOTS - bios_putc('.'); + prt_dot(); #endif sectno = (sect_nr)blkno * 2; @@ -505,6 +419,8 @@ get_now() { #asm + mov si,#5 +retry_get: xor dx,dx mov cx,[_firstsect] shr ch,#1 @@ -515,19 +431,91 @@ test ax,ax jz no_load mov ah,#2 + int $13 ! Try fetch + jnc no_load + xor ax,ax ! Bad, retry. int $13 - jc nogood + dec si + jnz retry_get + br _nogood no_load: xor ax,ax mov [_loadcount],ax #endasm } +#endif +/****************************************************************************/ +/* Section fd_bpb */ +/****************************************************************************/ +#ifndef HARDDISK #asm -nogood: - j _nogood +_set_bpb: +#ifdef MIN_SPACE +bios_tabl=temp_space ! Temp space. +bios_disk=temp_space+4 ! +#else +bios_tabl=dosfs_stat ! Temp space. +bios_disk=dosfs_stat+4 ! +#endif + +#ifndef __CALLER_SAVES__ + push si + push di +#endif + + mov di,#bios_disk + mov bx,#0x78 +! 0:bx is parameter table address + + push ds + push di + + mov si,[bx] + mov ax,[bx+2] + mov [bios_tabl],si + mov [bios_tabl+2],ax + push ax + + pop ds +! ds:si is source + +! copy 12 bytes + mov cl,#6 + cld + rep + movsw + + pop di + pop ds + mov ax,[_n_sectors] + movb 4[di],al ! patch sector count + + mov [bx],di + mov 2[bx],es + +#ifndef __CALLER_SAVES__ + pop si + pop di +#endif + ret + +_unset_bpb: +! 0:0x78 is parameter table address + + mov ax,[bios_tabl] + mov [0x78],ax + mov ax,[bios_tabl+2] + mov [0x78+2],ax + ret + #endasm +#endif +/****************************************************************************/ +/* Section fd_zeroblk */ +/****************************************************************************/ +#ifndef HARDDISK static zero_block(address) { @@ -547,87 +535,221 @@ pop di #endasm } +#endif -#endif /* !HARDDISK */ +/****************************************************************************/ +/* Section hd_block */ +/****************************************************************************/ +#ifdef HARDDISK +/*----------------------------------*/ +/* Hard disk block driver */ +/*----------------------------------*/ -#ifdef DOTS -static -bios_putc(c) -{ #asm -#if !__FIRST_ARG_IN_AX__ - mov bx,sp - mov ax,[bx+2] +_load_block: + push bp + mov bp,sp + + ! Fetch load location + mov ax,[bp+4] + mov es,ax + + ! Test for block zero + mov ax,6[bp] + test ax,ax + jne real_block + + ! Iff block zero, zap memory + push di + mov cx,#512 + xor ax,ax + mov di,ax + rep + stosw + pop di + +func_exit: + mov sp,bp + pop bp + ret + +real_block: +#ifdef DOTS + call _prt_dot #endif - mov ah,#$0E - mov bx,#7 - int $10 + +! Load a real block. + mov cx,ax + xor dx,dx + shl cx,#1 + rcl dx,#1 + + xor bx,bx + mov al,#2 + call load_sect + + j func_exit #endasm -} #endif -static -nogood() -{ -#ifdef HARDDISK +/****************************************************************************/ +/* Section prt_dots */ +/****************************************************************************/ +#ifdef DOTS #asm - mov si,#fail_fs -min_nextc: - lodsb - cmp al,#0 - jz min_eos +_prt_crlf: + mov al,#13 + call outch + mov al,#10 + j outch +_prt_dot: + mov al,#'. +outch: + mov ah,#$0E mov bx,#7 - mov ah,#$E ! Can't use $13 cause that's AT+ only! int $10 - jmp min_nextc -min_eos: ! Wait for a key then reboot - xor ax,ax - int $16 - !int $19 ! This should be OK as we haven't touched anything. - jmpi $0,$FFFF ! Wam! Try or die! - -fail_fs: - .asciz "Inital boot failed, press return to reboot\r\n" + ret #endasm -#else -/* This didn't work, chain the boot sector of the HD */ +#endif + +/****************************************************************************/ +/* Section sys_libs */ +/****************************************************************************/ #asm - push cs - pop es -hcode: - mov ax,#$0201 ! Read 1 sector - mov bx,#BOOTADDR ! In the boot area - mov cx,#$0001 ! From sector 1 - mov dx,#$0080 ! Of the hard drive head zero - int $13 - jc hcode ! Keep trying forever! - jmpi BOOTADDR,0 +! These functions are pulled from the C library. +libstuff: +imodu: + xor dx,dx + div bx + mov ax,dx ! instruction queue full so xchg slower + ret +idiv_u: + xor dx,dx + div bx + ret +#ifndef zone_shift +isl: +islu: + mov cl,bl + shl ax,cl + ret +#endif +libend: #endasm + +/****************************************************************************/ +/* Section sys_vars */ +/****************************************************************************/ +#asm +#ifdef MIN_SPACE + block temp_space+64 #endif -} +vars: +#ifndef HARDDISK +_n_sectors: .blkw 1 +#endif +_next_zone: .blkw 1 +_end_zone: .blkw 1 +_indirect: .blkw 1 +_ldaddr: .blkw 1 +_dirptr: .blkw 1 +_flength: .blkw 1 +#ifdef IMAGE_MAGIC +_checkflg: .blkw 1 +_segend: .blkw 1 +#endif +varend: +#ifdef MIN_SPACE + endb +#endif +#endasm /****************************************************************************/ +/* Section end_1 */ +/****************************************************************************/ +#if defined(HARDDISK) || !defined(MIN_SPACE) #asm end_of_part1: +#ifdef HARDDISK + if *>start+0x1FE ! Leave space for magic +#else if *>start+0x200 +#endif fail! Part 1 too large! endif .blkb 0x200+start-* #endasm +#endif /****************************************************************************/ +/* Section fd_probe */ +/****************************************************************************/ +#ifndef HARDDISK +#ifdef TRY_FLOPPY +#asm +!-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +! +! These are the number of sectors per track that will be scanned for. +! For 3.5 inch floppies 36 is 2.88 Mb, 18 is 1.44Mb, 21 is 1.68Mb on +! a 1.44Mb floppy drive. 15 and 9 are for 5.25 inch floppies. + +disksizes: .byte 36,21,18,15,9 + +! It seems that there is no BIOS call to get the number of sectors. Guess +! 36 sectors if sector 36 can be read, 18 sectors if sector 18 can be read, +! 15 if sector 15 can be read. Otherwise guess 9. + +_probe_sectors: + mov si,#disksizes ! table of sizes to try + +probe_loop: + lodsb + cbw ! extend to word + mov _n_sectors, ax + cmp al,#9 + je got_sectors ! if all else fails, try 9 + xchg ax, cx ! cx = track and sector + xor dx, dx ! drive 0, head 0 + mov bx,#probe_buf ! address after setup (es = cs) + mov ax,#0x0201 ! service 2, 1 sector + int 0x13 + jc probe_loop ! try next value +got_sectors: + + ret +#endasm +#endif +#endif + +/****************************************************************************/ +/* Section main */ +/****************************************************************************/ +#asm +code: + call _loadprog + call _runprog + br _nogood + +#endasm + +/****************************************************************************/ +/* Section prog_load */ +/****************************************************************************/ static loadprog() { #ifdef DOTS - bios_putc('+'); + prt_dot(); #endif if( b_super.s_magic != SUPER_MAGIC ) nogood(); - n_sectors = b_super.s_nzones / 80; - if( n_sectors < 5 ) n_sectors = b_super.s_nzones / 40; - #ifndef HARDDISK +#ifdef TRY_FLOPPY + probe_sectors(); +#else + if( (n_sectors = b_super.s_nzones / 40) > 11 ) n_sectors /= 2; +#endif + set_bpb(); #endif @@ -645,7 +767,14 @@ + 2); get_now(); +#ifdef ELKS_SETUP + ldaddr = SETUPSEG; /* Load at $02200, where setup expects to be */ +#else ldaddr = LOADSEG; /* Load at 64k mark */ +#endif +#ifdef IMAGE_MAGIC + checkflg = 1; +#endif { register d_inode * i_ptr; @@ -679,17 +808,30 @@ load_zone(ldaddr, *next_zone); next_zone++; ldaddr += (seg_at(1) << zone_shift); +#ifdef ELKS_SETUP + /* finished with setup segment? */ + if (ldaddr == (SETUPSEG+seg_of(SETUPSIZE))) ldaddr = LOADSEG; +#endif +#ifdef IMAGE_MAGIC + if (inode && checkflg) + { + get_now(); + checkflg=0; + if( mcheck() ) + segend = (ldaddr = mfetch(495)) + mfetch(497)*(512/16); + } + if (ldaddr == segend) ldaddr = LOADSEG; +#endif } get_now(); #ifdef DOTS - bios_putc('\r'); - bios_putc('\n'); + prt_crlf(); #endif if(!inode) { #ifdef DOTS - bios_putc('+'); + prt_dot(); #endif dirptr = directory; while(flength > 0) @@ -723,29 +865,78 @@ #endif } +/****************************************************************************/ +/* Section prog_magic */ +/****************************************************************************/ + +#ifdef IMAGE_MAGIC +#asm +; mfetch(0) != 0x301 && mfetch(486) == 'E'+'L'*256 && mfetch(488) == 'K'+'S'*256 ) +.text +export _mcheck +_mcheck: + mov ax,#LOADSEG + mov es,ax + xor ax,ax + mov bx,ax + cmp [bx],#0x301 + jz doret + cmp [bx+486],#'E+'L*256 + jnz doret + cmp [bx+488],#'K+'S*256 + jnz doret + inc ax +doret: + ret + +.text +export _mfetch +_mfetch: +#if __FIRST_ARG_IN_AX__ + mov bx,ax +#else + mov bx,sp + mov bx,2[bx] +#endif + mov ax,#LOADSEG + mov es,ax + seg es + mov ax,[bx] + ret +#endasm +#endif + +/****************************************************************************/ +/* Section prog_run */ +/****************************************************************************/ static runprog() { -/* This did work, run the loaded executable */ +/* It all worked, run the loaded executable */ #asm #ifdef HARDDISK mov dx,[bootpart+2] xchg dh,dl ! DX => hard drive push [bootpart] ! CX => partition offset + xor si,si #else xor dx,dx ! DX=0 => floppy drive push dx ! CX=0 => partition offset = 0 -#endif mov si,[_n_sectors] ! Save for monitor.out +#endif +#ifdef ELKS_SETUP + mov bx,#SETUPSEG + xor di,di +#else mov bx,#LOADSEG mov ds,bx ! DS = loadaddress - inc bx - inc bx ! bx = initial CS xor di,di ! Zero mov ax,[di] cmp ax,#0x0301 ! Right magic ? - bne _nogood ! Yuk ... + jnz binfile ! Yuk ... assume .SYS + inc bx + inc bx ! bx = initial CS mov ax,[di+2] and ax,#$20 ! Is it split I/D ? jz impure ! No ... @@ -758,6 +949,8 @@ mov ss,ax mov sp,[di+24] ! Chmem value mov ds,ax +binfile: +#endif push bx push di ! jmpi 0,#LOADSEG+2 @@ -765,48 +958,22 @@ #endasm } +/****************************************************************************/ +/* Section end_2 */ +/****************************************************************************/ #asm -! These functions are pulled from the C library. -libstuff: -imodu: - xor dx,dx - div bx - mov ax,dx ! instruction queue full so xchg slower - ret -idiv_u: - xor dx,dx - div bx - ret -#ifndef zone_shift -isl: -islu: - mov cl,bl - shl ax,cl - ret -#endif -libend: - -vars: -_n_sectors: .word 0 -_next_zone: .word 0 -_end_zone: .word 0 -_indirect: .word 0 -_ldaddr: .word 0 -_dirptr: .word 0 -_flength: .word 0 -varend: - end_of_prog: if *>start+0x400 - fail + fail! Part 2 too large! endif + if end_of_prog #include #include #include #include "i86_funcs.h" #include "readfs.h" +#include "version.h" #ifdef __STANDALONE__ #define NOT_VT52COLOUR @@ -60,7 +59,7 @@ if( x86 > 2 && !x86_emu ) /* Check some basics */ cmd_bzimage((void*)0); else - printf("System is not a 386+ in real mode, load aborted.\nUse 'bzimage' command toattempt load.\n"); + printf("System is not an 80386 compatible in real mode, load aborted.\nUse 'bzimage' command to attempt load.\n"); } for (;;) @@ -135,7 +134,11 @@ #ifdef VT52COLOUR printf("\033E\033Rg\033Sa\033J"); #endif - printf("Linux x86 boot monitor Version %s\n", VERSION); +#ifdef VERSION + printf("Linux x86 boot monitor, Version %s.\n", VERSION); +#else + printf("Linux x86 boot monitor.\n"); +#endif cpu_check(); mem_check(); diff -Nurd linux-86.old/bootblocks/noboot.s linux-86/bootblocks/noboot.s --- linux-86.old/bootblocks/noboot.s Thu Jan 1 01:00:00 1970 +++ linux-86/bootblocks/noboot.s Sat Jun 7 16:13:34 1997 @@ -0,0 +1,32 @@ + +org $7c00 + +include sysboot.s + +org dos_sysid + .ascii "PANIC" ! System ID + +org codestart + xor ax,ax + mov ds,ax + mov ss,ax + mov sp,ax + jmpi code,#0 + +no_os: + .asciz "PANIC! NO OS Found!\r\n" + +code: ! SI = pointer to error message + mov si,#no_os +nextc: + lodsb + cmp al,#0 + jz eos + mov bx,#7 + mov ah,#$E ! Can't use $13 cause that's AT+ only! + int $10 + jmp nextc +eos: ! Wait for a key then reboot + xor ax,ax + int $16 + jmpi $0,$FFFF ! Wam! Try or die! diff -Nurd linux-86.old/bootblocks/readfs.h linux-86/bootblocks/readfs.h --- linux-86.old/bootblocks/readfs.h Thu Jan 1 01:00:00 1970 +++ linux-86/bootblocks/readfs.h Sun Jan 5 10:25:32 1997 @@ -0,0 +1,17 @@ + +/* Functions for reading from one file at a time in the root directory + * of a raw filesystem. + */ + +#ifdef __STDC__ +#define P(x) x +#else +#define P(x) () +#endif + +int open_file P((char * fname)); +int rewind_file P((void)); +int close_file P((void)); +long file_length P((void)); +int read_block P((char * buffer)); + diff -Nurd linux-86.old/bootblocks/standalone.c linux-86/bootblocks/standalone.c --- linux-86.old/bootblocks/standalone.c Thu Jan 1 01:00:00 1970 +++ linux-86/bootblocks/standalone.c Sun Sep 29 14:39:14 1996 @@ -0,0 +1,309 @@ + +#include +#asm +entry _int_80 ! Tell ld86 we really do need this file. + ! then call the init stuff before main. + + loc 1 ! Make sure the pointer is in the correct segment +auto_func: ! Label for bcc -M to work. + .word _pre_main ! Pointer to the autorun function + .word no_op ! Space filler cause segs are padded to 4 bytes. + .text ! So the function after is also in the correct seg. +#endasm + +void int_80(); + +static void pre_main() +{ + /* Set the int 0x80 pointer to here */ + __set_es(0); + __doke_es(0x80*4+0, int_80); + __doke_es(0x80*4+2, __get_cs()); + bios_coninit(); +} + +void int_80() +{ +#asm +SYS_EXIT=1 +SYS_FORK=2 +SYS_READ=3 +SYS_WRITE=4 +SYS_OPEN=5 +SYS_CLOSE=6 +SYS_CHDIR=12 +SYS_LSEEK=19 +ENOSYS=38 + + push es + push si + push di + push dx + push cx + push bx + cmp ax,#SYS_READ + jne L1 + call _func_read + jmp L0 +L1: + cmp ax,#SYS_WRITE + jne L2 + call _func_write + jmp L0 +L2: + cmp ax,#SYS_LSEEK + jne L3 + call _func_lseek + jmp L0 +L3: + cmp ax,#SYS_EXIT + jne L4 + call _func_exit + jmp L0 +L4: + mov ax,#-ENOSYS +L0: + pop bx + pop cx + pop dx + pop di + pop si + pop es + iret +#endasm +} + +func_lseek() { return -38; } + +func_write(bx,cx,dx,di,si,es) +int bx,dx; +char * cx; +{ + register int v, c; + if(bx == 1 || bx == 2) + { + for(v=dx; v>0; v--) + { + c= *cx++; + if( c == '\n') bios_putc('\r'); + bios_putc(c); + } + return dx; + } + return -EBADF; +} + +func_read(bx,cx,dx,di,si,es) +int bx,dx; +char * cx; +{ + if(bx == 0) return read_line(cx, dx); + return -EBADF; +} + +read_line(buf, len) +char * buf; +int len; +{ + int ch; + int pos=0; + + if( len == 1 ) + { + buf[0]=((ch=bios_getc())&0xFF?ch&0xFF:((ch>>8)&0xFF|0x80)); + return 1; + } + + for(ch=0;;) + { + if(ch != '\003') + { + ch = bios_getc(); + if( pos == 0 && (ch&0xFF) == 0 ) + { + buf[0] = ((ch>>8)|0x80); + return 1; + } + ch &= 0x7F; + } + if( ch == '\r' ) + { + bios_putc('\r'); bios_putc('\n'); + buf[pos++] = '\n'; + return pos; + } + if( ch >= ' ' && ch != 0x7F && pos < len-1) + bios_putc(buf[pos++] = ch); + else if( (ch == '\003' || ch == '\b') && pos > 0 ) + { + bios_putc('\b'); bios_putc(' '); bios_putc('\b'); + pos--; + } + else if( ch == '\003' ) + return 0; + else + bios_putc('\007'); + } +} + +#define CTRL(x) ((x)&0x1F) +static int last_attr = 0x07; +static int con_mode; +static int con_size = 0x184F; +static int con_colour = 0; + +bios_coninit() +{ +#asm + mov ax,#$0F00 + int $10 + mov _con_mode,ax +#endasm + if( (con_mode &0xFF) > 39 ) con_size = (con_size&0xFF00) + (con_mode&0xFF); + if( (con_mode&0xFF00) != 0x700) + con_colour = 1; +} + +bios_putc(c) +int c; +{ +static char tbuf[3]; +static int tcnt=0; + if(tcnt) + { + tbuf[tcnt++] = c; + if( tcnt < 3 && (tbuf[0] != CTRL(']') || tbuf[1] < '`' || tbuf[1] > 'p')) + return; + if( tbuf[0] == CTRL('P') ) + { + if( tbuf[1] >= 32 && tbuf[1] <= 56 + && tbuf[2] >= 32 && tbuf[2] <= 111 ) + asm_cpos((tbuf[1]-32), (tbuf[2]-32)); + } + else + { + if( tbuf[1] >= '`' ) + last_attr = ( (tbuf[1]&0xF) | (last_attr&0xF0)); + else + last_attr = ( (tbuf[2]&0xF) | ((tbuf[1]&0xF)<<4)); + + if( !con_colour ) + last_attr = (last_attr&0x88) + ((last_attr&7)?0x07:0x70); + } + tcnt=0; + return; + } + if( c & 0xE0 ) { asm_colour(last_attr) ; asm_putc(c); } + else switch(c) + { + case CTRL('L'): + asm_cpos(0,0); + asm_cls(); + break; + case CTRL('P'): + case CTRL(']'): + tbuf[tcnt++] = c; + break; + default: + asm_putc(c); + break; + } + return; +} + +static asm_putc(c) +{ +#asm +#if !__FIRST_ARG_IN_AX__ + mov bx,sp + mov ax,[bx+2] +#endif + mov ah,#$0E + mov bx,#7 + int $10 +#endasm +} + +static asm_colour(c) +{ +#asm +#if __FIRST_ARG_IN_AX__ + mov bx,ax +#else + mov bx,sp + mov bx,[bx+2] +#endif + mov ah,#$08 + int $10 + mov ah,#$09 + mov cx,#1 + int $10 +#endasm +} + +static asm_cls() +{ +#asm + push bp ! Bug in some old BIOS's + !mov ax,#$0500 + !int $10 + mov ax,#$0600 + mov bh,_last_attr + mov cx,#$0000 + mov dx,_con_size + int $10 + pop bp +#endasm +} + +static asm_cpos(r,c) +{ +#asm +#if __FIRST_ARG_IN_AX__ + mov bx,sp + mov dh,al + mov ax,[bx+2] + mov dl,al +#else + mov bx,sp + mov ax,[bx+2] + mov dh,al + mov ax,[bx+4] + mov dl,al +#endif + mov ah,#$02 + mov bx,#7 + int $10 +#endasm +} + +bios_getc() +{ +#asm + xor ax,ax + int $16 +#endasm +} + +static void be_safe() +{ +#asm + iret +#endasm +} + +func_exit(bx,cx,dx,di,si,es) /* AKA reboot! */ +{ + __set_es(0); + __doke_es(0xE6*4+2,__get_cs()); + __doke_es(0xE6*4+0,be_safe); +#asm + mov ax,#$FFFF + int $E6 ! Try to exit DOSEMU + mov ax,#$0040 ! If we get here we're not in dosemu. + mov es,ax + seg es + mov [$72],#$1234 ! Warm reboot. + jmpi $0000,$FFFF +#endasm +} diff -Nurd linux-86.old/bootblocks/sysboot.s linux-86/bootblocks/sysboot.s --- linux-86.old/bootblocks/sysboot.s Sat May 3 08:03:40 1997 +++ linux-86/bootblocks/sysboot.s Sat Jun 7 16:11:16 1997 @@ -46,36 +46,11 @@ dos4_fattype: .blkb 8 ! FAT type ! -! This is where the code will be overlaid, the default is an 'oops' +! This is where the code will be overlaid, the default is a hang .blkb sysboot_start+0x3E-* public codestart codestart: - xor ax,ax - mov ds,ax - mov es,ax - mov ss,ax - mov sp,ax - jmpi sys_code+$7C00-sysboot_start,#0 - -sys_code: ! SI now has pointer to error message - mov si,#sys_no_os+$7C00-sysboot_start -sys_nextc: - lodsb - cmp al,#0 - jz sys_eos - mov bx,#7 - mov ah,#$E ! Can't use $13 cause that's AT+ only! - int $10 - jmp sys_nextc -sys_eos: ! Wait for a key then reboot - xor ax,ax - int $16 - !int $19 ! This should be OK as we haven't touched anything. - jmpi $0,$FFFF ! Wam! Try or die! - -sys_no_os: - .asciz "PANIC! NO OS Found!\r\n" - + j codestart ! Partition table public partition_1 diff -Nurd linux-86.old/bootblocks/tarboot.s linux-86/bootblocks/tarboot.s --- linux-86.old/bootblocks/tarboot.s Sat Nov 30 12:56:17 1996 +++ linux-86/bootblocks/tarboot.s Mon May 12 20:50:43 1997 @@ -137,7 +137,11 @@ blk_gid: .blkb 8 blk_size: .blkb 12 blk_mtime: .asciz "6141567743 " -blk_chksum: .asciz " 131141" +if DEBUG +blk_chksum: .asciz " 142273" +else +blk_chksum: .asciz " 127270" +endif blk_link: .byte 'V ! Sneaks here, overlay zero init vars on tar data. @@ -476,14 +480,16 @@ !-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -if DEBUG = 0 - locn(510) ! This isn't a hard disk boot sector so don't give it an HD magic +! locn(510) ! .word 0xAA55 +if DEBUG = 0 +locn(510) .word 0 endif ! From here down is where we load stuff. +locn(512) blk_load: ! Address of block load tar_name: .blkb 100 diff -Nurd linux-86.old/copt/Makefile linux-86/copt/Makefile --- linux-86.old/copt/Makefile Tue Feb 18 21:28:48 1997 +++ linux-86/copt/Makefile Thu Jul 10 23:46:47 1997 @@ -1,6 +1,8 @@ copt: copt.c - $(CC) $(CFLAGS) -o copt copt.c + $(CC) $(ANSI) $(CFLAGS) $(LDFLAGS) -o copt copt.c realclean clean: rm -f *.o copt + + diff -Nurd linux-86.old/dis88/Makefile linux-86/dis88/Makefile --- linux-86.old/dis88/Makefile Sat Dec 21 07:16:40 1996 +++ linux-86/dis88/Makefile Thu Jun 19 20:34:10 1997 @@ -27,6 +27,7 @@ #CC=bcc CFLAGS=-O LDFLAGS= +BINDIR=/usr/bin OBJ = disrel.o dismain.o distabs.o dishand.o disfp.o @@ -36,8 +37,8 @@ $(CC) $(LDFLAGS) -o dis88 $(OBJ) install: dis88 - install -m 755 -s dis88 $(DIST)/usr/bin/dis88 - install -m 644 dis88.1 $(DIST)/usr/man/man1/dis88.1 + install -m 755 -s dis88 $(DIST)$(BINDIR)/dis86 + install -m 644 dis88.1 $(DIST)/usr/man/man1/dis86.1 $(OBJ): dis.h a.out.h diff -Nurd linux-86.old/doselks/coroutine.c linux-86/doselks/coroutine.c --- linux-86.old/doselks/coroutine.c Wed May 8 07:20:43 1996 +++ linux-86/doselks/coroutine.c Sun Aug 17 10:52:31 1997 @@ -1,4 +1,4 @@ -#include + #include "doselks.h" int in_process = 0; diff -Nurd linux-86.old/doselks/doselks.c linux-86/doselks/doselks.c --- linux-86.old/doselks/doselks.c Sat May 18 21:58:22 1996 +++ linux-86/doselks/doselks.c Sun Aug 17 10:52:27 1997 @@ -1,4 +1,4 @@ -#include + #include "doselks.h" #define DEBUGGER diff -Nurd linux-86.old/doselks/doselks.h linux-86/doselks/doselks.h --- linux-86.old/doselks/doselks.h Sat May 18 20:26:15 1996 +++ linux-86/doselks/doselks.h Sun Aug 17 10:56:24 1997 @@ -1,13 +1,21 @@ +#include +/* Sneaky, use the _linuxmt_ header files _not_ dos */ +#undef __SYSINC__ +#define __SYSINC__(__h_file) + +#include +#include +#include +#include +#include +#include + +#include #include #include #include -#include #include -#include -#include -#include -#include /* Function return vals */ diff -Nurd linux-86.old/doselks/syscalls.c linux-86/doselks/syscalls.c --- linux-86.old/doselks/syscalls.c Sat May 18 21:46:48 1996 +++ linux-86/doselks/syscalls.c Sun Aug 17 10:52:46 1997 @@ -1,4 +1,4 @@ -#include + #include "doselks.h" #include "syscalls.h" diff -Nurd linux-86.old/elksemu/Makefile linux-86/elksemu/Makefile --- linux-86.old/elksemu/Makefile Mon Mar 31 20:34:38 1997 +++ linux-86/elksemu/Makefile Sun Sep 28 13:49:21 1997 @@ -2,14 +2,24 @@ # Makefile for elksemu. # -ifeq ($(CC),bcc) # Use BCC to make a tiny static a.out version. -CFLAGS=-O -3 -N -ansi -s -else -# For gcc with the default compiler +ifeq ($(CC),bcc) +CFLAGS=-Ml -ansi -s $(DEFS) +endif +ifeq ($(CC),ncc) +CFLAGS=-Ml -ansi -s $(DEFS) +endif + +# For gcc +ifeq ($(CC),gcc) CFLAGS=-O2 -fno-strength-reduce -Wall -idirafter . $(DEFS) endif +# Default +ifeq ($(CFLAGS),) +CFLAGS=-O +endif + # Turn on elkemu's strace like facility. # DEFS=-DDEBUG @@ -41,8 +51,9 @@ module: binfmt_elks.o # HOW to compile the module... +# BUT remember you don't need it for a recent 2.1.X; use binfmt_misc. -# This matches my compile (2.0.0); yours may be different. +# This matches my compile (2.0.x); yours may be different. MODCFLAGS=-D__KERNEL__ -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer \ -fno-strength-reduce -pipe -m486 -DCPU=486 -DMODULE -DMODVERSIONS \ -include /usr/include/linux/modversions.h diff -Nurd linux-86.old/elksemu/README linux-86/elksemu/README --- linux-86.old/elksemu/README Thu Jan 1 01:00:00 1970 +++ linux-86/elksemu/README Sat Jul 26 13:49:34 1997 @@ -0,0 +1,24 @@ + +Elksemu is an emulator for the environment that elks will provide on a +real ELKS machine. The emulator only runs on linux-i386 or similar. + +If your kernel version is 1.2.13 then apply the patch in the Kernel_patch +file. + +If you're using one of the 2.0.X series then the binfmt_elks.c module +should be able to compile and install. BUT do note you need the modules +and probably modversions options and you _may_ have to alter the compile +command to match those seen when you compile modules that come with the +kernel. + +If you're using a 2.1.43 or later then the binfmt_misc driver is in +the stock kernel add the following line to a /etc/rc*/* file and +you don't need to install a patch or module! + +echo ':i86-elks:M::\x01\x03\x00\x20:\xff\xff\x83\xff:/lib/elksemu:' \ + > /proc/sys/fs/binfmt_misc/register + +Rob. + +(NB I'm not running 2.1.X so I haven't tested the binfmt_misc method + as of 26/7/97) diff -Nurd linux-86.old/elksemu/Version linux-86/elksemu/Version --- linux-86.old/elksemu/Version Wed Oct 9 06:46:45 1996 +++ linux-86/elksemu/Version Thu Jan 1 01:00:00 1970 @@ -1 +0,0 @@ -Version elksemu-0.0.8 diff -Nurd linux-86.old/elksemu/elks.h linux-86/elksemu/elks.h --- linux-86.old/elksemu/elks.h Sun Mar 3 09:17:37 1996 +++ linux-86/elksemu/elks.h Mon May 12 20:24:30 1997 @@ -94,3 +94,4 @@ void db_printf(const char *, ...); int elks_syscall(void); +void minix_syscall(void); diff -Nurd linux-86.old/elksemu/minix.c linux-86/elksemu/minix.c --- linux-86.old/elksemu/minix.c Tue Jan 28 21:56:52 1997 +++ linux-86/elksemu/minix.c Mon May 12 20:31:59 1997 @@ -1,9 +1,3 @@ - -/* - * System calls are mostly pretty easy as the emulator is tightly bound to - * the minix task. - */ - #include #include #include diff -Nurd linux-86.old/ifdef.c linux-86/ifdef.c --- linux-86.old/ifdef.c Thu Apr 24 20:21:14 1997 +++ linux-86/ifdef.c Sat Jul 12 16:18:06 1997 @@ -167,6 +167,7 @@ } } fclose(fd); + if( iflevel != 0 ) fatal("Not enough endif's"); } void @@ -322,6 +323,14 @@ #ifdef GNUMAKE save_name("GNUMAKE", 'D'); #endif + if( sizeof(int) < 4 ) + save_name("__SMALL_INTS__", 'D'); + if( sizeof(char *) <= 2 ) + save_name("__SMALL_MEMORY__", 'D'); + if( sizeof(long) == 4 ) + save_name("__LONG_32_BIT__", 'D'); + if( sizeof(int) == 8 ) + save_name("__LONG_64_BIT__", 'D'); /* MSDOS */ #ifdef MSDOS diff -Nurd linux-86.old/ld/Makefile linux-86/ld/Makefile --- linux-86.old/ld/Makefile Fri Apr 25 20:39:09 1997 +++ linux-86/ld/Makefile Sun Oct 5 13:21:14 1997 @@ -1,7 +1,7 @@ LIBDIR =/usr/bin CFLAGS =-O -LDFLAGS =-s +LDFLAGS = # May need some of these if the auto-sense fails. # -DV7_A_OUT # a.out.h is like V7 @@ -18,7 +18,7 @@ OBJS= dumps.o io.o ld.o readobj.o table.o typeconv.o linksyms.o \ writex86.o writebin.o writerel.o -all: ld86 +all: ld86 objchop catimage ld86: $(OBJS) $(CC) $(LDFLAGS) $(OBJS) -o $@ @@ -28,7 +28,7 @@ install -m 755 ld86 $(LIBDIR) clean realclean: - rm -f $(OBJS) ld86 + rm -f *.o ld86 ld86r objchop catimage $(OBJS): align.h ar.h bindef.h byteord.h config.h const.h globvar.h obj.h \ syshead.h type.h x86_aout.h diff -Nurd linux-86.old/ld/README.1994 linux-86/ld/README.1994 --- linux-86.old/ld/README.1994 Sat Feb 19 23:26:16 1994 +++ linux-86/ld/README.1994 Thu Jan 1 01:00:00 1970 @@ -1,17 +0,0 @@ -The `bcc' and `ld' parts of the bin86 distribution are now covered by the -GNU GPL. The next release of the `as' part will be covered by the GPL. -The `a.out.h' part is no longer used and should be deleted. The `bccfp' -belongs in another package and may be deleted. - -`ld' is now correctly ported to linux. It now defaults to the target -a.out format for output. However, it still requires its own special -format for input. It is best used as a post-processor for `as' to -produce objects in a.out format. Then the target ld can be used to -link the objects. The post-processing step is: - - ld86 -r -o tmpfile.o file.o && mv tmpfile.o file.o - -This can be handled more simply by using the `bcc' compiler driver as -the assembler and never calling as86 or ld86 directly: - - AS86="bcc -G -0 -c" diff -Nurd linux-86.old/ld/ar.h linux-86/ld/ar.h --- linux-86.old/ld/ar.h Sat Feb 24 15:20:51 1996 +++ linux-86/ld/ar.h Thu Jan 1 01:00:00 1970 @@ -1,18 +0,0 @@ -#ifndef __AR_H -#define __AR_H - -#define ARMAG "!\n" -#define SARMAG 8 -#define ARFMAG "`\n" - -struct ar_hdr { - char ar_name[16], - ar_date[12], - ar_uid[6], - ar_gid[6], - ar_mode[8], - ar_size[10], - ar_fmag[2]; -}; - -#endif /* __AR_H */ diff -Nurd linux-86.old/ld/catimage.c linux-86/ld/catimage.c --- linux-86.old/ld/catimage.c Thu Jan 1 01:00:00 1970 +++ linux-86/ld/catimage.c Tue Jul 22 22:37:53 1997 @@ -0,0 +1,238 @@ +/* + * This program concatenates memory images the executables specified + * on it's command line. + * + * The 'boot' image must have a symbol table any symbols that match + * the below patterns have their values patched. + * + * int __seg0_text; - Always zero + * int __seg0_data; - Segment offset of data of boot executable + * + * int __seg1_text; - Segment offset of text of first executable + * int __seg1_data; - Segment offset of data of first executable + * int __seg2_text; - Segment offset of text of second executable + * int __seg2_data; - Segment offset of data of second executable + * + * int __seg9_text; - Segment offset of text of executable nine + * int __seg9_data; - Segment offset of data of executable nine + * + * Any segment that's not an exact multiple of 16 bytes long is rounded up. + * + */ + +#include +#include "x86_aout.h" + +#ifndef __OUT_OK +#error "Compile error: struct exec invalid (long not 32 bit ?)" +#endif + +unsigned long text_offt[10]; /* Locations to patch (0=don't) */ +unsigned long data_offt[10]; + +char * input_file = ""; +FILE * ofd; +FILE * ifd = 0; +struct exec header; + +main(argc, argv) +int argc; +char ** argv; +{ + long image_offset, text_off; + int image_id; + + if( argc < 3 || argc > 11 ) + fatal("Usage: catimage mem.bin boot.out [a1.out] ... [a9.out]"); + + open_obj(argv[2]); + + ofd = fopen(argv[1], "w"); + if( ofd == 0 ) fatal("Cannot open output file"); + + read_symtable(); + + image_offset = 0; + + for(image_id=0; image_id < argc-2; image_id++) + { + open_obj(argv[image_id+2]); + + printf("File %-14s seg=0x%04lx text=0x%04lx data=0x%04lx\n", + input_file, (image_offset>>4), + (header.a_text>>4), (header.a_total>>4)); + + text_off = image_offset; + if( header.a_flags & A_SEP ) + { + copy_segment(image_offset, A_TEXTPOS(header), header.a_text); + image_offset += header.a_text; + image_offset = ((image_offset+15L)&-16L); + + copy_segment(image_offset, A_DATAPOS(header), header.a_data); + } + else + { + copy_segment(image_offset, A_TEXTPOS(header), + header.a_text+header.a_data); + } + + patch_bin(text_offt[image_id], (unsigned)(text_off>>4)); + patch_bin(data_offt[image_id], (unsigned)(image_offset>>4)); + + image_offset += header.a_total; + image_offset = ((image_offset+15L)&-16L); + } + + if( fseek(ofd, image_offset-1, 0) < 0 ) + fatal("Cannot seek to end of output"); + + fputc('\0', ofd); + fclose(ofd); + + printf("Output file size %ldKb\n", ((image_offset+0x3FF)>>10)); + + if( ifd ) fclose(ifd); + exit(0); +} + +open_obj(fname) +char * fname; +{ + input_file = fname; + + if( ifd ) fclose(ifd); + + ifd = fopen(fname, "r"); + if( ifd == 0 ) fatal("Cannot open input file"); + + if( fread(&header, A_MINHDR, 1, ifd) != 1 ) + fatal("Incomplete executable header"); + + if( BADMAG(header) ) + fatal("Input file has bad magic number"); +} + +copy_segment(out_offset, in_offset, length) +long out_offset, in_offset, length; +{ + char buffer[1024]; + int ssize; + long bsize = length; + + if( fseek(ifd, in_offset, 0) < 0 ) + fatal("Cannot seek to start of input segment"); + + if( fseek(ofd, out_offset, 0) < 0 ) + fatal("Cannot seek to start of output segment"); + + while(bsize>0) + { + if( bsize > sizeof(buffer) ) ssize = sizeof(buffer); + else ssize = bsize; + + if( (ssize=fread(buffer, 1, ssize, ifd)) <= 0 ) + fatal("Error reading segment from executable"); + if( fwrite(buffer, 1, ssize, ofd) != ssize ) + fatal("Error writing output file"); + bsize -= ssize; + } +} + +patch_bin(file_off, value) +long file_off; +int value; +{ + char wbuf[4]; + if( file_off <= 0 ) return; + + printf("Patch at offset 0x%05lx = %04x\n", file_off, value); + + wbuf[0] = value; + wbuf[0] = (value>>8); + + if( fseek(ofd, file_off, 0) < 0 ) + fatal("Cannot seek to patch binary"); + + if( fwrite(wbuf, 1, 2, ofd) != 2 ) + fatal("Error patching output file"); +} + +read_symtable() +{ + struct nlist item; + int nitems; + long base_off = 0; + + if( header.a_syms == 0 ) + fatal("Input file has been stripped!"); + + if( fseek(ifd, A_SYMPOS(header), 0) < 0 ) + fatal("Cannot seek to start of symbols"); + + nitems = header.a_syms; + + /* Foreach symbol */ + while( fread(&item, sizeof(struct nlist), 1, ifd) == 1 ) + { + if( nitems-- <= 0 ) break; + + /* Match the name */ + if( memcmp(item.n_name, "__seg", 5) != 0 || item.n_name[6] != '_' ) + continue; + + /* Externals only */ + if( (item.n_sclass & N_CLASS) != C_EXT ) + continue; + + /* Data seg only */ + if( (item.n_sclass & N_SECT) != N_DATA && + (item.n_sclass & N_SECT) != N_BSS && + (item.n_sclass & N_SECT) != N_TEXT ) + continue; + + if( item.n_name[5] < '0' || item.n_name[5] > '9' ) + continue; + + if( (header.a_flags & A_SEP) && (item.n_sclass & N_SECT) != N_TEXT ) + base_off = header.a_text; + else + base_off = 0; + + switch( item.n_name[7] ) + { + case 'd': data_offt[item.n_name[5]-'0'] = base_off+item.n_value; break; + case 't': text_offt[item.n_name[5]-'0'] = base_off+item.n_value; break; + } + +#ifdef DEBUG + printf("%-8.8s ", item.n_name); + printf("%08lx ", item.n_value); + switch(item.n_sclass & N_CLASS) + { + case C_NULL: printf("C_NULL "); break; + case C_EXT: printf("C_EXT "); break; + case C_STAT: printf("C_STAT "); break; + default: printf("%-6d ", (item.n_sclass & N_CLASS)); break; + } + switch(item.n_sclass & N_SECT) + { + case N_UNDF: printf("N_UNDF "); break; + case N_ABS : printf("N_ABS "); break; + case N_TEXT: printf("N_TEXT "); break; + case N_DATA: printf("N_DATA "); break; + case N_BSS : printf("N_BSS "); break; + case N_COMM: printf("N_COMM "); break; + } + printf("\n"); +#endif + } +} + +fatal(str) +char * str; +{ + fprintf(stderr, "catimage:%s: %s\n", input_file, str); + exit(2); +} + diff -Nurd linux-86.old/ld/io.c linux-86/ld/io.c --- linux-86.old/ld/io.c Sat Feb 1 13:42:06 1997 +++ linux-86/ld/io.c Thu Jul 17 13:04:11 1997 @@ -121,8 +121,10 @@ PUBLIC void executable() { +#ifndef MSDOS if (errcount == 0) chmod(outputname, outputperms); +#endif } PUBLIC void flusherr() @@ -179,15 +181,18 @@ outputname = filename; #ifdef O_BINARY - if ((outfd = open(filename, O_BINARY|O_RDWR|O_CREAT|O_TRUNC, CREAT_PERMS)) == ERR) + if ((outfd = open(filename, O_BINARY|O_WRONLY|O_CREAT|O_TRUNC, CREAT_PERMS)) == ERR) #else if ((outfd = creat(filename, CREAT_PERMS)) == ERR) #endif outputerror("cannot open"); +#ifndef MSDOS + /* Can't do this on MSDOS; it upsets share.exe */ oldmask = umask(0); umask(oldmask); outputperms = ((CREAT_PERMS | EXEC_PERMS) & ~oldmask); chmod(filename, outputperms & ~EXEC_PERMS); +#endif #ifdef REL_OUTPUT drelbufptr = drelbuf; diff -Nurd linux-86.old/ld/ld.c linux-86/ld/ld.c --- linux-86.old/ld/ld.c Sun Apr 13 12:34:30 1997 +++ linux-86/ld/ld.c Sun Oct 5 11:49:53 1997 @@ -107,7 +107,6 @@ { argv[0] = "ld86r"; execv("/usr/bin/ld86r", argv); - execv("/usr/bin/ld86", argv); } #endif usage(); @@ -190,7 +189,7 @@ infilename = tfn; /* fatalerror(tfn); * XXX */ readsyms(infilename, flag['t']); - icount++; + icount+=2; break; case 'o': /* output file name */ if (arg[2] != 0 || ++argn >= argc || outfilename != NUL_PTR) @@ -205,18 +204,19 @@ #ifdef REL_OUTPUT #ifndef MSDOS -#ifndef BUGCOMPAT +#ifdef BUGCOMPAT + if( icount>1 && ( flag['r'] && !flag['N'] ) ) +#else if( flag['r'] && !flag['N'] ) +#endif { /* Ok, try for an alternate linker */ if( strcmp(argv[0], "ld86r") != 0 ) { argv[0] = "ld86r"; execv("/usr/bin/ld86r", argv); - execv("/usr/bin/ld86", argv); } } -#endif #endif #endif diff -Nurd linux-86.old/ld/ld86r.c linux-86/ld/ld86r.c --- linux-86.old/ld/ld86r.c Thu Jan 1 01:00:00 1970 +++ linux-86/ld/ld86r.c Sun Oct 5 12:39:16 1997 @@ -0,0 +1,81 @@ +#include +#include +#include +#include +#include + +#define ARMAG "!\n" +#define SARMAG 8 +#define ARFMAG "`\n" + +struct ar_hdr { + char ar_name[16], + ar_date[12], + ar_uid[6], + ar_gid[6], + ar_mode[8], + ar_size[10], + ar_fmag[2]; +} arbuf; + +void +fatal(char * str) { fprintf(stderr, "%s\n", str); exit(2); } + +void +main(int argc, char ** argv) +{ +char buf[128]; + FILE * fd, * ifd; + struct stat st; + int ar, libarg=0, need_o = 0, got_o = 0; + + for(ar=1; ar 1 || need_o > got_o ) + fatal("Err, what's the output gonna be called?"); + + if( (fd =fopen(argv[libarg], "wb")) == 0 ) fatal("Cannot open archive"); + if( fwrite(ARMAG, 1, SARMAG, fd) != SARMAG) fatal("Cannot write magic"); + + for(ar=1; ar +#include "x86_aout.h" + +#ifndef __OUT_OK + +main() +{ + fprintf(stderr, "Compile error: struct exec invalid\n"); + exit(1); +} + +#else + +FILE * ifd; +struct exec header; + +main(argc, argv) +int argc; +char ** argv; +{ + FILE * ofd; + if( argc != 5 ) fatal("Usage: objchop a.out text.bin data.bin sizes.asm"); + + ifd = fopen(argv[1], "r"); + if( ifd == 0 ) fatal("Cannot open input file"); + + if( fread(&header, A_MINHDR, 1, ifd) != 1 ) + fatal("Incomplete executable header"); + + if( BADMAG(header) ) + fatal("Input file has bad magic number"); + + if( fseek(ifd, A_TEXTPOS(header), 0) < 0 ) + fatal("Cannot seek to start of text"); + + write_file(argv[2], header.a_text); + + if( fseek(ifd, A_DATAPOS(header), 0) < 0 ) + fatal("Cannot seek to start of data"); + + write_file(argv[3], header.a_data); + + ofd = fopen(argv[4], "w"); + if( ofd == 0 ) fatal("Cannot open output file"); + + fprintf(ofd, "TEXT_SIZE=%ld\nDATA_SIZE=%ld\nBSS_SIZE=%ld\nALLOC_SIZE=%ld\n", + header.a_text, header.a_data, header.a_bss, header.a_total); + + fclose(ofd); + + exit(0); +} + +write_file(fname, bsize) +char * fname; +long bsize; +{ + char buffer[1024]; + int ssize; + FILE * ofd; + + ofd = fopen(fname, "w"); + if( ofd == 0 ) fatal("Cannout open output file"); + + while(bsize>0) + { + if( bsize > sizeof(buffer) ) ssize = sizeof(buffer); + else ssize = bsize; + + if( (ssize=fread(buffer, 1, ssize, ifd)) <= 0 ) + fatal("Error reading segment from executable"); + if( fwrite(buffer, 1, ssize, ofd) != ssize ) + fatal("Error writing output file"); + bsize -= ssize; + } + fclose(ofd); +} + +fatal(str) +char * str; +{ + fprintf(stderr, "objchop: %s\n", str); + exit(2); +} + +#endif diff -Nurd linux-86.old/ld/syshead.h linux-86/ld/syshead.h --- linux-86.old/ld/syshead.h Sat Feb 1 12:00:47 1997 +++ linux-86/ld/syshead.h Sun Sep 28 11:52:25 1997 @@ -1,15 +1,15 @@ -#ifndef STDC_HEADERS_MISSING -#include -#include -#include -#endif - #ifndef POSIX_HEADERS_MISSING #include #include #include #include +#endif + +#ifndef STDC_HEADERS_MISSING +#include +#include +#include #endif #ifdef MSDOS diff -Nurd linux-86.old/ld/typeconv.c linux-86/ld/typeconv.c --- linux-86.old/ld/typeconv.c Fri Apr 25 21:02:49 1997 +++ linux-86/ld/typeconv.c Sat Jun 7 08:38:27 1997 @@ -156,6 +156,8 @@ { switch (count) { + case 0: + return 0; case 1: return buf[0] & 0xFF; case 2: @@ -174,6 +176,8 @@ { switch (count) { + case 0: + return 0; case 1: return buf[0] & 0xFF; case 2: diff -Nurd linux-86.old/ld/typeconv.c.old linux-86/ld/typeconv.c.old --- linux-86.old/ld/typeconv.c.old Sun Apr 13 14:57:23 1997 +++ linux-86/ld/typeconv.c.old Thu Jan 1 01:00:00 1970 @@ -1,536 +0,0 @@ -/* typeconv.c - convert between char arrays and unsigneds */ - -/* Copyright (C) 1994 Bruce Evans */ - -/* - c2u2(): 2 byte array to 2 byte unsigned - c4u4(): 4 byte array to 4 byte unsigned - cnu2(): n byte array to 2 byte unsigned - cnu4(): n byte array to 4 byte unsigned - u2c2(): 2 byte unsigned to 2 byte array - u2cn(): 2 byte unsigned to n byte array - u4c4(): 4 byte unsigned to 4 byte array - u4cn(): 4 byte unsigned to n byte array - typeconv_init: (re)initialise for given byte order. - Default is no swapping, but the initialisation should be done - anyway to provide some validity checks (returns FALSE if error). - - Not provided: - c2u4(), c4u2(), u2c4(), u4c2(). - Each of these is best done by truncating or extending a return value - or argument to the appropiate fixed-count function. - c4u2() has too many cases to do in-line conveniently, and the others - are hardly more efficient when done in-line. - - 4 byte orderings for both char arrays and unsigneds are supported: - 0123 - little-endian - 3210 - big-endian - 2301 - little-endian with long words big-endian (pdp11) - 1032 - big-endian with long words little_endian (who knows?) - - The unsigned's byte order is that of the machine on which these - routines are running. - It is determined at run time initialisation since the compiler/ - preprocessor is too dumb to tell us at compile time. -*/ - -#include "const.h" -#include "type.h" -#include "globvar.h" - -FORWARD u2_pt c2u2_00 P((char *buf)); -FORWARD u4_pt c4u4_00 P((char *buf)); -FORWARD u2_pt c2u2_ss P((char *buf)); -FORWARD u4_pt c4u4_ss P((char *buf)); -FORWARD u4_pt c4u4_s0 P((char *buf)); -FORWARD u4_pt c4u4_0s P((char *buf)); -FORWARD void u2c2_00 P((char *buf, u2_pt offset)); -FORWARD void u4c4_00 P((char *buf, u4_t offset)); -FORWARD void u2c2_ss P((char *buf, u2_pt offset)); -FORWARD void u4c4_ss P((char *buf, u4_t offset)); -FORWARD void u4c4_s0 P((char *buf, u4_t offset)); -FORWARD void u4c4_0s P((char *buf, u4_t offset)); - -PRIVATE u2_pt (*pc2u2) P((char *buf)) = c2u2_00; -PRIVATE u4_pt (*pc4u4) P((char *buf)) = c4u4_00; -PRIVATE void (*pu2c2) P((char *buf, u2_pt offset)) = u2c2_00; -PRIVATE void (*pu4c4) P((char *buf, u4_t offset)) = u4c4_00; - -/* === char arrays to unsigneds === */ - -/* no bytes swapped, longwinded to avoid alignment problems */ - -PRIVATE u2_pt c2u2_00(buf) -register char *buf; -{ - u2_t offset; - - ((char *) &offset)[0] = buf[0]; - ((char *) &offset)[1] = buf[1]; - return offset; -} - -PRIVATE u4_pt c4u4_00(buf) -register char *buf; -{ - u4_t offset; - - ((char *) &offset)[0] = buf[0]; - ((char *) &offset)[1] = buf[1]; - ((char *) &offset)[2] = buf[2]; - ((char *) &offset)[3] = buf[3]; - return offset; -} - -/* straight swapping for little-endian to big-endian and vice versa */ - -PRIVATE u2_pt c2u2_ss(buf) -register char *buf; -{ - u2_t offset; - - ((char *) &offset)[0] = buf[1]; - ((char *) &offset)[1] = buf[0]; - return offset; -} - -PRIVATE u4_pt c4u4_ss(buf) -register char *buf; -{ - u4_t offset; - - ((char *) &offset)[0] = buf[3]; - ((char *) &offset)[1] = buf[2]; - ((char *) &offset)[2] = buf[1]; - ((char *) &offset)[3] = buf[0]; - return offset; -} - -/* wierd swapping for different-endian u2's, same-endian u4's */ - -PRIVATE u4_pt c4u4_s0(buf) -register char *buf; -{ - u4_t offset; - - ((char *) &offset)[0] = buf[1]; - ((char *) &offset)[1] = buf[0]; - ((char *) &offset)[2] = buf[3]; - ((char *) &offset)[3] = buf[2]; - return offset; -} - -/* very wierd swapping for same-endian u2's, different-endian u4's */ - -PRIVATE u4_pt c4u4_0s(buf) -register char *buf; -{ - u4_t offset; - - ((char *) &offset)[0] = buf[2]; - ((char *) &offset)[1] = buf[3]; - ((char *) &offset)[2] = buf[0]; - ((char *) &offset)[3] = buf[1]; - return offset; -} - -/* === entry points === */ - -PUBLIC u2_pt c2u2(buf) -char *buf; -{ - return (*pc2u2) (buf); -} - -PUBLIC u4_t c4u4(buf) -char *buf; -{ - return (*pc4u4) (buf); -} - -PUBLIC u2_pt cnu2(buf, count) -char *buf; -unsigned count; -{ - switch (count) - { - case 1: - return buf[0] & 0xFF; - case 2: - return (*pc2u2) (buf); - case 4: - return (u2_pt) (*pc4u4) (buf); - default: - return 0; - } -} - -PUBLIC u4_t cnu4(buf, count) -char *buf; -unsigned count; -{ - switch (count) - { - case 1: - return buf[0] & 0xFF; - case 2: - return (*pc2u2) (buf); - case 4: - return (*pc4u4) (buf); - default: - return 0; - } -} - -/* === unsigneds to char arrays === */ - -/* no bytes swapped, longwinded to avoid alignment problems */ - -PRIVATE void u2c2_00(buf, offset) -register char *buf; -u2_pt offset; -{ - - buf[0] = ((char *) &offset)[0]; - buf[1] = ((char *) &offset)[1]; -} - -PRIVATE void u4c4_00(buf, offset) -register char *buf; -u4_t offset; -{ - buf[0] = ((char *) &offset)[0]; - buf[1] = ((char *) &offset)[1]; - buf[2] = ((char *) &offset)[2]; - buf[3] = ((char *) &offset)[3]; -} - -/* straight swapping for little-endian to big-endian and vice versa */ - -PRIVATE void u2c2_ss(buf, offset) -register char *buf; -u2_pt offset; -{ - u2_t offset2; - - offset2 = offset; - buf[0] = ((char *) &offset2)[1]; - buf[1] = ((char *) &offset2)[0]; -} - -PRIVATE void u4c4_ss(buf, offset) -register char *buf; -u4_t offset; -{ - buf[0] = ((char *) &offset)[3]; - buf[1] = ((char *) &offset)[2]; - buf[2] = ((char *) &offset)[1]; - buf[3] = ((char *) &offset)[0]; -} - -/* wierd swapping for different-endian u2's, same-endian u4's */ - -PRIVATE void u4c4_s0(buf, offset) -register char *buf; -u4_t offset; -{ - buf[0] = ((char *) &offset)[1]; - buf[1] = ((char *) &offset)[0]; - buf[2] = ((char *) &offset)[3]; - buf[3] = ((char *) &offset)[2]; -} - -/* very wierd swapping for same-endian u2's, different-endian u4's */ - -PRIVATE void u4c4_0s(buf, offset) -register char *buf; -u4_t offset; -{ - buf[0] = ((char *) &offset)[2]; - buf[1] = ((char *) &offset)[3]; - buf[2] = ((char *) &offset)[0]; - buf[3] = ((char *) &offset)[1]; -} - -/* === entry points === */ - -PUBLIC void u2c2(buf, offset) -register char *buf; -u2_pt offset; -{ - (*pu2c2) (buf, offset); -} - -PUBLIC void u4c4(buf, offset) -register char *buf; -u4_t offset; -{ - (*pu4c4) (buf, offset); -} - -PUBLIC void u2cn(buf, offset, count) -register char *buf; -u2_pt offset; -unsigned count; -{ - switch (count) - { - case 1: - buf[0] = (char) offset; - return; - case 2: - (*pu2c2) (buf, offset); - return; - case 4: - (*pu4c4) (buf, (u4_t) offset); - return; - } -} - -PUBLIC void u4cn(buf, offset, count) -register char *buf; -u4_t offset; -unsigned count; -{ - switch (count) - { - case 1: - buf[0] = (char) offset; - return; - case 2: - (*pu2c2) (buf, (u2_pt) (u2_t) offset); - return; - case 4: - (*pu4c4) (buf, offset); - return; - } -} - -/* initialise type conversion, return FALSE if it cannot be handled */ - -PUBLIC bool_pt typeconv_init(big_endian, long_big_endian) -bool_pt big_endian; -bool_pt long_big_endian; -{ - u2_pt conv2; - u4_pt conv4; - char *conv2ptr; - char *conv4ptr; - - if (sizeof(u2_t) != 2 || sizeof(u4_t) != 4) - /* dumb preprocessor's don't accept sizeof in #if expressions */ - return FALSE; - - if (big_endian) - { - conv2ptr = (conv4ptr = "\1\2\3\4") + 2; - if (!long_big_endian) - conv4ptr = "\3\4\1\2"; - } - else - { - conv2ptr = conv4ptr = "\4\3\2\1"; - if (long_big_endian) - conv4ptr = "\2\1\4\3"; - } - conv2 = c2u2_00(conv2ptr); - conv4 = c4u4_00(conv4ptr); - if (conv2 == 0x0304) - { - pc2u2 = c2u2_00; - pc4u4 = c4u4_00; - pu2c2 = u2c2_00; - pu4c4 = u4c4_00; - if (conv4 == 0x03040102L) - { - pc4u4 = c4u4_0s; - pu4c4 = u4c4_0s; - } - else if (conv4 != 0x01020304L) - return FALSE; - } - else if (conv2 == 0x0403) - { - pc2u2 = c2u2_ss; - pc4u4 = c4u4_ss; - pu2c2 = u2c2_ss; - pu4c4 = u4c4_ss; - if (conv4 == 0x02010403L) - { - pc4u4 = c4u4_s0; - pu4c4 = u4c4_s0; - } - else if (conv4 != 0x04030201L) - return FALSE; - } - else - return FALSE; - return TRUE; -} - -#ifdef DEBUG_TYPECONV - -main() -{ - char *source; - char target[4]; - u2_t u2; - u2_t u2a; - u4_t u4; - u4_t u4a; - - printf("%u\n", typeconv_init(FALSE, FALSE)); - printf("%u\n", typeconv_init(FALSE, TRUE)); - printf("%u\n", typeconv_init(TRUE, FALSE)); - printf("%u\n", typeconv_init(TRUE, TRUE)); - - typeconv_init(FALSE, FALSE); - source = "\4\3\2\1"; - - target[0] = 0; - target[1] = 0; - u2 = cnu2(source, 2); - u2cn(target, u2, 2); - if (strncmp(source, target, 2)) - printf("oops9\n"); - - target[0] = 0; - target[1] = 0; - u4a = cnu4(source, 2); - u4cn(target, u4a, 2); - if (strncmp(source, target, 2)) - printf("oops10\n"); - - target[0] = 0; - target[1] = 0; - target[2] = 0; - target[3] = 0; - u2a = cnu2(source, 4); - u2cn(target, u2a, 4); - if (strncmp(target, "\4\3\0\0", 4)) - printf("oops11\n"); - - target[0] = 0; - target[1] = 0; - target[2] = 0; - target[3] = 0; - u4 = cnu4(source, 4); - u4cn(target, u4, 4); - if (strncmp(source, target, 4)) - printf("oops12\n"); - - printf("%04x %04x %08lx %08lx\n", u2, u2a, u4, u4a); - - typeconv_init(FALSE, TRUE); - source = "\2\1\4\3"; - - target[0] = 0; - target[1] = 0; - u2 = cnu2(source + 2, 2); - u2cn(target, u2, 2); - if (strncmp(source + 2, target, 2)) - printf("oops13\n"); - - target[0] = 0; - target[1] = 0; - u4a = cnu4(source + 2, 2); - u4cn(target, u4a, 2); - if (strncmp(source + 2, target, 2)) - printf("oops14\n"); - - target[0] = 0; - target[1] = 0; - target[2] = 0; - target[3] = 0; - u2a = cnu2(source, 4); - u2cn(target, u2a, 4); - if (strncmp(target, "\0\0\4\3", 4)) - printf("oops15\n"); - - target[0] = 0; - target[1] = 0; - target[2] = 0; - target[3] = 0; - u4 = cnu4(source, 4); - u4cn(target, u4, 4); - if (strncmp(source, target, 4)) - printf("oops16\n"); - - printf("%04x %04x %08lx %08lx\n", u2, u2a, u4, u4a); - - typeconv_init(TRUE, FALSE); - source = "\3\4\1\2"; - - target[0] = 0; - target[1] = 0; - u2 = cnu2(source, 2); - u2cn(target, u2, 2); - if (strncmp(source, target, 2)) - printf("oops5\n"); - - target[0] = 0; - target[1] = 0; - u4a = cnu4(source, 2); - u4cn(target, u4a, 2); - if (strncmp(source, target, 2)) - printf("oops6\n"); - - target[0] = 0; - target[1] = 0; - target[2] = 0; - target[3] = 0; - u2a = cnu2(source, 4); - u2cn(target, u2a, 4); - if (strncmp(target, "\3\4\0\0", 4)) - printf("oops7\n"); - - target[0] = 0; - target[1] = 0; - target[2] = 0; - target[3] = 0; - u4 = cnu4(source, 4); - u4cn(target, u4, 4); - if (strncmp(source, target, 4)) - printf("oops8\n"); - - printf("%04x %04x %08lx %08lx\n", u2, u2a, u4, u4a); - - typeconv_init(TRUE, TRUE); - source = "\1\2\3\4"; - - target[0] = 0; - target[1] = 0; - u2 = cnu2(source + 2, 2); - u2cn(target, u2, 2); - if (strncmp(source + 2, target, 2)) - printf("oops1\n"); - - target[0] = 0; - target[1] = 0; - u4a = cnu4(source + 2, 2); - u4cn(target, u4a, 2); - if (strncmp(source + 2, target, 2)) - printf("oops2\n"); - - target[0] = 0; - target[1] = 0; - target[2] = 0; - target[3] = 0; - u2a = cnu2(source, 4); - u2cn(target, u2a, 4); - if (strncmp(target, "\0\0\3\4", 4)) - printf("oops3\n"); - - target[0] = 0; - target[1] = 0; - target[2] = 0; - target[3] = 0; - u4 = cnu4(source, 4); - u4cn(target, u4, 4); - if (strncmp(source, target, 4)) - printf("oops4\n"); - - printf("%04x %04x %08lx %08lx\n", u2, u2a, u4, u4a); -} - -#endif /* DEBUG_TYPECONV */ diff -Nurd linux-86.old/ld/x86_aout.h linux-86/ld/x86_aout.h --- linux-86.old/ld/x86_aout.h Fri Apr 25 21:53:36 1997 +++ linux-86/ld/x86_aout.h Tue Jul 22 21:56:26 1997 @@ -9,7 +9,7 @@ #define __AOUT_H /* If the host isn't an x86 all bets are off, use chars. */ -#if defined(i386) || defined(__BCC__) +#if defined(i386) || defined(__BCC__) || defined(MSDOS) typedef long Long; #define __OUT_OK 1 #else @@ -118,7 +118,7 @@ /* High bits of storage class. */ #define N_CLASS 0370 /* storage class mask */ -#define C_NULL +#define C_NULL 0 #define C_EXT 0020 /* external symbol */ #define C_STAT 0030 /* static */ diff -Nurd linux-86.old/libc/Config.dflt linux-86/libc/Config.dflt --- linux-86.old/libc/Config.dflt Thu Jan 1 01:00:00 1970 +++ linux-86/libc/Config.dflt Sat Aug 16 11:25:41 1997 @@ -0,0 +1,16 @@ +bcc:+: +bios:+: +error:+: +getent:+: +gtermcap:+: +i386fp:+: +i386sys:+: +malloc1:+: +misc:+: +msdos:+: +regexp:+: +stdio2:+: +string:+: +syscall:+: +termios:+: +time:+: diff -Nurd linux-86.old/libc/Config_sh linux-86/libc/Config_sh --- linux-86.old/libc/Config_sh Sat Apr 19 20:29:58 1997 +++ linux-86/libc/Config_sh Sun Sep 28 10:25:22 1997 @@ -6,14 +6,22 @@ main() { rm -f .config.tmp - ALLON=no + ALLON=yes - if [ -f .config.lst ] + if [ "$ALLON" = yes -a -f .config.lst ] then grep '^[^:]*:+:' .config.lst > .config.tmp - if [ ! -s .config.tmp ] - then ALLON=yes - fi - else ALLON=yes + [ -s .config.tmp ] && ALLON=no + fi + + if [ "$ALLON" = yes -a -f Config.dflt ] + then grep '^[^:]*:+:' Config.dflt > .config.tmp + [ -s .config.tmp ] && { + ALLON=no + grep -q '^kinclude:' .config.tmp >/dev/null 2>&1 || { + [ -d "$ELKSSRC/include" ] || + echo 'kinclude:+:' >> .config.tmp + } + } fi egrep -v '^#|^$' /dev/null */[Cc]onfig | \ @@ -38,7 +46,7 @@ do display echo - echo -n 'Option to flip [or quit] >' + echon 'Option to flip [or quit] >' read n v="" case "$n" in @@ -140,6 +148,16 @@ cat .config.tmp[12] > .config.lst rm .config.tmp[12] unset_dups +} + +echon() { + [ "$ECHON" = "" ] && { + if echo -n | grep -e -n >/dev/null + then ECHON="echo "; ECHOT='\c' + else ECHON="echo -n"; ECHOT='' + fi + } + $ECHON "$@""$ECHOT" } main diff -Nurd linux-86.old/libc/Make.defs linux-86/libc/Make.defs --- linux-86.old/libc/Make.defs Fri Feb 21 20:38:07 1997 +++ linux-86/libc/Make.defs Tue Aug 12 21:41:16 1997 @@ -54,6 +54,19 @@ endif ############################################################################## +# GCC 386. + +ifeq ($(PLATFORM),i386-GCC) +OBJ=crtg.o +LIBC=$(TOP)/libcg.a +ARCH= +LIB_CPU=g386 +LIB_OS=ELKS +CC=gcc +CCFLAGS=-O -g -nostdinc -I$(TOP)/include +endif + +############################################################################## # Anonymous ifeq ($(PLATFORM),ANON) diff -Nurd linux-86.old/libc/Makefile linux-86/libc/Makefile --- linux-86.old/libc/Makefile Fri May 9 18:33:51 1997 +++ linux-86/libc/Makefile Wed Sep 17 20:23:46 1997 @@ -10,7 +10,7 @@ endif VERMAJOR=0 -VERMINOR=12 +VERMINOR=13 VERPATCH=0 VER=$(VERMAJOR).$(VERMINOR).$(VERPATCH) @@ -18,6 +18,11 @@ CCFLAGS=-I -I$(TOP)/include DEFS=-D__LIBC__ +ifeq ($(ELKSSRC),) +ELKSSRC=/usr/src/elks +endif +export ELKSSRC + include Make.defs CFLAGS=$(ARCH) $(CCFLAGS) $(DEFS) @@ -43,8 +48,12 @@ crt0.o: crt0.c Makefile $(CC) -c $(CFLAGS) -D__LIBC_VER__='"$(VER)"' -o $@ crt0.c +crtg.o: crt0.c Makefile + $(CC) -c $(CFLAGS) -D__LIBC_VER__='"$(VER)"' -o $@ crt0.c + crtX.o: - @echo "You need to define the 'PLATFORM=...' variable" + @echo "You need to define the 'PLATFORM=...' variable," + @echo "Preferably by doing make from `dirname \`pwd\``" @exit 1 ############################################################################ @@ -54,8 +63,10 @@ grep -s '^transfer' $$i/Makefile && $(MAKE) -s -C $$i $@ ; \ done ; echo -n @[ -f kinclude/Used ] || \ - { rm -f include/linuxmt ; \ - ln -s $(ELKSSRC)/include/linuxmt include ; } + { rm -f include/linuxmt include/arch ; \ + ln -s $(ELKSSRC)/include/linuxmt include ; \ + ln -s $(ELKSSRC)/include/arch include ; \ + } ############################################################################ @@ -74,8 +85,9 @@ cp -pr include $(BCCHOME)/include if [ -f kinclude/Used ] ; \ then cp -pr kinclude/arch $(BCCHOME)/include/arch ; \ - else rm -rf $(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 ; \ fi -chown -R root:root $(BCCHOME)/include 2>/dev/null -chmod -R u=rwX,og=rX $(BCCHOME)/include diff -Nurd linux-86.old/libc/bcc/__ldivmod.c linux-86/libc/bcc/__ldivmod.c --- linux-86.old/libc/bcc/__ldivmod.c Sat Jan 6 19:41:58 1996 +++ linux-86/libc/bcc/__ldivmod.c Thu Sep 4 19:42:19 1997 @@ -1,5 +1,6 @@ /************************************************************************/ /* This file contains the BCC compiler helper functions */ +/* (C) Copyright Bruce Evans */ /* Function ldivmod */ #ifdef __AS386_16__ diff -Nurd linux-86.old/libc/bcc/bcc_bsw.c linux-86/libc/bcc/bcc_bsw.c --- linux-86.old/libc/bcc/bcc_bsw.c Sat Jan 6 19:42:38 1996 +++ linux-86/libc/bcc/bcc_bsw.c Thu Sep 4 19:42:29 1997 @@ -1,5 +1,6 @@ /************************************************************************/ /* This file contains the BCC compiler helper functions */ +/* (C) Copyright Bruce Evans */ /* Support for long arithmetic on big-endian (words-swapped) longs * __laddb.o __landb.o __lcmpb.o __lcomb.o __ldecb.o __ldivb.o __ldivub.o * __leorb.o __lincb.o __lmodb.o __lmodub.o __lmulb.o __lnegb.o __lorb.o diff -Nurd linux-86.old/libc/bcc/bcc_i386.c linux-86/libc/bcc/bcc_i386.c --- linux-86.old/libc/bcc/bcc_i386.c Fri Oct 11 13:37:20 1996 +++ linux-86/libc/bcc/bcc_i386.c Thu Sep 4 19:42:38 1997 @@ -1,5 +1,6 @@ /************************************************************************/ /* This file contains the BCC compiler helper functions */ +/* (C) Copyright Bruce Evans */ /* Support for 386 integer arithmetic * __divsi3.o __idiv.o __idivu.o __imod.o __imodu.o __imul.o * __isl.o __isr.o __isru.o diff -Nurd linux-86.old/libc/bcc/bcc_int.c linux-86/libc/bcc/bcc_int.c --- linux-86.old/libc/bcc/bcc_int.c Sat Jan 6 19:42:57 1996 +++ linux-86/libc/bcc/bcc_int.c Thu Sep 4 19:42:45 1997 @@ -1,5 +1,6 @@ /************************************************************************/ /* This file contains the BCC compiler helper functions */ +/* (C) Copyright Bruce Evans */ /* Support for integer arithmetic * __idiv.o __idivu.o __imod.o __imodu.o __imul.o __isl.o __isr.o __isru.o */ diff -Nurd linux-86.old/libc/bcc/bcc_io.c linux-86/libc/bcc/bcc_io.c --- linux-86.old/libc/bcc/bcc_io.c Sat Jan 6 19:43:35 1996 +++ linux-86/libc/bcc/bcc_io.c Thu Sep 4 19:44:39 1997 @@ -1,5 +1,6 @@ /************************************************************************/ /* This file contains the BCC compiler helper functions */ +/* (C) Prentice Hall (Minix) http://www.cs.vu.nl/~ast/minix.html */ /* Miscellaneous obsolete junk * __inport.o __inportb.o __outport.o __outportb.o __peekb.o __peekw.o * __pokeb.o __pokew.o diff -Nurd linux-86.old/libc/bcc/bcc_long.c linux-86/libc/bcc/bcc_long.c --- linux-86.old/libc/bcc/bcc_long.c Sat Jan 6 19:43:49 1996 +++ linux-86/libc/bcc/bcc_long.c Thu Sep 4 19:44:49 1997 @@ -1,5 +1,6 @@ /************************************************************************/ /* This file contains the BCC compiler helper functions */ +/* (C) Copyright Bruce Evans */ /* Support for long arithmetic on little-endian (normal) longs * __laddl.o __landl.o __lcmpl.o __lcoml.o __ldecl.o __ldivl.o __ldivul.o * __leorl.o __lincl.o __lmodl.o __lmodul.o __lmull.o __lnegl.o __lorl.o diff -Nurd linux-86.old/libc/bcc/ldiv.c linux-86/libc/bcc/ldiv.c --- linux-86.old/libc/bcc/ldiv.c Fri Oct 11 13:30:25 1996 +++ linux-86/libc/bcc/ldiv.c Thu Sep 4 19:45:29 1997 @@ -1,3 +1,6 @@ +/************************************************************************/ +/* This file contains the BCC compiler helper functions */ +/* (C) Copyright Bruce Evans */ #ifdef __AS386_16__ #asm diff -Nurd linux-86.old/libc/crt0.c linux-86/libc/crt0.c --- linux-86.old/libc/crt0.c Sat Feb 1 11:21:45 1997 +++ linux-86/libc/crt0.c Sat Aug 9 07:09:28 1997 @@ -41,14 +41,15 @@ #endif /* __AS386_16__ or __AS386_32__ */ #if defined(__GNUC__) && defined(__i386__) -#define CRT0_OK - #ifdef __ELF__ -__asm__(".globl __startup\n__startup:"); +#define CRT0_OK +__asm__(".globl _start\n_start:"); __asm__("jmp __cstartup"); __asm__(".globl __no_op\n__no_op:"); __asm__("ret"); #else + +#error This library is for ELF only, sorry. __asm__(".globl startup\nstartup:"); __asm__("jmp ___cstartup"); __asm__(".globl no_op\nno_op:"); diff -Nurd linux-86.old/libc/gnu_i386/Config linux-86/libc/gnu_i386/Config --- linux-86.old/libc/gnu_i386/Config Thu Jan 1 01:00:00 1970 +++ linux-86/libc/gnu_i386/Config Sat Aug 9 06:58:05 1997 @@ -0,0 +1 @@ +gnu386: Linux-i386 system call routines GCC diff -Nurd linux-86.old/libc/gnu_i386/Makefile linux-86/libc/gnu_i386/Makefile --- linux-86.old/libc/gnu_i386/Makefile Thu Jan 1 01:00:00 1970 +++ linux-86/libc/gnu_i386/Makefile Sun Aug 17 15:27:48 1997 @@ -0,0 +1,59 @@ +# Copyright (C) 1995,1996 Robert de Bath +# This file is part of the Linux-8086 C library and is distributed +# under the GNU Library General Public License. + +CSRC=cstartup.s +COBJ=cstartup.o + +ESRC=exec.c +EOBJ=execl.o execv.o execle.o execlp.o execvp.o + +DSRC=dirent.c +DOBJ=opendir.o closedir.o readdir.o + +HSRC=heap.c +HOBJ=__brk_addr.o brk.o sbrk.o + +ifeq ($(LIB_CPU)-$(LIB_OS),g386-ELKS) +OBJ=$(COBJ) $(EOBJ) $(DOBJ) $(HOBJ) +SYSCALLS=syscalls + +CFLAGS=$(ARCH) $(CCFLAGS) $(DEFS) + +all: $(SYSCALLS) $(LIBC)($(OBJ)) + @$(RM) $(OBJ) + +syscalls: syscall.mak + $(MAKE) -f syscall.mak LIBC="$(LIBC)" CFLAGS="$(CFLAGS)" + +syscall.mak: mksyscall syscall.dat + sh mksyscall + +$(LIBC)($(LOBJ)): $(LSRC) + $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o + $(AR) $(ARFLAGS) $@ $*.o + +$(LIBC)($(COBJ)): $(CSRC) + $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o + $(AR) $(ARFLAGS) $@ $*.o + +$(LIBC)($(DOBJ)): $(DSRC) + $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o + $(AR) $(ARFLAGS) $@ $*.o + +$(LIBC)($(EOBJ)): $(ESRC) + $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o + $(AR) $(ARFLAGS) $@ $*.o + +$(LIBC)($(HOBJ)): $(HSRC) + $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o + $(AR) $(ARFLAGS) $@ $*.o +else +all: + @: +endif + +clean: + rm -f *.o libc.a + rm -f syscall.c syscall.mak + diff -Nurd linux-86.old/libc/gnu_i386/cstartup.s linux-86/libc/gnu_i386/cstartup.s --- linux-86.old/libc/gnu_i386/cstartup.s Thu Jan 1 01:00:00 1970 +++ linux-86/libc/gnu_i386/cstartup.s Tue Aug 12 22:10:36 1997 @@ -0,0 +1,85 @@ +# +# This is a startup for GCC compiling to an ELF executable. +# +# + .file "cstartup.s" + +# void (*__cleanup)() = 0; + +.globl __cleanup +.data + .align 4 + .type __cleanup,@object + .size __cleanup,4 +__cleanup: + .long 0 + +.globl errno + .align 4 + .type errno,@object + .size errno,4 +errno: + .long 0 + +# char ** environ; + .comm environ,4,4 + +.text + .align 16 +.globl __cstartup +.type __cstartup,@function +__cstartup: # Crt0 startup (Linux style) + cmpl $0,(%esp) + jz call_exit # If argc == 0 this is being called by ldd, exit. + + popl %ecx + movl %esp,%ebx # Points to the arguments + movl %esp,%eax + movl %ecx,%edx + addl %edx,%edx + addl %edx,%edx + addl %edx,%eax + addl $4,%eax # Now points to environ. + + pushl %eax # envp + pushl %ebx # argp + pushl %ecx # argc + + # mov 8(%esp),%eax + mov %eax,environ + + call main + push %eax # Main has returned, +call_exit: + call exit # return val and call exit(); +bad_exit: + jmp bad_exit # Exit returned !! + +# Exit - call __cleanup then _exit + + .align 16 +.globl exit + .type exit,@function +exit: + pushl %ebp + movl %esp,%ebp + pushl %ebx + movl 8(%ebp),%ebx + movl __cleanup,%eax + testl %eax,%eax + je .L8 + pushl %ebx + call *%eax + addl $4,%esp +.L8: + pushl %ebx + call _exit + jmp bad_exit + +# _exit is an alias for __exit + .align 16 +.globl _exit + .type _exit,@function +_exit: + jmp __exit + diff -Nurd linux-86.old/libc/gnu_i386/dirent.c linux-86/libc/gnu_i386/dirent.c --- linux-86.old/libc/gnu_i386/dirent.c Thu Jan 1 01:00:00 1970 +++ linux-86/libc/gnu_i386/dirent.c Thu Jan 30 19:15:39 1997 @@ -0,0 +1,106 @@ + +#include +#include +#include +#include +#include +#include + +#ifdef L_opendir +DIR * +opendir(dname) +const char *dname; +{ + struct stat st; + int fd; + DIR *p; + + if (stat(dname, &st) < 0) + return 0; + + if (!S_ISDIR(st.st_mode)) + { + errno = ENOTDIR; + return 0; + } + if ((fd = open(dname, O_RDONLY)) < 0) + return 0; + + p = malloc(sizeof(DIR)); + if (p == 0) + { + close(fd); + return 0; + } + + p->dd_buf = malloc(sizeof(struct dirent)); + if (p->dd_buf == 0) + { + free(p); + close(fd); + return 0; + } + p->dd_fd = fd; + p->dd_loc = p->dd_size = 0; + + return p; +} +#endif + +#ifdef L_closedir +int +closedir(dirp) +DIR *dirp; +{ + int fd; + fd = dirp->dd_fd; + free(dirp->dd_buf); + free(dirp); + return close(fd); +} +#endif + +#ifdef __AS386_16__ +#ifdef L_readdir +/* + * This currently assumes we see a v. simple diectory structure, it's + * probably faked! + */ +struct dirent * +readdir(dirp) +DIR *dirp; +{ + int cc; + cc = read(dirp->dd_fd, dirp->dd_buf, sizeof(struct dirent)); + + if (cc <= 0) + return 0; + if (cc != sizeof(struct dirent)) + { + errno = EBADF; + return 0; + } + return dirp->dd_buf; +} +#endif +#else + +/* This is for 386 linux */ + +#ifdef L_readdir +struct dirent * +readdir(dirp) +DIR *dirp; +{ + int cc; + + cc = __readdir(dirp->dd_fd, dirp->dd_buf, 1); + if (cc <= 0) + return 0; + if (cc>1) dirp->dd_buf->d_name[cc] = 0; + + return dirp->dd_buf; +} +#endif + +#endif diff -Nurd linux-86.old/libc/gnu_i386/exec.c linux-86/libc/gnu_i386/exec.c --- linux-86.old/libc/gnu_i386/exec.c Thu Jan 1 01:00:00 1970 +++ linux-86/libc/gnu_i386/exec.c Thu Jan 30 19:15:39 1997 @@ -0,0 +1,292 @@ + +#include +#include + +extern char ** environ; + +#ifdef L_execl +int +execl(fname, arg0) +char * fname, *arg0; +{ + return execve(fname, &arg0, environ); +} +#endif + +#ifdef L_execv +int +execv(fname, argv) +char * fname, **argv; +{ + return execve(fname, argv, environ); +} +#endif + +#ifdef L_execle +int +execle(fname, arg0) +char *fname, *arg0; +{ + char ** envp = &arg0; + while(*envp) envp++; + return execve(fname, &arg0, envp+1); +} +#endif + +#ifdef L_execve +int +execve(fname, argv, envp) +char * fname; +char ** argv; +char ** envp; +{ + char **p; + int argv_len=0, argv_count=0; + int envp_len=0, envp_count=0; + int stack_bytes; + unsigned short * pip; + char * pcp, * stk_ptr, *baseoff; + int rv; + + /* How much space for argv */ + for(p=argv; p && *p && argv_len >= 0; p++) + { + argv_count++; argv_len += strlen(*p)+1; + } + + /* How much space for envp */ + for(p=envp; p && *p && envp_len >= 0; p++) + { + envp_count++; envp_len += strlen(*p)+1; + } + + /* tot it all up */ + stack_bytes = 2 /* argc */ + + argv_count * 2 + 2 /* argv */ + + argv_len + + envp_count * 2 + 2 /* envp */ + + envp_len; + + /* Allocate it */ + if( argv_len < 0 || envp_len < 0 || stack_bytes <= 0 + || (int)(stk_ptr = (char*)sbrk(stack_bytes)) == -1) + { + errno = ENOMEM; + return -1; + } + +/* Sanity check + printf("Argv = (%d,%d), Envp=(%d,%d), stack=%d\n", + argv_count, argv_len, envp_count, envp_len, stack_bytes); +*/ + + /* Now copy in the strings */ + pip=(unsigned short *) stk_ptr; + pcp=stk_ptr+2*(1+argv_count+1+envp_count+1); + + /* baseoff = stk_ptr + stack_bytes; */ + baseoff = stk_ptr; + *pip++ = argv_count; + for(p=argv; p && *p; p++) + { + int l; + *pip++ = pcp-baseoff; + l = strlen(*p)+1; + memcpy(pcp, *p, l); + pcp += l; + } + *pip++ = 0; + + for(p=envp; p && *p; p++) + { + int l; + *pip++ = pcp-baseoff; + l = strlen(*p)+1; + memcpy(pcp, *p, l); + pcp += l; + } + *pip++ = 0; + + rv = __exec(fname, stk_ptr, stack_bytes); + /* FIXME: This will probably have to interpret '#!' style exe's */ + sbrk(-stack_bytes); + return rv; +} +#endif + +#ifdef L_execlp +int +execlp(fname, arg0) +char * fname, *arg0; +{ + return execvp(fname, &arg0); +} +#endif + +#ifdef L_execvp +int +execvp(fname, argv) +char * fname, **argv; +{ + char *pname = fname, *path; + int besterr = ENOENT; + int flen, plen; + char * bp = sbrk(0); + + if( *fname != '/' && (path = getenv("PATH")) != 0 ) + { + flen = strlen(fname)+2; + + for(;path;) + { + if( *path == ':' || *path == '\0' ) + { + tryrun(fname, argv); + if( errno == EACCES ) besterr = EACCES; + if( *path ) path++; else break; + } + else + { + char * p = strchr(path, ':'); + if(p) *p = '\0'; + plen = strlen(path); + pname = sbrk(plen+flen); + + strcpy(pname, path); + strcat(pname, "/"); + strcat(pname, fname); + + tryrun(pname, argv); + if( errno == EACCES ) besterr = EACCES; + + brk(pname); + pname = fname; + if(p) *p++ = ':'; + path=p; + } + } + } + + tryrun(pname, argv); + brk(bp); + if( errno == ENOENT || errno == 0 ) errno = besterr; + return -1; +} + +static int tryrun(pname, argv) +char * pname; +char ** argv; +{ +static char *shprog[] = {"/bin/sh", "", 0}; + struct stat st; + + if( stat(pname, &st) < 0 ) return; + if( !S_ISREG(st.st_mode) ) return; + +#ifdef __AS386_16__ + __execvve(pname, (void*)0, argv, environ); + if( errno == ENOEXEC ) + { + shprog[1] = pname; + __execvve(shprog[0], shprog, argv, environ); + } +#else + execve(pname, argv, environ); + /* FIXME - running /bin/sh in 386 mode */ +#endif +} + +#ifdef __AS386_16__ +static int +__execvve(fname, interp, argv, envp) +char * fname; +char ** interp; +char ** argv; +char ** envp; +{ + char **p; + int argv_len=0, argv_count=0; + int envp_len=0, envp_count=0; + int stack_bytes; + unsigned short * pip; + char * pcp, * stk_ptr, *baseoff; + int rv; + + /* How much space for argv */ + for(p=interp; p && *p && argv_len >= 0; p++) + { + argv_count++; argv_len += strlen(*p)+1; + } + for(p=argv; p && *p && argv_len >= 0; p++) + { + argv_count++; argv_len += strlen(*p)+1; + } + + /* How much space for envp */ + for(p=envp; p && *p && envp_len >= 0; p++) + { + envp_count++; envp_len += strlen(*p)+1; + } + + /* tot it all up */ + stack_bytes = 2 /* argc */ + + argv_count * 2 + 2 /* argv */ + + argv_len + + envp_count * 2 + 2 /* envp */ + + envp_len; + + /* Allocate it */ + if( argv_len < 0 || envp_len < 0 || stack_bytes <= 0 + || (int)(stk_ptr = (char*)sbrk(stack_bytes)) == -1) + { + errno = ENOMEM; + return -1; + } + +/* Sanity check + printf("Argv = (%d,%d), Envp=(%d,%d), stack=%d\n", + argv_count, argv_len, envp_count, envp_len, stack_bytes); +*/ + + /* Now copy in the strings */ + pip=(unsigned short *) stk_ptr; + pcp=stk_ptr+2*(1+argv_count+1+envp_count+1); + + /* baseoff = stk_ptr + stack_bytes; */ + baseoff = stk_ptr; + *pip++ = argv_count; + for(p=interp; p && *p; p++) + { + int l; + *pip++ = pcp-baseoff; + l = strlen(*p)+1; + memcpy(pcp, *p, l); + pcp += l; + } + for(p=argv; p && *p; p++) + { + int l; + *pip++ = pcp-baseoff; + l = strlen(*p)+1; + memcpy(pcp, *p, l); + pcp += l; + } + *pip++ = 0; + + for(p=envp; p && *p; p++) + { + int l; + *pip++ = pcp-baseoff; + l = strlen(*p)+1; + memcpy(pcp, *p, l); + pcp += l; + } + *pip++ = 0; + + rv = __exec(fname, stk_ptr, stack_bytes); + /* FIXME: This will probably have to interpret '#!' style exe's */ + sbrk(-stack_bytes); + return rv; +} +#endif +#endif diff -Nurd linux-86.old/libc/gnu_i386/heap.c linux-86/libc/gnu_i386/heap.c --- linux-86.old/libc/gnu_i386/heap.c Thu Jan 1 01:00:00 1970 +++ linux-86/libc/gnu_i386/heap.c Tue Aug 12 20:42:51 1997 @@ -0,0 +1,76 @@ +/* Copyright (C) 1995-1997 Robert de Bath + * This file is part of the Linux-8086 C library and is distributed + * under the GNU Library General Public License. + */ + +#include + +/****************************************************************************/ + +#if defined(__GNUC__) && defined(__i386__) +extern char * __brk_addr; +extern char * __brk(); + +#ifdef L___brk_addr +char * __brk_addr = 0; /* This holds the current return for sbrk(0) */ + + /* "mov %ebx,4(%esp),%ebx\n\t" "mov $45,%eax\n\t" */ + +char * +__brk(char * val) +{ + char * retval; + __asm__( + "int $0x80" + : "=a" (retval) + : "0" (45), "b" (val) + ); + return retval; +} + +__brk_addr_init() +{ + if( __brk_addr == 0 && (__brk_addr = __brk(0)) == 0 ) + { + errno = ENOMEM; + return -1; + } + return 0; +} +#endif + +#ifdef L_sbrk +char * +sbrk(brk_off) +int brk_off; +{ + char * new_brk; + if( __brk_addr_init() ) return (char*)-1; + if( brk_off == 0 ) return __brk_addr; + + new_brk = __brk_addr + brk_off; + __brk_addr = __brk(new_brk); + if( __brk_addr != new_brk ) + { + errno = ENOMEM; + return (char*)-1; + } + return __brk_addr - brk_off; +} +#endif + +#ifdef L_brk +int +brk(new_brk) +char * new_brk; +{ + if( __brk_addr_init() ) return -1; + + __brk_addr = __brk(new_brk); + if( __brk_addr == new_brk ) return 0; + errno = ENOMEM; + return -1; +} +#endif + +#endif diff -Nurd linux-86.old/libc/gnu_i386/mksyscall linux-86/libc/gnu_i386/mksyscall --- linux-86.old/libc/gnu_i386/mksyscall Thu Jan 1 01:00:00 1970 +++ linux-86/libc/gnu_i386/mksyscall Tue Aug 12 21:26:01 1997 @@ -0,0 +1,123 @@ +# Copyright (C) 1995-1997 Robert de Bath +# This file is part of the Linux-8086 C library and is distributed +# under the GNU Library General Public License. +# +# This script generates the 'simple' system calls for the 386 +# +# Each call is put into it's own object file, if the semantics of the +# call are not correct UNIX then the 4th field in the dat file has a +# marker and the function is generated with a __ prefix. +# +# +# Different levels of squeeze +# 0 = each is complete +# 1 = Short codes calling common function + +rm -f syscall.c syscall.mak + +tr '[A-Z]' '[a-z]' < syscall.dat | \ +awk 'BEGIN{ + print "# Copyright (C) 1995-1997 Robert de Bath " > "syscall.mak"; + print "# This file is part of the Linux-8086 C library and is distributed" > "syscall.mak"; + print "# under the GNU Library General Public License." > "syscall.mak"; + print "# " > "syscall.mak"; + print "# This file is automatically generated\n" > "syscall.mak" + + print "# Copyright (C) 1995-1997 Robert de Bath "; + print "# This file is part of the Linux-8086 C library and is distributed"; + print "# under the GNU Library General Public License."; + print "# "; + print "# This file is automatically generated */\n" + obj="OBJ="; + + print "# Standard start\n\n" + printf("#ifndef __MSDOS__\n"); + printf("#ifdef __AS386_32__\n"); + printf(" .text\n"); + printf(" .align 16\n"); + + COMPACT=0; +} +/^[ ]*#/ { next; } +/^[ ]*$/ { next; } +{ + if( $2 > max_call ) max_call = $2; + + if( $3 == "x" || $3 == "" ) next; + else if( $4 == "-" ) next; + else if( $4 == "*" ) funcname="__" $1; + else funcname=$1; + + if( length(obj) > 60 ) + { + printf("%s\t\\\n", obj) > "syscall.mak"; + obj=" "; + } + obj=obj funcname ".o "; + + printf "# CALL %s\n\n", $0; + + printf(".ifdef L_%s\n", funcname); + printf(".globl %s\n", funcname); + printf(".type %s,@function\n", funcname); + printf("%s:\n", funcname); + + # Inline assembler max to 5 args (20 bytes) + if( $3 != 4 && $3 != 5 && ( COMPACT || $3 > 5 )) + { + printf(" mov %%eax,#%d\n", $2); + printf(" br sys_call%d\n", $3); + } + else + { + printf(" pushl %%ebp\n"); + printf(" movl %%esp,%%ebp\n"); + printf(" pushl %%ebx\n"); + if( $3 >= 1 ) printf(" mov 8(%%ebp),%%ebx\n"); + if( $3 >= 2 ) printf(" mov 12(%%ebp),%%ecx\n"); + if( $3 >= 3 ) printf(" mov 16(%%ebp),%%edx\n"); + if( $3 >= 4 ) printf(" push %%esi\n"); + if( $3 >= 4 ) printf(" mov 20(%%ebp),%%esi\n"); + if( $3 >= 5 ) printf(" push %%edi\n"); + if( $3 >= 5 ) printf(" mov 24(%%ebp),%%edi\n"); + printf(" mov $%d,%%eax\n", $2); + printf(" int $0x80\n"); + + if( $3 >= 5 ) printf(" pop %%edi\n"); + if( $3 >= 4 ) printf(" pop %%esi\n"); + printf(" pop %%ebx\n"); + + printf(" test %%eax,%%eax\n"); + printf(" jge syscall_ok\n"); + printf(" neg %%eax\n"); + printf(" mov %%eax,errno\n"); + printf(" mov $-1,%%eax\n"); + printf("syscall_ok:\n"); + printf(" movl %%ebp,%%esp\n"); + printf(" popl %%ebp\n"); + printf(" ret\n"); + } + printf(".endif\n\n"); +} +END{ + + printf("#endif /* __AS386_32__ */\n\n"); + printf("#endif /* __MSDOS__ */\n\n"); + printf("%s\n", obj) > "syscall.mak"; + printf "\n" > "syscall.mak"; + +}' > syscall.s + +cat >> syscall.mak <<\! + +CFLAGS=$(ARCH) $(CCFLAGS) $(DEFS) + +all: $(LIBC)($(OBJ)) + @$(RM) $(OBJ) + +$(LIBC)($(OBJ)): syscall.dat mksyscall + $(AS) --defsym L_$*=0 syscall.s -o $*.o + $(AR) $(ARFLAGS) $@ $*.o +! + +exit $? diff -Nurd linux-86.old/libc/gnu_i386/syscall.dat linux-86/libc/gnu_i386/syscall.dat --- linux-86.old/libc/gnu_i386/syscall.dat Thu Jan 1 01:00:00 1970 +++ linux-86/libc/gnu_i386/syscall.dat Sat Aug 9 09:29:28 1997 @@ -0,0 +1,155 @@ + +# +# Name No Args Flag, comment +# +# . = Ok, with comment +# * = Needs libc code (Prefix __) +# - = Obsolete/not required +# +# Name N C +setup 0 X +exit 1 1 * +fork 2 0 +vfork 2 0 . Fake alias of fork +read 3 3 +write 4 3 +open 5 3 +close 6 1 +waitpid 7 3 +creat 8 2 +link 9 2 +unlink 10 1 +execve 11 3 +chdir 12 1 +time 13 1 +dv32_mknod 14 3 * Has correct args for 32bit dev_t +chmod 15 2 +chown 16 3 +break 17 X - This is done in a special function +oldstat 18 X - +lseek 19 3 +getpid 20 0 +mount 21 5 +umount 22 1 +setuid 23 1 +getuid 24 0 +stime 25 1 +ptrace 26 4 +alarm 27 1 +oldfstat 28 X - +pause 29 0 +utime 30 2 +stty 31 X - +gtty 32 X - +access 33 2 +nice 34 1 +ftime 35 1 +sync 36 0 +kill 37 2 +rename 38 2 +mkdir 39 2 +rmdir 40 1 +dup 41 1 +pipe 42 1 +times 43 1 +prof 44 X - +brk 45 1 - need to save brk_addr & -ve is valid return. +setgid 46 1 +getgid 47 0 +signal 48 2 +geteuid 49 0 +getegid 50 0 +acct 51 1 +phys 52 X - +lock 53 X - +ioctl 54 3 +fcntl 55 3 +mpx 56 X - +setpgid 57 2 +ulimit 58 2 +oldolduname 59 X - +umask 60 1 +chroot 61 1 +dv32_ustat 62 2 * Has correct args for 32bit dev_t +dup2 63 2 +getppid 64 0 +getpgrp 65 0 +setsid 66 0 +sigaction 67 3 +siggetmask 68 0 +sigsetmask 69 1 +setreuid 70 2 +setregid 71 2 +sigsuspend 72 1 +sigpending 73 1 +sethostname 74 2 +setrlimit 75 2 +getrlimit 76 2 +getrusage 77 2 +gettimeofday 78 2 +settimeofday 79 2 +getgroups 80 2 +setgroups 81 2 +select 82 1 * select's arg is &arg1 +symlink 83 2 +oldlstat 84 X - +readlink 85 3 +uselib 86 1 +swapon 87 2 +reboot 88 3 +readdir 89 3 * Takes the fd not a ddptr +mmap 90 1 * Is a pointer to a buffer with the 6 args. +munmap 91 2 +truncate 92 2 +ftruncate 93 2 +fchmod 94 2 +fchown 95 2 +getpriority 96 2 +setpriority 97 3 +profil 98 X - glibc has userspace +statfs 99 2 +fstatfs 100 2 +ioperm 101 3 +socketcall 102 2 * This is a lib internal for socket stuff +klog 103 X +setitimer 104 3 +getitimer 105 2 +dv32_stat 106 2 * Has correct args for 32 bit dev_t +dv32_lstat 107 2 * Has correct args for 32 bit dev_t +dv32_fstat 108 2 * Has correct args for 32 bit dev_t +olduname 109 X - +iopl 110 1 +vhangup 111 0 +idle 112 0 - System internal +vm86 113 1 +wait4 114 4 +swapoff 115 1 +sysinfo 116 1 +ipc 117 5 * SYSV ipc entry point +fsync 118 1 +sigreturn 119 1 * Signal internal +clone 120 2 +setdomainname 121 2 +uname 122 1 +modify_ldt 123 X +adjtimex 124 1 +mprotect 125 3 +sigprocmask 126 3 +create_module 127 X - Module handling, NO WAY! +init_module 128 X +delete_module 129 X +get_kernel_syms 130 X +quotactl 131 X +getpgid 132 1 +fchdir 133 1 +bdflush 134 2 +sysfs 135 3 +personality 136 1 * Linux specific. +afs_syscall 137 X +setfsuid 138 1 +setfsgid 139 1 +_llseek 140 X +getdents 141 3 * New style readdir ? +_newselect 142 X +flock 143 2 +syscall_flock 143 X diff -Nurd linux-86.old/libc/gnu_i386/syscall.s linux-86/libc/gnu_i386/syscall.s --- linux-86.old/libc/gnu_i386/syscall.s Thu Jan 1 01:00:00 1970 +++ linux-86/libc/gnu_i386/syscall.s Tue Aug 12 21:26:10 1997 @@ -0,0 +1,2969 @@ +# Copyright (C) 1995-1997 Robert de Bath +# This file is part of the Linux-8086 C library and is distributed +# under the GNU Library General Public License. +# +# This file is automatically generated */ + +# Standard start + + +#ifndef __MSDOS__ +#ifdef __AS386_32__ + .text + .align 16 +# CALL exit 1 1 * + +.ifdef L___exit +.globl __exit +.type __exit,@function +__exit: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov $1,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL fork 2 0 + +.ifdef L_fork +.globl fork +.type fork,@function +fork: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov $2,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL vfork 2 0 . fake alias of fork + +.ifdef L_vfork +.globl vfork +.type vfork,@function +vfork: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov $2,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL read 3 3 + +.ifdef L_read +.globl read +.type read,@function +read: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov 16(%ebp),%edx + mov $3,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL write 4 3 + +.ifdef L_write +.globl write +.type write,@function +write: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov 16(%ebp),%edx + mov $4,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL open 5 3 + +.ifdef L_open +.globl open +.type open,@function +open: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov 16(%ebp),%edx + mov $5,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL close 6 1 + +.ifdef L_close +.globl close +.type close,@function +close: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov $6,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL waitpid 7 3 + +.ifdef L_waitpid +.globl waitpid +.type waitpid,@function +waitpid: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov 16(%ebp),%edx + mov $7,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL creat 8 2 + +.ifdef L_creat +.globl creat +.type creat,@function +creat: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $8,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL link 9 2 + +.ifdef L_link +.globl link +.type link,@function +link: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $9,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL unlink 10 1 + +.ifdef L_unlink +.globl unlink +.type unlink,@function +unlink: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov $10,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL execve 11 3 + +.ifdef L_execve +.globl execve +.type execve,@function +execve: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov 16(%ebp),%edx + mov $11,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL chdir 12 1 + +.ifdef L_chdir +.globl chdir +.type chdir,@function +chdir: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov $12,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL time 13 1 + +.ifdef L_time +.globl time +.type time,@function +time: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov $13,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL dv32_mknod 14 3 * has correct args for 32bit dev_t + +.ifdef L___dv32_mknod +.globl __dv32_mknod +.type __dv32_mknod,@function +__dv32_mknod: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov 16(%ebp),%edx + mov $14,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL chmod 15 2 + +.ifdef L_chmod +.globl chmod +.type chmod,@function +chmod: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $15,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL chown 16 3 + +.ifdef L_chown +.globl chown +.type chown,@function +chown: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov 16(%ebp),%edx + mov $16,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL lseek 19 3 + +.ifdef L_lseek +.globl lseek +.type lseek,@function +lseek: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov 16(%ebp),%edx + mov $19,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL getpid 20 0 + +.ifdef L_getpid +.globl getpid +.type getpid,@function +getpid: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov $20,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL mount 21 5 + +.ifdef L_mount +.globl mount +.type mount,@function +mount: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov 16(%ebp),%edx + push %esi + mov 20(%ebp),%esi + push %edi + mov 24(%ebp),%edi + mov $21,%eax + int $0x80 + pop %edi + pop %esi + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL umount 22 1 + +.ifdef L_umount +.globl umount +.type umount,@function +umount: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov $22,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL setuid 23 1 + +.ifdef L_setuid +.globl setuid +.type setuid,@function +setuid: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov $23,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL getuid 24 0 + +.ifdef L_getuid +.globl getuid +.type getuid,@function +getuid: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov $24,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL stime 25 1 + +.ifdef L_stime +.globl stime +.type stime,@function +stime: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov $25,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL ptrace 26 4 + +.ifdef L_ptrace +.globl ptrace +.type ptrace,@function +ptrace: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov 16(%ebp),%edx + push %esi + mov 20(%ebp),%esi + mov $26,%eax + int $0x80 + pop %esi + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL alarm 27 1 + +.ifdef L_alarm +.globl alarm +.type alarm,@function +alarm: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov $27,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL pause 29 0 + +.ifdef L_pause +.globl pause +.type pause,@function +pause: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov $29,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL utime 30 2 + +.ifdef L_utime +.globl utime +.type utime,@function +utime: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $30,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL access 33 2 + +.ifdef L_access +.globl access +.type access,@function +access: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $33,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL nice 34 1 + +.ifdef L_nice +.globl nice +.type nice,@function +nice: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov $34,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL ftime 35 1 + +.ifdef L_ftime +.globl ftime +.type ftime,@function +ftime: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov $35,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL sync 36 0 + +.ifdef L_sync +.globl sync +.type sync,@function +sync: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov $36,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL kill 37 2 + +.ifdef L_kill +.globl kill +.type kill,@function +kill: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $37,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL rename 38 2 + +.ifdef L_rename +.globl rename +.type rename,@function +rename: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $38,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL mkdir 39 2 + +.ifdef L_mkdir +.globl mkdir +.type mkdir,@function +mkdir: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $39,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL rmdir 40 1 + +.ifdef L_rmdir +.globl rmdir +.type rmdir,@function +rmdir: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov $40,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL dup 41 1 + +.ifdef L_dup +.globl dup +.type dup,@function +dup: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov $41,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL pipe 42 1 + +.ifdef L_pipe +.globl pipe +.type pipe,@function +pipe: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov $42,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL times 43 1 + +.ifdef L_times +.globl times +.type times,@function +times: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov $43,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL setgid 46 1 + +.ifdef L_setgid +.globl setgid +.type setgid,@function +setgid: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov $46,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL getgid 47 0 + +.ifdef L_getgid +.globl getgid +.type getgid,@function +getgid: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov $47,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL signal 48 2 + +.ifdef L_signal +.globl signal +.type signal,@function +signal: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $48,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL geteuid 49 0 + +.ifdef L_geteuid +.globl geteuid +.type geteuid,@function +geteuid: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov $49,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL getegid 50 0 + +.ifdef L_getegid +.globl getegid +.type getegid,@function +getegid: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov $50,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL acct 51 1 + +.ifdef L_acct +.globl acct +.type acct,@function +acct: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov $51,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL ioctl 54 3 + +.ifdef L_ioctl +.globl ioctl +.type ioctl,@function +ioctl: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov 16(%ebp),%edx + mov $54,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL fcntl 55 3 + +.ifdef L_fcntl +.globl fcntl +.type fcntl,@function +fcntl: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov 16(%ebp),%edx + mov $55,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL setpgid 57 2 + +.ifdef L_setpgid +.globl setpgid +.type setpgid,@function +setpgid: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $57,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL ulimit 58 2 + +.ifdef L_ulimit +.globl ulimit +.type ulimit,@function +ulimit: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $58,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL umask 60 1 + +.ifdef L_umask +.globl umask +.type umask,@function +umask: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov $60,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL chroot 61 1 + +.ifdef L_chroot +.globl chroot +.type chroot,@function +chroot: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov $61,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL dv32_ustat 62 2 * has correct args for 32bit dev_t + +.ifdef L___dv32_ustat +.globl __dv32_ustat +.type __dv32_ustat,@function +__dv32_ustat: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $62,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL dup2 63 2 + +.ifdef L_dup2 +.globl dup2 +.type dup2,@function +dup2: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $63,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL getppid 64 0 + +.ifdef L_getppid +.globl getppid +.type getppid,@function +getppid: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov $64,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL getpgrp 65 0 + +.ifdef L_getpgrp +.globl getpgrp +.type getpgrp,@function +getpgrp: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov $65,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL setsid 66 0 + +.ifdef L_setsid +.globl setsid +.type setsid,@function +setsid: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov $66,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL sigaction 67 3 + +.ifdef L_sigaction +.globl sigaction +.type sigaction,@function +sigaction: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov 16(%ebp),%edx + mov $67,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL siggetmask 68 0 + +.ifdef L_siggetmask +.globl siggetmask +.type siggetmask,@function +siggetmask: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov $68,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL sigsetmask 69 1 + +.ifdef L_sigsetmask +.globl sigsetmask +.type sigsetmask,@function +sigsetmask: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov $69,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL setreuid 70 2 + +.ifdef L_setreuid +.globl setreuid +.type setreuid,@function +setreuid: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $70,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL setregid 71 2 + +.ifdef L_setregid +.globl setregid +.type setregid,@function +setregid: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $71,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL sigsuspend 72 1 + +.ifdef L_sigsuspend +.globl sigsuspend +.type sigsuspend,@function +sigsuspend: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov $72,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL sigpending 73 1 + +.ifdef L_sigpending +.globl sigpending +.type sigpending,@function +sigpending: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov $73,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL sethostname 74 2 + +.ifdef L_sethostname +.globl sethostname +.type sethostname,@function +sethostname: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $74,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL setrlimit 75 2 + +.ifdef L_setrlimit +.globl setrlimit +.type setrlimit,@function +setrlimit: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $75,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL getrlimit 76 2 + +.ifdef L_getrlimit +.globl getrlimit +.type getrlimit,@function +getrlimit: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $76,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL getrusage 77 2 + +.ifdef L_getrusage +.globl getrusage +.type getrusage,@function +getrusage: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $77,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL gettimeofday 78 2 + +.ifdef L_gettimeofday +.globl gettimeofday +.type gettimeofday,@function +gettimeofday: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $78,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL settimeofday 79 2 + +.ifdef L_settimeofday +.globl settimeofday +.type settimeofday,@function +settimeofday: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $79,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL getgroups 80 2 + +.ifdef L_getgroups +.globl getgroups +.type getgroups,@function +getgroups: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $80,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL setgroups 81 2 + +.ifdef L_setgroups +.globl setgroups +.type setgroups,@function +setgroups: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $81,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL select 82 1 * select's arg is &arg1 + +.ifdef L___select +.globl __select +.type __select,@function +__select: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov $82,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL symlink 83 2 + +.ifdef L_symlink +.globl symlink +.type symlink,@function +symlink: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $83,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL readlink 85 3 + +.ifdef L_readlink +.globl readlink +.type readlink,@function +readlink: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov 16(%ebp),%edx + mov $85,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL uselib 86 1 + +.ifdef L_uselib +.globl uselib +.type uselib,@function +uselib: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov $86,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL swapon 87 2 + +.ifdef L_swapon +.globl swapon +.type swapon,@function +swapon: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $87,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL reboot 88 3 + +.ifdef L_reboot +.globl reboot +.type reboot,@function +reboot: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov 16(%ebp),%edx + mov $88,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL readdir 89 3 * takes the fd not a ddptr + +.ifdef L___readdir +.globl __readdir +.type __readdir,@function +__readdir: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov 16(%ebp),%edx + mov $89,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL mmap 90 1 * is a pointer to a buffer with the 6 args. + +.ifdef L___mmap +.globl __mmap +.type __mmap,@function +__mmap: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov $90,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL munmap 91 2 + +.ifdef L_munmap +.globl munmap +.type munmap,@function +munmap: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $91,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL truncate 92 2 + +.ifdef L_truncate +.globl truncate +.type truncate,@function +truncate: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $92,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL ftruncate 93 2 + +.ifdef L_ftruncate +.globl ftruncate +.type ftruncate,@function +ftruncate: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $93,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL fchmod 94 2 + +.ifdef L_fchmod +.globl fchmod +.type fchmod,@function +fchmod: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $94,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL fchown 95 2 + +.ifdef L_fchown +.globl fchown +.type fchown,@function +fchown: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $95,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL getpriority 96 2 + +.ifdef L_getpriority +.globl getpriority +.type getpriority,@function +getpriority: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $96,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL setpriority 97 3 + +.ifdef L_setpriority +.globl setpriority +.type setpriority,@function +setpriority: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov 16(%ebp),%edx + mov $97,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL statfs 99 2 + +.ifdef L_statfs +.globl statfs +.type statfs,@function +statfs: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $99,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL fstatfs 100 2 + +.ifdef L_fstatfs +.globl fstatfs +.type fstatfs,@function +fstatfs: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $100,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL ioperm 101 3 + +.ifdef L_ioperm +.globl ioperm +.type ioperm,@function +ioperm: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov 16(%ebp),%edx + mov $101,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL socketcall 102 2 * this is a lib internal for socket stuff + +.ifdef L___socketcall +.globl __socketcall +.type __socketcall,@function +__socketcall: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $102,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL setitimer 104 3 + +.ifdef L_setitimer +.globl setitimer +.type setitimer,@function +setitimer: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov 16(%ebp),%edx + mov $104,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL getitimer 105 2 + +.ifdef L_getitimer +.globl getitimer +.type getitimer,@function +getitimer: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $105,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL dv32_stat 106 2 * has correct args for 32 bit dev_t + +.ifdef L___dv32_stat +.globl __dv32_stat +.type __dv32_stat,@function +__dv32_stat: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $106,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL dv32_lstat 107 2 * has correct args for 32 bit dev_t + +.ifdef L___dv32_lstat +.globl __dv32_lstat +.type __dv32_lstat,@function +__dv32_lstat: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $107,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL dv32_fstat 108 2 * has correct args for 32 bit dev_t + +.ifdef L___dv32_fstat +.globl __dv32_fstat +.type __dv32_fstat,@function +__dv32_fstat: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $108,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL iopl 110 1 + +.ifdef L_iopl +.globl iopl +.type iopl,@function +iopl: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov $110,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL vhangup 111 0 + +.ifdef L_vhangup +.globl vhangup +.type vhangup,@function +vhangup: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov $111,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL vm86 113 1 + +.ifdef L_vm86 +.globl vm86 +.type vm86,@function +vm86: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov $113,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL wait4 114 4 + +.ifdef L_wait4 +.globl wait4 +.type wait4,@function +wait4: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov 16(%ebp),%edx + push %esi + mov 20(%ebp),%esi + mov $114,%eax + int $0x80 + pop %esi + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL swapoff 115 1 + +.ifdef L_swapoff +.globl swapoff +.type swapoff,@function +swapoff: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov $115,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL sysinfo 116 1 + +.ifdef L_sysinfo +.globl sysinfo +.type sysinfo,@function +sysinfo: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov $116,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL ipc 117 5 * sysv ipc entry point + +.ifdef L___ipc +.globl __ipc +.type __ipc,@function +__ipc: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov 16(%ebp),%edx + push %esi + mov 20(%ebp),%esi + push %edi + mov 24(%ebp),%edi + mov $117,%eax + int $0x80 + pop %edi + pop %esi + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL fsync 118 1 + +.ifdef L_fsync +.globl fsync +.type fsync,@function +fsync: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov $118,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL sigreturn 119 1 * signal internal + +.ifdef L___sigreturn +.globl __sigreturn +.type __sigreturn,@function +__sigreturn: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov $119,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL clone 120 2 + +.ifdef L_clone +.globl clone +.type clone,@function +clone: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $120,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL setdomainname 121 2 + +.ifdef L_setdomainname +.globl setdomainname +.type setdomainname,@function +setdomainname: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $121,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL uname 122 1 + +.ifdef L_uname +.globl uname +.type uname,@function +uname: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov $122,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL adjtimex 124 1 + +.ifdef L_adjtimex +.globl adjtimex +.type adjtimex,@function +adjtimex: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov $124,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL mprotect 125 3 + +.ifdef L_mprotect +.globl mprotect +.type mprotect,@function +mprotect: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov 16(%ebp),%edx + mov $125,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL sigprocmask 126 3 + +.ifdef L_sigprocmask +.globl sigprocmask +.type sigprocmask,@function +sigprocmask: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov 16(%ebp),%edx + mov $126,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL getpgid 132 1 + +.ifdef L_getpgid +.globl getpgid +.type getpgid,@function +getpgid: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov $132,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL fchdir 133 1 + +.ifdef L_fchdir +.globl fchdir +.type fchdir,@function +fchdir: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov $133,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL bdflush 134 2 + +.ifdef L_bdflush +.globl bdflush +.type bdflush,@function +bdflush: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $134,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL sysfs 135 3 + +.ifdef L_sysfs +.globl sysfs +.type sysfs,@function +sysfs: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov 16(%ebp),%edx + mov $135,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL personality 136 1 * linux specific. + +.ifdef L___personality +.globl __personality +.type __personality,@function +__personality: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov $136,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL setfsuid 138 1 + +.ifdef L_setfsuid +.globl setfsuid +.type setfsuid,@function +setfsuid: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov $138,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL setfsgid 139 1 + +.ifdef L_setfsgid +.globl setfsgid +.type setfsgid,@function +setfsgid: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov $139,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL getdents 141 3 * new style readdir ? + +.ifdef L___getdents +.globl __getdents +.type __getdents,@function +__getdents: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov 16(%ebp),%edx + mov $141,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +# CALL flock 143 2 + +.ifdef L_flock +.globl flock +.type flock,@function +flock: + pushl %ebp + movl %esp,%ebp + pushl %ebx + mov 8(%ebp),%ebx + mov 12(%ebp),%ecx + mov $143,%eax + int $0x80 + pop %ebx + test %eax,%eax + jge syscall_ok + neg %eax + mov %eax,errno + mov $-1,%eax +syscall_ok: + movl %ebp,%esp + popl %ebp + ret +.endif + +#endif /* __AS386_32__ */ + +#endif /* __MSDOS__ */ + diff -Nurd linux-86.old/libc/gtermcap/Config linux-86/libc/gtermcap/Config --- linux-86.old/libc/gtermcap/Config Thu Jan 1 01:00:00 1970 +++ linux-86/libc/gtermcap/Config Sun May 25 11:45:43 1997 @@ -0,0 +1 @@ +gtermcap:GNU termcap routines diff -Nurd linux-86.old/libc/i386fp/README linux-86/libc/i386fp/README --- linux-86.old/libc/i386fp/README Thu Jan 1 01:00:00 1970 +++ linux-86/libc/i386fp/README Thu Sep 4 19:53:50 1997 @@ -0,0 +1,5 @@ +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 -Nurd linux-86.old/libc/i386sys/Makefile linux-86/libc/i386sys/Makefile --- linux-86.old/libc/i386sys/Makefile Sat Mar 8 20:13:27 1997 +++ linux-86/libc/i386sys/Makefile Sun Aug 17 15:28:58 1997 @@ -2,9 +2,8 @@ # This file is part of the Linux-8086 C library and is distributed # under the GNU Library General Public License. -LSRC=syslibc.c -LOBJ=__cstart3.o time.o abort.o wait.o waitpid.o wait3.o killpg.o setpgrp.o \ - sleep.o usleep.o +LSRC=cstartup.c +LOBJ=__cstart3.o ESRC=exec.c EOBJ=execl.o execv.o execle.o execlp.o execvp.o diff -Nurd linux-86.old/libc/i386sys/cstartup.c linux-86/libc/i386sys/cstartup.c --- linux-86.old/libc/i386sys/cstartup.c Thu Jan 1 01:00:00 1970 +++ linux-86/libc/i386sys/cstartup.c Sun Aug 17 15:28:39 1997 @@ -0,0 +1,98 @@ +/* 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. + */ + +#include +#include +#include +#include + +#ifdef __unix__ +#ifdef __AS386_32__ + +/********************** Function __cstartup *******************************/ + +void (*__cleanup)() = 0; +char ** environ; + +#asm + loc 2 +call_main: + .long _main ! Segment 2 is the trailing pointers, main and the + .long call_exit ! routine to call exit. +#if __FIRST_ARG_IN_AX__ + .data +saved_arg1: + .long 0 +#endif + .data +loop_safe: + .long 0 + .text + +export ___mkargv +___mkargv: ! BCC Tells linker to init argv ... none needed. + +export ___cstartup +___cstartup: ! Crt0 startup (Linux style) + mov eax,[esp] + test eax,eax + jz call_exit ! If argc == 0 this is being called by ldd, exit. + mov eax,[esp+8] + mov [_environ],eax +#if __FIRST_ARG_IN_AX__ + pop [saved_arg1] ! Argc will go into eax +#endif + + mov ebx,#auto_start ! Pointer to first autostart function +auto_run: +#if __FIRST_ARG_IN_AX__ + mov eax,[saved_arg1] +#endif + mov [loop_safe],ebx + mov ebx,[ebx] + test ebx,ebx + jz no_func + call ebx ! Call the function +no_func: + mov ebx,[loop_safe] + add ebx,#4 ! next + jmp auto_run ! And round for the next. + +call_exit: ! Last item called by above. + pop ebx ! Be tidy. +#if !__FIRST_ARG_IN_AX__ + push eax ! At the end the last called was main() push it`s +#endif + call _exit ! return val and call exit(); +bad_exit: + jmp bad_exit ! Exit returned !! + +export _exit +export __exit +_exit: ! exit(rv) function +#if __FIRST_ARG_IN_AX__ + mov [saved_arg1],eax +#else + push [esp+4] ! Copy the `rv` for the exit fuctions. +#endif + mov ebx,[___cleanup] ! Call exit, normally this is `__do_exit` + test ebx,ebx + je no_clean ! But it`s default is null + call ebx +no_clean: +#if __FIRST_ARG_IN_AX__ + mov eax,[saved_arg1] +#else + add esp,#4 +#endif +__exit: ! _exit(rv) + br ___exit ! This is just an alias for __exit(); + +#endasm + +/********************** THE END ********************************************/ + +#endif /* __unix__ */ +#endif diff -Nurd linux-86.old/libc/i386sys/signal.c linux-86/libc/i386sys/signal.c --- linux-86.old/libc/i386sys/signal.c Thu Jan 30 19:15:39 1997 +++ linux-86/libc/i386sys/signal.c Thu Jan 1 01:00:00 1970 @@ -1,99 +0,0 @@ - -#ifndef __MSDOS__ -#ifdef __AS386_16__ - -#include -#include - -typedef __sighandler_t Sig; - -extern int __signal __P((int, __sighandler_t)); -static Sig system_signal(); - -Sig __sigtable[_NSIG-1]; - -/* - * Signal handler. - * - */ - -/* - * KERNEL INTERFACE: - * It is assumed the kernel will never give us a signal we haven't - * _explicitly_ asked for! - * - * The Kernel need only save space for _one_ function pointer - * (to system_signal) and must deal with SIG_DFL and SIG_IGN - * in kernel space. - * - * When a signal is required the kernel must set all the registers as if - * returning from a interrupt normally then push the number of the signal - * to be generated, push the current pc value, then set the pc to the - * address of the 'system_signal' function. - */ - -Sig -signal(number, pointer) -int number; -Sig pointer; -{ - Sig old_sig; - int rv; - if( number < 1 || number >= _NSIG ) { errno=EINVAL; return SIG_ERR; } - - if( pointer == SIG_DFL || pointer == SIG_IGN ) - rv = __signal(number, pointer); - else - rv = __signal(number, (__sighandler_t) system_signal); - - if( rv < 0 ) return SIG_ERR; - - old_sig = __sigtable[number-1]; - __sigtable[number-1] = pointer; - - switch(rv) - { - case 0: return SIG_DFL; - case 1: return SIG_IGN; - return old_sig; - } -} - -#asm - .text -_system_signal: ! When this is called by the kernel the stack contains - pushf ! in order: - push ax ! - push bx ! The signal number, (NOS) - push cx ! The program counter, (TOS) - push dx ! - push si ! It does NOT contain the CS register or the flags. - push di ! This means it cannot be unraveled by an iret. - push bp - push es ! Note also only ES segment register is saved. - mov bx,sp ! Unlike minix the rv from a system call is in AX. - mov bx,[bx+20] -#if __FIRST_ARG_IN_AX__ - mov ax,bx -#else - push bx ! NB this is _unchecked_, do we want to ? -#endif - add bx,bx - mov bx,[bx+___sigtable-2] ! Offset by 2 cause no entry for signal 0 - call bx ! Do we want to check BX for 0 or 1 ? - inc sp - inc sp - pop es - pop bp - pop di - pop si - pop dx - pop cx - pop bx - pop ax - popf - ret #2 ! Get rid of the signum too. -#endasm - -#endif /* __AS386_16__ */ -#endif /* __MSDOS__ */ diff -Nurd linux-86.old/libc/i386sys/syslibc.c linux-86/libc/i386sys/syslibc.c --- linux-86.old/libc/i386sys/syslibc.c Thu Jan 30 19:31:00 1997 +++ linux-86/libc/i386sys/syslibc.c Thu Jan 1 01:00:00 1970 @@ -1,255 +0,0 @@ -/* 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. - */ - -#include -#include -#include -#include - -/* MSDOS has it's own versions */ -#ifndef __MSDOS__ -#ifdef __AS386_32__ - -/********************** Function __cstartup *******************************/ - -#ifdef L___cstart3 - -void (*__cleanup)() = 0; -char ** environ; - -#asm - loc 2 -call_main: - .long _main ! Segment 2 is the trailing pointers, main and the - .long call_exit ! routine to call exit. -#if __FIRST_ARG_IN_AX__ - .data -saved_arg1: - .long 0 -#endif - .data -loop_safe: - .long 0 - .text - -export ___mkargv -___mkargv: ! BCC Tells linker to init argv ... none needed. - -export ___cstartup -___cstartup: ! Crt0 startup (Linux style) - mov eax,[esp] - test eax,eax - jz call_exit ! If argc == 0 this is being called by ldd, exit. - mov eax,[esp+8] - mov [_environ],eax -#if __FIRST_ARG_IN_AX__ - pop [saved_arg1] ! Argc will go into eax -#endif - - mov ebx,#auto_start ! Pointer to first autostart function -auto_run: -#if __FIRST_ARG_IN_AX__ - mov eax,[saved_arg1] -#endif - mov [loop_safe],ebx - mov ebx,[ebx] - test ebx,ebx - jz no_func - call ebx ! Call the function -no_func: - mov ebx,[loop_safe] - add ebx,#4 ! next - jmp auto_run ! And round for the next. - -call_exit: ! Last item called by above. - pop ebx ! Be tidy. -#if !__FIRST_ARG_IN_AX__ - push eax ! At the end the last called was main() push it`s -#endif - call _exit ! return val and call exit(); -bad_exit: - jmp bad_exit ! Exit returned !! - -export _exit -export __exit -_exit: ! exit(rv) function -#if __FIRST_ARG_IN_AX__ - mov [saved_arg1],eax -#else - push [esp+4] ! Copy the `rv` for the exit fuctions. -#endif - mov ebx,[___cleanup] ! Call exit, normally this is `__do_exit` - test ebx,ebx - je no_clean ! But it`s default is null - call ebx -no_clean: -#if __FIRST_ARG_IN_AX__ - mov eax,[saved_arg1] -#else - add esp,#4 -#endif -__exit: ! _exit(rv) - br ___exit ! This is just an alias for __exit(); - -#endasm -#endif - -/********************** Function time ************************************/ - -#ifdef L_time -time_t time(where) -time_t *where; -{ - struct timeval rv; - if( gettimeofday(&rv, (void*)0) < 0 ) return -1; - if(where) *where = rv.tv_sec; - return rv.tv_sec; -} -#endif - -/********************** Function abort ************************************/ - -#ifdef L_abort -#include - -int abort() -{ - signal(SIGABRT, SIG_DFL); - kill(SIGABRT, getpid()); /* Correct one */ - pause(); /* System may just schedule */ - signal(SIGKILL, SIG_DFL); - kill(SIGKILL, getpid()); /* Can't trap this! */ - __exit(255); /* WHAT!! */ -} -#endif - -/********************** Function wait ************************************/ - -#ifdef L_wait -int -wait(status) -int * status; -{ - return wait4(-1, status, 0, (void*)0); -} -#endif - -/********************** Function wait3 **************************************/ - -#ifdef L_wait3 -int -wait3(status, opts, usage) -int * status; -int opts; -struct rusage * usage; -{ - return wait4(-1, status, opts, usage); -} -#endif - -/********************** Function waitpid ************************************/ - -#ifdef L_waitpid -int -waitpid(pid, status, opts) -int pid; -int * status; -int opts; -{ - return wait4(pid, status, opts, (void*)0); -} -#endif - -/********************** Function killpg ************************************/ - -#ifdef L_killpg -int -killpg(pid, sig) -int pid; -int sig; -{ - if(pid == 0) - pid = getpgrp(); - if(pid > 1) - return kill(-pid, sig); - errno = EINVAL; - return -1; -} -#endif - -/********************** Function setpgrp ************************************/ - -#ifdef L_setpgrp -int -setpgrp() -{ - return setpgid(0,0); -} -#endif - -/********************** Function sleep ************************************/ - -#ifdef L_sleep -#include - -/* This uses SIGALRM, it does keep the previous alarm call but will lose - * any alarms that go off during the sleep - */ - -static void alrm() { } - -unsigned int sleep(seconds) -unsigned int seconds; -{ - void (*last_alarm)(); - unsigned int prev_sec; - - prev_sec = alarm(0); - if( prev_sec <= seconds ) prev_sec = 1; else prev_sec -= seconds; - - last_alarm = signal(SIGALRM, alrm); - alarm(seconds); - pause(); - seconds = alarm(prev_sec); - signal(SIGALRM, last_alarm); - return seconds; -} -#if 0 - /* Is this a better way ? If we have select of course :-) */ -#include -unsigned int -sleep(seconds) -unsigned int seconds; -{ - struct timeval timeout; - time_t start = time((void*)0); - timeout.tv_sec = seconds; - timeout.tv_usec = 0; - select(1, NULL, NULL, NULL, &timeout); - 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 ********************************************/ - -#endif /* __MSDOS__ */ -#endif diff -Nurd linux-86.old/libc/include/asm/limits.h linux-86/libc/include/asm/limits.h --- linux-86.old/libc/include/asm/limits.h Thu Jan 1 01:00:00 1970 +++ linux-86/libc/include/asm/limits.h Sun Aug 17 18:16:40 1997 @@ -0,0 +1,57 @@ +/* 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. + */ + +#ifndef __ASM_LIMITS_H +#define __ASM_LIMITS_H + +/* Common defines for current processors */ +#define MB_LEN_MAX 1 /* Longest multi-byte character */ +#define CHAR_BIT 8 /* number of bits in a char */ +#define SHRT_MAX 32767 /* maximum (signed) short value */ +#define SHRT_MIN (-32767) /* minimum (signed) short value */ +#define LONG_MAX 2147483647 /* maximum (signed) long value */ +#define LONG_MIN (-2147483647) /* minimum (signed) long value */ +#define UCHAR_MAX 255 /* maximum unsigned char value */ +#define USHRT_MAX 0xffff /* maximum unsigned short value */ +#define ULONG_MAX 0xffffffff /* maximum unsigned long value */ + +#ifdef __BCC__ +#define CHAR_MAX 255 /* maximum char value */ +#define CHAR_MIN (0) /* mimimum char value */ + +#ifdef __AS386_32__ +#define INT_MAX 2147483647 /* maximum (signed) int value */ +#define INT_MIN (-2147483647) /* minimum (signed) int value */ +#define UINT_MAX 0xffffffff /* maximum unsigned int value */ +#else +#define INT_MAX 32767 /* maximum (signed) int value */ +#define INT_MIN (-32767) /* minimum (signed) int value */ +#define UINT_MAX 0xffff /* maximum unsigned int value */ +#endif + +/* BCC doesn't have signed char */ +/* #define SCHAR_MAX 127 /* maximum signed char value */ +/* #define SCHAR_MIN (-127) /* minimum signed char value */ +#endif + +#if defined(__GNUC__) && defined(__i386__) +#define CHAR_MAX 127 /* maximum char value */ +#define CHAR_MIN (-127) /* mimimum char value */ +#define SCHAR_MAX 127 /* maximum signed char value */ +#define SCHAR_MIN (-127) /* minimum signed char value */ +#define INT_MAX 2147483647 /* maximum (signed) int value */ +#define INT_MIN (-2147483647) /* minimum (signed) int value */ +#define UINT_MAX 0xffffffff /* maximum unsigned int value */ +#endif + +#ifndef INT_MAX +#error "Limits.h not fully implemented" +#endif + +#ifndef RAND_MAX +#define RAND_MAX INT_MAX +#endif + +#endif diff -Nurd linux-86.old/libc/include/asm/types.h linux-86/libc/include/asm/types.h --- linux-86.old/libc/include/asm/types.h Thu Jan 1 01:00:00 1970 +++ linux-86/libc/include/asm/types.h Sat Aug 16 11:41:06 1997 @@ -0,0 +1,34 @@ + +/* asm/types.h - Basic sized C data types. */ + +#ifndef __ASM_8086_TYPES +#define __ASM_8086_TYPES + +/* First we define all of the __u and __s types...*/ + +typedef unsigned char __u8; +typedef unsigned char * __pu8; + +#ifndef __BCC__ /* NOTE! BCC does _not_ have a signed char type! */ +typedef char __s8; +typedef char * __ps8; +#endif + +typedef unsigned short __u16; +typedef unsigned short * __pu16; +typedef short __s16; +typedef short * __ps16; + +typedef unsigned long __u32; +typedef unsigned long * __pu32; +typedef long __s32; +typedef long * __ps32; + +/* __uint == 16bit on 8086 32bit on i386 */ + +typedef unsigned int __uint; +typedef int __sint; +typedef unsigned int * __puint; +typedef int * __psint; + +#endif diff -Nurd linux-86.old/libc/include/errno.h linux-86/libc/include/errno.h --- linux-86.old/libc/include/errno.h Sat Feb 24 16:15:40 1996 +++ linux-86/libc/include/errno.h Sun Aug 17 09:55:25 1997 @@ -1,25 +1 @@ -#ifndef __ERRNO_H -#define __ERRNO_H - -#include -#include - -#ifdef __USE_BSD -extern int sys_nerr; -extern char *sys_errlist[]; -#endif -#ifdef __USE_GNU -extern int _sys_nerr; -extern char *_sys_errlist[]; -#endif - -extern int errno; - -__BEGIN_DECLS - -extern void perror __P ((__const char* __s)); -extern char* strerror __P ((int __errno)); - -__END_DECLS - -#endif +#include diff -Nurd linux-86.old/libc/include/fcntl.h linux-86/libc/include/fcntl.h --- linux-86.old/libc/include/fcntl.h Sat Feb 24 16:14:50 1996 +++ linux-86/libc/include/fcntl.h Sun Aug 17 16:43:27 1997 @@ -1,9 +1,9 @@ -#ifndef __FCNTL_H -#define __FCNTL_H +#ifndef __FCNTL__H +#define __FCNTL__H #include #include -#include +#include __SYSINC__(fcntl.h) #ifndef FNDELAY #define FNDELAY O_NDELAY diff -Nurd linux-86.old/libc/include/features.h linux-86/libc/include/features.h --- linux-86.old/libc/include/features.h Sat Feb 24 15:22:14 1996 +++ linux-86/libc/include/features.h Sun Aug 17 09:53:44 1997 @@ -22,6 +22,26 @@ #endif +/* Pick an OS sysinclude directory */ +/* Use with #include __SYSINC__(errno.h) */ + +#ifdef __ELKS__ +#define __SYSINC__(_h_file_) +#endif + +#ifdef __linux__ +#undef linux /* Eyuk! */ +#define __SYSINC__(_h_file_) +#endif + +#ifdef __MSDOS__ +#define __SYSINC__(_h_file_) +#endif + +#ifndef __SYSINC__ +#define __SYSINC__(_h_file_) +#endif + /* No C++ */ #define __BEGIN_DECLS #define __END_DECLS @@ -33,4 +53,3 @@ #include #endif - diff -Nurd linux-86.old/libc/include/generic/errno.h linux-86/libc/include/generic/errno.h --- linux-86.old/libc/include/generic/errno.h Thu Jan 1 01:00:00 1970 +++ linux-86/libc/include/generic/errno.h Sat Aug 16 09:46:19 1997 @@ -0,0 +1,130 @@ +#ifndef _I86_ERRNO_H +#define _I86_ERRNO_H + +#define EPERM 1 /* Operation not permitted */ +#define ENOENT 2 /* No such file or directory */ +#define ESRCH 3 /* No such process */ +#define EINTR 4 /* Interrupted system call */ +#define EIO 5 /* I/O error */ +#define ENXIO 6 /* No such device or address */ +#define E2BIG 7 /* Arg list too long */ +#define ENOEXEC 8 /* Exec format error */ +#define EBADF 9 /* Bad file number */ +#define ECHILD 10 /* No child processes */ +#define EAGAIN 11 /* Try again */ +#define ENOMEM 12 /* Out of memory */ +#define EACCES 13 /* Permission denied */ +#define EFAULT 14 /* Bad address */ +#define ENOTBLK 15 /* Block device required */ +#define EBUSY 16 /* Device or resource busy */ +#define EEXIST 17 /* File exists */ +#define EXDEV 18 /* Cross-device link */ +#define ENODEV 19 /* No such device */ +#define ENOTDIR 20 /* Not a directory */ +#define EISDIR 21 /* Is a directory */ +#define EINVAL 22 /* Invalid argument */ +#define ENFILE 23 /* File table overflow */ +#define EMFILE 24 /* Too many open files */ +#define ENOTTY 25 /* Not a typewriter */ +#define ETXTBSY 26 /* Text file busy */ +#define EFBIG 27 /* File too large */ +#define ENOSPC 28 /* No space left on device */ +#define ESPIPE 29 /* Illegal seek */ +#define EROFS 30 /* Read-only file system */ +#define EMLINK 31 /* Too many links */ +#define EPIPE 32 /* Broken pipe */ +#define EDOM 33 /* Math argument out of domain of func */ +#define ERANGE 34 /* Math result not representable */ +#define EDEADLK 35 /* Resource deadlock would occur */ +#define ENAMETOOLONG 36 /* File name too long */ +#define ENOLCK 37 /* No record locks available */ +#define ENOSYS 38 /* Function not implemented */ +#define ENOTEMPTY 39 /* Directory not empty */ +#define ELOOP 40 /* Too many symbolic links encountered */ +#define EWOULDBLOCK EAGAIN /* Operation would block */ + +#if 0 +#define ENOMSG 42 /* No message of desired type */ +#define EIDRM 43 /* Identifier removed */ +#define ECHRNG 44 /* Channel number out of range */ +#define EL2NSYNC 45 /* Level 2 not synchronized */ +#define EL3HLT 46 /* Level 3 halted */ +#define EL3RST 47 /* Level 3 reset */ +#define ELNRNG 48 /* Link number out of range */ +#define EUNATCH 49 /* Protocol driver not attached */ +#define ENOCSI 50 /* No CSI structure available */ +#define EL2HLT 51 /* Level 2 halted */ +#define EBADE 52 /* Invalid exchange */ +#define EBADR 53 /* Invalid request descriptor */ +#define EXFULL 54 /* Exchange full */ +#define ENOANO 55 /* No anode */ +#define EBADRQC 56 /* Invalid request code */ +#define EBADSLT 57 /* Invalid slot */ +#define EDEADLOCK 58 /* File locking deadlock error */ +#define EBFONT 59 /* Bad font file format */ +#define ENOSTR 60 /* Device not a stream */ +#define ENODATA 61 /* No data available */ +#define ETIME 62 /* Timer expired */ +#define ENOSR 63 /* Out of streams resources */ +#define ENONET 64 /* Machine is not on the network */ +#define ENOPKG 65 /* Package not installed */ +#define EREMOTE 66 /* Object is remote */ +#define ENOLINK 67 /* Link has been severed */ +#define EADV 68 /* Advertise error */ +#define ESRMNT 69 /* Srmount error */ +#define ECOMM 70 /* Communication error on send */ +#define EPROTO 71 /* Protocol error */ +#define EMULTIHOP 72 /* Multihop attempted */ +#define EDOTDOT 73 /* RFS specific error */ +#define EBADMSG 74 /* Not a data message */ +#define EOVERFLOW 75 /* Value too large for defined data type */ +#define ENOTUNIQ 76 /* Name not unique on network */ +#define EBADFD 77 /* File descriptor in bad state */ +#define EREMCHG 78 /* Remote address changed */ +#define ELIBACC 79 /* Can not access a needed shared library */ +#define ELIBBAD 80 /* Accessing a corrupted shared library */ +#define ELIBSCN 81 /* .lib section in a.out corrupted */ +#define ELIBMAX 82 /* Attempting to link in too many shared libraries */ +#define ELIBEXEC 83 /* Cannot exec a shared library directly */ +#define EILSEQ 84 /* Illegal byte sequence */ +#define ERESTART 85 /* Interrupted system call should be restarted */ +#define ESTRPIPE 86 /* Streams pipe error */ +#define EUSERS 87 /* Too many users */ +#define ENOTSOCK 88 /* Socket operation on non-socket */ +#define EDESTADDRREQ 89 /* Destination address required */ +#define EMSGSIZE 90 /* Message too long */ +#define EPROTOTYPE 91 /* Protocol wrong type for socket */ +#define ENOPROTOOPT 92 /* Protocol not available */ +#define EPROTONOSUPPORT 93 /* Protocol not supported */ +#define ESOCKTNOSUPPORT 94 /* Socket type not supported */ +#define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */ +#define EPFNOSUPPORT 96 /* Protocol family not supported */ +#define EAFNOSUPPORT 97 /* Address family not supported by protocol */ +#define EADDRINUSE 98 /* Address already in use */ +#define EADDRNOTAVAIL 99 /* Cannot assign requested address */ +#define ENETDOWN 100 /* Network is down */ +#define ENETUNREACH 101 /* Network is unreachable */ +#define ENETRESET 102 /* Network dropped connection because of reset */ +#define ECONNABORTED 103 /* Software caused connection abort */ +#define ECONNRESET 104 /* Connection reset by peer */ +#define ENOBUFS 105 /* No buffer space available */ +#define EISCONN 106 /* Transport endpoint is already connected */ +#define ENOTCONN 107 /* Transport endpoint is not connected */ +#define ESHUTDOWN 108 /* Cannot send after transport endpoint shutdown */ +#define ETOOMANYREFS 109 /* Too many references: cannot splice */ +#define ETIMEDOUT 110 /* Connection timed out */ +#define ECONNREFUSED 111 /* Connection refused */ +#define EHOSTDOWN 112 /* Host is down */ +#define EHOSTUNREACH 113 /* No route to host */ +#define EALREADY 114 /* Operation already in progress */ +#define EINPROGRESS 115 /* Operation now in progress */ +#define ESTALE 116 /* Stale NFS file handle */ +#define EUCLEAN 117 /* Structure needs cleaning */ +#define ENOTNAM 118 /* Not a XENIX named type file */ +#define ENAVAIL 119 /* No XENIX semaphores available */ +#define EISNAM 120 /* Is a named type file */ +#define EREMOTEIO 121 /* Remote I/O error */ +#define EDQUOT 122 /* Quota exceeded */ +#endif + +#endif diff -Nurd linux-86.old/libc/include/generic/fcntl.h linux-86/libc/include/generic/fcntl.h --- linux-86.old/libc/include/generic/fcntl.h Thu Jan 1 01:00:00 1970 +++ linux-86/libc/include/generic/fcntl.h Sat Aug 16 11:49:40 1997 @@ -0,0 +1,73 @@ +#ifndef __UNK_FCNTL_H +#define __UNK_FCNTL_H + +/* + * Definitions taken from the i386 Linux kernel. + */ + +/* open/fcntl */ + +#define O_ACCMODE 0003 +#define O_RDONLY 00 +#define O_WRONLY 01 +#define O_RDWR 02 +#define O_CREAT 0100 /* not fcntl */ +#define O_EXCL 0200 /* not fcntl */ +#define O_TRUNC 01000 /* not fcntl */ +#define O_APPEND 02000 + +#if 0 +#define O_NOCTTY 0400 /* not fcntl */ +#define O_NONBLOCK 04000 +#define O_NDELAY O_NONBLOCK +#define O_SYNC 010000 /* Not supported */ +#define FASYNC 020000 /* Not supported */ +#endif + +#define F_DUPFD 0 /* dup */ +#define F_GETFD 1 /* get f_flags */ +#define F_SETFD 2 /* set f_flags */ +#define F_GETFL 3 /* more flags (cloexec) */ +#define F_SETFL 4 +#define F_GETLK 5 +#define F_SETLK 6 +#define F_SETLKW 7 + +#if 0 +#define F_SETOWN 8 /* for sockets. */ +#define F_GETOWN 9 /* for sockets. */ + +/* for F_[GET|SET]FL */ +#define FD_CLOEXEC 1 /* actually anything with low bit set goes */ + +/* for posix fcntl() and lockf() */ +#define F_RDLCK 0 +#define F_WRLCK 1 +#define F_UNLCK 2 + +/* for old implementation of bsd flock () */ +#define F_EXLCK 4 /* or 3 */ +#define F_SHLCK 8 /* or 4 */ + +/* operations for bsd flock(), also used by the kernel implementation */ +#define LOCK_SH 1 /* shared lock */ +#define LOCK_EX 2 /* exclusive lock */ +#define LOCK_NB 4 /* or'd with one of the above to prevent + blocking */ +#define LOCK_UN 8 /* remove lock */ + +#ifdef __KERNEL__ +#define F_POSIX 1 +#define F_FLOCK 2 +#endif /* __KERNEL__ */ + +struct flock { + short l_type; + short l_whence; + off_t l_start; + off_t l_len; + pid_t l_pid; +}; +#endif + +#endif diff -Nurd linux-86.old/libc/include/generic/types.h linux-86/libc/include/generic/types.h --- linux-86.old/libc/include/generic/types.h Thu Jan 1 01:00:00 1970 +++ linux-86/libc/include/generic/types.h Sun Aug 17 17:53:29 1997 @@ -0,0 +1,22 @@ + +/* arch/i86/include/asm/types.h - Basic Linux/MT data types. */ + +#ifndef __GENERIC_TYPES_H +#define __GENERIC_TYPES_H + +#include + +typedef __u32 off_t; +typedef __u32 time_t; +typedef __u16 mode_t; +typedef __u32 loff_t; +typedef __u32 speed_t; + +typedef __u32 tcflag_t; +typedef __u8 cc_t; + +typedef int ptrdiff_t; +typedef int size_t; + +#endif + diff -Nurd linux-86.old/libc/include/limits.h linux-86/libc/include/limits.h --- linux-86.old/libc/include/limits.h Sun Oct 13 20:57:38 1996 +++ linux-86/libc/include/limits.h Sun Aug 17 18:15:55 1997 @@ -5,53 +5,5 @@ #ifndef __LIMITS_H #define __LIMITS_H - -#if __AS386_16__ -#define MB_LEN_MAX 1 /* Longest multi-byte character */ -#define CHAR_MAX 127 /* maximum char value */ -#define CHAR_MIN (-127) /* mimimum char value */ -#define SCHAR_MAX 127 /* maximum signed char value */ -#define SCHAR_MIN (-127) /* minimum signed char value */ -#define CHAR_BIT 8 /* number of bits in a char */ -#define SHRT_MAX 32767 /* maximum (signed) short value */ -#define SHRT_MIN (-32767) /* minimum (signed) short value */ -#define INT_MAX 32767 /* maximum (signed) int value */ -#define INT_MIN (-32767) /* minimum (signed) int value */ -#define LONG_MAX 2147483647 /* maximum (signed) long value */ -#define LONG_MIN (-2147483647) /* minimum (signed) long value */ -#define UCHAR_MAX 255 /* maximum unsigned char value */ -#define USHRT_MAX 0xffff /* maximum unsigned short value */ -#define UINT_MAX 0xffff /* maximum unsigned int value */ -#define ULONG_MAX 0xffffffff /* maximum unsigned long value */ -#ifndef RAND_MAX -#define RAND_MAX INT_MAX -#endif -#endif - -#if __AS386_32__ -#define MB_LEN_MAX 1 /* Longest multi-byte character */ -#define CHAR_MAX 127 /* maximum char value */ -#define CHAR_MIN (-127) /* mimimum char value */ -#define SCHAR_MAX 127 /* maximum signed char value */ -#define SCHAR_MIN (-127) /* minimum signed char value */ -#define CHAR_BIT 8 /* number of bits in a char */ -#define SHRT_MAX 32767 /* maximum (signed) short value */ -#define SHRT_MIN (-32767) /* minimum (signed) short value */ -#define INT_MAX 2147483647 /* maximum (signed) int value */ -#define INT_MIN (-2147483647) /* minimum (signed) int value */ -#define LONG_MAX 2147483647 /* maximum (signed) long value */ -#define LONG_MIN (-2147483647) /* minimum (signed) long value */ -#define UCHAR_MAX 255 /* maximum unsigned char value */ -#define USHRT_MAX 0xffff /* maximum unsigned short value */ -#define UINT_MAX 0xffffffff /* maximum unsigned int value */ -#define ULONG_MAX 0xffffffff /* maximum unsigned long value */ -#ifndef RAND_MAX -#define RAND_MAX INT_MAX -#endif -#endif - -#ifndef CHAR_MAX -#error "Limits.h not implemented" -#endif - +#include #endif diff -Nurd linux-86.old/libc/include/linux/errno.h linux-86/libc/include/linux/errno.h --- linux-86.old/libc/include/linux/errno.h Thu Jan 1 01:00:00 1970 +++ linux-86/libc/include/linux/errno.h Sat Nov 4 16:43:30 1995 @@ -0,0 +1,127 @@ +#ifndef _I86_ERRNO_H +#define _I86_ERRNO_H + +#define EPERM 1 /* Operation not permitted */ +#define ENOENT 2 /* No such file or directory */ +#define ESRCH 3 /* No such process */ +#define EINTR 4 /* Interrupted system call */ +#define EIO 5 /* I/O error */ +#define ENXIO 6 /* No such device or address */ +#define E2BIG 7 /* Arg list too long */ +#define ENOEXEC 8 /* Exec format error */ +#define EBADF 9 /* Bad file number */ +#define ECHILD 10 /* No child processes */ +#define EAGAIN 11 /* Try again */ +#define ENOMEM 12 /* Out of memory */ +#define EACCES 13 /* Permission denied */ +#define EFAULT 14 /* Bad address */ +#define ENOTBLK 15 /* Block device required */ +#define EBUSY 16 /* Device or resource busy */ +#define EEXIST 17 /* File exists */ +#define EXDEV 18 /* Cross-device link */ +#define ENODEV 19 /* No such device */ +#define ENOTDIR 20 /* Not a directory */ +#define EISDIR 21 /* Is a directory */ +#define EINVAL 22 /* Invalid argument */ +#define ENFILE 23 /* File table overflow */ +#define EMFILE 24 /* Too many open files */ +#define ENOTTY 25 /* Not a typewriter */ +#define ETXTBSY 26 /* Text file busy */ +#define EFBIG 27 /* File too large */ +#define ENOSPC 28 /* No space left on device */ +#define ESPIPE 29 /* Illegal seek */ +#define EROFS 30 /* Read-only file system */ +#define EMLINK 31 /* Too many links */ +#define EPIPE 32 /* Broken pipe */ +#define EDOM 33 /* Math argument out of domain of func */ +#define ERANGE 34 /* Math result not representable */ +#define EDEADLK 35 /* Resource deadlock would occur */ +#define ENAMETOOLONG 36 /* File name too long */ +#define ENOLCK 37 /* No record locks available */ +#define ENOSYS 38 /* Function not implemented */ +#define ENOTEMPTY 39 /* Directory not empty */ +#define ELOOP 40 /* Too many symbolic links encountered */ +#define EWOULDBLOCK EAGAIN /* Operation would block */ +#define ENOMSG 42 /* No message of desired type */ +#define EIDRM 43 /* Identifier removed */ +#define ECHRNG 44 /* Channel number out of range */ +#define EL2NSYNC 45 /* Level 2 not synchronized */ +#define EL3HLT 46 /* Level 3 halted */ +#define EL3RST 47 /* Level 3 reset */ +#define ELNRNG 48 /* Link number out of range */ +#define EUNATCH 49 /* Protocol driver not attached */ +#define ENOCSI 50 /* No CSI structure available */ +#define EL2HLT 51 /* Level 2 halted */ +#define EBADE 52 /* Invalid exchange */ +#define EBADR 53 /* Invalid request descriptor */ +#define EXFULL 54 /* Exchange full */ +#define ENOANO 55 /* No anode */ +#define EBADRQC 56 /* Invalid request code */ +#define EBADSLT 57 /* Invalid slot */ +#define EDEADLOCK 58 /* File locking deadlock error */ +#define EBFONT 59 /* Bad font file format */ +#define ENOSTR 60 /* Device not a stream */ +#define ENODATA 61 /* No data available */ +#define ETIME 62 /* Timer expired */ +#define ENOSR 63 /* Out of streams resources */ +#define ENONET 64 /* Machine is not on the network */ +#define ENOPKG 65 /* Package not installed */ +#define EREMOTE 66 /* Object is remote */ +#define ENOLINK 67 /* Link has been severed */ +#define EADV 68 /* Advertise error */ +#define ESRMNT 69 /* Srmount error */ +#define ECOMM 70 /* Communication error on send */ +#define EPROTO 71 /* Protocol error */ +#define EMULTIHOP 72 /* Multihop attempted */ +#define EDOTDOT 73 /* RFS specific error */ +#define EBADMSG 74 /* Not a data message */ +#define EOVERFLOW 75 /* Value too large for defined data type */ +#define ENOTUNIQ 76 /* Name not unique on network */ +#define EBADFD 77 /* File descriptor in bad state */ +#define EREMCHG 78 /* Remote address changed */ +#define ELIBACC 79 /* Can not access a needed shared library */ +#define ELIBBAD 80 /* Accessing a corrupted shared library */ +#define ELIBSCN 81 /* .lib section in a.out corrupted */ +#define ELIBMAX 82 /* Attempting to link in too many shared libraries */ +#define ELIBEXEC 83 /* Cannot exec a shared library directly */ +#define EILSEQ 84 /* Illegal byte sequence */ +#define ERESTART 85 /* Interrupted system call should be restarted */ +#define ESTRPIPE 86 /* Streams pipe error */ +#define EUSERS 87 /* Too many users */ +#define ENOTSOCK 88 /* Socket operation on non-socket */ +#define EDESTADDRREQ 89 /* Destination address required */ +#define EMSGSIZE 90 /* Message too long */ +#define EPROTOTYPE 91 /* Protocol wrong type for socket */ +#define ENOPROTOOPT 92 /* Protocol not available */ +#define EPROTONOSUPPORT 93 /* Protocol not supported */ +#define ESOCKTNOSUPPORT 94 /* Socket type not supported */ +#define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */ +#define EPFNOSUPPORT 96 /* Protocol family not supported */ +#define EAFNOSUPPORT 97 /* Address family not supported by protocol */ +#define EADDRINUSE 98 /* Address already in use */ +#define EADDRNOTAVAIL 99 /* Cannot assign requested address */ +#define ENETDOWN 100 /* Network is down */ +#define ENETUNREACH 101 /* Network is unreachable */ +#define ENETRESET 102 /* Network dropped connection because of reset */ +#define ECONNABORTED 103 /* Software caused connection abort */ +#define ECONNRESET 104 /* Connection reset by peer */ +#define ENOBUFS 105 /* No buffer space available */ +#define EISCONN 106 /* Transport endpoint is already connected */ +#define ENOTCONN 107 /* Transport endpoint is not connected */ +#define ESHUTDOWN 108 /* Cannot send after transport endpoint shutdown */ +#define ETOOMANYREFS 109 /* Too many references: cannot splice */ +#define ETIMEDOUT 110 /* Connection timed out */ +#define ECONNREFUSED 111 /* Connection refused */ +#define EHOSTDOWN 112 /* Host is down */ +#define EHOSTUNREACH 113 /* No route to host */ +#define EALREADY 114 /* Operation already in progress */ +#define EINPROGRESS 115 /* Operation now in progress */ +#define ESTALE 116 /* Stale NFS file handle */ +#define EUCLEAN 117 /* Structure needs cleaning */ +#define ENOTNAM 118 /* Not a XENIX named type file */ +#define ENAVAIL 119 /* No XENIX semaphores available */ +#define EISNAM 120 /* Is a named type file */ +#define EREMOTEIO 121 /* Remote I/O error */ +#define EDQUOT 122 /* Quota exceeded */ + +#endif diff -Nurd linux-86.old/libc/include/linux/fcntl.h linux-86/libc/include/linux/fcntl.h --- linux-86.old/libc/include/linux/fcntl.h Thu Jan 1 01:00:00 1970 +++ linux-86/libc/include/linux/fcntl.h Sat Aug 16 11:47:15 1997 @@ -0,0 +1,70 @@ +#ifndef __LINUX_FCNTL_H +#define __LINUX_FCNTL_H + +/* + * Definitions taken from the i386 Linux kernel. + */ + +/* open/fcntl */ + +#define O_ACCMODE 0003 +#define O_RDONLY 00 +#define O_WRONLY 01 +#define O_RDWR 02 +#define O_CREAT 0100 /* not fcntl */ +#define O_EXCL 0200 /* not fcntl */ +#define O_NOCTTY 0400 /* not fcntl */ +#define O_TRUNC 01000 /* not fcntl */ +#define O_APPEND 02000 +#define O_NONBLOCK 04000 +#define O_NDELAY O_NONBLOCK +#if 0 +#define O_SYNC 010000 /* Not supported */ +#define FASYNC 020000 /* Not supported */ +#endif + +#define F_DUPFD 0 /* dup */ +#define F_GETFD 1 /* get f_flags */ +#define F_SETFD 2 /* set f_flags */ +#define F_GETFL 3 /* more flags (cloexec) */ +#define F_SETFL 4 +#define F_GETLK 5 +#define F_SETLK 6 +#define F_SETLKW 7 + +#define F_SETOWN 8 /* for sockets. */ +#define F_GETOWN 9 /* for sockets. */ + +/* for F_[GET|SET]FL */ +#define FD_CLOEXEC 1 /* actually anything with low bit set goes */ + +/* for posix fcntl() and lockf() */ +#define F_RDLCK 0 +#define F_WRLCK 1 +#define F_UNLCK 2 + +/* for old implementation of bsd flock () */ +#define F_EXLCK 4 /* or 3 */ +#define F_SHLCK 8 /* or 4 */ + +/* operations for bsd flock(), also used by the kernel implementation */ +#define LOCK_SH 1 /* shared lock */ +#define LOCK_EX 2 /* exclusive lock */ +#define LOCK_NB 4 /* or'd with one of the above to prevent + blocking */ +#define LOCK_UN 8 /* remove lock */ + +#ifdef __KERNEL__ +#define F_POSIX 1 +#define F_FLOCK 2 +#endif /* __KERNEL__ */ + +struct flock { + short l_type; + short l_whence; + off_t l_start; + off_t l_len; + pid_t l_pid; +}; + +#endif diff -Nurd linux-86.old/libc/include/linux/mman.h linux-86/libc/include/linux/mman.h --- linux-86.old/libc/include/linux/mman.h Thu Jan 1 01:00:00 1970 +++ linux-86/libc/include/linux/mman.h Sun Sep 28 11:59:30 1997 @@ -0,0 +1,52 @@ +#ifndef _SYS_MMAN_H +#define _SYS_MMAN_H + +#include +#include + +#define PROT_READ 0x1 /* page can be read */ +#define PROT_WRITE 0x2 /* page can be written */ +#define PROT_EXEC 0x4 /* page can be executed */ +#define PROT_NONE 0x0 /* page can not be accessed */ + +#define MAP_SHARED 0x01 /* Share changes */ +#define MAP_PRIVATE 0x02 /* Changes are private */ +#define MAP_TYPE 0x0f /* Mask for type of mapping */ +#define MAP_FIXED 0x10 /* Interpret addr exactly */ +#define MAP_ANONYMOUS 0x20 /* don't use a file */ + +#define MAP_GROWSDOWN 0x0100 /* stack-like segment */ +#define MAP_DENYWRITE 0x0800 /* ETXTBSY */ +#define MAP_EXECUTABLE 0x1000 /* mark it as a executable */ +#define MAP_LOCKED 0x2000 /* pages are locked */ + +#define MS_ASYNC 1 /* sync memory asynchronously */ +#define MS_INVALIDATE 2 /* invalidate the caches */ +#define MS_SYNC 4 /* synchronous memory sync */ + +#define MCL_CURRENT 1 /* lock all current mappings */ +#define MCL_FUTURE 2 /* lock all future mappings */ + +/* compatibility flags */ +#define MAP_ANON MAP_ANONYMOUS +#define MAP_FILE 0 + +#define MREMAP_MAYMOVE 1 + +extern __ptr_t mmap __P((__ptr_t __addr, size_t __len, + int __prot, int __flags, int __fd, off_t __off)); +extern int munmap __P((__ptr_t __addr, size_t __len)); +extern int mprotect __P ((__const __ptr_t __addr, size_t __len, int __prot)); + +extern int msync __P((__ptr_t __addr, size_t __len, int __flags)); + +extern int mlock __P((__const __ptr_t __addr, size_t __len)); +extern int munlock __P((__const __ptr_t __addr, size_t __len)); + +extern int mlockall __P((int __flags)); +extern int munlockall __P((void)); + +extern __ptr_t mremap __P((__ptr_t __addr, size_t __old_len, + size_t __new_len, int __may_move)); + +#endif /* _SYS_MMAN_H */ diff -Nurd linux-86.old/libc/include/linux/resource.h linux-86/libc/include/linux/resource.h --- linux-86.old/libc/include/linux/resource.h Thu Jan 1 01:00:00 1970 +++ linux-86/libc/include/linux/resource.h Sun Aug 17 09:48:04 1997 @@ -0,0 +1,73 @@ +/* + * Resource control/accounting header file for linux-86 + */ + +#ifndef __LINUX_RESOURCE_H +#define __LINUX_RESOURCE_H + +#include +#include +#include + +#define RUSAGE_SELF 0 +#define RUSAGE_CHILDREN (-1) +#define RUSAGE_BOTH (-2) /* sys_wait4() uses this */ + +struct rusage { + struct timeval ru_utime; /* user time used */ + struct timeval ru_stime; /* system time used */ + long ru_maxrss; /* maximum resident set size */ + long ru_ixrss; /* integral shared memory size */ + long ru_idrss; /* integral unshared data size */ + long ru_isrss; /* integral unshared stack size */ + long ru_minflt; /* page reclaims */ + long ru_majflt; /* page faults */ + long ru_nswap; /* swaps */ + long ru_inblock; /* block input operations */ + long ru_oublock; /* block output operations */ + long ru_msgsnd; /* messages sent */ + long ru_msgrcv; /* messages received */ + long ru_nsignals; /* signals received */ + long ru_nvcsw; /* voluntary context switches */ + long ru_nivcsw; /* involuntary " */ +}; + +#define RLIM_INFINITY ((long)(~0UL>>1)) + +struct rlimit { + long rlim_cur; + long rlim_max; +}; + +#define PRIO_MIN (-20) +#define PRIO_MAX 20 + +#define PRIO_PROCESS 0 +#define PRIO_PGRP 1 +#define PRIO_USER 2 + +#define RLIMIT_CPU 0 /* CPU time in ms */ +#define RLIMIT_FSIZE 1 /* Maximum filesize */ +#define RLIMIT_DATA 2 /* max data size */ +#define RLIMIT_STACK 3 /* max stack size */ +#define RLIMIT_CORE 4 /* max core file size */ +#define RLIMIT_RSS 5 /* max resident set size */ +#define RLIMIT_NPROC 6 /* max number of processes */ +#define RLIMIT_NOFILE 7 /* max number of open files */ +#define RLIMIT_MEMLOCK 8 /* max locked-in-memory address space */ + +#define RLIM_NLIMITS 9 + +extern int getrlimit __P ((int __resource, + struct rlimit *__rlp)); +extern int setrlimit __P ((int __resource, + __const struct rlimit *__rlp)); + +extern int getpriority __P((int __which, int __who)); +extern int setpriority __P((int __which, int __who, + int __prio)); + +extern int __getrusage __P ((int __who, struct rusage *__rusage)); +extern int getrusage __P ((int __who, struct rusage *__rusage)); + +#endif /* __LINUX_RESOURCE_H */ diff -Nurd linux-86.old/libc/include/linux/stat.h linux-86/libc/include/linux/stat.h --- linux-86.old/libc/include/linux/stat.h Thu Jan 1 01:00:00 1970 +++ linux-86/libc/include/linux/stat.h Sat Aug 16 12:19:41 1997 @@ -0,0 +1,76 @@ +#ifndef _LINUX_STAT_H +#define _LINUX_STAT_H + +/* This is for Linux-386, ho hum, I wish BCC could compile the proper one */ +#define mknod __dv32_mknod +#define stat __dv32_stat +#define lstat __dv32_lstat +#define fstat __dv32_fstat + +struct stat { + dev_t st_dev; + unsigned short __pad1; + ino_t st_ino; + umode_t st_mode; + nlink_t st_nlink; + uid_t st_uid; + gid_t st_gid; + dev_t st_rdev; + unsigned short __pad2; + off_t st_size; + unsigned long st_blksize; + unsigned long st_blocks; + time_t st_atime; + unsigned long __unused1; + time_t st_mtime; + unsigned long __unused2; + time_t st_ctime; + unsigned long __unused3; + unsigned long __unused4; + unsigned long __unused5; +}; + +#define S_IFMT 00170000 +#define S_IFSOCK 0140000 +#define S_IFLNK 0120000 +#define S_IFREG 0100000 +#define S_IFBLK 0060000 +#define S_IFDIR 0040000 +#define S_IFCHR 0020000 +#define S_IFIFO 0010000 +#define S_ISUID 0004000 +#define S_ISGID 0002000 +#define S_ISVTX 0001000 + +#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) +#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) +#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) +#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR) +#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK) +#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO) +#define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK) + +#define S_IRWXU 00700 +#define S_IRUSR 00400 +#define S_IWUSR 00200 +#define S_IXUSR 00100 + +#define S_IRWXG 00070 +#define S_IRGRP 00040 +#define S_IWGRP 00020 +#define S_IXGRP 00010 + +#define S_IRWXO 00007 +#define S_IROTH 00004 +#define S_IWOTH 00002 +#define S_IXOTH 00001 + +#ifdef __KERNEL__ +#define S_IRWXUGO (S_IRWXU|S_IRWXG|S_IRWXO) +#define S_IALLUGO (S_ISUID|S_ISGID|S_ISVTX|S_IRWXUGO) +#define S_IRUGO (S_IRUSR|S_IRGRP|S_IROTH) +#define S_IWUGO (S_IWUSR|S_IWGRP|S_IWOTH) +#define S_IXUGO (S_IXUSR|S_IXGRP|S_IXOTH) +#endif + +#endif diff -Nurd linux-86.old/libc/include/linux/termios.h linux-86/libc/include/linux/termios.h --- linux-86.old/libc/include/linux/termios.h Thu Jan 1 01:00:00 1970 +++ linux-86/libc/include/linux/termios.h Sun Aug 17 17:22:54 1997 @@ -0,0 +1,257 @@ +#ifndef __LINUX_TERMIOS_H +#define __LINUX_TERMIOS_H + +/* This is just a magic number to make these relatively unique ('T') */ +#define __TERMIOS_MAJ ('T'<<8) + +#define TCGETS (__TERMIOS_MAJ+0x01) +#define TCSETS (__TERMIOS_MAJ+0x02) +#define TCSETSW (__TERMIOS_MAJ+0x03) +#define TCSETSF (__TERMIOS_MAJ+0x04) +#define TCGETA (__TERMIOS_MAJ+0x05) +#define TCSETA (__TERMIOS_MAJ+0x06) +#define TCSETAW (__TERMIOS_MAJ+0x07) +#define TCSETAF (__TERMIOS_MAJ+0x08) +#define TCSBRK (__TERMIOS_MAJ+0x09) +#define TCXONC (__TERMIOS_MAJ+0x0A) +#define TCFLSH (__TERMIOS_MAJ+0x0B) +#define TIOCEXCL (__TERMIOS_MAJ+0x0C) +#define TIOCNXCL (__TERMIOS_MAJ+0x0D) +#define TIOCSCTTY (__TERMIOS_MAJ+0x0E) +#define TIOCGPGRP (__TERMIOS_MAJ+0x0F) +#define TIOCSPGRP (__TERMIOS_MAJ+0x10) +#define TIOCOUTQ (__TERMIOS_MAJ+0x11) +#define TIOCSTI (__TERMIOS_MAJ+0x12) +#define TIOCGWINSZ (__TERMIOS_MAJ+0x13) +#define TIOCSWINSZ (__TERMIOS_MAJ+0x14) +#define TIOCMGET (__TERMIOS_MAJ+0x15) +#define TIOCMBIS (__TERMIOS_MAJ+0x16) +#define TIOCMBIC (__TERMIOS_MAJ+0x17) +#define TIOCMSET (__TERMIOS_MAJ+0x18) +#define TIOCGSOFTCAR (__TERMIOS_MAJ+0x19) +#define TIOCSSOFTCAR (__TERMIOS_MAJ+0x1A) +#define FIONREAD (__TERMIOS_MAJ+0x1B) +#define TIOCINQ FIONREAD +#define TIOCLINUX (__TERMIOS_MAJ+0x1C) +#define TIOCCONS (__TERMIOS_MAJ+0x1D) +#define TIOCGSERIAL (__TERMIOS_MAJ+0x1E) +#define TIOCSSERIAL (__TERMIOS_MAJ+0x1F) +#define TIOCPKT (__TERMIOS_MAJ+0x20) +#define FIONBIO (__TERMIOS_MAJ+0x21) +#define TIOCNOTTY (__TERMIOS_MAJ+0x22) +#define TIOCSETD (__TERMIOS_MAJ+0x23) +#define TIOCGETD (__TERMIOS_MAJ+0x24) +#define TCSBRKP (__TERMIOS_MAJ+0x25) /* Needed for POSIX tcsendbreak */ +#define TIOCTTYGSTRUCT (__TERMIOS_MAJ+0x26) /* For debugging only */ +#define FIONCLEX (__TERMIOS_MAJ+0x50) /* these numbers need to be adjusted. */ +#define FIOCLEX (__TERMIOS_MAJ+0x51) +#define FIOASYNC (__TERMIOS_MAJ+0x52) +#define TIOCSERCONFIG (__TERMIOS_MAJ+0x53) +#define TIOCSERGWILD (__TERMIOS_MAJ+0x54) +#define TIOCSERSWILD (__TERMIOS_MAJ+0x55) +#define TIOCGLCKTRMIOS (__TERMIOS_MAJ+0x56) +#define TIOCSLCKTRMIOS (__TERMIOS_MAJ+0x57) +#define TIOCSERGSTRUCT (__TERMIOS_MAJ+0x58) /* For debugging only */ +#define TIOCSERGETLSR (__TERMIOS_MAJ+0x59) /* Get line status register */ +#define TIOCSERGETMULTI (__TERMIOS_MAJ+0x5A) /* Get multiport config */ +#define TIOCSERSETMULTI (__TERMIOS_MAJ+0x5B) /* Set multiport config */ + +/* Used for packet mode */ +#define TIOCPKT_DATA 0 +#define TIOCPKT_FLUSHREAD 1 +#define TIOCPKT_FLUSHWRITE 2 +#define TIOCPKT_STOP 4 +#define TIOCPKT_START 8 +#define TIOCPKT_NOSTOP 16 +#define TIOCPKT_DOSTOP 32 + +struct winsize { + unsigned short ws_row; + unsigned short ws_col; + unsigned short ws_xpixel; + unsigned short ws_ypixel; +}; + +#define NCC 8 +struct termio { + unsigned short c_iflag; /* input mode flags */ + unsigned short c_oflag; /* output mode flags */ + unsigned short c_cflag; /* control mode flags */ + unsigned short c_lflag; /* local mode flags */ + unsigned char c_line; /* line discipline */ + unsigned char c_cc[NCC]; /* control characters */ +}; + +#define NCCS 19 +struct termios { + tcflag_t c_iflag; /* input mode flags */ + tcflag_t c_oflag; /* output mode flags */ + tcflag_t c_cflag; /* control mode flags */ + tcflag_t c_lflag; /* local mode flags */ + cc_t c_line; /* line discipline */ + cc_t c_cc[NCCS]; /* control characters */ +}; + +/* c_cc characters */ +#define VINTR 0 +#define VQUIT 1 +#define VERASE 2 +#define VKILL 3 +#define VEOF 4 +#define VTIME 5 +#define VMIN 6 +#define VSWTC 7 +#define VSTART 8 +#define VSTOP 9 +#define VSUSP 10 +#define VEOL 11 +#define VREPRINT 12 +#define VDISCARD 13 +#define VWERASE 14 +#define VLNEXT 15 +#define VEOL2 16 + +/* c_iflag bits */ +#define IGNBRK 0000001 +#define BRKINT 0000002 +#define IGNPAR 0000004 +#define PARMRK 0000010 +#define INPCK 0000020 +#define ISTRIP 0000040 +#define INLCR 0000100 +#define IGNCR 0000200 +#define ICRNL 0000400 +#define IUCLC 0001000 +#define IXON 0002000 +#define IXANY 0004000 +#define IXOFF 0010000 +#define IMAXBEL 0020000 + +/* c_oflag bits */ +#define OPOST 0000001 +#define OLCUC 0000002 +#define ONLCR 0000004 +#define OCRNL 0000010 +#define ONOCR 0000020 +#define ONLRET 0000040 +#define OFILL 0000100 +#define OFDEL 0000200 +#define NLDLY 0000400 +#define NL0 0000000 +#define NL1 0000400 +#define CRDLY 0003000 +#define CR0 0000000 +#define CR1 0001000 +#define CR2 0002000 +#define CR3 0003000 +#define TABDLY 0014000 +#define TAB0 0000000 +#define TAB1 0004000 +#define TAB2 0010000 +#define TAB3 0014000 +#define XTABS 0014000 +#define BSDLY 0020000 +#define BS0 0000000 +#define BS1 0020000 +#define VTDLY 0040000 +#define VT0 0000000 +#define VT1 0040000 +#define FFDLY 0100000 +#define FF0 0000000 +#define FF1 0100000 + +/* c_cflag bit meaning */ +#define CBAUD 0010017 +#define B0 0000000 /* hang up */ +#define B50 0000001 +#define B75 0000002 +#define B110 0000003 +#define B134 0000004 +#define B150 0000005 +#define B200 0000006 +#define B300 0000007 +#define B600 0000010 +#define B1200 0000011 +#define B1800 0000012 +#define B2400 0000013 +#define B4800 0000014 +#define B9600 0000015 +#define B19200 0000016 +#define B38400 0000017 +#define EXTA B19200 +#define EXTB B38400 +#define CSIZE 0000060 +#define CS5 0000000 +#define CS6 0000020 +#define CS7 0000040 +#define CS8 0000060 +#define CSTOPB 0000100 +#define CREAD 0000200 +#define PARENB 0000400 +#define PARODD 0001000 +#define HUPCL 0002000 +#define CLOCAL 0004000 +#define CBAUDEX 0010000 +#define B57600 0010001 +#define B115200 0010002 +#define B230400 0010003 +#define CIBAUD 002003600000 /* input baud rate (not used) */ +#define CRTSCTS 020000000000 /* flow control */ + +/* c_lflag bits */ +#define ISIG 0000001 +#define ICANON 0000002 +#define XCASE 0000004 +#define ECHO 0000010 +#define ECHOE 0000020 +#define ECHOK 0000040 +#define ECHONL 0000100 +#define NOFLSH 0000200 +#define TOSTOP 0000400 +#define ECHOCTL 0001000 +#define ECHOPRT 0002000 +#define ECHOKE 0004000 +#define FLUSHO 0010000 +#define PENDIN 0040000 +#define IEXTEN 0100000 + +/* modem lines */ +#define TIOCM_LE 0x001 +#define TIOCM_DTR 0x002 +#define TIOCM_RTS 0x004 +#define TIOCM_ST 0x008 +#define TIOCM_SR 0x010 +#define TIOCM_CTS 0x020 +#define TIOCM_CAR 0x040 +#define TIOCM_RNG 0x080 +#define TIOCM_DSR 0x100 +#define TIOCM_CD TIOCM_CAR +#define TIOCM_RI TIOCM_RNG + +/* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */ +#define TIOCSER_TEMT 0x01 /* Transmitter physically empty */ + + +/* tcflow() and TCXONC use these */ +#define TCOOFF 0 +#define TCOON 1 +#define TCIOFF 2 +#define TCION 3 + +/* tcflush() and TCFLSH use these */ +#define TCIFLUSH 0 +#define TCOFLUSH 1 +#define TCIOFLUSH 2 + +/* tcsetattr uses these */ +#define TCSANOW 0 +#define TCSADRAIN 1 +#define TCSAFLUSH 2 + +/* line disciplines */ +#define N_TTY 0 +#define N_SLIP 1 +#define N_MOUSE 2 +#define N_PPP 3 + +#endif /* __LINUXMT_TERMIOS_H */ diff -Nurd linux-86.old/libc/include/linux/types.h linux-86/libc/include/linux/types.h --- linux-86.old/libc/include/linux/types.h Thu Jan 1 01:00:00 1970 +++ linux-86/libc/include/linux/types.h Sun Aug 17 18:01:52 1997 @@ -0,0 +1,26 @@ +#ifndef __LINUX_TYPES_H +#define __LINUX_TYPES_H + +#include + +typedef __u32 off_t; +typedef __u16 pid_t; +typedef __u16 uid_t; +typedef __u16 gid_t; +typedef __u32 time_t; +typedef __u16 umode_t; +typedef __u16 nlink_t; +typedef __u16 mode_t; +typedef __u32 loff_t; +typedef __u32 speed_t; + +typedef __u16 dev_t; +typedef __u32 ino_t; +typedef __u32 tcflag_t; +typedef __u8 cc_t; +typedef __u32 size_t; + +typedef int ptrdiff_t; + +#endif + diff -Nurd linux-86.old/libc/include/linux/utsname.h linux-86/libc/include/linux/utsname.h --- linux-86.old/libc/include/linux/utsname.h Thu Jan 1 01:00:00 1970 +++ linux-86/libc/include/linux/utsname.h Sun Aug 17 16:59:35 1997 @@ -0,0 +1,15 @@ +#ifndef __LINUX_UTSNAME_H +#define __LINUX_UTSNAME_H + +struct utsname { + char sysname[65]; + char nodename[65]; + char release[65]; + char version[65]; + char machine[65]; + char domainname[65]; +}; + +extern int uname __P ((struct utsname * __utsbuf)); + +#endif diff -Nurd linux-86.old/libc/include/linux/vm86.h linux-86/libc/include/linux/vm86.h --- linux-86.old/libc/include/linux/vm86.h Thu Jan 1 01:00:00 1970 +++ linux-86/libc/include/linux/vm86.h Mon Oct 21 22:23:53 1996 @@ -0,0 +1,125 @@ +#if !__AS386_16__ + +#ifndef _SYS_VM86_H +#define _SYS_VM86_H + +#include +#ifndef _LINUX_VM86_H +#define _LINUX_VM86_H + +/* + * I'm guessing at the VIF/VIP flag usage, but hope that this is how + * the Pentium uses them. Linux will return from vm86 mode when both + * VIF and VIP is set. + * + * On a Pentium, we could probably optimize the virtual flags directly + * in the eflags register instead of doing it "by hand" in vflags... + * + * Linus + */ + +#define TF_MASK 0x00000100 +#define IF_MASK 0x00000200 +#define IOPL_MASK 0x00003000 +#define NT_MASK 0x00004000 +#define VM_MASK 0x00020000 +#define AC_MASK 0x00040000 +#define VIF_MASK 0x00080000 /* virtual interrupt flag */ +#define VIP_MASK 0x00100000 /* virtual interrupt pending */ +#define ID_MASK 0x00200000 + +#define BIOSSEG 0x0f000 + +#define CPU_086 0 +#define CPU_186 1 +#define CPU_286 2 +#define CPU_386 3 +#define CPU_486 4 +#define CPU_586 5 + +/* + * Return values for the 'vm86()' system call + */ +#define VM86_TYPE(retval) ((retval) & 0xff) +#define VM86_ARG(retval) ((retval) >> 8) + +#define VM86_SIGNAL 0 /* return due to signal */ +#define VM86_UNKNOWN 1 /* unhandled GP fault - IO-instruction or similar */ +#define VM86_INTx 2 /* int3/int x instruction (ARG = x) */ +#define VM86_STI 3 /* sti/popf/iret instruction enabled virtual interrupts */ + +/* + * This is the stack-layout when we have done a "SAVE_ALL" from vm86 + * mode - the main change is that the old segment descriptors aren't + * useful any more and are forced to be zero by the kernel (and the + * hardware when a trap occurs), and the real segment descriptors are + * at the end of the structure. Look at ptrace.h to see the "normal" + * setup. + */ + +struct vm86_regs { +/* + * normal regs, with special meaning for the segment descriptors.. + */ + long ebx; + long ecx; + long edx; + long esi; + long edi; + long ebp; + long eax; + long __null_ds; + long __null_es; + long __null_fs; + long __null_gs; + long orig_eax; + long eip; + unsigned short cs, __csh; + long eflags; + long esp; + unsigned short ss, __ssh; +/* + * these are specific to v86 mode: + */ + unsigned short es, __esh; + unsigned short ds, __dsh; + unsigned short fs, __fsh; + unsigned short gs, __gsh; +}; + +struct revectored_struct { + unsigned long __map[8]; /* 256 bits */ +}; + +struct vm86_struct { + struct vm86_regs regs; + unsigned long flags; + unsigned long screen_bitmap; + unsigned long cpu_type; + struct revectored_struct int_revectored; + struct revectored_struct int21_revectored; +}; + +/* + * flags masks + */ +#define VM86_SCREEN_BITMAP 0x0001 + +#ifdef __KERNEL__ + +void handle_vm86_fault(struct vm86_regs *, long); +void handle_vm86_debug(struct vm86_regs *, long); + +#endif + +#endif + +__BEGIN_DECLS + +extern vm86(struct vm86_struct * __info); + +__END_DECLS + +#endif /*_SYS_VM86_H */ + +#endif diff -Nurd linux-86.old/libc/include/msdos/errno.h linux-86/libc/include/msdos/errno.h --- linux-86.old/libc/include/msdos/errno.h Thu Jan 1 01:00:00 1970 +++ linux-86/libc/include/msdos/errno.h Sun Aug 17 09:38:49 1997 @@ -0,0 +1,46 @@ +#ifndef __MSDOS_ERRNO_H +#define __MSDOS_ERRNO_H + +#define EPERM 1 /* Operation not permitted */ +#define ENOENT 2 /* No such file or directory */ +#define ESRCH 3 /* No such process */ +#define EINTR 4 /* Interrupted system call */ +#define EIO 5 /* I/O error */ +#define ENXIO 6 /* No such device or address */ +#define E2BIG 7 /* Arg list too long */ +#define ENOEXEC 8 /* Exec format error */ +#define EBADF 9 /* Bad file number */ +#define ECHILD 10 /* No child processes */ +#define EAGAIN 11 /* Try again */ +#define ENOMEM 12 /* Out of memory */ +#define EACCES 13 /* Permission denied */ +#define EFAULT 14 /* Bad address */ +#define ENOTBLK 15 /* Block device required */ +#define EBUSY 16 /* Device or resource busy */ +#define EEXIST 17 /* File exists */ +#define EXDEV 18 /* Cross-device link */ +#define ENODEV 19 /* No such device */ +#define ENOTDIR 20 /* Not a directory */ +#define EISDIR 21 /* Is a directory */ +#define EINVAL 22 /* Invalid argument */ +#define ENFILE 23 /* File table overflow */ +#define EMFILE 24 /* Too many open files */ +#define ENOTTY 25 /* Not a typewriter */ +#define ETXTBSY 26 /* Text file busy */ +#define EFBIG 27 /* File too large */ +#define ENOSPC 28 /* No space left on device */ +#define ESPIPE 29 /* Illegal seek */ +#define EROFS 30 /* Read-only file system */ +#define EMLINK 31 /* Too many links */ +#define EPIPE 32 /* Broken pipe */ +#define EDOM 33 /* Math argument out of domain of func */ +#define ERANGE 34 /* Math result not representable */ +#define EDEADLK 35 /* Resource deadlock would occur */ +#define ENAMETOOLONG 36 /* File name too long */ +#define ENOLCK 37 /* No record locks available */ +#define ENOSYS 38 /* Function not implemented */ +#define ENOTEMPTY 39 /* Directory not empty */ +#define ELOOP 40 /* Too many symbolic links encountered */ +#define EWOULDBLOCK EAGAIN /* Operation would block */ + +#endif diff -Nurd linux-86.old/libc/include/msdos/fcntl.h linux-86/libc/include/msdos/fcntl.h --- linux-86.old/libc/include/msdos/fcntl.h Thu Jan 1 01:00:00 1970 +++ linux-86/libc/include/msdos/fcntl.h Sun Aug 17 09:41:25 1997 @@ -0,0 +1,24 @@ +#ifndef __MSDOS_FCNTL_H +#define __MSDOS_FCNTL_H + +/* Definitions taken from the i386 Linux kernel. */ + +#define O_ACCMODE 0003 +#define O_RDONLY 00 +#define O_WRONLY 01 +#define O_RDWR 02 +#define O_CREAT 0100 /* not fcntl */ +#define O_EXCL 0200 /* not fcntl */ +#define O_TRUNC 01000 /* not fcntl */ +#define O_APPEND 02000 + +#define F_DUPFD 0 /* dup */ +#define F_GETFD 1 /* get f_flags */ +#define F_SETFD 2 /* set f_flags */ +#define F_GETFL 3 /* more flags (cloexec) */ +#define F_SETFL 4 +#define F_GETLK 5 +#define F_SETLK 6 +#define F_SETLKW 7 + +#endif diff -Nurd linux-86.old/libc/include/msdos/types.h linux-86/libc/include/msdos/types.h --- linux-86.old/libc/include/msdos/types.h Thu Jan 1 01:00:00 1970 +++ linux-86/libc/include/msdos/types.h Sun Aug 17 17:55:01 1997 @@ -0,0 +1,22 @@ + +/* arch/i86/include/asm/types.h - Basic Linux/MT data types. */ + +#ifndef __MSDOS_TYPES +#define __MSDOS_TYPES + +#include + +typedef __u32 off_t; +typedef __u32 time_t; +typedef __u16 mode_t; +typedef __u32 loff_t; +typedef __u32 speed_t; + +typedef __u32 tcflag_t; +typedef __u8 cc_t; +typedef __u16 size_t; + +typedef int ptrdiff_t; + +#endif + diff -Nurd linux-86.old/libc/include/signal.h linux-86/libc/include/signal.h --- linux-86.old/libc/include/signal.h Sat Feb 24 15:25:48 1996 +++ linux-86/libc/include/signal.h Sun Aug 17 14:58:14 1997 @@ -79,7 +79,9 @@ }; /* BSDisms */ +#ifdef BSD extern __const char * __const sys_siglist[]; #define sig_t __sighandler_t +#endif #endif diff -Nurd linux-86.old/libc/include/stddef.h linux-86/libc/include/stddef.h --- linux-86.old/libc/include/stddef.h Fri Oct 11 11:10:34 1996 +++ linux-86/libc/include/stddef.h Sun Aug 17 16:39:43 1997 @@ -4,25 +4,13 @@ */ /* We don't care, ignore GCC's __need hackery */ -#undef __need_wchar_t -#undef __need_size_t -#undef __need_ptrdiff_t -#undef __need_NULL - -/* Fact is these are _normal_ */ -#if 1 /* __BCC__ */ /* Only for Bcc 8086/80386 */ - #ifndef __STDDEF_H #define __STDDEF_H -#ifndef _SIZE_T -#define _SIZE_T -typedef unsigned int size_t; -#endif +#include #ifndef NULL #define NULL 0 #endif #endif /* __STDDEF_H */ -#endif /* __AS386_16__ */ diff -Nurd linux-86.old/libc/include/sys/errno.h linux-86/libc/include/sys/errno.h --- linux-86.old/libc/include/sys/errno.h Sat Feb 24 16:15:21 1996 +++ linux-86/libc/include/sys/errno.h Sat Aug 16 09:57:42 1997 @@ -1 +1,25 @@ -#include +#ifndef __ERRNO_H +#define __ERRNO_H + +#include +#include __SYSINC__(errno.h) + +#ifdef __USE_BSD +extern int sys_nerr; +extern char *sys_errlist[]; +#endif +#ifdef __USE_GNU +extern int _sys_nerr; +extern char *_sys_errlist[]; +#endif + +extern int errno; + +__BEGIN_DECLS + +extern void perror __P ((__const char* __s)); +extern char* strerror __P ((int __errno)); + +__END_DECLS + +#endif diff -Nurd linux-86.old/libc/include/sys/ioctl.h linux-86/libc/include/sys/ioctl.h --- linux-86.old/libc/include/sys/ioctl.h Sat Feb 24 16:08:46 1996 +++ linux-86/libc/include/sys/ioctl.h Sat Aug 16 10:01:29 1997 @@ -2,7 +2,7 @@ #ifndef _SYS_IOCTL_H #define _SYS_IOCTL_H #include -#include +#include __SYSINC__(ioctl.h) extern int ioctl __P((int __fildes, int __cmd, ...)); diff -Nurd linux-86.old/libc/include/sys/mman.h linux-86/libc/include/sys/mman.h --- linux-86.old/libc/include/sys/mman.h Mon Oct 21 22:13:26 1996 +++ linux-86/libc/include/sys/mman.h Sat Aug 16 12:09:04 1997 @@ -0,0 +1,6 @@ + +#ifndef __SYS_MMAN_H +#define __SYS_MMAN_H +#include +#include __SYSINC__(mman.h) +#endif diff -Nurd linux-86.old/libc/include/sys/resource.h linux-86/libc/include/sys/resource.h --- linux-86.old/libc/include/sys/resource.h Mon Apr 22 21:03:21 1996 +++ linux-86/libc/include/sys/resource.h Sun Aug 17 09:47:43 1997 @@ -1,73 +1,6 @@ -/* - * Resource control/accounting header file for linux-86 - */ - -#ifndef _SYS_RESOURCE_H -#define _SYS_RESOURCE_H +#ifndef __SYS_RESOURCE_H +#define __SYS_RESOURCE_H #include -#include -#include - -#define RUSAGE_SELF 0 -#define RUSAGE_CHILDREN (-1) -#define RUSAGE_BOTH (-2) /* sys_wait4() uses this */ - -struct rusage { - struct timeval ru_utime; /* user time used */ - struct timeval ru_stime; /* system time used */ - long ru_maxrss; /* maximum resident set size */ - long ru_ixrss; /* integral shared memory size */ - long ru_idrss; /* integral unshared data size */ - long ru_isrss; /* integral unshared stack size */ - long ru_minflt; /* page reclaims */ - long ru_majflt; /* page faults */ - long ru_nswap; /* swaps */ - long ru_inblock; /* block input operations */ - long ru_oublock; /* block output operations */ - long ru_msgsnd; /* messages sent */ - long ru_msgrcv; /* messages received */ - long ru_nsignals; /* signals received */ - long ru_nvcsw; /* voluntary context switches */ - long ru_nivcsw; /* involuntary " */ -}; - -#define RLIM_INFINITY ((long)(~0UL>>1)) - -struct rlimit { - long rlim_cur; - long rlim_max; -}; - -#define PRIO_MIN (-20) -#define PRIO_MAX 20 - -#define PRIO_PROCESS 0 -#define PRIO_PGRP 1 -#define PRIO_USER 2 - -#define RLIMIT_CPU 0 /* CPU time in ms */ -#define RLIMIT_FSIZE 1 /* Maximum filesize */ -#define RLIMIT_DATA 2 /* max data size */ -#define RLIMIT_STACK 3 /* max stack size */ -#define RLIMIT_CORE 4 /* max core file size */ -#define RLIMIT_RSS 5 /* max resident set size */ -#define RLIMIT_NPROC 6 /* max number of processes */ -#define RLIMIT_NOFILE 7 /* max number of open files */ -#define RLIMIT_MEMLOCK 8 /* max locked-in-memory address space */ - -#define RLIM_NLIMITS 9 - -extern int getrlimit __P ((int __resource, - struct rlimit *__rlp)); -extern int setrlimit __P ((int __resource, - __const struct rlimit *__rlp)); - -extern int getpriority __P((int __which, int __who)); -extern int setpriority __P((int __which, int __who, - int __prio)); - -extern int __getrusage __P ((int __who, struct rusage *__rusage)); -extern int getrusage __P ((int __who, struct rusage *__rusage)); - -#endif /* _SYS_RESOURCE_H */ +#include __SYSINC__(resource.h) +#endif diff -Nurd linux-86.old/libc/include/sys/socket.h linux-86/libc/include/sys/socket.h --- linux-86.old/libc/include/sys/socket.h Thu Jan 1 01:00:00 1970 +++ linux-86/libc/include/sys/socket.h Sat Aug 16 12:37:20 1997 @@ -0,0 +1,6 @@ + +#ifndef __SYS_SOCKET_H +#define __SYS_SOCKET_H +#include +#include __SYSINC__(socket.h) +#endif diff -Nurd linux-86.old/libc/include/sys/stat.h linux-86/libc/include/sys/stat.h --- linux-86.old/libc/include/sys/stat.h Tue Jan 28 20:55:06 1997 +++ linux-86/libc/include/sys/stat.h Sat Aug 16 12:18:32 1997 @@ -1,57 +1,9 @@ #ifndef _SYS_STAT_H #define _SYS_STAT_H -#include -#include #include - -#ifdef __AS386_32__ -/* This is for Linux-386, ho hum, I wish BCC could compile the proper one */ -#define mknod __dv32_mknod -#define stat __dv32_stat -#define lstat __dv32_lstat -#define fstat __dv32_fstat - -struct stat { - dev_t st_dev; - unsigned short __pad1; - ino_t st_ino; - umode_t st_mode; - nlink_t st_nlink; - uid_t st_uid; - gid_t st_gid; - dev_t st_rdev; - unsigned short __pad2; - off_t st_size; - unsigned long st_blksize; - unsigned long st_blocks; - time_t st_atime; - unsigned long __unused1; - time_t st_mtime; - unsigned long __unused2; - time_t st_ctime; - unsigned long __unused3; - unsigned long __unused4; - unsigned long __unused5; -}; -#endif - -#ifdef __AS386_16__ -struct stat -{ - dev_t st_dev; - ino_t st_ino; - mode_t st_mode; - nlink_t st_nlink; - uid_t st_uid; - gid_t st_gid; - dev_t st_rdev; - off_t st_size; - time_t st_atime; - time_t st_mtime; - time_t st_ctime; -}; -#endif +#include +#include __SYSINC__(stat.h) int stat __P((__const char * __path, struct stat * __statbuf)); int lstat __P((__const char * __path, struct stat * __statbuf)); diff -Nurd linux-86.old/libc/include/sys/types.h linux-86/libc/include/sys/types.h --- linux-86.old/libc/include/sys/types.h Sat Feb 24 16:12:03 1996 +++ linux-86/libc/include/sys/types.h Sat Aug 16 10:09:55 1997 @@ -1,2 +1,3 @@ +#include #include -#include +#include __SYSINC__(types.h) diff -Nurd linux-86.old/libc/include/sys/utsname.h linux-86/libc/include/sys/utsname.h --- linux-86.old/libc/include/sys/utsname.h Sat Mar 23 08:41:25 1996 +++ linux-86/libc/include/sys/utsname.h Sun Aug 17 16:59:52 1997 @@ -3,16 +3,6 @@ #include #include - -struct utsname { - char sysname[65]; - char nodename[65]; - char release[65]; - char version[65]; - char machine[65]; - char domainname[65]; -}; - -extern int uname __P ((struct utsname * __utsbuf)); +#include __SYSINC__(utsname.h) #endif diff -Nurd linux-86.old/libc/include/sys/vm86.h linux-86/libc/include/sys/vm86.h --- linux-86.old/libc/include/sys/vm86.h Mon Oct 21 22:23:53 1996 +++ linux-86/libc/include/sys/vm86.h Sat Aug 16 12:10:11 1997 @@ -1,125 +1,5 @@ -#if !__AS386_16__ - -#ifndef _SYS_VM86_H -#define _SYS_VM86_H - +#ifndef __SYS_VM86_H +#define __SYS_VM86_H #include -#ifndef _LINUX_VM86_H -#define _LINUX_VM86_H - -/* - * I'm guessing at the VIF/VIP flag usage, but hope that this is how - * the Pentium uses them. Linux will return from vm86 mode when both - * VIF and VIP is set. - * - * On a Pentium, we could probably optimize the virtual flags directly - * in the eflags register instead of doing it "by hand" in vflags... - * - * Linus - */ - -#define TF_MASK 0x00000100 -#define IF_MASK 0x00000200 -#define IOPL_MASK 0x00003000 -#define NT_MASK 0x00004000 -#define VM_MASK 0x00020000 -#define AC_MASK 0x00040000 -#define VIF_MASK 0x00080000 /* virtual interrupt flag */ -#define VIP_MASK 0x00100000 /* virtual interrupt pending */ -#define ID_MASK 0x00200000 - -#define BIOSSEG 0x0f000 - -#define CPU_086 0 -#define CPU_186 1 -#define CPU_286 2 -#define CPU_386 3 -#define CPU_486 4 -#define CPU_586 5 - -/* - * Return values for the 'vm86()' system call - */ -#define VM86_TYPE(retval) ((retval) & 0xff) -#define VM86_ARG(retval) ((retval) >> 8) - -#define VM86_SIGNAL 0 /* return due to signal */ -#define VM86_UNKNOWN 1 /* unhandled GP fault - IO-instruction or similar */ -#define VM86_INTx 2 /* int3/int x instruction (ARG = x) */ -#define VM86_STI 3 /* sti/popf/iret instruction enabled virtual interrupts */ - -/* - * This is the stack-layout when we have done a "SAVE_ALL" from vm86 - * mode - the main change is that the old segment descriptors aren't - * useful any more and are forced to be zero by the kernel (and the - * hardware when a trap occurs), and the real segment descriptors are - * at the end of the structure. Look at ptrace.h to see the "normal" - * setup. - */ - -struct vm86_regs { -/* - * normal regs, with special meaning for the segment descriptors.. - */ - long ebx; - long ecx; - long edx; - long esi; - long edi; - long ebp; - long eax; - long __null_ds; - long __null_es; - long __null_fs; - long __null_gs; - long orig_eax; - long eip; - unsigned short cs, __csh; - long eflags; - long esp; - unsigned short ss, __ssh; -/* - * these are specific to v86 mode: - */ - unsigned short es, __esh; - unsigned short ds, __dsh; - unsigned short fs, __fsh; - unsigned short gs, __gsh; -}; - -struct revectored_struct { - unsigned long __map[8]; /* 256 bits */ -}; - -struct vm86_struct { - struct vm86_regs regs; - unsigned long flags; - unsigned long screen_bitmap; - unsigned long cpu_type; - struct revectored_struct int_revectored; - struct revectored_struct int21_revectored; -}; - -/* - * flags masks - */ -#define VM86_SCREEN_BITMAP 0x0001 - -#ifdef __KERNEL__ - -void handle_vm86_fault(struct vm86_regs *, long); -void handle_vm86_debug(struct vm86_regs *, long); - -#endif - -#endif - -__BEGIN_DECLS - -extern vm86(struct vm86_struct * __info); - -__END_DECLS - -#endif /*_SYS_VM86_H */ - +#include __SYSINC__(vm86.h) #endif diff -Nurd linux-86.old/libc/include/termios.h linux-86/libc/include/termios.h --- linux-86.old/libc/include/termios.h Tue Apr 23 21:46:41 1996 +++ linux-86/libc/include/termios.h Sat Aug 16 10:00:41 1997 @@ -3,7 +3,7 @@ #include #include -#include +#include __SYSINC__(termios.h) extern speed_t cfgetispeed __P ((struct termios *__termios_p)); extern speed_t cfgetospeed __P ((struct termios *__termios_p)); diff -Nurd linux-86.old/libc/include/unistd.h linux-86/libc/include/unistd.h --- linux-86.old/libc/include/unistd.h Tue Mar 19 20:16:19 1996 +++ linux-86/libc/include/unistd.h Sun Aug 17 17:22:27 1997 @@ -32,6 +32,8 @@ #define F_OK 0 /* Test for existence. */ #endif +#define _POSIX_VDISABLE '\0' + #endif /* __UNISTD_H */ diff -Nurd linux-86.old/libc/kinclude/Config linux-86/libc/kinclude/Config --- linux-86.old/libc/kinclude/Config Sat Mar 16 13:03:16 1996 +++ linux-86/libc/kinclude/Config Sat Aug 16 11:29:30 1997 @@ -1 +1 @@ -kinc: The kernel include files +kinc: Example kernel include files diff -Nurd linux-86.old/libc/kinclude/Makefile linux-86/libc/kinclude/Makefile --- linux-86.old/libc/kinclude/Makefile Sun Dec 15 10:33:10 1996 +++ linux-86/libc/kinclude/Makefile Sat Aug 16 09:25:45 1997 @@ -6,16 +6,11 @@ @: transfer: - -@rm -f ../include/linuxmt + -@rm -f ../include/linuxmt ../include/arch ln -s ../kinclude/linuxmt ../include + ln -s ../kinclude/arch ../include @touch Used -# This is for use once linuxmt's syscall interface really gets working. -# beware the arch directory must be removed when you do this. -real_transfer: - -@rm -f ../include/linuxmt - cd ../include ; ln -s ../../linuxmt/include/linuxmt . - clean: - -@rm -f ../include/linuxmt + -@rm -f ../include/linuxmt ../include/arch -@rm -f Used diff -Nurd linux-86.old/libc/kinclude/arch/errno.h linux-86/libc/kinclude/arch/errno.h --- linux-86.old/libc/kinclude/arch/errno.h Sat Nov 4 16:43:30 1995 +++ linux-86/libc/kinclude/arch/errno.h Sun Aug 17 09:53:04 1997 @@ -1,5 +1,5 @@ -#ifndef _I86_ERRNO_H -#define _I86_ERRNO_H +#ifndef __ARCH_ERRNO_H +#define __ARCH_ERRNO_H #define EPERM 1 /* Operation not permitted */ #define ENOENT 2 /* No such file or directory */ diff -Nurd linux-86.old/libc/kinclude/arch/stat.h linux-86/libc/kinclude/arch/stat.h --- linux-86.old/libc/kinclude/arch/stat.h Thu Jan 1 01:00:00 1970 +++ linux-86/libc/kinclude/arch/stat.h Sat Aug 16 12:16:25 1997 @@ -0,0 +1,19 @@ + +#ifndef _ARCH_STAT_H +#define _ARCH_STAT_H + +struct stat +{ + dev_t st_dev; + ino_t st_ino; + mode_t st_mode; + nlink_t st_nlink; + uid_t st_uid; + gid_t st_gid; + dev_t st_rdev; + off_t st_size; + time_t st_atime; + time_t st_mtime; + time_t st_ctime; +}; +#endif diff -Nurd linux-86.old/libc/kinclude/arch/types.h linux-86/libc/kinclude/arch/types.h --- linux-86.old/libc/kinclude/arch/types.h Wed Oct 16 19:07:08 1996 +++ linux-86/libc/kinclude/arch/types.h Sat Aug 16 11:40:38 1997 @@ -2,33 +2,9 @@ #ifndef __LINUXMT_8086_TYPES #define __LINUXMT_8086_TYPES - -/* First we define all of the __u and __s types...*/ - -typedef unsigned char __u8; -typedef unsigned char * __pu8; -typedef char __s8; -typedef char * __ps8; - -typedef unsigned short __u16; -typedef unsigned short * __pu16; -typedef short __s16; -typedef short * __ps16; - -typedef unsigned long __u32; -typedef unsigned long * __pu32; -typedef long __s32; -typedef long * __ps32; - -/* __uint == 16bit here */ - -typedef unsigned int __uint; -typedef int __sint; -typedef unsigned int * __puint; -typedef int * __psint; - -/* Then we define registers, etc... */ +#include + struct _registers { __u16 ksp, sp, ss, ax, bx, cx, dx, di, si, ds, es, bp, ip, cs, flags; }; diff -Nurd linux-86.old/libc/kinclude/linuxmt/resource.h linux-86/libc/kinclude/linuxmt/resource.h --- linux-86.old/libc/kinclude/linuxmt/resource.h Thu Jan 1 01:00:00 1970 +++ linux-86/libc/kinclude/linuxmt/resource.h Sun Aug 17 09:48:41 1997 @@ -0,0 +1,73 @@ +/* + * Resource control/accounting header file for linux-86 + */ + +#ifndef __LINUXMT_RESOURCE_H +#define __LINUXMT_RESOURCE_H + +#include +#include +#include + +#define RUSAGE_SELF 0 +#define RUSAGE_CHILDREN (-1) +#define RUSAGE_BOTH (-2) /* sys_wait4() uses this */ + +struct rusage { + struct timeval ru_utime; /* user time used */ + struct timeval ru_stime; /* system time used */ + long ru_maxrss; /* maximum resident set size */ + long ru_ixrss; /* integral shared memory size */ + long ru_idrss; /* integral unshared data size */ + long ru_isrss; /* integral unshared stack size */ + long ru_minflt; /* page reclaims */ + long ru_majflt; /* page faults */ + long ru_nswap; /* swaps */ + long ru_inblock; /* block input operations */ + long ru_oublock; /* block output operations */ + long ru_msgsnd; /* messages sent */ + long ru_msgrcv; /* messages received */ + long ru_nsignals; /* signals received */ + long ru_nvcsw; /* voluntary context switches */ + long ru_nivcsw; /* involuntary " */ +}; + +#define RLIM_INFINITY ((long)(~0UL>>1)) + +struct rlimit { + long rlim_cur; + long rlim_max; +}; + +#define PRIO_MIN (-20) +#define PRIO_MAX 20 + +#define PRIO_PROCESS 0 +#define PRIO_PGRP 1 +#define PRIO_USER 2 + +#define RLIMIT_CPU 0 /* CPU time in ms */ +#define RLIMIT_FSIZE 1 /* Maximum filesize */ +#define RLIMIT_DATA 2 /* max data size */ +#define RLIMIT_STACK 3 /* max stack size */ +#define RLIMIT_CORE 4 /* max core file size */ +#define RLIMIT_RSS 5 /* max resident set size */ +#define RLIMIT_NPROC 6 /* max number of processes */ +#define RLIMIT_NOFILE 7 /* max number of open files */ +#define RLIMIT_MEMLOCK 8 /* max locked-in-memory address space */ + +#define RLIM_NLIMITS 9 + +extern int getrlimit __P ((int __resource, + struct rlimit *__rlp)); +extern int setrlimit __P ((int __resource, + __const struct rlimit *__rlp)); + +extern int getpriority __P((int __which, int __who)); +extern int setpriority __P((int __which, int __who, + int __prio)); + +extern int __getrusage __P ((int __who, struct rusage *__rusage)); +extern int getrusage __P ((int __who, struct rusage *__rusage)); + +#endif /* __LINUXMT_RESOURCE_H */ diff -Nurd linux-86.old/libc/kinclude/linuxmt/stat.h linux-86/libc/kinclude/linuxmt/stat.h --- linux-86.old/libc/kinclude/linuxmt/stat.h Wed Oct 16 20:20:27 1996 +++ linux-86/libc/kinclude/linuxmt/stat.h Sat Aug 16 12:18:14 1997 @@ -1,11 +1,7 @@ #ifndef __LINUXMT_STAT_H #define __LINUXMT_STAT_H -#ifdef __KERNEL__ - -#include "../arch/stat.h" - -#endif +#include #define S_IFMT 00170000 #ifdef __LINUXMT_NETWORK__ diff -Nurd linux-86.old/libc/kinclude/linuxmt/types.h linux-86/libc/kinclude/linuxmt/types.h --- linux-86.old/libc/kinclude/linuxmt/types.h Wed Oct 16 19:09:57 1996 +++ linux-86/libc/kinclude/linuxmt/types.h Sun Aug 17 18:19:38 1997 @@ -1,16 +1,7 @@ #ifndef __LINUXMT_TYPES_H #define __LINUXMT_TYPES_H -#include "../arch/types.h" - -/* Throw away _FUNCTION parameters - the syntax is ripped off of Minix's - _PROTOTYPE. Considering Borland did the same thing to MFC on a bigger - scale, I don't think PH will mind :) */ - -/* Yes, this should be in arch/types.h too */ - -#define _FUNCTION(function, params) function() -#define _VFUNCTION(functiom, params) (*function) () +#include typedef __u32 off_t; typedef __u16 pid_t; @@ -22,6 +13,7 @@ typedef __u16 mode_t; typedef __u32 loff_t; typedef __u32 speed_t; +typedef __u16 size_t; typedef __u16 dev_t; typedef __uint ino_t; diff -Nurd linux-86.old/libc/misc/Makefile linux-86/libc/misc/Makefile --- linux-86.old/libc/misc/Makefile Sat Mar 8 20:14:34 1997 +++ linux-86/libc/misc/Makefile Sun Aug 17 15:22:23 1997 @@ -14,9 +14,12 @@ UOBJ=getenv.o putenv.o popen.o system.o setenv.o getcwd.o +SSRC=syslib.c +SOBJ=time.o abort.o wait.o wait3.o waitpid.o killpg.o setpgrp.o sleep.o \ + usleep.o mkfifo.o ifeq ($(LIB_OS),ELKS) -OBJ=$(MOBJ) $(EOBJ) $(GOBJ) $(UOBJ) +OBJ=$(MOBJ) $(EOBJ) $(GOBJ) $(UOBJ) $(SOBJ) else OBJ=$(MOBJ) $(EOBJ) $(GOBJ) endif @@ -38,6 +41,10 @@ $(AR) $(ARFLAGS) $@ $*.o $(LIBC)($(EOBJ)): $(ESRC) + $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o + $(AR) $(ARFLAGS) $@ $*.o + +$(LIBC)($(SOBJ)): $(SSRC) $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o $(AR) $(ARFLAGS) $@ $*.o diff -Nurd linux-86.old/libc/misc/cputype.c linux-86/libc/misc/cputype.c --- linux-86.old/libc/misc/cputype.c Fri Oct 11 11:00:21 1996 +++ linux-86/libc/misc/cputype.c Thu Jun 26 17:55:24 1997 @@ -1,4 +1,8 @@ -/* +/* Copyright (C) 1989,1996 Robert de Bath + * This file is part of the Linux-8086 C library and is distributed + * under the terms of the GNU Library General Public License. + ********************************************************************** + * * This does a determination of the cpu type that is actually being used. * It can determine the CPU on anything upto and including a 386 accuratly * whatever mode the CPU is in (This is 16 bit code) @@ -12,18 +16,6 @@ * $ cputype # Call cputype(0) and interpret * $ cputype + # Call cputype(1) get a SIGILL (or perhaps interpret) * - * NOTE: This code is COPYRIGHT and not under the GNU Lib copyright, this - * may be distributed freely as source or as a standalone binary - * compiled from this unmodified source. - * - * You may use the cputype() function in your own personal code. - * You may distribute a binary version of code containing the - * cputype() function if either you distribute this source with - * the binary version or distribute a clear reference to a freely - * available copy of this source code and the source code to the - * rest of your package with the binary version of the package. - * - * (C) Copyright R de Bath 1989-1996 */ #ifdef STANDALONE diff -Nurd linux-86.old/libc/misc/syslib.c linux-86/libc/misc/syslib.c --- linux-86.old/libc/misc/syslib.c Thu Jan 1 01:00:00 1970 +++ linux-86/libc/misc/syslib.c Sun Aug 17 15:31:36 1997 @@ -0,0 +1,181 @@ +/* Copyright (C) 1995,1996 Robert de Bath + * This file is part of the Linux-8086 C library and is distributed + * under the GNU Library General Public License. + */ + +#include +#include +#include +#include +#include +#include + +/* This only for the various unix version */ +#ifdef __unix__ + +/********************** Function time ************************************/ + +#ifdef L_time +time_t time(where) +time_t *where; +{ + struct timeval rv; + if( gettimeofday(&rv, (void*)0) < 0 ) return -1; + if(where) *where = rv.tv_sec; + return rv.tv_sec; +} +#endif + +/********************** Function abort ************************************/ + +#ifdef L_abort + +int abort() +{ + signal(SIGABRT, SIG_DFL); + kill(SIGABRT, getpid()); /* Correct one */ + pause(); /* System may just schedule */ + signal(SIGKILL, SIG_DFL); + kill(SIGKILL, getpid()); /* Can't trap this! */ + __exit(255); /* WHAT!! */ +} +#endif + +/********************** Function wait ************************************/ + +#ifdef L_wait +int +wait(status) +int * status; +{ + return wait4(-1, status, 0, (void*)0); +} +#endif + +/********************** Function wait3 **************************************/ + +#ifdef L_wait3 +int +wait3(status, opts, usage) +int * status; +int opts; +struct rusage * usage; +{ + return wait4(-1, status, opts, usage); +} +#endif + +/********************** Function waitpid ************************************/ + +#ifdef L_waitpid +int +waitpid(pid, status, opts) +int pid; +int * status; +int opts; +{ + return wait4(pid, status, opts, (void*)0); +} +#endif + +/********************** Function killpg ************************************/ + +#ifdef L_killpg +int +killpg(pid, sig) +int pid; +int sig; +{ + if(pid == 0) + pid = getpgrp(); + if(pid > 1) + return kill(-pid, sig); + errno = EINVAL; + return -1; +} +#endif + +/********************** Function setpgrp ************************************/ + +#ifdef L_setpgrp +int +setpgrp() +{ + return setpgid(0,0); +} +#endif + +/********************** Function sleep ************************************/ + +#ifdef L_sleep + +#ifdef __ELKS__ +/* This uses SIGALRM, it does keep the previous alarm call but will lose + * any alarms that go off during the sleep + */ + +static void alrm() { } + +unsigned int sleep(seconds) +unsigned int seconds; +{ + void (*last_alarm)(); + unsigned int prev_sec; + + prev_sec = alarm(0); + if( prev_sec <= seconds ) prev_sec = 1; else prev_sec -= seconds; + + last_alarm = signal(SIGALRM, alrm); + alarm(seconds); + pause(); + seconds = alarm(prev_sec); + signal(SIGALRM, last_alarm); + return seconds; +} + +#else + /* Is this a better way ? If we have select of course :-) */ +unsigned int +sleep(seconds) +unsigned int seconds; +{ + struct timeval timeout; + time_t start = time((void*)0); + timeout.tv_sec = seconds; + timeout.tv_usec = 0; + select(1, NULL, NULL, NULL, &timeout); + return seconds - (time((void*)0) - start); +} +#endif + +#endif + +/********************** Function usleep ************************************/ + +#ifdef L_usleep +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 + +/********************** Function mkfifo ************************************/ + +#ifdef L_mkfifo +int +mkfifo(path, mode) +char * path; +int mode; +{ + return mknod(path, mode | S_IFIFO, 0); +} +#endif + +/********************** THE END ********************************************/ + +#endif /* __unix__ */ diff -Nurd linux-86.old/libc/stdio1/BUGS linux-86/libc/stdio1/BUGS --- linux-86.old/libc/stdio1/BUGS Thu Jan 1 01:00:00 1970 +++ linux-86/libc/stdio1/BUGS Mon Jan 1 03:38:30 1996 @@ -0,0 +1,15 @@ +Error checking is known to be wanting. However the author just wants to +get it working right now. + +fread() and fwrite() are not supported. open(), read(), write(), and close() +work very well for binary data. + +fopen() is the only way to open a file. None of the temp stuff is supported, +and frepon() is unsupported. + +GNU extensions are unsupported. + +Some printf specifications may not work. Read the code for details of what +IS supported. + +Other than that, this should be a perfectly normal stdio lib when it's finished. diff -Nurd linux-86.old/libc/stdio1/Config linux-86/libc/stdio1/Config --- linux-86.old/libc/stdio1/Config Thu Jan 1 01:00:00 1970 +++ linux-86/libc/stdio1/Config Tue Feb 13 22:39:40 1996 @@ -0,0 +1,3 @@ + + +stdio: Joel's stdio package altered by Nat diff -Nurd linux-86.old/libc/stdio1/NOTICE linux-86/libc/stdio1/NOTICE --- linux-86.old/libc/stdio1/NOTICE Thu Jan 1 01:00:00 1970 +++ linux-86/libc/stdio1/NOTICE Mon Jan 1 03:18:25 1996 @@ -0,0 +1,17 @@ +/* + Copyright (C) 1996 Joel N. Weber II + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ diff -Nurd linux-86.old/libc/stdio1/README linux-86/libc/stdio1/README --- linux-86.old/libc/stdio1/README Thu Jan 1 01:00:00 1970 +++ linux-86/libc/stdio1/README Sat Dec 14 15:37:41 1996 @@ -0,0 +1,8 @@ +I found that it was helpful to have the extern stuff actually defined in +one file as not external... + +Still trying to find the other problems + +Whether it is desireable to list stdio.h as a dependency is debateable + +-Joel diff -Nurd linux-86.old/libc/stdio1/TODO linux-86/libc/stdio1/TODO --- linux-86.old/libc/stdio1/TODO Thu Jan 1 01:00:00 1970 +++ linux-86/libc/stdio1/TODO Tue Jan 23 01:48:52 1996 @@ -0,0 +1,33 @@ +Sun Jan 21 18:16:03 EST 1996 -- Nat Friedman +============================================ +I've made a load of changes to this code, but there's still a lot to be done. +- scanf, fscanf + + + + +input, file positioning, eof, declarations of functions, printf + +look for unsigned char references + +specifically +fix printf and figure out what's going on in there. +write idealgetline, scanf, other stuff +then deal with above stuff... + + +LATEST LIST: +printf, fprintf +scanf, fscanf +feof +seek support +error handling (not too hard since system calls only in a few places) +atexit stuff (close files; will need to add a linked list of files) +setvbuf if desired +check that fopen() and stdio_init() fill in ALL the fields +testing! + +rm NOTICE + + + diff -Nurd linux-86.old/libc/stdio1/__ffillbuf.c linux-86/libc/stdio1/__ffillbuf.c --- linux-86.old/libc/stdio1/__ffillbuf.c Thu Jan 1 01:00:00 1970 +++ linux-86/libc/stdio1/__ffillbuf.c Sun Jan 21 22:39:15 1996 @@ -0,0 +1,55 @@ +/* simplified linux __ffillbuf.c + Copyright (C) 1995 Joel N. Weber II + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +#include +#include "stdio.h" + +/* this function makes the mistake of assuming the buffer really DOES +need to be filled. */ + +/* RDB: + * Added simple processing for EOF and errors + * As this is _only_ called from getc() the memory footprint is smaller + * if it pretends to be getc in the complex case. + */ + +int +__ffillbuf(stream) +FILE *stream; +{ + int stat; + + if( stream->fd < 0 || ferror(stream) ) return EOF; + + stat = read(stream->fd, (char *) stream->bufstart, stream->bufend - stream->bufstart); + if( stat > 0 ) + stream->bufread = stream->bufstart + stat; + else if( stat == 0 ) + { + stream->fc_eof = 1; + return EOF; + } + else + { + stream->fc_err = 1; + return EOF; + } + + stream->bufpos = stream->bufstart; + + return getc(stream); +} diff -Nurd linux-86.old/libc/stdio1/__stdio_init.c linux-86/libc/stdio1/__stdio_init.c --- linux-86.old/libc/stdio1/__stdio_init.c Thu Jan 1 01:00:00 1970 +++ linux-86/libc/stdio1/__stdio_init.c Mon Jan 8 23:42:28 1996 @@ -0,0 +1,66 @@ +/* simplified linux __stdio_init.c + Copyright (C) 1995 Joel N. Weber II + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +#include "stdio.h" + +/* + OK, Complete hackup here, I've removed the need for the init function. + Not also I've make the types into 'unsigned char' this is so it doesn't + return EOF when it really means '\377' + */ + +static unsigned char __stdinbuf[BUFSIZ], __stdoutbuf[BUFSIZ], __stderrbuf[80]; + +static FILE __the_stdin = { + 0, + __stdinbuf, + __stdinbuf, + __stdinbuf, + __stdinbuf+sizeof(__stdinbuf), + _IOLBF, + _MODE_READ, + 0, 0, + 0, 0, 1 +}; + +static FILE __the_stdout = { + 1, + __stdoutbuf, + __stdoutbuf, + __stdoutbuf, + __stdoutbuf+sizeof(__stdoutbuf), + _IOLBF, + _MODE_WRITE, + 0, 0, + 0, 0, 1 +}; + +static FILE __the_stderr = { + 2, + __stderrbuf, + __stderrbuf, + __stderrbuf, + __stderrbuf+sizeof(__stderrbuf), + _IOLBF, + _MODE_WRITE, + 0, 0, + 0, 0, 1 +}; + +FILE *stdin = &__the_stdin, + *stdout = &__the_stdout, + *stderr = &__the_stderr; diff -Nurd linux-86.old/libc/stdio1/fclose.c linux-86/libc/stdio1/fclose.c --- linux-86.old/libc/stdio1/fclose.c Thu Jan 1 01:00:00 1970 +++ linux-86/libc/stdio1/fclose.c Sun Jan 21 22:36:33 1996 @@ -0,0 +1,41 @@ +/* simplified linux fclose.c + Copyright (C) 1995 Joel N. Weber II + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +#include +#include "stdio.h" + +int fclose (stream) +FILE *stream; +{ + /* only allow fclose() on what was fopen()ed. */ + /* + This isn't right, there's nothing wrong with fclosing stdin + but the next fopen/open will be given fd 0 and so become stdin + Of course you do have to be a little careful :-) + RDB + */ + + if ((stream == stdin) || (stream == stdout) || (stream == stderr)) return EOF; + + if (fflush(stream)) return EOF; + + if (close(stream->fd)) return EOF; + + free(stream->bufstart); + free(stream); + return 0; +} diff -Nurd linux-86.old/libc/stdio1/fcntl.h linux-86/libc/stdio1/fcntl.h --- linux-86.old/libc/stdio1/fcntl.h Thu Jan 1 01:00:00 1970 +++ linux-86/libc/stdio1/fcntl.h Mon Jan 1 22:46:44 1996 @@ -0,0 +1,72 @@ +#ifndef __FCNTL_H +#define __FCNTL_H + +/* + * Definitions taken from the i386 Linux kernel. + */ + +/* open/fcntl */ + +#define O_ACCMODE 0003 +#define O_RDONLY 00 +#define O_WRONLY 01 +#define O_RDWR 02 +#define O_CREAT 0100 /* not fcntl */ +#define O_EXCL 0200 /* not fcntl */ +#define O_NOCTTY 0400 /* not fcntl */ +#define O_TRUNC 01000 /* not fcntl */ +#define O_APPEND 02000 +#define O_NONBLOCK 04000 +#define O_NDELAY O_NONBLOCK +#if 0 +#define O_SYNC 010000 /* Not supported */ +#define FASYNC 020000 /* Not supported */ +#endif + +#define F_DUPFD 0 /* dup */ +#define F_GETFD 1 /* get f_flags */ +#define F_SETFD 2 /* set f_flags */ +#define F_GETFL 3 /* more flags (cloexec) */ +#define F_SETFL 4 +#define F_GETLK 5 +#define F_SETLK 6 +#define F_SETLKW 7 + +#define F_SETOWN 8 /* for sockets. */ +#define F_GETOWN 9 /* for sockets. */ + +/* for F_[GET|SET]FL */ +#define FD_CLOEXEC 1 /* actually anything with low bit set goes */ + +/* for posix fcntl() and lockf() */ +#define F_RDLCK 0 +#define F_WRLCK 1 +#define F_UNLCK 2 + +/* for old implementation of bsd flock () */ +#define F_EXLCK 4 /* or 3 */ +#define F_SHLCK 8 /* or 4 */ + +/* operations for bsd flock(), also used by the kernel implementation */ +#define LOCK_SH 1 /* shared lock */ +#define LOCK_EX 2 /* exclusive lock */ +#define LOCK_NB 4 /* or'd with one of the above to prevent + blocking */ +#define LOCK_UN 8 /* remove lock */ + +#ifdef __KERNEL__ +#define F_POSIX 1 +#define F_FLOCK 2 +#endif /* __KERNEL__ */ + +#if 0 +struct flock { + short l_type; + short l_whence; + off_t l_start; + off_t l_len; + pid_t l_pid; +}; +#endif + +#endif diff -Nurd linux-86.old/libc/stdio1/fflush.c linux-86/libc/stdio1/fflush.c --- linux-86.old/libc/stdio1/fflush.c Thu Jan 1 01:00:00 1970 +++ linux-86/libc/stdio1/fflush.c Sun Jan 21 22:39:37 1996 @@ -0,0 +1,36 @@ +/* simplified linux fflush.c + Copyright (C) 1995 Joel N. Weber II + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include "stdio.h" + +int fflush(stream) +FILE *stream; +{ + if (stream == 0) return 0; + if ((stream->file_mode == _MODE_WRITE) + ||(stream->file_mode == (_MODE_WRITE & _MODE_RDWR))){ + write(stream->fd, (char *) stream->bufstart, + stream->bufpos - stream->bufstart); + stream->bufpos = stream->bufstart; + } + return 0; +} +/* TODO: return EOF or 0; support NULL stream */ +/* The only place an error can come from is the write; you're not checking RDB + */ diff -Nurd linux-86.old/libc/stdio1/fgetc.c linux-86/libc/stdio1/fgetc.c --- linux-86.old/libc/stdio1/fgetc.c Thu Jan 1 01:00:00 1970 +++ linux-86/libc/stdio1/fgetc.c Fri Jan 5 20:38:24 1996 @@ -0,0 +1,39 @@ +/* + Copyright (C) 1996 Joel N. Weber II + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "stdio.h" + +/* + * Make this not dependent on getc() then we can: + #define getc(fp) fgetc(fp) + * if memory is _really_ tight. + */ + +int fgetc(stream) +FILE *stream; +{ + if( stream->ungetted ) + { + stream->ungetted = 0; + return stream->ungetchar; + } + if( stream->bufpos == stream->bufread ) + return __ffillbuf(stream); + else + return *stream->bufpos++; +} diff -Nurd linux-86.old/libc/stdio1/fgets.c linux-86/libc/stdio1/fgets.c --- linux-86.old/libc/stdio1/fgets.c Thu Jan 1 01:00:00 1970 +++ linux-86/libc/stdio1/fgets.c Sun Jan 14 17:49:50 1996 @@ -0,0 +1,50 @@ +/* fgets.c for limited linux stdio + Copyright (C) 1996 Joel N. Weber II + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "stdio.h" + +/* + RDB BZZZT! This should only read upto and including any newline! +*/ + +char *fgets(s, count, f) +char *s; +size_t count; +FILE *f; +{ + char *ret; + register size_t i; + register int ch; + + ret = s; + for(i=count; i>0; i--) + { + ch = getc(f); + if( ch == EOF ) + { + if(s==ret) return 0; + break; + } + *s++ = (char) ch; + if( ch == '\n' ) break; + } + *s = 0; + + if( ferror(f) ) return 0; + return ret; +} diff -Nurd linux-86.old/libc/stdio1/fopen.c linux-86/libc/stdio1/fopen.c --- linux-86.old/libc/stdio1/fopen.c Thu Jan 1 01:00:00 1970 +++ linux-86/libc/stdio1/fopen.c Mon Jan 8 23:55:15 1996 @@ -0,0 +1,80 @@ +/* simplified linux fopen.c + Copyright (C) 1995 Joel N. Weber II + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +#include "stdio.h" +#include + +FILE * fopen(name, openmode) +char *name; +char *openmode; +{ + FILE *new; + int openplus=0; + char basemode; + + basemode = openmode[0]; + while (openmode[0] != 0){ + switch(openmode[0]){ + case '+': openplus=1; break; + } + openmode++; + } + + new = malloc(sizeof(new)); + if( new == 0 ) return 0; + new->bufread = new->bufpos = new->bufstart = malloc(BUFSIZ); + if( new->bufstart == 0 ) { free(new) ; return 0; } + + new->bufend = new->bufstart + BUFSIZ; + new->buffer_mode = _IOFBF; + new->iotrans = 0; + new->fd = -1; + if (openplus){ + new->file_mode = _MODE_RDWR; + switch (basemode){ + case 'a': + new->fd = open(name, O_RDWR | O_APPEND | O_CREAT); + break; + case 'r': + new->fd = open(name, O_RDWR); + break; + case 'w': + new->fd = open(name, O_RDWR | O_TRUNC | O_CREAT); + break; + } + } else switch (basemode){ + case 'a': + new->fd = open(name, O_WRONLY | O_APPEND | O_CREAT); + new->file_mode = _MODE_WRITE; + break; + case 'r': + new->fd = open(name, O_RDONLY); + new->file_mode = _MODE_READ; + break; + case 'w': + new->fd = open(name, O_WRONLY | O_TRUNC | O_CREAT); + new->file_mode = _MODE_WRITE; + break; + } + if( new->fd < 0 ) + { + free(new->bufstart); + free(new); + return 0; + } + return new; +} diff -Nurd linux-86.old/libc/stdio1/fputc.c linux-86/libc/stdio1/fputc.c --- linux-86.old/libc/stdio1/fputc.c Thu Jan 1 01:00:00 1970 +++ linux-86/libc/stdio1/fputc.c Mon Jan 22 07:51:00 1996 @@ -0,0 +1,53 @@ +/* simplified linux fputc.c + Copyright (C) 1995 Joel N. Weber II + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +#include "stdio.h" + +/* + * Make this not dependent on putc() then we can: + #define putc(c, fp) fputc(c, fp) + * if memory is _really_ tight. + */ + +#undef putc +#define putc(c, stream) \ + (((stream)->bufpos[0] = (c)), \ + ((stream)->bufpos++), \ + ((((stream)->bufpos == (stream)->bufend) \ + ||((stream)->buffer_mode == _IONBF) \ + ||(((stream)->buffer_mode == _IOLBF) \ + && ((stream)->bufpos != (stream)->bufstart) \ + && ((stream)->bufpos[-1] == '\n'))) \ + ? fflush(stream):0)) + +#define new_putc(c, stream) \ + ((unsigned char)( \ + ((stream)->bufpos>=(stream)->bufread) ? fputc((c), (stream)) \ + : *(stream)->bufpos++ = (c) \ + )) + +int +fputc(int c, FILE * stream) +{ +#ifdef __MSDOS__ + if( c == '\n' && stream->iotrans ) fputc('\r', stream); +#endif + return putc(c, stream); +} + + + diff -Nurd linux-86.old/libc/stdio1/fputs.c linux-86/libc/stdio1/fputs.c --- linux-86.old/libc/stdio1/fputs.c Thu Jan 1 01:00:00 1970 +++ linux-86/libc/stdio1/fputs.c Sun Jan 21 23:18:33 1996 @@ -0,0 +1,32 @@ +/* simplified linux fputs.c + Copyright (C) 1995 Joel N. Weber II + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +#include +#include +#include "stdio.h" + +int +fputs(__const char * string, FILE * stream) +{ + if (stream->buffer_mode != _IONBF){ + while (string[0] != 0){ + putc(string[0], stream); + string++; + } + } else write(stream->fd, string, strlen(string)); + return 0; +} diff -Nurd linux-86.old/libc/stdio1/idealgetline.c linux-86/libc/stdio1/idealgetline.c --- linux-86.old/libc/stdio1/idealgetline.c Thu Jan 1 01:00:00 1970 +++ linux-86/libc/stdio1/idealgetline.c Fri Jan 5 20:49:32 1996 @@ -0,0 +1,67 @@ +/* idealgetline.c -- my idea of an ideal getline function for stdio + Copyright (C) 1996 Joel N. Weber II + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/* I actually intend to use this in 32 bit programs, unlike the other stuff + in this lib. IMHO GNU getline is broken. It is too hard to use. + + Just pass this function a FILE * and it will retrieve a line for you using + getc(). It will realloc() exactly the amount of memory needed, and will + generate error messages for non-ascii characters on stderr. + + This may not be your ideal. It probably generates far too many errors. + It doesn't work well for those who don't use English (but since + Linux-less-than-32 libc and kernels are each being produced by one + person in the US and one in the UK, this isn't a problem). It probably + is not what you (or I) want for interactive input. + + You're welcome to modify this routine to meet your needs. However, if + you change the semantics significantly, please change the name. + + (Maybe I should have put my own name on it so there will be no confusion + about who thought it was ideal). */ + +#include +#include + +char *idealgetline(f) +FILE *f; +{ + char c; + char *ret; + int size = 0, bufsize = 256; + + ret = malloc(256); + c = getc(f); + while ((c != EOF) && (c != '\n')){ + if ((c >= ' ') && (c <= 126)){ + ret[size] = c; + size++; + if (size == bufsize){ + bufsize += 256; + ret = realloc(ret, bufsize); + } + } else { + fprintf(stderr, "Unexpected character 0x%x encountered in input", c); + free(ret); + return 0; + } + } + ret[size] = '\0'; + size++; + return realloc(ret, size); +} diff -Nurd linux-86.old/libc/stdio1/makefile linux-86/libc/stdio1/makefile --- linux-86.old/libc/stdio1/makefile Thu Jan 1 01:00:00 1970 +++ linux-86/libc/stdio1/makefile Wed Mar 20 21:11:48 1996 @@ -0,0 +1,36 @@ +TOP=.. +include $(TOP)/Make.defs +OBJ = __ffillbuf.o __stdio_init.o fflush.o fgetc.o fgets.o \ + fputc.o fputs.o puts.o printf.o fopen.o fclose.o scanf.o + +#missing functions from above: printf etc, scanf etc, idealgetline +#seek + +#fopen.c, fclose.c removed because of malloc() use + +CFLAGS+=$(WALL) + +ifeq ($(PLATFORM),i86-ELKS) +CFLAGS=$(CCFLAGS) $(DEFS) -ansi +endif + +all: $(OBJ) + +libc.a: $(OBJ) + ar r ../$(LIBC) $(OBJ) + @touch libc.a + +$(OBJ): stdio.h + +test: test.o $(OBJ) + $(CC) -o test test.o $(OBJ) + +%.o: %.c + $(CC) $(CFLAGS) -o $@ $< -c + +clean: + rm -f *.o test libc.a + +transfer: + -@rm -f ../include/stdio.h + cp -p stdio.h ../include/. diff -Nurd linux-86.old/libc/stdio1/old_printf.c linux-86/libc/stdio1/old_printf.c --- linux-86.old/libc/stdio1/old_printf.c Thu Jan 1 01:00:00 1970 +++ linux-86/libc/stdio1/old_printf.c Tue Feb 13 06:42:48 1996 @@ -0,0 +1,230 @@ +/* fprintf.c for limited Linux libc + Copyright (C) 1996 Joel N. Weber II + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +/* Thanks Alan for writing the hard routine for me :-) + * Alan said that this works "most of the time". Something tells me I'm making + * it even worse! */ +/* The basic idea here is to make fprintf the core routine. printf obviously + can just call fprintf with stdout followed by all of its arguments. + sprintf() works using the fake file &the_sprintf. It's marked as fully + buffered, so that it will only write(2) when &the_sprintf->bufpos == + &the_sprintf->bufend, which I doubt will happen since &the_sprintf->bufend + = 0. The trick is that sprintf must set &the_sprintf->bufstart = + &the_sprintf->bufpos = its first argument. Not as orthagonal (is that + the right word?) as glibc's facilities for non-files, but this isn't a + library for people who have unlimited RAM budgets. (not like the libc + I use on linux/i586 enjoys an unlimited RAM budget either; I only have + 8 MB + + I'm not sure what the "correct" way to pass the variable arguments + from one function to the next is. Rather than pass the arguments + themselves, I'm passing a pointer to them. However, the following + explaination from Alan is probably a polite way of saying it will not + work on a 386 anyway. + Joel Weber + + [ I've migrated all of this code over to the ELKS stdarg that I wrote. + The accepted way to do it is for the wrapper function to accept a + variable number of arguments, use stdarg to make an argument pointer, + and then pass the argument pointer on to the core function, as I've + done here. This should definitely work on a 386, as the arguments + are still passed in the stack, and stack order is maintained. -Nat ] + */ + +/* + * This is NOT stunningly portable, but works + * for pretty dumb non ANSI compilers and is + * tight. Adjust the sizes to taste. + * + * Illegal format strings will break it. Only the + * following simple subset is supported + * + * %x - hex + * %d - decimal + * %s - string + * %c - char + * + * And the h/l length specifiers for %d/%x + * + * Alan Cox. + */ + +#include +#include "stdio.h" + +/* 17 to make sure that there's room for the trailing newline. + I'm not really sure if this is ideal... */ +static char nstring[17]="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]; +} + +static int +internal_fprintf(FILE * stream, __const char * fmt, va_list ap) +{ + register int c; + int count = 0; + int type, base; + + while(c=*fmt++) + { + if(c!='%') + { + putc(c, stream); + count++; + } + else + { + type=1; + do { c=*fmt++; } while( c=='.' || (c>='0' && c<='9')); + if( c == 0 ) break; + if(c=='h') + { + c=*fmt++; + type = 0; + } + else if(c=='l') + { + c=*fmt++; + type = 2; + } + + switch(c) + { + case 'x': + case 'o': + case 'd': + if (c=='x') base=16; + if (c=='o') base=8; + if (c=='d') base=10; + { + long 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; + } + fputs((__const char *)__numout(val,base),stream); + } + break; + case 's': + { + char *cp; + cp=va_arg(ap, char *); + while(*cp) + putc(*cp++, stream); + break; + } + case 'c': + putc(va_arg(ap, int), stream); + break; + default: + putc(c, stream); + } + } + } + return count; +} + + +int +fprintf(FILE * stream, __const char * fmt, ...) +{ + va_list ap; + int retval; + va_start(ap, fmt); + retval=internal_fprintf(stream, fmt, ap); + va_end(ap); + return(retval); +} + +int +printf(__const char * fmt, ...) +{ + va_list ap; + int retval; + va_start(ap, fmt); + retval=internal_fprintf(stdout, fmt, ap); + va_end(ap); + return(retval); +} + +/* This is a strange way of doing sprintf, but it should work */ +int sprintf(char * s, __const char * fmt, ...) +{ + static FILE the_sprintf = { + -1, + 0, + 0, + 0, + 0, + _IOFBF, + _MODE_WRITE, + 0, 0, + 0, 0}; + va_list ap; + int retval; + + va_start(ap, fmt); + the_sprintf.bufstart = the_sprintf.bufpos = (unsigned char *) s; + the_sprintf.fc_err = 0; + + retval = internal_fprintf(&the_sprintf, fmt, ap); + /* null-terminate the string */ + putc('\0', &the_sprintf); + + va_end(ap); + return retval; +} + + + + + diff -Nurd linux-86.old/libc/stdio1/printf.c linux-86/libc/stdio1/printf.c --- linux-86.old/libc/stdio1/printf.c Thu Jan 1 01:00:00 1970 +++ linux-86/libc/stdio1/printf.c Sat Feb 24 12:56:00 1996 @@ -0,0 +1,649 @@ +/* fprintf.c for limited Linux libc + Copyright (C) 1996 Joel N. Weber II + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +/* Thanks Alan for writing the hard routine for me :-) + * Alan said that this works "most of the time". Something tells me I'm making + * it even worse! */ +/* The basic idea here is to make fprintf the core routine. printf obviously + can just call fprintf with stdout followed by all of its arguments. + sprintf() works using the fake file &the_sprintf. It's marked as fully + buffered, so that it will only write(2) when &the_sprintf->bufpos == + &the_sprintf->bufend, which I doubt will happen since &the_sprintf->bufend + = 0. The trick is that sprintf must set &the_sprintf->bufstart = + &the_sprintf->bufpos = its first argument. Not as orthagonal (is that + the right word?) as glibc's facilities for non-files, but this isn't a + library for people who have unlimited RAM budgets. (not like the libc + I use on linux/i586 enjoys an unlimited RAM budget either; I only have + 8 MB + + I'm not sure what the "correct" way to pass the variable arguments + from one function to the next is. Rather than pass the arguments + themselves, I'm passing a pointer to them. However, the following + explaination from Alan is probably a polite way of saying it will not + work on a 386 anyway. + Joel Weber + + [ I've migrated all of this code over to the ELKS stdarg that I wrote. + The accepted way to do it is for the wrapper function to accept a + variable number of arguments, use stdarg to make an argument pointer, + and then pass the argument pointer on to the core function, as I've + done here. This should definitely work on a 386, as the arguments + are still passed in the stack, and stack order is maintained. -Nat ] + */ + +/* + * This is NOT stunningly portable, but works + * for pretty dumb non ANSI compilers and is + * tight. Adjust the sizes to taste. + * + * Illegal format strings will break it. Only the + * following simple subset is supported + * + * %x - hex + * %d - decimal + * %s - string + * %c - char + * + * And the h/l length specifiers for %d/%x + * + * Alan Cox. + */ + +#include +#include "stdio.h" + +/* 17 to make sure that there's room for the trailing newline. + I'm not really sure if this is ideal... */ +static char nstring[17]="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]; +} + +int +fprintf(FILE * stream, __const char * fmt, ...) +{ + va_list ap; + int retval; + va_start(ap, fmt); + retval=internal_fprintf(stream, fmt, ap); + va_end(ap); + return(retval); +} + +int +printf(__const char * fmt, ...) +{ + va_list ap; + int retval; + va_start(ap, fmt); + retval=internal_fprintf(stdout, fmt, ap); + va_end(ap); + return(retval); +} + +/* This is a strange way of doing sprintf, but it should work */ +int sprintf(char * s, __const char * fmt, ...) +{ + static FILE the_sprintf = { + -1, + 0, + 0, + 0, + 0, + _IOFBF, + _MODE_WRITE, + 0, 0, + 0, 0}; + va_list ap; + int retval; + + va_start(ap, fmt); + the_sprintf.bufstart = the_sprintf.bufpos = (unsigned char *) s; + the_sprintf.fc_err = 0; + + retval = internal_fprintf(&the_sprintf, fmt, ap); + /* null-terminate the string */ + putc('\0', &the_sprintf); + + va_end(ap); + return retval; +} + + + + + +/* + * printf.c - This is the more complete fprintf() replacement for libc8086 + * Copyright (C) 1996 Steven Huang . + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include +#include + +/* + * This decides if the little test main program gets included + */ +#undef TEST +/* + * This decides if printf() should act like standard. When undefined, + * - prints out "(err)" if a bad format is encountered + * - supports the %b (binary) format + */ +#define STANDARD + +/* + * Shut bcc up about 'const', which doesn't seem to be handled right + * by unproto. + */ +#ifdef __BCC__ +#define const +#endif + +#define BUF_SIZE 128 +#define OUTC(c) { putc(c, stream); n++; } +#define max(a, b) ((a > b) ? a : b) +/* + * if you change the ff, you need to change the order of characters in + * the string 'flagstr' defined in _printf() + */ +#define FLAG_PADZERO (1<<0) +#define FLAG_LEFTJUST (1<<1) +#define FLAG_SIGNED (1<<2) +#define FLAG_ALT (1<<3) +#define FLAG_SPACE (1<<4) + +static char *utoa(unsigned int val, char *buf, int radix) +/* + * Converts an integer to a variable-radix string representation + * + * Note: + * Does not perform sanity checking for 'radix' + * Assumes 'buf' has memory allocated to it + */ +{ + int divisor; + char *p = buf; + const char *digitstr = "0123456789abcdef"; + + for (divisor = 1; val / divisor >= radix; divisor *= radix); + do { + *p++ = digitstr[val / divisor]; + val %= divisor; + divisor /= radix; + } while (divisor >= 1); + *p = '\0'; + return(buf); +} + +static +internal_fprintf(FILE * stream, const char * fmt, char *args) + +/* static int _printf(FILE *stream, const char *fmt, char *args) */ +/* + * The one that does all the work. + * This is a fairly complete implementation of printf(), supporting + * everything EXCEPT: + * - floating point (eEDOUfg formats) + * - pointers (realizes them but doesn't understand how to print them) + * - short and long (h/l) modifiers (dunno what to do about them) + * It's even slightly faster than gcc's printf() on Linux. Can't beat + * HP-UX's printf() though ;) + * + * Supports: + * d, signed integer + * i + * o unsigned octal integer + * u unsigned integer + * x unsigned hex lowercase a-f + * X unsigned hex uppercase A-F + * c character + * s string (character pointer) + * p void pointer (ignores it) + * % % character + * n number of characters output so far + * + * Special feature: (no really, it's not a bug =) ) + * b prints an integer in binary form (i think this might come + * in handy *somewhere*) + * + * # alternate format for octal (leading 0) and hex (0x/0X) + * 0 leading zeroes for d, i, o, u, x, and X + * - left justify, overrides '0' + * ' ' (space) force a blank in front of positive numbers + * + force a sign in front of any number + * + * width.precision, including support for '*' (reads value from + * the parameter list (MUST BE INT)) + * + * h, short/long modifiers, recognized but ignored. + * l + * + * Warning: + * The way varargs is implemented in libc is evil. Don't think + * there's a better way, but misaligned or wrong parameters + * passed to printf() can break a lot of things. I've tried my + * best to handle errors in the format string, though. + * + * Each %something field cannot exceed 'BUF_SIZE' characters, + * which I set to 128 right now. %s fields are not subject to + * this limit. + * + * Note: + * The semicolon -looks- missing in a few places but that's + * because of the macro def of 'OUTC'. did it that way to + * save a few lines of source ;) + * + * Expects a 'char *' as varargs parameter, unlike libc8086's + * printf(), which takes a 'int *' then casts it to a 'char *'. + * Either has to change, but it should be trivial. + * + * This function aborts whenever it scans an illegal format, unlike + * gcc's libc which prints out the illegal format as if it's -not- + * a format string. The 'STANDARD' preprocessor flag controls if + * if just aborts (when defined) or prints out "(err)" (when undefined). + */ +{ + /* + * the "0-+# " and "dcs..." strings are listed in my idea of their + * frequency of use, with the most popular in front. not terribly + * important but strchr() might have an easier time that way. + * if you change the ordering of 'flagstr', make sure you update + * the #define FLAG_* stuff on top of this file too. + */ + char c, *s, *f; + const char *flagstr = "0-+# ", +#ifdef STANDARD + *typestr = "dcsixXuop"; +#else + *typestr = "dcsixXuopb"; +#endif + int n = 0, flags, width, actwidth, prec, bad = 0, neg, i; + static char buf[BUF_SIZE]; + + for (c = *fmt++; c && !bad;) { + if (c != '%') { /* just copy */ + OUTC(c); + c = *fmt++; + } + else { + c = *fmt++; /* chew the % sign */ + flags = width = prec = 0; + /* + * Parse the "0-+# " flags + */ + while ((f = strchr(flagstr, c)) != NULL) { + flags |= 1 << (f - flagstr); + c = *fmt++; + } + /* + * The '*' parameter says fetch width value from varargs + */ + if (c == '*') { + width = *(int *) args; + args += sizeof(int); + if (width < 0) { + width = abs(width); + flags |= FLAG_LEFTJUST; /* set '-' flag */ + } + c = *fmt++; + } + else + /* + * scan and convert the width parameter + */ + if (isdigit(c)) + while (isdigit(c)) { + width *= 10; + width += c - '0'; + c = *fmt++; + } + /* + * a '.' means there may be a precision parameter + */ + if (c == '.') { + c = *fmt++; + /* + * fetch precision value from varargs + */ + if (c == '*') { + prec = *(int *) args; + if (prec < 0) + prec = 0; + args += sizeof(int); + c = *fmt++; + } + else + /* + * scan and convert precision field + */ + if (isdigit(c)) + while (isdigit(c)) { + prec *= 10; + prec += c - '0'; + c = *fmt++; + } + } + /* + * short and long modifiers. ignored for the moment + */ + if (c == 'h') { + c = *fmt++; + } + else + if (c == 'l') { + c = *fmt++; + } + /* + * check if it's a valid type "dioux..." + */ + if (strchr(typestr, c) != NULL) { + neg = 0; + switch (c) { + case 'd': + case 'i': { + int val = *(int *) args; + args += sizeof(int); + neg = (val < 0); + val = abs(val); + actwidth = strlen(utoa(val, buf, 10)); } + /* + * if negative or '+'/' ' flags set + */ + if (neg || (flags & FLAG_SIGNED) || (flags & FLAG_SPACE)) + actwidth++; + break; + case 'u': { + unsigned int uval = *(unsigned int *) args; + args += sizeof(unsigned int); + actwidth = strlen(utoa(uval, buf, 10)); } + /* + * if '+'/' ' flags set + */ + if ((flags & FLAG_SIGNED) || (flags & FLAG_SPACE)) + actwidth++; + break; + case 'x': + case 'X': { + int val = *(int *) args; + args += sizeof(int); + actwidth = strlen(utoa(val, buf, 16)); } + if (flags & FLAG_ALT) + actwidth += 2; + break; + case 'o': { + int val = *(int *) args; + args += sizeof(int); + actwidth = strlen(utoa(val, buf, 8)); } + if (flags & FLAG_ALT) + actwidth++; + break; + case 's': + s = *(char **) args; + args += sizeof(char *); + actwidth = strlen(s); + break; + case 'c': + buf[0] = *(char *) args; + buf[1] = '\0'; + args += sizeof(char); + actwidth = 1; + break; + /* + * dunno how to handle pointers - what's the format of + * linux86 pointers?! right now just prints "(ptr)" + */ + case 'p': + strcpy(buf, "(ptr)"); + args += sizeof(void *); + actwidth = strlen(buf); + s = buf; /* pretend we're a string */ + c = 's'; + break; +#ifndef STANDARD + case 'b': { + int val = *(int *) args; + args += sizeof(int); + actwidth = strlen(utoa(val, buf, 2)); } + break; +#endif + } + /* + * strings behave differently to the width.precision + * parameters, so handle separately. besides, we avoid + * an extra 'memcpy' to 'buf' + */ + if (c == 's') { + if (prec == 0) + prec = actwidth; + width = max(width, prec); + /* + * pad to the left if not left justified + */ + if (!(flags & FLAG_LEFTJUST)) { + for (i = width; i > prec; i--) + OUTC(' '); + } + /* + * print out entire string if no precision specified, otherwise + * that's our upper limit + */ + if (prec == 0) + for (; *s; s++) + OUTC(*s) /* no semicolon here */ + else + for (i = 0; i < prec; i++) + OUTC(s[i]); + } + else { + /* + * precision is as wide as width if it's not specified and + * the leading zero '0' flag is set, and left-justify is + * -not- set. c standard says left justify overrides the + * leading 0. + */ + if (prec == 0 && (flags & FLAG_PADZERO) && !(flags & FLAG_LEFTJUST)) + prec = width; + /* + * expand width.precision to fit the actual width. printf + * width specifies the -minimum-, and aside from the + * precision of %s fields, there's no way to specify maximum + */ + prec = max(prec, actwidth); + width = max(width, prec); + /* + * pad to the left if we're not left justified + */ + if (!(flags & FLAG_LEFTJUST)) { + for (i = width; i > prec; i--) + OUTC(' '); + } + /* + * check if we might need to print the sign + */ + if (strchr("diu", c) != NULL) { + if (neg) /* print if negative */ + OUTC('-') /* yes, no ';' here =) */ + else + if (flags & FLAG_SIGNED) /* or '+' specified */ + OUTC('+') /* nor here */ + else + if (flags & FLAG_SPACE) /* or ' ' specified */ + OUTC(' ') /* nor here */ + } + /* + * the alternate '#' flag is set. doesn't affect all though + */ + if (flags & FLAG_ALT) { + switch (c) { + case 'o': + OUTC('0'); /* leading zero for octals */ + break; + case 'x': + case 'X': /* prints 0x or 0X */ + OUTC('0'); + OUTC(c); + break; + } + } + /* + * fill the precision field with either spaces or zeroes, + * depending if we're printing numbers + */ + if (strchr("diuxXo", c) != NULL) + for (i = prec; i > actwidth; i--) + OUTC('0') + else + for (i = prec; i > actwidth; i--) + OUTC(' '); + /* + * print the field, except for 'X', which we convert to caps + */ + if (c != 'X') + for (f = buf; *f; f++) + OUTC(*f) /* none here either */ + else + for (f = buf; *f; f++) + OUTC(toupper(*f)); + } + /* + * if we're left justified, we now need to pad spaces to the + * right so that width will be correct + */ + if (flags & FLAG_LEFTJUST) + for (i = width; i > prec; i--) + OUTC(' '); + } + else { + /* + * miscellaneous %thingies + */ + switch (c) { + case '%': /* %% -> % */ + OUTC('%'); + break; + case 'n': /* %n writes current output count */ + *(*(int **) args) = n; + args += sizeof(int *); + break; + default: /* oops, got a bad %thingy */ + bad = 1; + } + } + c = *fmt++; + } + } +#ifndef STANDARD + /* + * dunno what the standard wants if the format string is badly + * formed, so i print (err) if the debug flag is set + */ + if (bad) { + OUTC('('); + OUTC('e'); + OUTC('r'); + OUTC('r'); + OUTC(')'); + } +#endif + return(n); +} + +#ifdef TEST + +#include + +int main() +{ + static unsigned char xbuf[128], *x; + char *fmt = "%s, %s %d, %.*d:%.*d\n"; + int rv1, rv2, i, dt1, dt2; + clock_t t1, t2; + + x = xbuf; + *(char **) x = "Sun"; + x += sizeof(char *); + *(char **) x = "Feb"; + x += sizeof(char *); + *(int *) x = 18; + x += sizeof(int); + *(int *) x = 2; + x += sizeof(int); + *(int *) x = 10; + x += sizeof(int); + *(int *) x = 2; + x += sizeof(int); + *(int *) x = 56; + x += sizeof(int); + t1 = clock(); + for (i = 0; i < 1000; i++) + rv1 = _printf(stdout, fmt, xbuf); + t2 = clock(); + dt1 = t2 - t1; + + t1 = clock(); + for (i = 0; i < 1000; i++) + rv2 = printf(fmt, "Sun", "Feb", 18, 2, 10, 2, 56); + t2 = clock(); + dt2 = t2 - t1; + + printf("\nrv1: %d, rv2: %d, dt1: %d, dt2: %d\n", rv1, rv2, dt1, dt2); + return(0); +} + +#endif diff -Nurd linux-86.old/libc/stdio1/puts.c linux-86/libc/stdio1/puts.c --- linux-86.old/libc/stdio1/puts.c Thu Jan 1 01:00:00 1970 +++ linux-86/libc/stdio1/puts.c Fri Jan 5 21:09:04 1996 @@ -0,0 +1,26 @@ +/* simplified linux puts.c + Copyright (C) 1995 Joel N. Weber II + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +#include "stdio.h" + +int puts (string) +char *string; +{ + fputs(string, stdout); + putc('\n', stdout); + return 0; +} diff -Nurd linux-86.old/libc/stdio1/scanf.c linux-86/libc/stdio1/scanf.c --- linux-86.old/libc/stdio1/scanf.c Thu Jan 1 01:00:00 1970 +++ linux-86/libc/stdio1/scanf.c Tue Feb 13 22:21:21 1996 @@ -0,0 +1,151 @@ +/* scanf.c for limited Linux libc + Copyright (C) 1996 Joel N. Weber II + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/* This scanf code was derived from my printf code, which in turn was + * derived from Alan Cox's printk. It was tested by [no one so far...] + */ + +/* Disclaimer: I haven't even THOUGHT about testing this. If you do decide + * to be brave and test it, and it doesn't work, you have the following + * options: + * o Send me mail telling me it doesn't work, which I will ignore + * since I already knew that. + * o Fix it yourself + * o isolate the problem and send it to the list, and maybe + * I'll fix it + */ + +/* BTW, the above comment may be destroyed once this has been tested. It's + * not nessisary for my great great grandchildren to see it when they + * take Ancient Linux History... + */ + +/* Incidentally, if it doesn't work, it may well be because I never bothered + * to learn how to use scanf()...I briefly tried it for the usaco qualification + * round, but had some wierd problems...ask me after mid February...BTW the + * problems had nothing to do with scanf(); it was still broken (hopelessly) + * when I went to getchar(). + */ + +/* Note, too that the current version probably assumes some things with + * variable argument handling that it shouldn't. Don't expect this to + * work on a 386 in 32 bit mode, don't expect this to work on a Z80, + * or anything other than an 8086. In fact, don't expect it to even + * work on an 8086 ;-) + */ + +/* One of these days the headers will work painlessly... */ +/* #include */ +/* #include */ +#include "stdio.h" + +/* note that we assume base == 10... */ +static int numin(int *num, int base, FILE *stream, int c) +{ + if ((c < '0') || (c > '9')) return 0; + *num = 0; + while ((c >= '0') && (c <= '9')) { + *num = *num * base + c - '0'; + c = getc(stream); + } + ungetc(c, stream); +} + +/* currently, the h/l specifications are ignored */ +static int internal_scanf(stream,fmt,a1) +FILE *stream; +char *fmt; +int *a1; +{ + unsigned char *p=(char *)a1; + char c; + int inc; + int count = 0; + + while(c=*fmt++) + { + do { + inc = getc(stream); + } while ((inc == ' ') || (inc == '\t') || (inc == '\n')); + + if ((c == '\n') || (c == '\t') || (c == ' ')) + ; + else if (c!='%') { + if (c != inc) { + ungetc(inc, stream); + return count; + } + } else { + int len=2; + c=*fmt++; + if(c=='h') c=*fmt++; + else if(c=='l') c=*fmt++; + + switch(c) + { + case 'x': + if (numin(p, 16, stream, inc)) count++; + else return count; + p+=2; + break; + case 'd': + if (numin(p, 10, stream, inc)) count++; + else return count; + p+=2; + break; + case 's': + { + char *cp=*((char **)p); + p+=sizeof(char *); + while(*cp) + putc(cp++, stream); + while ((inc != ' ') && (inc != '\t') + && (inc != '\n') && (inc != EOF)) { + *cp++ = inc; + inc = getc(stream); + } + ungetc(inc, stream); + break; + } + case 'c': + *p++ = inc; + p++; + break; + default: + putc('?', stream); + } + } + } + return count; +} + + +int fscanf(stream,fmt,a1) +FILE *stream; +char *fmt; +int a1; +{ + return internal_fscanf(stream,fmt,&a1); +} + +int scanf(fmt,a1) +char *fmt; +int a1; +{ + return internal_fscanf(stdout,fmt,&a1); +} diff -Nurd linux-86.old/libc/stdio1/stdio.h linux-86/libc/stdio1/stdio.h --- linux-86.old/libc/stdio1/stdio.h Thu Jan 1 01:00:00 1970 +++ linux-86/libc/stdio1/stdio.h Sun Feb 18 19:59:51 1996 @@ -0,0 +1,135 @@ +/* simplified linux stdio.h + Copyright (C) 1995 Joel N. Weber II + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include +#include + +#ifndef __STDIO_H +#define __STDIO_H + +/* when you add or change fields here, be sure to change the initialization + * in stdio_init and fopen */ +struct __stdio_file { + int fd; /* the file descriptor associated with the stream */ + unsigned char *bufstart; /* the start of the buffer */ + unsigned char *bufpos; /* the next byte to write to or read from */ + unsigned char *bufread; /* the end of data returned by last read() */ + unsigned char *bufend; /* the end of the buffer; ie the byte after the last + malloc()ed byte */ + int buffer_mode; +#define _IONBF 0xB111 /* no buffering */ +#define _IOLBF 0xB112 /* line buffering */ +#define _IOFBF 0xB113 /* full buffering */ + int file_mode; +#define _MODE_READ 0xB121 +#define _MODE_WRITE 0xB122 +#define _MODE_RDWR 0xB124 /* used when a file is readwrite and is ord with + what's in the buffer now */ + unsigned char ungetted, ungetchar; + /* ungetted = 1 if there's data unread; else 0 + ungetchar contains the character */ + int fc_eof:1; + int fc_err:1; /* eof and error conditions */ + int iotrans:1; /* Translate \n -> \r\n on MSDOS */ +}; + +#define EOF (-1) + +typedef struct __stdio_file FILE; + +#define BUFSIZ 256 + +extern FILE *stdin, *stdout, *stderr, *__stdsprintf; + +/* The following macros are used for all access to the buffers. If you + * know the file is unbuffered, however, you may write to it directly, as + * fputs.c does. However, be aware that sprintf assumes that by setting + * bufend to 0, no file writing will occur. Also, since NO streams use + * unbuffered mode by default and the function to change this behavior is + * not implemented yet, I'm considering disallowing raw access at the cost + * of having each byte of a string written individually. However, that + * IS what you're asking for with non-buffered mode. + * + * RDB: It's considered very bad form to use the raw read() & write() + * calls on the same files you use the stdio functions. + */ +#ifdef __MSDOS__ +#define putc(c, fp) fputc(c, fp) +#define getc(fp) fgetc(fp) +#else +#define putc(c, stream) \ + (((stream)->bufpos[0] = (c)), \ + ((stream)->bufpos++), \ + ((((stream)->bufpos == (stream)->bufend) \ + ||((stream)->buffer_mode == _IONBF) \ + ||(((stream)->buffer_mode == _IOLBF) \ + && ((stream)->bufpos != (stream)->bufstart) \ + && ((stream)->bufpos[-1] == '\n'))) \ + ? fflush(stream):0)) + +#define getc(stream) \ + ((stream)->ungetted ? (((stream)->ungetted = 0), ((stream)->ungetchar)) : \ + (((stream)->bufpos == (stream)->bufread)?__ffillbuf(stream): \ + (*(stream)->bufpos++))) + +#endif + +#define putchar(c) putc((c), stdout) +#define getchar() getc(stdin) +#define ungetc(c, stream) (((stream)->ungetted = 1), ((stream)->ungetchar = c)) + +#define ferror(fp) ((fp)->fc_err) +#define feof(fp) ((fp)->fc_eof) + +#define fileno(fp) ((fp)->fd) +/* declare functions; not like it makes much difference without ANSI */ +/* RDB: The return values _are_ important, especially if we ever use + 8086 'large' model + */ + +#ifndef __P +#define __P(x) () +#endif + +int setvbuf __P((FILE*, char*, int, size_t)); +int __ffillbuf __P((FILE*)); +void __stdio_init __P((void)); +int fclose __P((FILE*)); +int fflush __P((FILE*)); +int fgetc __P((FILE*)); +char *fgets __P((char*, size_t, FILE*)); +FILE *fopen __P((char*, char*)); + +int fputc __P((int, FILE*)); +int fputs __P((__const char*, FILE*)); +char *idealgetline __P((FILE*)); +int puts __P((char*)); + +int printf __P ((__const char *, ...)); +int fprintf __P ((FILE *, __const char *, ...)); +int sprintf __P ((char *, __const char *, ...)); + +#ifndef SEEK_SET +#define SEEK_SET 0 +#define SEEK_CUR 1 +#define SEEK_END 2 +#endif + +#endif /* __STDIO_H */ +/* TODO: add scanf, fscanf */ diff -Nurd linux-86.old/libc/stdio1/test.sh linux-86/libc/stdio1/test.sh --- linux-86.old/libc/stdio1/test.sh Thu Jan 1 01:00:00 1970 +++ linux-86/libc/stdio1/test.sh Mon Jan 22 07:17:50 1996 @@ -0,0 +1,12 @@ +#!/bin/sh + +echo 'rm -f *.o test *.a' +rm -f *.o test *.a +echo 'make' +make +echo 'ar r libnat.a *.o' +ar r libnat.a *.o +echo 'ranlib libnat.a' +ranlib libnat.a +echo 'gcc test.c -I- -I../include -fno-builtin -o test.o -L./ -lnat' +gcc test.c -I- -I../include -fno-builtin -o test.o -L./ -lnat diff -Nurd linux-86.old/libc/stdio2/stdio.c linux-86/libc/stdio2/stdio.c --- linux-86.old/libc/stdio2/stdio.c Mon Mar 31 20:13:53 1997 +++ linux-86/libc/stdio2/stdio.c Tue Aug 12 21:33:43 1997 @@ -107,7 +107,8 @@ #ifndef __AS386_16__ #ifndef __AS386_32__ static int first_time = 1; - if( !first_time ) return ; first_time = 1; + if( !first_time ) return ; + first_time = 0; #endif #endif if (isatty(1)) @@ -182,6 +183,10 @@ /* Nothing in the buffer - fill it up */ if (fp->bufpos >= fp->bufread) { + /* Bind stdin to stdout if it's open and line buffered */ + if( fp == stdin && stdout->fd >= 0 && (stdout->mode & _IOLBF )) + fflush(stdout); + fp->bufpos = fp->bufread = fp->bufstart; ch = fread(fp->bufpos, 1, fp->bufend - fp->bufstart, fp); if (ch == 0) @@ -244,7 +249,7 @@ bstart+=cc; len-=cc; } } - while ( cc>0 || (cc == -1 && errno == EINTR)); + while ( len>0 && (cc>0 || (cc == -1 && errno == EINTR))); /* * If we get here with len!=0 there was an error, exactly what to * do about it is another matter ... diff -Nurd linux-86.old/libc/syscall/Makefile linux-86/libc/syscall/Makefile --- linux-86.old/libc/syscall/Makefile Sat Mar 8 20:16:33 1997 +++ linux-86/libc/syscall/Makefile Sun Aug 17 15:24:03 1997 @@ -2,12 +2,8 @@ # This file is part of the Linux-8086 C library and is distributed # under the GNU Library General Public License. -LSRC=syslibc.c -LOBJ=time.o abort.o wait.o waitpid.o wait3.o killpg.o setpgrp.o sleep.o \ - usleep.o - -LSRC0=syslib0.c -LOBJ0=__cstartup.o lseek.o getpid.o getppid.o getuid.o geteuid.o getgid.o \ +LSRC=syslib0.c +LOBJ=__cstartup.o lseek.o getpid.o getppid.o getuid.o geteuid.o getgid.o \ getegid.o dup2.o dup.o getpgrp.o times.o ESRC=exec.c @@ -17,7 +13,7 @@ DOBJ=opendir.o closedir.o readdir.o ifeq ($(LIB_CPU)-$(LIB_OS),i86-ELKS) -OBJ=$(LOBJ0) $(LOBJ) $(DOBJ) $(EOBJ) signal.o setjmp.o +OBJ=$(LOBJ) $(LOBJ) $(DOBJ) $(EOBJ) signal.o setjmp.o SYSCALLS=call_i86 endif @@ -47,10 +43,6 @@ $(AR) $(ARFLAGS) $@ $*.o $(LIBC)($(EOBJ)): $(ESRC) - $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o - $(AR) $(ARFLAGS) $@ $*.o - -$(LIBC)($(LOBJ0)): $(LSRC0) $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o $(AR) $(ARFLAGS) $@ $*.o diff -Nurd linux-86.old/libc/syscall/TODO linux-86/libc/syscall/TODO --- linux-86.old/libc/syscall/TODO Mon Dec 9 22:48:02 1996 +++ linux-86/libc/syscall/TODO Tue Aug 12 20:21:09 1997 @@ -3,3 +3,128 @@ Idea, for RPC syscall, seperate all the FD related calls from the system ones IIRC all the single FD related ones have the FD in arg0 + +-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +Subject: 8086 Shared Libs and local RPC. + +True shared libs are impossible with the 8086 in small model. +BUT we can use RPC type links to provide a similar system. + +Client side +----------- + +shl_open("socket", 0x81); + Open the shared lib called '/lib/socket.shl' on irq 0x81 + + The kernel starts the server daemon from /lib and binds it to the interrupt. + + If the server is already loaded and has flag 'Multi_access' it will not + be reloaded; note the daemon can be loaded by init or similar. + + The binding may be global or process specific depending on if we are + running in real mode or protected and the options the server starts + with. If the interrupt is busy or the program cannot be run an error + is returned. + + Note also the server has the option to reject the connection even if the + kernel is happy. + + If the server does a shl_open() on itself it is registering a request to + be known on the given interrupt by any process without prior registration. + +int + The must be the interrupt previously accepted by the kernel. + The registers AX,BX,CX,DX,DI,SI are passed to the server in the + structure for shl_accept in the vars: rtype, arg1, ... arg5. + Also the DS register is saved for access by the server. + If the server has died or doesn't respond after a (long) timeout an error + should be returned. + Note: A server that is not present may be respawned if it's stateless. + + Note this is _very_ similar to the system call interrupt and it's possible + the system call server can be a model for a multi-threaded server. + +Server side +----------- + +shl_register("socket", flags); + + Flags: + Multi_access: Server can accept accesses from multiple clients. + Stateless: If server dies it can be restarted in some manner + without the clients being aware. + Non-block: Calls to shl_accept do not block, return error. + + Another possibility is to register to a device (major/minor pair) + when a client attempts to access this device messages the open + syscall is passed to the server like the syscalls for fds opened + by shl_popen(). The server can then do a shl_popen to allow the + client access to a channel. + + This has the advantage that the client doesn't need to know anything + special about the server. + +shl_accept(struct shl_message *); + A client has just made an INT call. + + If pid == 0 this is a shl_open request passed via the kernel, arg1 is + pid, arg2 is euid and arg3 is the egid. The reply will be the return + from the shl_open syscall. + +struct shl_message { + int pid; + int rtype; /* AX register */ + int arg1, arg2, arg3, arg4, arg5; /* BX,CX,DX,DI,SI registers */ + int dseg; /* DS register */ +} + buffer; Structure for 'accept' and 'reply' calls. + +shl_reply(struct shl_message *); + The rtype, arg1..3 values are copied back to the registers in the calling + program. + +shl_notify(int flag); + Allow asychronus notification of the arrival of shl_accept requests. + Perhaps a signal, SIGURG ? + The flag could be a ms time between signals while there are pending items. + (0=none, -1=1 per item, >0=time) + (If this used fds this could be done via select but as we ain't got it ...) + +shl_popen(int pid); + Open a file descriptor on the given process, return the FD number. + + THIS WILL ONLY WORK IF THE PROCESS IS CURRENTLY WAITING FOR A REPLY. + + This FD when accessed will send messages to the server process, + + These messages will be identical in form to the normal messages + except that the value 0x8000 will be ored with the syscall number + in AX. + + Beware also the semantics of fork and exec which can give a server + FD to a process that either knows nothing about the server or will + later register with the server in it's own right. + + (This will probably need a 'dup3(fd, oldpid, newpid)' style call) + +shl_force(struct shl_message *); + This forces the remote process to execute a syscall + + THIS WILL ONLY WORK IF THE PROCESS IS CURRENTLY WAITING FOR A REPLY. + + This would be useful for: shl_open("minix", 0x20); or if an error + causes a forced closure of an FD. + +shl_copy(int io, char * localbuf, int pid, char * remotebuf); + Copies data between the address space of the client process and the + server. (Could be shl_read and shl_write) + + THIS WILL ONLY WORK IF THE PROCESS IS CURRENTLY WAITING FOR A REPLY. + + On Linux-8086 this will just be a far memcpy, in protected mode the + segment descriptor will have to be setup, either specially or previously. + + This will be complicated slightly by the problem that a multi-threaded + server may have many clients waiting at the same time. + + Also the kernel is able to change the segment that a given program resides. diff -Nurd linux-86.old/libc/syscall/syscall.dat.chad linux-86/libc/syscall/syscall.dat.chad --- linux-86.old/libc/syscall/syscall.dat.chad Mon Jan 6 21:03:10 1997 +++ linux-86/libc/syscall/syscall.dat.chad Thu Jan 1 01:00:00 1970 @@ -1,55 +0,0 @@ -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 -wait 7 0 . THIS one is different -creat 8 0 . THIS one is different -link 9 2 -unlink 10 1 -exec 11 3 * minix style exec -chdir 12 1 -time 13 0 . THIS one is different -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 -alarm 27 2 -fstat 28 2 -pause 29 0 -utime 30 2 -access 33 2 -nice 34 1 . -sleep 35 0 . THIS one is different -sync 36 0 -kill 37 2 -rename 38 2 -mkdir 39 2 -rmdir 40 1 -dup 41 1 - using nasty fcntl function -pipe 42 1 -times 43 2 * 2nd arg is pointer for long ret val. -profil 44 0 -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 - -phys 52 0 . THIS one is different -lock 53 0 . THIS one is different -ioctl 54 3 . make this and fcntl the same ? -reboot 55 3 . the magic number is 0xfee1,0xdead,... -mpx 56 0 . THIS one is different -dup2 57 0 . THIS one is different -umask 60 1 diff -Nurd linux-86.old/libc/syscall/syscall.dat.code linux-86/libc/syscall/syscall.dat.code --- linux-86.old/libc/syscall/syscall.dat.code Mon Jan 6 21:14:30 1997 +++ linux-86/libc/syscall/syscall.dat.code Thu Jan 1 01:00:00 1970 @@ -1,70 +0,0 @@ -( -tr '[A-Z]' '[a-z]' < syscall.dat.rdb -echo %%% -cat < - * This file is part of the Linux-8086 C library and is distributed - * under the GNU Library General Public License. - */ - -#include -#include -#include - -/* MSDOS has it's own versions */ -#ifndef __MSDOS__ - -/********************** Function time ************************************/ - -#ifdef L_time -time_t time(where) -time_t *where; -{ - struct timeval rv; - if( gettimeofday(&rv, (void*)0) < 0 ) return -1; - if(where) *where = rv.tv_sec; - return rv.tv_sec; -} -#endif - -/********************** Function abort ************************************/ - -#ifdef L_abort -#include - -int abort() -{ - signal(SIGABRT, SIG_DFL); - kill(SIGABRT, getpid()); /* Correct one */ - pause(); /* System may just schedule */ - signal(SIGKILL, SIG_DFL); - kill(SIGKILL, getpid()); /* Can't trap this! */ - __exit(255); /* WHAT!! */ -} -#endif - -/********************** Function wait ************************************/ - -#ifdef L_wait -int -wait(status) -int * status; -{ - return wait4(-1, status, 0, (void*)0); -} -#endif - -/********************** Function wait3 **************************************/ - -#ifdef L_wait3 -int -wait3(status, opts, usage) -int * status; -int opts; -struct rusage * usage; -{ - return wait4(-1, status, opts, usage); -} -#endif - -/********************** Function waitpid ************************************/ - -#ifdef L_waitpid -int -waitpid(pid, status, opts) -int pid; -int * status; -int opts; -{ - return wait4(pid, status, opts, (void*)0); -} -#endif - -/********************** Function killpg ************************************/ - -#ifdef L_killpg -int -killpg(pid, sig) -int pid; -int sig; -{ - if(pid == 0) - pid = getpgrp(); - if(pid > 1) - return kill(-pid, sig); - errno = EINVAL; - return -1; -} -#endif - -/********************** Function setpgrp ************************************/ - -#ifdef L_setpgrp -int -setpgrp() -{ - return setpgid(0,0); -} -#endif - -/********************** Function sleep ************************************/ - -#ifdef L_sleep -#include - -/* This uses SIGALRM, it does keep the previous alarm call but will lose - * any alarms that go off during the sleep - */ - -static void alrm() { } - -unsigned int sleep(seconds) -unsigned int seconds; -{ - void (*last_alarm)(); - unsigned int prev_sec; - - prev_sec = alarm(0); - if( prev_sec <= seconds ) prev_sec = 1; else prev_sec -= seconds; - - last_alarm = signal(SIGALRM, alrm); - alarm(seconds); - pause(); - seconds = alarm(prev_sec); - signal(SIGALRM, last_alarm); - return seconds; -} -#if 0 - /* Is this a better way ? If we have select of course :-) */ -#include -unsigned int -sleep(seconds) -unsigned int seconds; -{ - struct timeval timeout; - time_t start = time((void*)0); - timeout.tv_sec = seconds; - timeout.tv_usec = 0; - select(1, NULL, NULL, NULL, &timeout); - 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 ********************************************/ - -#endif /* __MSDOS__ */ diff -Nurd linux-86.old/libcompat linux-86/libcompat --- linux-86.old/libcompat Thu Jan 1 01:00:00 1970 +++ linux-86/libcompat Sun Oct 5 13:18:06 1997 @@ -0,0 +1,24 @@ +#!/bin/sh - + +FILES="$*" +[ "$FILES" = "" ] && FILES="lib/*.a" + +for i in $FILES +do + ID="`dd bs=8 count=1 < $i 2>/dev/null | cat -v`" + [ "$ID" != "!" ] && { + make ld86r || exit $? + + echo Translating archive $i + rm -rf libconv.d + mkdir libconv.d + cd libconv.d + ar x ../$i + cd .. + + bin/ld86r -o $i libconv.d/* || exit $? + rm -rf libconv.d + } +done + +exit 0 diff -Nurd linux-86.old/makefile.in linux-86/makefile.in --- linux-86.old/makefile.in Thu Apr 24 23:13:56 1997 +++ linux-86/makefile.in Sun Oct 5 13:13:10 1997 @@ -13,10 +13,11 @@ # Defaults, generic C ARFLAGS =r -CFLAGS =-O -LDFLAGS =-s +CC =%CC% +CFLAGS =%CFLAGS% +LDFLAGS = MAKEARG =CC='$(CC)' CFLAGS='$(CFLAGS)' LDFLAGS='$(LDFLAGS)' PREFIX=$(PREFIX) \ - LIBDIR='$(LIBDIR)' BINDIR='$(BINDIR)' + LIBDIR='$(LIBDIR)' BINDIR='$(BINDIR)' ANSI='$(ANSI)' MAKEC=$(MAKE) -C MAKEX= @@ -32,11 +33,10 @@ CC =gcc $(GCCFLAG) #ifdef __i386__ -CFLAGS =-Wall $(WALL) -O2 -m486 -fno-strength-reduce +CFLAGS =-Wall $(WALL) -O2 -m486 -fno-strength-reduce -g #else -CFLAGS =-Wall $(WALL) -O2 -fno-strength-reduce -#endf -LDFLAGS =-s +CFLAGS =-Wall $(WALL) -O6 -g +#endif #endif #ifndef GNUMAKE @@ -52,23 +52,27 @@ #endif #ifdef __BCC__ -CC =bcc +ANSI =-ansi #ifdef __AS386_32__ CFLAGS =-3 LDFLAGS =-3 -s -N #else CFLAGS =-0 LDFLAGS =-0 -s -H10000 +BCCARCH =-Mf #endif #endif # Alter these if for some reason you don't want this done as root. INDAT=-o root -g root -m 644 -INEXE=-o root -g root -m 755 +INEXE=-o root -g root -m 755 -s +INSCR=-o root -g root -m 755 -all: check_config bcc unproto copt as86 ld86 library alt-libs elksemu +all: check_config bcc unproto copt as86 ld86 \ + library lib-bsd alt-libs elksemu -install: check_config install-bcc install-man install-lib install-lib2 install-emu +install: check_config install-bcc install-man \ + install-lib install-lib2 install-emu install-all: install install-other @@ -76,10 +80,10 @@ LIBARGS= CC=ncc CCFLAGS= ARFLAGS=$(ARFLAGS) -# Season to taste -PREFIX= /usr/bcc -BINDIR= /usr/bin -LIBDIR= $(PREFIX)/lib/bcc +# Season in the top makefile +PREFIX= %PREFIX% +BINDIR= %BINDIR% +LIBDIR= %LIBDIR% DISTBIN= $(DIST)$(BINDIR) DISTLIB= $(DIST)$(LIBDIR) @@ -100,8 +104,8 @@ phony: bcc: bindir - $(MAKEC) bcc $(MAKEARG) bcc ncc bcc-cc1 - cp -p bcc/bcc bin/bcc + $(MAKEC) bcc $(MAKEARG) BCCARCH=$(BCCARCH) bcc ncc bcc-cc1 + cp -p bcc/bcc bin/Bcc cp -p bcc/ncc bin/ncc cp -p bcc/bcc-cc1 lib/bcc-cc1 @@ -123,14 +127,34 @@ $(MAKEC) ld $(MAKEARG) ld86 cp -p ld/ld86 bin/ld86 +ld86r: bindir + $(MAKEC) ld $(MAKEARG) ld86r + cp -p ld/ld86r bin/ld86r + elksemu: bindir - $(MAKEC) elksemu $(MAKEARG) elksemu +#ifdef __i386__ + $(MAKEC) elksemu \ + CC='$(CC)' PREFIX=$(PREFIX) LIBDIR='$(LIBDIR)' BINDIR='$(BINDIR)' \ + elksemu +#else + $(MAKEC) elksemu CC='ncc' DEFS=-N- elksemu +#endif cp -p elksemu/elksemu bin/elksemu +install-ln: bcc unproto copt as86 ld86 elksemu + install -d $(DISTBIN) + ln -fs `pwd`/bin/ncc $(DISTBIN)/bcc + ln -fs `pwd`/bin/as86_encap $(DISTBIN)/as86_encap + ln -fs `pwd`/bin/as86 $(DISTBIN)/as86 + ln -fs `pwd`/bin/ld86 $(DISTBIN)/ld86 + ln -fs `pwd`/bin/elksemu $(DIST)/lib/elksemu + install -d $(DIST)/usr/lib + install $(INDAT) libc/error/liberror.txt $(DIST)/usr/lib/liberror.txt + install-bcc: bcc unproto copt as86 ld86 install -d $(DISTBIN) $(DISTLIB) $(DISTLIB)/i86 - install $(INEXE) bin/bcc $(DISTBIN)/bcc - install $(INEXE) bin/as86_encap $(DISTBIN)/as86_encap + install $(INEXE) bin/Bcc $(DISTBIN)/bcc + install $(INSCR) bin/as86_encap $(DISTBIN)/as86_encap install $(INEXE) bin/as86 $(DISTBIN)/as86 install $(INEXE) bin/ld86 $(DISTBIN)/ld86 install $(INEXE) lib/bcc-cc1 $(DISTLIB)/bcc-cc1 @@ -140,6 +164,7 @@ @test ! -f $(DISTLIB)/as86 || rm -f $(DISTLIB)/as86 @test ! -f $(DISTLIB)/ld86 || rm -f $(DISTLIB)/ld86 +# NB: This doesn't install as a suid root, that's ok though. install-emu: elksemu install -d $(DIST)/lib install $(INEXE) bin/elksemu $(DIST)/lib/elksemu @@ -147,17 +172,17 @@ install-man: -$(MAKEC) man MANDIR=$(DIST)/usr/man install -install-lib: lib/lib0-done +install-lib: lib/lib0-done lib/lib2-done install -d $(DISTLIB)/i86 $(MAKEC) libc $(LIBARGS) BCCHOME=$(DISTPRE) install_incl install $(INDAT) lib/crt0.o $(DISTLIB)/i86/crt0.o install $(INDAT) lib/libc.a $(DISTLIB)/i86/libc.a + install $(INDAT) lib/libbsd.a $(DISTLIB)/i86/libbsd.a install -d $(DIST)/usr/lib install $(INDAT) libc/error/liberror.txt $(DIST)/usr/lib/liberror.txt install-lib2: lib/lib1-done install -d $(DISTLIB)/i86 - install $(INDAT) lib/libbsd.a $(DISTLIB)/i86/libbsd.a install $(INDAT) lib/libc_f.a $(DISTLIB)/i86/libc_f.a install $(INDAT) lib/libc_s.a $(DISTLIB)/i86/libc_s.a install $(INDAT) lib/libdos.a $(DISTLIB)/i86/libdos.a @@ -172,34 +197,53 @@ lib/lib1-done: $(MAKE) -f make.fil alt-libs +lib/lib2-done: + $(MAKE) -f make.fil lib-bsd + +all-libs: library lib-bsd alt-libs + @: + library: bindir + test -f bin/ncc $(MAKEC) libc $(LIBARGS) PLATFORM=i86-ELKS cp -p libc/crt0.o libc/libc.a lib/. + sh libcompat lib/libc.a @touch lib/lib0-done -alt-libs: lib-bsd lib-fast lib-stand lib-dos lib-386 - @touch lib/lib1-done - lib-bsd: bindir + test -f bin/ncc $(MAKEC) libbsd $(LIBARGS) cp -p libbsd/libbsd.a lib/libbsd.a + sh libcompat lib/libbsd.a + @touch lib/lib2-done + +alt-libs: lib-stand lib-dos lib-386 lib-fast + @touch lib/lib1-done lib-fast: bindir + test -f bin/ncc $(MAKEC) libc $(LIBARGS) PLATFORM=i86-FAST cp -p libc/libc_f.a lib/libc_f.a + sh libcompat lib/libc_f.a lib-stand: bindir + test -f bin/ncc $(MAKEC) libc $(LIBARGS) PLATFORM=i86-BIOS cp -p libc/libc_s.a lib/libc_s.a + sh libcompat lib/libc_s.a lib-dos: bindir + test -f bin/ncc $(MAKEC) libc $(LIBARGS) PLATFORM=i86-DOS cp -p libc/libdos.a lib/libdos.a + sh libcompat lib/libdos.a lib-386: bindir + test -f bin/ncc $(MAKEC) libc $(LIBARGS) PLATFORM=i386-BCC cp -p libc/crt3.o lib/i386/crt0.o cp -p libc/libc3.a lib/i386/libc.a + sh libcompat lib/i386/libc.a ############################################################################## @@ -228,12 +272,10 @@ $(MAKEC) $$i BCC=ncc DIST=$(DIST) install || exit 1 ; \ done -other: phony - @for i in $(OTHERS) ; do \ - $(MAKEC) $$i BCC=ncc || exit 1 ; done +other: $(OTHERS) -tests: phony - $(MAKEC) tests BCC=ncc +$(OTHERS): phony + $(MAKEC) $@ BCC=ncc clean: -@for i in $(CLEANLIST) ; do $(MAKEC) $$i $@ ; true ; done diff -Nurd linux-86.old/man/as86.1 linux-86/man/as86.1 --- linux-86.old/man/as86.1 Sun Mar 23 11:35:34 1997 +++ linux-86/man/as86.1 Sun Oct 5 11:16:41 1997 @@ -120,10 +120,10 @@ items in the table are the start and end addresses of the binary file. .TP .B -u -take undefined symbols as imported-with-unspecified segment +assume undefined symbols are imported-with-unspecified segment. .TP -.B -w -don't print warnings +.B -w- +allow the assembler to print warning messages. .P .SH AS86 SOURCE Special characters diff -Nurd linux-86.old/man/bcc.1 linux-86/man/bcc.1 --- linux-86.old/man/bcc.1 Tue Apr 29 06:56:06 1997 +++ linux-86/man/bcc.1 Sun Aug 3 21:59:18 1997 @@ -175,7 +175,7 @@ names of files being unlinked. Three or more -v's print names of paths being searched. .TP -.B -W +.B -w allow the assembler to generate warnings, useful for finding 80186+ instructions. .P diff -Nurd linux-86.old/tests/README linux-86/tests/README --- linux-86.old/tests/README Sun Jan 26 17:43:48 1997 +++ linux-86/tests/README Sun May 11 20:43:01 1997 @@ -18,7 +18,4 @@ grab.c Grabs _all_ available memory (3GB+ on Linux-i386) then frees rand.c Generates random numbers and pipes them to 'hd' -BTW: i386 OMAGIC files can be converted to deformed ELFs with this: - $ objcopy -O elf32-i386 sync - -Robert diff -Nurd linux-86.old/tests/ft.c linux-86/tests/ft.c --- linux-86.old/tests/ft.c Sun Oct 20 07:39:28 1996 +++ linux-86/tests/ft.c Sun Aug 17 18:18:26 1997 @@ -24,15 +24,19 @@ #include #include -#ifdef S_IFSOCK -#include +#if defined(S_IFSOCK) && !defined(__BCC__) +#defined __HAS_SOCKETS #endif #ifndef S_IFLNK #define lstat stat #endif +#ifdef __HAS_SOCKETS +#include +#endif + /* Ansi prototypes */ -#ifdef __STTDC__ +#ifdef __STDC__ #define PR(x) x #else #define PR(x) () @@ -106,7 +110,7 @@ { "ln", CMD_LN, -1, "vifs" }, { "mkdir", CMD_MKDIR, 0, "m:" }, { "mkfifo", CMD_MKFIFO, 0, "m:" }, -#ifdef S_IFSOCK +#ifdef __HAS_SOCKETS { "mksock", CMD_MKSOCK, 0, "m:" }, #endif { "mknod", CMD_MKNOD, 4, "m:" }, @@ -505,7 +509,7 @@ case CMD_MKDIR: rv = cmd_mkdir(fname); break; case CMD_MKFIFO: rv = cmd_mkfifo(fname); break; -#ifdef S_IFSOCK +#ifdef __HAS_SOCKETS case CMD_MKSOCK: rv = cmd_mksock(fname); break; #endif case CMD_MKNOD: break; @@ -721,7 +725,7 @@ { case S_IFDIR: printf("\td"); break; case S_IFIFO: printf("\tp"); break; -#ifdef S_IFSOCK +#ifdef __HAS_SOCKETS case S_IFSOCK: printf("\ts"); break; #endif case S_IFBLK: printf("\tb,%d,%d", cur_file_stat.st_rdev>>8, @@ -756,7 +760,7 @@ return rv; } -#ifdef S_IFSOCK +#ifdef __HAS_SOCKETS int cmd_mksock(fname) char * fname; diff -Nurd linux-86.old/tests/hd.c linux-86/tests/hd.c --- linux-86.old/tests/hd.c Sun Nov 17 16:10:45 1996 +++ linux-86/tests/hd.c Thu Jul 3 22:30:56 1997 @@ -9,6 +9,10 @@ FILE *fd; +FILE * ofd = stdout; +char * outfile = 0; +int reverse = 0; + main(argc, argv) int argc; char **argv; @@ -21,25 +25,52 @@ if (aflag && argv[ar][0] == '-') switch (argv[ar][1]) { - case 'r': - return reverse_hd(argc, argv); - case 'o': + case 'r': /* Reverse */ + reverse = 1; + break; + case 's': /* Skip */ offset = strtol(argv[ar] + 2, (void *) 0, 0); break; case '-': aflag = 0; break; + case 'o': /* Output */ + if( argv[ar][2] ) outfile = argv[ar]+2; + else + { + if( ++ar >= argc ) Usage(); + outfile = argv[ar]; + } + break; default: Usage(); } else { + if( outfile ) + { + if( ofd != stdout ) fclose(ofd); +#ifdef MSDOS + if( reverse ) + ofd = fopen(outfile, "wb"); + else +#endif + ofd = fopen(outfile, "w"); + if( ofd == 0 ) + { + fprintf(stderr, "Cannot open file '%s'\n", outfile); + exit(9); + } + } fd = fopen(argv[ar], "rb"); if (fd == 0) fprintf(stderr, "Cannot open file '%s'\n", argv[ar]); else { - do_fd(); + if( reverse ) + do_rev_fd(); + else + do_fd(); fclose(fd); } done = 1; @@ -51,14 +82,19 @@ #else { fd = stdin; - do_fd(); + if( reverse ) + do_rev_fd(); + else + do_fd(); } #endif + + exit(0); } Usage() { - fprintf(stderr, "Usage: hd [-r]|[[-oOffset] file]\n"); + fprintf(stderr, "Usage: hd [-o Outfile][-r]|[[-sSkip_bytes] file]\n"); exit(1); } @@ -109,28 +145,28 @@ { if (lastaddr + 16 == address) { - printf("*\n"); - fflush(stdout); + fprintf(ofd, "*\n"); + fflush(ofd); } return; } } lastaddr = address; - printf("%06lx:", address); + fprintf(ofd, "%06lx:", address); for (j = 0; j < 16; j++) { if (j == 8) - putchar(' '); + fputc(' ', ofd); if (num[j] >= 0) - printf(" %02x", num[j]); + fprintf(ofd, " %02x", num[j]); else - printf(" "); + fprintf(ofd, " "); lastnum[j] = num[j]; num[j] = -1; } - printf(" %.16s\n", chr); + fprintf(ofd, " %.16s\n", chr); } @@ -139,13 +175,12 @@ * file */ -/* -- 0 1 2 3 4 5 6 7 8 9 a b c d e f */ -static char *datafmt = "%x: %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x\n"; -reverse_hd() +do_rev_fd() { char str[160]; char * ptr; - int c[16], d[16], x, i, nxtaddr, addr; + int c[16], i, nxtaddr, addr; + int zap_last = 1; for (i = 0; i < 16; i++) c[i] = 0; @@ -153,30 +188,32 @@ for (nxtaddr = 0;;) { - if (gets(str) == NULL) + if (fgets(str, sizeof(str), fd) == NULL) break; str[57] = 0; ptr = str; + if( *ptr == '*' ) zap_last = 0; if( !isxdigit(*ptr) ) continue; addr = strtol(ptr, &ptr, 16); if( *ptr == ':' ) ptr++; if (nxtaddr == 0) nxtaddr = addr; + if( zap_last ) memset(c, 0, sizeof(c)); + else zap_last = 1; while (nxtaddr < addr) { - nxtaddr += 16; - for (i = 0; i < 16; i++) - putchar(c[i]); + for (i = 0; nxtaddr < addr && i < 16; i++, nxtaddr++) + fputc(c[i], ofd); } for (i = 0; i < 16 && *ptr; i++) { char * ptr2; c[i] = strtol(ptr, &ptr2, 16); if( ptr == ptr2 ) break; - putchar(c[i]); + fputc(c[i], ofd); ptr = ptr2; } nxtaddr += 16; diff -Nurd linux-86.old/unproto/tok_io.c linux-86/unproto/tok_io.c --- linux-86.old/unproto/tok_io.c Fri Jun 18 22:48:00 1993 +++ linux-86/unproto/tok_io.c Sat Aug 9 15:49:39 1997 @@ -396,7 +396,11 @@ if ((INPUT(c)) == EOF) { /* EOF, punt */ break; } else if (c == 'a') { /* \a -> audible bell */ +#ifdef BELL if ((cp = vs_strcpy(vs, cp, BELL)) == 0) +#else + if ((cp = vs_strcpy(vs, cp, "\007")) == 0) +#endif fatal("out of memory"); } else if (c == 'x') { /* \xhh -> \nnn */ cp = read_hex(vs, cp);