ast@cs.vu.nl (Andy Tanenbaum) (05/30/88)
: This is a shar archive. Extract with sh, not csh.
: This archive ends with exit, so do not worry about trailing junk.
: --------------------------- cut here --------------------------
PATH=/bin:/usr/bin:/usr/ucb
echo Extracting 'malloc.c.diff'
sed 's/^X//' > 'malloc.c.diff' << '+ END-OF-FILE ''malloc.c.diff'
X0a1
X> #define i8088 1 /* For IBM PC only */
X2,4c3,5
X< #define CLICK_SIZE 16
X< typedef unsigned short vir_bytes;
X< extern bcopy();
X---
X> /* replace undef by define */
X> #undef DEBUG /* check assertions */
X> #undef SLOWDEBUG /* some extra test loops (requires DEBUG) */
X6,8c7,11
X< #define ALIGN(x, a) (((x) + (a - 1)) & ~(a - 1))
X< #define BUSY 1
X< #define NEXT(p) (* (char **) (p))
X---
X> #ifdef DEBUG
X> #define ASSERT(b) if (!(b)) assert_failed();
X> #else
X> #define ASSERT(b) /* empty */
X> #endif
X10,11c13,18
X< extern char *sbrk();
X< static char *bottom, *top;
X---
X> #ifdef i8088
X> #define ptrint int
X> #endif
X> #ifdef ATARI_ST
X> #define ptrint long
X> #endif
X12a20,42
X> #define BRKSIZE 1024
X> #define PTRSIZE sizeof(char *)
X> #define Align(x,a) (((x) + (a - 1)) & ~(a - 1))
X> #define NextSlot(p) (* (char **) ((p) - PTRSIZE))
X> #define NextFree(p) (* (char **) (p))
X>
X> /*
X> * A short explanation of the data structure and algorithms.
X> * An area returned by malloc() is called a slot. Each slot
X> * contains the number of bytes requested, but preceeded by
X> * an extra pointer to the next the slot in memory.
X> * 'bottom' and 'top' point to the first/last slot.
X> * More memory is asked for using brk() and appended to top.
X> * The list of free slots is maintained to keep malloc() fast.
X> * 'empty' points the the first free slot. Free slots are
X> * linked together by a pointer at the start of the
X> * user visable part, so just after the next-slot pointer.
X> * Free slots are merged together by free().
X> */
X>
X> extern char *sbrk(), *brk();
X> static char *bottom, *top, *empty;
X>
X18,20c48,50
X< p = (char *) ALIGN((vir_bytes) top + sizeof(char *) + len, CLICK_SIZE)
X< - sizeof(char *);
X< if (p < top || brk(p) < 0)
X---
X> ASSERT(NextSlot(top) == 0);
X> p = (char *) Align((ptrint)top + len, BRKSIZE);
X> if (p < top || brk(p) != 0)
X21a52,54
X> NextSlot(top) = p;
X> NextSlot(p) = 0;
X> free(top);
X23,26d55
X< for (p = bottom; NEXT(p) != 0; p = (char *) (* (vir_bytes *) p & ~BUSY))
X< ;
X< NEXT(p) = top;
X< NEXT(top) = 0;
X33,34c62,63
X< register char *p, *next, *new;
X< register unsigned len = ALIGN(size, sizeof(char *)) + sizeof(char *);
X---
X> register char *prev, *p, *next, *new;
X> register unsigned len, ntries;
X36,50c65,91
X< if ((p = bottom) == 0) {
X< top = bottom = p = sbrk(sizeof(char *));
X< NEXT(top) = 0;
X< }
X< while ((next = NEXT(p)) != 0)
X< if ((vir_bytes) next & BUSY) /* already in use */
X< p = (char *) ((vir_bytes) next & ~BUSY);
X< else {
X< while ((new = NEXT(next)) != 0 && !((vir_bytes) new & BUSY))
X< next = new;
X< if (next - p >= len) { /* fits */
X< if ((new = p + len) < next) /* too big */
X< NEXT(new) = next;
X< NEXT(p) = (char *) ((vir_bytes) new | BUSY);
X< return(p + sizeof(char *));
X---
X> if (size == 0)
X> size = PTRSIZE; /* avoid slots less that 2*PTRSIZE */
X> for (ntries = 0; ntries < 2; ntries++) {
X> len = Align(size, PTRSIZE) + PTRSIZE;
X> if (bottom == 0) {
X> p = sbrk(2 * PTRSIZE);
X> p = (char *) Align((ptrint)p, PTRSIZE);
X> p += PTRSIZE;
X> top = bottom = p;
X> NextSlot(p) = 0;
X> }
X> #ifdef SLOWDEBUG
X> for (p = bottom; (next = NextSlot(p)) != 0; p = next)
X> ASSERT(next > p);
X> ASSERT(p == top);
X> #endif
X> for (prev = 0, p = empty; p != 0; prev = p, p = NextFree(p)) {
X> next = NextSlot(p);
X> new = p + len;
X> if (new > next)
X> continue; /* too small */
X> if (new + PTRSIZE < next) { /* too big, so split */
X> /* + PTRSIZE avoids tiny slots on free list */
X> NextSlot(new) = next;
X> NextSlot(p) = new;
X> NextFree(new) = NextFree(p);
X> NextFree(p) = new;
X52c93,97
X< p = next;
X---
X> if (prev)
X> NextFree(prev) = NextFree(p);
X> else
X> empty = NextFree(p);
X> return(p);
X54c99,103
X< return grow(len) ? malloc(size) : 0;
X---
X> if (grow(len) == 0)
X> break;
X> }
X> ASSERT(ntries != 2);
X> return(0);
X61,62c110,111
X< register char *p = old - sizeof(char *), *next, *new;
X< register unsigned len = ALIGN(size, sizeof(char *)) + sizeof(char *), n;
X---
X> register char *prev, *p, *next, *new;
X> register unsigned len, n;
X64,71c113,129
X< next = (char *) (* (vir_bytes *) p & ~BUSY);
X< n = next - old; /* old size */
X< while ((new = NEXT(next)) != 0 && !((vir_bytes) new & BUSY))
X< next = new;
X< if (next - p >= len) { /* does it still fit */
X< if ((new = p + len) < next) { /* even too big */
X< NEXT(new) = next;
X< NEXT(p) = (char *) ((vir_bytes) new | BUSY);
X---
X> len = Align(size, PTRSIZE) + PTRSIZE;
X> next = NextSlot(old);
X> n = (int)(next - old); /* old length */
X> /*
X> * extend old if there is any free space just behind it
X> */
X> for (prev = 0, p = empty; p != 0; prev = p, p = NextFree(p)) {
X> if (p > next)
X> break;
X> if (p == next) { /* 'next' is a free slot: merge */
X> NextSlot(old) = NextSlot(p);
X> if (prev)
X> NextFree(prev) = NextFree(p);
X> else
X> empty = NextFree(p);
X> next = NextSlot(old);
X> break;
X73,74c131,142
X< else
X< NEXT(p) = (char *) ((vir_bytes) next | BUSY);
X---
X> }
X> new = old + len;
X> /*
X> * Can we use the old, possibly extended slot?
X> */
X> if (new <= next) { /* it does fit */
X> if (new + PTRSIZE < next) { /* too big, so split */
X> /* + PTRSIZE avoids tiny slots on free list */
X> NextSlot(new) = next;
X> NextSlot(old) = new;
X> free(new);
X> }
X77c145
X< if ((new = malloc(size)) == 0) /* it didn't fit */
X---
X> if ((new = malloc(size)) == 0) /* it didn't fit */
X79,80c147,148
X< bcopy(old, new, n); /* n < size */
X< * (vir_bytes *) p &= ~BUSY;
X---
X> bcopy(old, new, n); /* n < size */
X> free(old);
X84,85c152,154
X< char *calloc(m,size)
X< unsigned m,size;
X---
X> static bcopy(old, new, n)
X> register char *old, *new;
X> register n;
X87,90c156,158
X< char *malloc();
X< char *cp;
X< register int i;
X< register char *temp;
X---
X> while (n--)
X> *new++ = *old++;
X> }
X92,93c160,163
X< i = m*size;
X< if ((cp=malloc(i))==(char *)0) return (char *)0;
X---
X> char *calloc(n, size)
X> unsigned n, size;
X> {
X> register char *p, *cp;
X95,97c165,171
X< /* malloc succeeded--clear allocated memory */
X< for (temp = cp ; i-- ; ) *temp++ = '\0';
X< return cp;
X---
X> n *= size;
X> cp = malloc(n);
X> if (cp == (char *)0)
X> return ((char *)0);
X> for (p = cp; n-- != 0; )
X> *p++ = '\0';
X> return(cp);
X100d173
X<
X104c177,201
X< * (vir_bytes *) (p - sizeof(char *)) &= ~BUSY;
X---
X> register char *prev, *next;
X>
X> ASSERT(NextSlot(p) > p);
X> for (prev = 0, next = empty; next != 0; prev = next, next = NextFree(next))
X> if (p < next)
X> break;
X> NextFree(p) = next;
X> if (prev)
X> NextFree(prev) = p;
X> else
X> empty = p;
X> if (next) {
X> ASSERT(NextSlot(p) <= next);
X> if (NextSlot(p) == next) { /* merge p and next */
X> NextSlot(p) = NextSlot(next);
X> NextFree(p) = NextFree(next);
X> }
X> }
X> if (prev) {
X> ASSERT(NextSlot(prev) <= p);
X> if (NextSlot(prev) == p) { /* merge prev and p */
X> NextSlot(prev) = NextSlot(p);
X> NextFree(prev) = NextFree(p);
X> }
X> }
X105a203,210
X>
X> #ifdef DEBUG
X> static assert_failed()
X> {
X> write(2, "assert failed in lib/malloc.c\n", 30);
X> abort();
X> }
X> #endif
+ END-OF-FILE malloc.c.diff
chmod 'u=rw,g=rw,o=rw' 'malloc.c.diff'
set `wc -c 'malloc.c.diff'`
count=$1
case $count in
7176) :;;
*) echo 'Bad character count in ''malloc.c.diff' >&2
echo 'Count should be 7176' >&2
esac
echo Extracting 'message.c.diff'
sed 's/^X//' > 'message.c.diff' << '+ END-OF-FILE ''message.c.diff'
X1,2c1,2
X< #include "../h/const.h"
X< #include "../h/type.h"
X---
X> #include <minix/const.h>
X> #include <minix/type.h>
X4c4,5
X< message M;
X---
X> /* some compilers require an initializer to force storage allocation */
X> message M = {0};
+ END-OF-FILE message.c.diff
chmod 'u=rw,g=rw,o=rw' 'message.c.diff'
set `wc -c 'message.c.diff'`
count=$1
case $count in
232) :;;
*) echo 'Bad character count in ''message.c.diff' >&2
echo 'Count should be 232' >&2
esac
echo Extracting 'mknod.c.diff'
sed 's/^X//' > 'mknod.c.diff' << '+ END-OF-FILE ''mknod.c.diff'
X1c1
X< #include "../include/lib.h"
X---
X> #include "lib.h"
+ END-OF-FILE mknod.c.diff
chmod 'u=rw,g=rw,o=rw' 'mknod.c.diff'
set `wc -c 'mknod.c.diff'`
count=$1
case $count in
57) :;;
*) echo 'Bad character count in ''mknod.c.diff' >&2
echo 'Count should be 57' >&2
esac
echo Extracting 'mount.c.diff'
sed 's/^X//' > 'mount.c.diff' << '+ END-OF-FILE ''mount.c.diff'
X1c1
X< #include "../include/lib.h"
X---
X> #include "lib.h"
+ END-OF-FILE mount.c.diff
chmod 'u=rw,g=rw,o=rw' 'mount.c.diff'
set `wc -c 'mount.c.diff'`
count=$1
case $count in
57) :;;
*) echo 'Bad character count in ''mount.c.diff' >&2
echo 'Count should be 57' >&2
esac
echo Extracting 'open.c.diff'
sed 's/^X//' > 'open.c.diff' << '+ END-OF-FILE ''open.c.diff'
X1c1
X< #include "../include/lib.h"
X---
X> #include "lib.h"
+ END-OF-FILE open.c.diff
chmod 'u=rw,g=rw,o=rw' 'open.c.diff'
set `wc -c 'open.c.diff'`
count=$1
case $count in
57) :;;
*) echo 'Bad character count in ''open.c.diff' >&2
echo 'Count should be 57' >&2
esac
echo Extracting 'pause.c.diff'
sed 's/^X//' > 'pause.c.diff' << '+ END-OF-FILE ''pause.c.diff'
X1c1
X< #include "../include/lib.h"
X---
X> #include "lib.h"
+ END-OF-FILE pause.c.diff
chmod 'u=rw,g=rw,o=rw' 'pause.c.diff'
set `wc -c 'pause.c.diff'`
count=$1
case $count in
57) :;;
*) echo 'Bad character count in ''pause.c.diff' >&2
echo 'Count should be 57' >&2
esac
echo Extracting 'perror.c.diff'
sed 's/^X//' > 'perror.c.diff' << '+ END-OF-FILE ''perror.c.diff'
X3c3
X< #include "../h/error.h"
X---
X> #include <errno.h>
X5,41c5,41
X< char *error_message[NERROR+1] = {
X< "Error 0",
X< "Not owner",
X< "No such file or directory",
X< "No such process",
X< "Interrupted system call",
X< "I/O error",
X< "No such device or address",
X< "Arg list too long",
X< "Exec format error",
X< "Bad file number",
X< "No children",
X< "No more processes",
X< "Not enough core",
X< "Permission denied",
X< "Bad address",
X< "Block device required",
X< "Mount device busy",
X< "File exists",
X< "Cross-device link",
X< "No such device",
X< "Not a directory",
X< "Is a directory",
X< "Invalid argument",
X< "File table overflow",
X< "Too many open files",
X< "Not a typewriter",
X< "Text file busy",
X< "File too large",
X< "No space left on device",
X< "Illegal seek",
X< "Read-only file system",
X< "Too many links",
X< "Broken pipe",
X< "Math argument",
X< "Result too large"
X< };
X---
X> char *sys_errlist[] = {
X> "Error 0",
X> "Not owner",
X> "No such file or directory",
X> "No such process",
X> "Interrupted system call",
X> "I/O error",
X> "No such device or address",
X> "Arg list too long",
X> "Exec format error",
X> "Bad file number",
X> "No children",
X> "No more processes",
X> "Not enough core",
X> "Permission denied",
X> "Bad address",
X> "Block device required",
X> "Mount device busy",
X> "File exists",
X> "Cross-device link",
X> "No such device",
X> "Not a directory",
X> "Is a directory",
X> "Invalid argument",
X> "File table overflow",
X> "Too many open files",
X> "Not a typewriter",
X> "Text file busy",
X> "File too large",
X> "No space left on device",
X> "Illegal seek",
X> "Read-only file system",
X> "Too many links",
X> "Broken pipe",
X> "Math argument",
X> "Result too large"
X> };
X42a43
X> int sys_nerr = sizeof(sys_errlist)/sizeof(char *);
X47c48
X< if (errno < 0 || errno > NERROR) {
X---
X> if (errno < 0 || errno >= sizeof(sys_errlist)/sizeof(char *)) {
X52c53
X< write(2, error_message[errno], slen(error_message[errno]));
X---
X> write(2, sys_errlist[errno], slen(sys_errlist[errno]));
+ END-OF-FILE perror.c.diff
chmod 'u=rw,g=rw,o=rw' 'perror.c.diff'
set `wc -c 'perror.c.diff'`
count=$1
case $count in
2563) :;;
*) echo 'Bad character count in ''perror.c.diff' >&2
echo 'Count should be 2563' >&2
esac
echo Extracting 'pipe.c.diff'
sed 's/^X//' > 'pipe.c.diff' << '+ END-OF-FILE ''pipe.c.diff'
X1c1
X< #include "../include/lib.h"
X---
X> #include "lib.h"
+ END-OF-FILE pipe.c.diff
chmod 'u=rw,g=rw,o=rw' 'pipe.c.diff'
set `wc -c 'pipe.c.diff'`
count=$1
case $count in
57) :;;
*) echo 'Bad character count in ''pipe.c.diff' >&2
echo 'Count should be 57' >&2
esac
echo Extracting 'popen.c.diff'
sed 's/^X//' > 'popen.c.diff' << '+ END-OF-FILE ''popen.c.diff'
X12a13
X> extern FILE *fdopen();
X29c30
X< _exit(127); /* like system() ??? */
X---
X> exit(127); /* like system() ??? */
+ END-OF-FILE popen.c.diff
chmod 'u=rw,g=rw,o=rw' 'popen.c.diff'
set `wc -c 'popen.c.diff'`
count=$1
case $count in
121) :;;
*) echo 'Bad character count in ''popen.c.diff' >&2
echo 'Count should be 121' >&2
esac
echo Extracting 'printdat.c.diff'
sed 's/^X//' > 'printdat.c.diff' << '+ END-OF-FILE ''printdat.c.diff'
X1c1
X< #include "../include/stdio.h"
X---
X> #include <stdio.h>
+ END-OF-FILE printdat.c.diff
chmod 'u=rw,g=rw,o=rw' 'printdat.c.diff'
set `wc -c 'printdat.c.diff'`
count=$1
case $count in
61) :;;
*) echo 'Bad character count in ''printdat.c.diff' >&2
echo 'Count should be 61' >&2
esac
echo Extracting 'printk.c.diff'
sed 's/^X//' > 'printk.c.diff' << '+ END-OF-FILE ''printk.c.diff'
X1,4c1,5
X< /* This is a special version of printf. It is used only by the operating
X< * system itself, and should never be included in user programs. The name
X< * printk never appears in the operating system, because the macro printf
X< * has been defined as printk there.
X---
X> /*
X> * three compile time options:
X> * STACKUP fetch arguments using *p-- instead of *p++
X> * NO_LONGD %d and %ld/%D are equal
X> * NO_FLOAT abort on %e, %f and %g
X6a8
X> #define NO_FLOAT
X8c10,14
X< #define MAXDIGITS 12
X---
X> #ifdef NO_FLOAT
X> #define MAXDIG 11 /* 32 bits in radix 8 */
X> #else
X> #define MAXDIG 128 /* this must be enough */
X> #endif
X10,12c16,20
X< printk(s, arglist)
X< char *s;
X< int *arglist;
X---
X> static char *
X> itoa(p, num, radix)
X> register char *p;
X> register unsigned num;
X> register radix;
X14,18c22,23
X< int w, k, r, *valp;
X< unsigned u;
X< char **pp;
X< long l, *lp;
X< char a[MAXDIGITS], *p, *p1, c;
X---
X> register i;
X> register char *q;
X20,25c25,38
X< valp = (int *) &arglist;
X< while (*s != '\0') {
X< if (*s != '%') {
X< putc(*s++);
X< continue;
X< }
X---
X> q = p + MAXDIG;
X> do {
X> i = (int)(num % radix);
X> i += '0';
X> if (i > '9')
X> i += 'A' - '0' - 10;
X> *--q = i;
X> } while (num = num / radix);
X> i = p + MAXDIG - q;
X> do
X> *p++ = *q++;
X> while (--i);
X> return(p);
X> }
X27,32c40,48
X< w = 0;
X< s++;
X< while (*s >= '0' && *s <= '9') {
X< w = 10 * w + (*s - '0');
X< s++;
X< }
X---
X> #ifndef NO_LONGD
X> static char *
X> ltoa(p, num, radix)
X> register char *p;
X> register unsigned long num;
X> register radix;
X> {
X> register i;
X> register char *q;
X34,57c50,62
X< lp = (long *) valp;
X< pp = (char **) valp;
X<
X< switch(*s) {
X< case 'd': k = *valp++; l = k; r = 10; break;
X< case 'o': k = *valp++; u = k; l = u; r = 8; break;
X< case 'x': k = *valp++; u = k; l = u; r = 16; break;
X< case 'D': l = *lp++; r = 10; valp = (int *) lp; break;
X< case 'O': l = *lp++; r = 8; valp = (int *) lp; break;
X< case 'X': l = *lp++; r = 16; valp = (int *) lp; break;
X< case 'c': k = *valp++; putc(k); s++; continue;
X< case 's': p = *pp++; valp = (int *) pp;
X< p1 = p;
X< while(c = *p++) putc(c); s++;
X< if ( (k = w - (p-p1-1)) > 0) while (k--) putc(' ');
X< continue;
X< default: putc('%'); putc(*s++); continue;
X< }
X<
X< k = bintoascii(l, r, a);
X< if ( (r = w - k) > 0) while(r--) putc(' ');
X< for (r = k - 1; r >= 0; r--) putc(a[r]);
X< s++;
X< }
X---
X> q = p + MAXDIG;
X> do {
X> i = (int)(num % radix);
X> i += '0';
X> if (i > '9')
X> i += 'A' - '0' - 10;
X> *--q = i;
X> } while (num = num / radix);
X> i = p + MAXDIG - q;
X> do
X> *p++ = *q++;
X> while (--i);
X> return(p);
X58a64
X> #endif
X59a66,70
X> #ifndef NO_FLOAT
X> extern char *_ecvt();
X> extern char *_fcvt();
X> extern char *_gcvt();
X> #endif
X60a72,76
X> #ifdef STACKUP
X> #define GETARG(typ) *((typ *)args)--
X> #else
X> #define GETARG(typ) *((typ *)args)++
X> #endif STACKUP
X62,65c78,79
X< static int bintoascii(num, radix, a)
X< long num;
X< int radix;
X< char a[MAXDIGITS];
X---
X> printk(fmt, arg1)
X> register char *fmt;
X66a81,95
X> char buf[MAXDIG+1]; /* +1 for sign */
X> register int *args = &arg1;
X> register char *p;
X> register char *s;
X> register c;
X> register i;
X> register short width;
X> register short ndigit;
X> register ndfnd;
X> register ljust;
X> register zfill;
X> #ifndef NO_LONGD
X> register lflag;
X> register long l;
X> #endif
X68,93c97,266
X< int i, n, hit, negative;
X<
X< negative = 0;
X< if (num == 0) {a[0] = '0'; return(1);}
X< if (num < 0 && radix == 10) {num = -num; negative++;}
X< for (n = 0; n < MAXDIGITS; n++) a[n] = 0;
X< n = 0;
X<
X< do {
X< if (radix == 10) {a[n] = num % 10; num = (num -a[n])/10;}
X< if (radix == 8) {a[n] = num & 0x7; num = (num >> 3) & 0x1FFFFFFF;}
X< if (radix == 16) {a[n] = num & 0xF; num = (num >> 4) & 0x0FFFFFFF;}
X< n++;
X< } while (num != 0);
X<
X< /* Convert to ASCII. */
X< hit = 0;
X< for (i = n - 1; i >= 0; i--) {
X< if (a[i] == 0 && hit == 0) {
X< a[i] = ' ';
X< } else {
X< if (a[i] < 10)
X< a[i] += '0';
X< else
X< a[i] += 'A' - 10;
X< hit++;
X---
X> for (;;) {
X> c = *fmt++;
X> if (c == 0)
X> return;
X> if (c != '%') {
X> putc(c);
X> continue;
X> }
X> p = buf;
X> s = buf;
X> ljust = 0;
X> if (*fmt == '-') {
X> fmt++;
X> ljust++;
X> }
X> zfill = ' ';
X> if (*fmt == '0') {
X> fmt++;
X> zfill = '0';
X> }
X> for (width = 0;;) {
X> c = *fmt++;
X> if (c >= '0' && c <= '9')
X> c -= '0';
X> else if (c == '*')
X> c = GETARG(int);
X> else
X> break;
X> width *= 10;
X> width += c;
X> }
X> ndfnd = 0;
X> ndigit = 0;
X> if (c == '.') {
X> for (;;) {
X> c = *fmt++;
X> if (c >= '0' && c <= '9')
X> c -= '0';
X> else if (c == '*')
X> c = GETARG(int);
X> else
X> break;
X> ndigit *= 10;
X> ndigit += c;
X> ndfnd++;
X> }
X> }
X> #ifndef NO_LONGD
X> lflag = 0;
X> #endif
X> if (c == 'l' || c == 'L') {
X> #ifndef NO_LONGD
X> lflag++;
X> #endif
X> if (*fmt)
X> c = *fmt++;
X> }
X> switch (c) {
X> case 'X':
X> #ifndef NO_LONGD
X> lflag++;
X> #endif
X> case 'x':
X> c = 16;
X> goto oxu;
X> case 'U':
X> #ifndef NO_LONGD
X> lflag++;
X> #endif
X> case 'u':
X> c = 10;
X> goto oxu;
X> case 'O':
X> #ifndef NO_LONGD
X> lflag++;
X> #endif
X> case 'o':
X> c = 8;
X> oxu:
X> #ifndef NO_LONGD
X> if (lflag) {
X> p = ltoa(p, GETARG(long), c);
X> break;
X> }
X> #endif
X> p = itoa(p, GETARG(int), c);
X> break;
X> case 'D':
X> #ifndef NO_LONGD
X> lflag++;
X> #endif
X> case 'd':
X> #ifndef NO_LONGD
X> if (lflag) {
X> if ((l = GETARG(long)) < 0) {
X> *p++ = '-';
X> l = -l;
X> }
X> p = ltoa(p, l, 10);
X> break;
X> }
X> #endif
X> if ((i = GETARG(int)) < 0) {
X> *p++ = '-';
X> i = -i;
X> }
X> p = itoa(p, i, 10);
X> break;
X> #ifdef NO_FLOAT
X> case 'e':
X> case 'f':
X> case 'g':
X> zfill = ' ';
X> *p++ = '?';
X> break;
X> #else
X> case 'e':
X> if (ndfnd == 0)
X> ndigit = 6;
X> ndigit++;
X> p = _ecvt(p, GETARG(double), ndigit);
X> break;
X> case 'f':
X> if (ndfnd == 0)
X> ndigit = 6;
X> p = _fcvt(p, GETARG(double), ndigit);
X> break;
X> case 'g':
X> if (ndfnd == 0)
X> ndigit = 6;
X> p = _gcvt(p, GETARG(double), ndigit);
X> break;
X> #endif
X> case 'c':
X> zfill = ' ';
X> *p++ = GETARG(int);
X> break;
X> case 's':
X> zfill = ' ';
X> if ((s = GETARG(char *)) == 0)
X> s = "(null)";
X> if (ndigit == 0)
X> ndigit = 32767;
X> for (p = s; *p && --ndigit >= 0; p++)
X> ;
X> break;
X> default:
X> *p++ = c;
X> break;
X> }
X> i = p - s;
X> if ((width -= i) < 0)
X> width = 0;
X> if (ljust == 0)
X> width = -width;
X> if (width < 0) {
X> if (*s == '-' && zfill == '0') {
X> putc(*s++);
X> i--;
X> }
X> do
X> putc(zfill);
X> while (++width != 0);
X> }
X> while (--i >= 0)
X> putc(*s++);
X> while (width) {
X> putc(zfill);
X> width--;
X> }
X95,97d267
X< }
X< if (negative) a[n++] = '-';
X< return(n);
+ END-OF-FILE printk.c.diff
chmod 'u=rw,g=rw,o=rw' 'printk.c.diff'
set `wc -c 'printk.c.diff'`
count=$1
case $count in
7023) :;;
*) echo 'Bad character count in ''printk.c.diff' >&2
echo 'Count should be 7023' >&2
esac
echo Extracting 'prints.c.diff'
sed 's/^X//' > 'prints.c.diff' << '+ END-OF-FILE ''prints.c.diff'
X7a8
X> static put();
X40c41,42
X< case 's': p = (char *) *valp++;
X---
X> case 's': p = *((char **)valp);
X> valp += sizeof(char *) / sizeof(int);
X43c45
X< if ( (k = w - (p-p1-1)) > 0) while (k--) put(' ');
X---
X> if ( (k = w - ((int)(p-p1)-1)) > 0) while (k--) put(' ');
X49c51
X< write(OUT, Buf, Bufp - Buf); /* write everything in one blow. */
X---
X> write(OUT, Buf, (int)(Bufp - Buf)); /* write everything in one blow. */
+ END-OF-FILE prints.c.diff
chmod 'u=rw,g=rw,o=rw' 'prints.c.diff'
set `wc -c 'prints.c.diff'`
count=$1
case $count in
439) :;;
*) echo 'Bad character count in ''prints.c.diff' >&2
echo 'Count should be 439' >&2
esac
echo Extracting 'putc.c.diff'
sed 's/^X//' > 'putc.c.diff' << '+ END-OF-FILE ''putc.c.diff'
X1c1
X< #include "../include/stdio.h"
X---
X> #include <stdio.h>
X2a3,4
X> extern int (*__cleanup)();
X> extern int _cleanup();
X22a25
X> __cleanup = _cleanup;
+ END-OF-FILE putc.c.diff
chmod 'u=rw,g=rw,o=rw' 'putc.c.diff'
set `wc -c 'putc.c.diff'`
count=$1
case $count in
153) :;;
*) echo 'Bad character count in ''putc.c.diff' >&2
echo 'Count should be 153' >&2
esac
echo Extracting 'rand.c.diff'
sed 's/^X//' > 'rand.c.diff' << '+ END-OF-FILE ''rand.c.diff'
X2a3,8
X> int srand(x)
X> unsigned x;
X> {
X> seed = (long)x;
X> }
X>
+ END-OF-FILE rand.c.diff
chmod 'u=rw,g=rw,o=rw' 'rand.c.diff'
set `wc -c 'rand.c.diff'`
count=$1
case $count in
66) :;;
*) echo 'Bad character count in ''rand.c.diff' >&2
echo 'Count should be 66' >&2
esac
echo Extracting 'read.c.diff'
sed 's/^X//' > 'read.c.diff' << '+ END-OF-FILE ''read.c.diff'
X1c1
X< #include "../include/lib.h"
X---
X> #include "lib.h"
+ END-OF-FILE read.c.diff
chmod 'u=rw,g=rw,o=rw' 'read.c.diff'
set `wc -c 'read.c.diff'`
count=$1
case $count in
57) :;;
*) echo 'Bad character count in ''read.c.diff' >&2
echo 'Count should be 57' >&2
esac
echo Extracting 'regexp.c.diff'
sed 's/^X//' > 'regexp.c.diff' << '+ END-OF-FILE ''regexp.c.diff'
X29,30c29,30
X< #include "../include/stdio.h"
X< #include "../include/regexp.h"
X---
X> #include <stdio.h>
X> #include <regexp.h>
X124c124
X< #define NEXT(p) (((*((p)+1)&0377)<<8) + *((p)+2)&0377)
X---
X> #define NEXT(p) (((*((p)+1)&0377)<<8) + (*((p)+2)&0377))
X1080c1080
X< printf("%2d%s", s-r->program, regprop(s)); /* Where, what. */
X---
X> printf("%2d%s", (int)(s-r->program), regprop(s)); /* Where, what. */
X1085c1085
X< printf("(%d)", (s-r->program)+(next-s));
X---
X> printf("(%d)", (int)(s-r->program)+(int)(next-s));
+ END-OF-FILE regexp.c.diff
chmod 'u=rw,g=rw,o=rw' 'regexp.c.diff'
set `wc -c 'regexp.c.diff'`
count=$1
case $count in
517) :;;
*) echo 'Bad character count in ''regexp.c.diff' >&2
echo 'Count should be 517' >&2
esac
echo Extracting 'regsub.c.diff'
sed 's/^X//' > 'regsub.c.diff' << '+ END-OF-FILE ''regsub.c.diff'
X21,22c21,22
X< #include "../include/stdio.h"
X< #include "../include/regexp.h"
X---
X> #include <stdio.h>
X> #include <regexp.h>
X76c76
X< len = prog->endp[no] - prog->startp[no];
X---
X> len = (int)(prog->endp[no] - prog->startp[no]);
+ END-OF-FILE regsub.c.diff
chmod 'u=rw,g=rw,o=rw' 'regsub.c.diff'
set `wc -c 'regsub.c.diff'`
count=$1
case $count in
233) :;;
*) echo 'Bad character count in ''regsub.c.diff' >&2
echo 'Count should be 233' >&2
esac
echo Extracting 'run.diff'
sed 's/^X//' > 'run.diff' << '+ END-OF-FILE ''run.diff'
X41c41
X< if grep -s $f list > /dev/null 2>&1 ; then cat /dev/null ; else echo ar av libc.a $f >> new.files ; fi
X---
X> if grep -s "^$f" list > /dev/null 2>&1 ; then cat /dev/null ; else echo ar av libc.a $f >> new.files ; fi
+ END-OF-FILE run.diff
chmod 'u=rw,g=rw,o=rw' 'run.diff'
set `wc -c 'run.diff'`
count=$1
case $count in
231) :;;
*) echo 'Bad character count in ''run.diff' >&2
echo 'Count should be 231' >&2
esac
echo Extracting 'scanf.c.diff'
sed 's/^X//' > 'scanf.c.diff' << '+ END-OF-FILE ''scanf.c.diff'
X3c3
X< #include "stdio.h"
X---
X> #include <stdio.h>
+ END-OF-FILE scanf.c.diff
chmod 'u=rw,g=rw,o=rw' 'scanf.c.diff'
set `wc -c 'scanf.c.diff'`
count=$1
case $count in
50) :;;
*) echo 'Bad character count in ''scanf.c.diff' >&2
echo 'Count should be 50' >&2
esac
echo Extracting 'setbuf.c.diff'
sed 's/^X//' > 'setbuf.c.diff' << '+ END-OF-FILE ''setbuf.c.diff'
X1c1
X< #include "../include/stdio.h"
X---
X> #include <stdio.h>
+ END-OF-FILE setbuf.c.diff
chmod 'u=rw,g=rw,o=rw' 'setbuf.c.diff'
set `wc -c 'setbuf.c.diff'`
count=$1
case $count in
61) :;;
*) echo 'Bad character count in ''setbuf.c.diff' >&2
echo 'Count should be 61' >&2
esac
echo Extracting 'setgid.c.diff'
sed 's/^X//' > 'setgid.c.diff' << '+ END-OF-FILE ''setgid.c.diff'
X1c1
X< #include "../include/lib.h"
X---
X> #include "lib.h"
+ END-OF-FILE setgid.c.diff
chmod 'u=rw,g=rw,o=rw' 'setgid.c.diff'
set `wc -c 'setgid.c.diff'`
count=$1
case $count in
57) :;;
*) echo 'Bad character count in ''setgid.c.diff' >&2
echo 'Count should be 57' >&2
esac
echo Extracting 'setuid.c.diff'
sed 's/^X//' > 'setuid.c.diff' << '+ END-OF-FILE ''setuid.c.diff'
X1c1
X< #include "../include/lib.h"
X---
X> #include "lib.h"
+ END-OF-FILE setuid.c.diff
chmod 'u=rw,g=rw,o=rw' 'setuid.c.diff'
set `wc -c 'setuid.c.diff'`
count=$1
case $count in
57) :;;
*) echo 'Bad character count in ''setuid.c.diff' >&2
echo 'Count should be 57' >&2
esac
echo Extracting 'signal.c.diff'
sed 's/^X//' > 'signal.c.diff' << '+ END-OF-FILE ''signal.c.diff'
X1,2c1,2
X< #include "../include/lib.h"
X< #include "../include/signal.h"
X---
X> #include "lib.h"
X> #include <signal.h>
X4c4
X< int (*vectab[NR_SIGS])(); /* array of functions to catch signals */
X---
X> int (*vectab[NSIG])(); /* array of functions to catch signals */
X25a26,27
X> if (r == 1)
X> old = SIG_IGN;
+ END-OF-FILE signal.c.diff
chmod 'u=rw,g=rw,o=rw' 'signal.c.diff'
set `wc -c 'signal.c.diff'`
count=$1
case $count in
304) :;;
*) echo 'Bad character count in ''signal.c.diff' >&2
echo 'Count should be 304' >&2
esac
echo Extracting 'sleep.c.diff'
sed 's/^X//' > 'sleep.c.diff' << '+ END-OF-FILE ''sleep.c.diff'
X1,2c1,2
X< #include "../include/lib.h"
X< #include "../include/signal.h"
X---
X> #include "lib.h"
X> #include <signal.h>
+ END-OF-FILE sleep.c.diff
chmod 'u=rw,g=rw,o=rw' 'sleep.c.diff'
set `wc -c 'sleep.c.diff'`
count=$1
case $count in
116) :;;
*) echo 'Bad character count in ''sleep.c.diff' >&2
echo 'Count should be 116' >&2
esac
echo Extracting 'sprintf.c.diff'
sed 's/^X//' > 'sprintf.c.diff' << '+ END-OF-FILE ''sprintf.c.diff'
X1c1
X< #include "../include/stdio.h"
X---
X> #include <stdio.h>
+ END-OF-FILE sprintf.c.diff
chmod 'u=rw,g=rw,o=rw' 'sprintf.c.diff'
set `wc -c 'sprintf.c.diff'`
count=$1
case $count in
61) :;;
*) echo 'Bad character count in ''sprintf.c.diff' >&2
echo 'Count should be 61' >&2
esac
echo Extracting 'stat.c.diff'
sed 's/^X//' > 'stat.c.diff' << '+ END-OF-FILE ''stat.c.diff'
X1c1
X< #include "../include/lib.h"
X---
X> #include "lib.h"
+ END-OF-FILE stat.c.diff
chmod 'u=rw,g=rw,o=rw' 'stat.c.diff'
set `wc -c 'stat.c.diff'`
count=$1
case $count in
57) :;;
*) echo 'Bad character count in ''stat.c.diff' >&2
echo 'Count should be 57' >&2
esac
echo Extracting 'stderr.c.diff'
sed 's/^X//' > 'stderr.c.diff' << '+ END-OF-FILE ''stderr.c.diff'
X7c7
X< write(2, s, p - s);
X---
X> write(2, s, (int)(p - s));
+ END-OF-FILE stderr.c.diff
chmod 'u=rw,g=rw,o=rw' 'stderr.c.diff'
set `wc -c 'stderr.c.diff'`
count=$1
case $count in
63) :;;
*) echo 'Bad character count in ''stderr.c.diff' >&2
echo 'Count should be 63' >&2
esac
echo Extracting 'stime.c.diff'
sed 's/^X//' > 'stime.c.diff' << '+ END-OF-FILE ''stime.c.diff'
X1c1
X< #include "../include/lib.h"
X---
X> #include "lib.h"
+ END-OF-FILE stime.c.diff
chmod 'u=rw,g=rw,o=rw' 'stime.c.diff'
set `wc -c 'stime.c.diff'`
count=$1
case $count in
57) :;;
*) echo 'Bad character count in ''stime.c.diff' >&2
echo 'Count should be 57' >&2
esac
echo Extracting 'sync.c.diff'
sed 's/^X//' > 'sync.c.diff' << '+ END-OF-FILE ''sync.c.diff'
X1c1
X< #include "../include/lib.h"
X---
X> #include "lib.h"
+ END-OF-FILE sync.c.diff
chmod 'u=rw,g=rw,o=rw' 'sync.c.diff'
set `wc -c 'sync.c.diff'`
count=$1
case $count in
57) :;;
*) echo 'Bad character count in ''sync.c.diff' >&2
echo 'Count should be 57' >&2
esac
echo Extracting 'syslib.c.diff'
sed 's/^X//' > 'syslib.c.diff' << '+ END-OF-FILE ''syslib.c.diff'
X1,5c1,5
X< #include "../h/const.h"
X< #include "../h/type.h"
X< #include "../h/callnr.h"
X< #include "../h/com.h"
X< #include "../h/error.h"
X---
X> #include <minix/const.h>
X> #include <minix/type.h>
X> #include <minix/callnr.h>
X> #include <minix/com.h>
X> #include <errno.h>
X10d9
X< extern int errno;
X17a17,20
X> #ifdef ATARI_ST
X> PUBLIC sys_xit(parent, proc, basep, sizep)
X> phys_clicks *basep, *sizep;
X> #else
X18a22
X> #endif
X24a29,32
X> #ifdef ATARI_ST
X> *basep = (phys_clicks)M.m1_i1;
X> *sizep = (phys_clicks)M.m1_i2;
X> #endif
X53a62,67
X> #ifdef ATARI_ST
X> PUBLIC sys_fork(parent, child, pid, shadow)
X> #ifdef ALCYON_C_BUG_FIXED
X> phys_clicks shadow; /* memory allocated for shadow */
X> #endif
X> #else
X54a69
X> #endif
X60a76,78
X> #ifdef ATARI_ST
X> callm1(SYSTASK, SYS_FORK, parent, child, pid, (char *)shadow, NIL_PTR, NIL_PTR);
X> #else
X61a80
X> #endif
X117a137,144
X> #ifdef ATARI_ST
X> PUBLIC sys_fresh(proc, ptr, dc, basep, sizep)
X> int proc; /* proc whose map is to be changed */
X> char *ptr; /* pointer to new map */
X> phys_clicks dc; /* size of initialized data */
X> phys_clicks *basep, *sizep; /* base and size for free_mem() */
X> {
X> /* Create a fresh process image for exec(). Tell the kernel. */
X118a146,164
X> callm1(SYSTASK, SYS_FRESH, proc, (int)dc, 0, ptr, NIL_PTR, NIL_PTR);
X> *basep = (phys_clicks)M.m1_i1;
X> *sizep = (phys_clicks)M.m1_i2;
X> }
X> #endif
X>
X>
X> PUBLIC sys_kill(proc, sig)
X> int proc; /* which proc has exited */
X> int sig; /* signal number: 1 - 16 */
X> {
X> /* A proc has to be signaled via MM. Tell the kernel. */
X>
X> M.m6_i1 = proc;
X> M.m6_i2 = sig;
X> callx(SYSTASK, SYS_KILL);
X> }
X>
X>
X125c171
X< * tell_fs(FORK, parent, child, 0)
X---
X> * tell_fs(FORK, parent, child, pid)
X129a176
X> * tell_fs(SETPGRP, proc, 0, 0)
+ END-OF-FILE syslib.c.diff
chmod 'u=rw,g=rw,o=rw' 'syslib.c.diff'
set `wc -c 'syslib.c.diff'`
count=$1
case $count in
1782) :;;
*) echo 'Bad character count in ''syslib.c.diff' >&2
echo 'Count should be 1782' >&2
esac
echo Extracting 'time.c.diff'
sed 's/^X//' > 'time.c.diff' << '+ END-OF-FILE ''time.c.diff'
X1c1
X< #include "../include/lib.h"
X---
X> #include "lib.h"
+ END-OF-FILE time.c.diff
chmod 'u=rw,g=rw,o=rw' 'time.c.diff'
set `wc -c 'time.c.diff'`
count=$1
case $count in
57) :;;
*) echo 'Bad character count in ''time.c.diff' >&2
echo 'Count should be 57' >&2
esac
echo Extracting 'times.c.diff'
sed 's/^X//' > 'times.c.diff' << '+ END-OF-FILE ''times.c.diff'
X1c1,3
X< #include "../include/lib.h"
X---
X> #include "lib.h"
X> #include <sys/types.h>
X> #include <sys/times.h>
X3d4
X< struct tbuf { long b1, b2, b3, b4;};
X5c6
X< struct tbuf *buf;
X---
X> struct tms *buf;
X9,12c10,13
X< buf->b1 = M.m4_l1;
X< buf->b2 = M.m4_l2;
X< buf->b3 = M.m4_l3;
X< buf->b4 = M.m4_l4;
X---
X> buf->tms_utime = M.m4_l1;
X> buf->tms_stime = M.m4_l2;
X> buf->tms_cutime = M.m4_l3;
X> buf->tms_cstime = M.m4_l4;
+ END-OF-FILE times.c.diff
chmod 'u=rw,g=rw,o=rw' 'times.c.diff'
set `wc -c 'times.c.diff'`
count=$1
case $count in
428) :;;
*) echo 'Bad character count in ''times.c.diff' >&2
echo 'Count should be 428' >&2
esac
echo Extracting 'umask.c.diff'
sed 's/^X//' > 'umask.c.diff' << '+ END-OF-FILE ''umask.c.diff'
X1c1
X< #include "../include/lib.h"
X---
X> #include "lib.h"
+ END-OF-FILE umask.c.diff
chmod 'u=rw,g=rw,o=rw' 'umask.c.diff'
set `wc -c 'umask.c.diff'`
count=$1
case $count in
57) :;;
*) echo 'Bad character count in ''umask.c.diff' >&2
echo 'Count should be 57' >&2
esac
echo Extracting 'umount.c.diff'
sed 's/^X//' > 'umount.c.diff' << '+ END-OF-FILE ''umount.c.diff'
X1c1
X< #include "../include/lib.h"
X---
X> #include "lib.h"
+ END-OF-FILE umount.c.diff
chmod 'u=rw,g=rw,o=rw' 'umount.c.diff'
set `wc -c 'umount.c.diff'`
count=$1
case $count in
57) :;;
*) echo 'Bad character count in ''umount.c.diff' >&2
echo 'Count should be 57' >&2
esac
echo Extracting 'ungetc.c.diff'
sed 's/^X//' > 'ungetc.c.diff' << '+ END-OF-FILE ''ungetc.c.diff'
X1c1
X< #include "../include/stdio.h"
X---
X> #include <stdio.h>
+ END-OF-FILE ungetc.c.diff
chmod 'u=rw,g=rw,o=rw' 'ungetc.c.diff'
set `wc -c 'ungetc.c.diff'`
count=$1
case $count in
61) :;;
*) echo 'Bad character count in ''ungetc.c.diff' >&2
echo 'Count should be 61' >&2
esac
echo Extracting 'unlink.c.diff'
sed 's/^X//' > 'unlink.c.diff' << '+ END-OF-FILE ''unlink.c.diff'
X1c1
X< #include "../include/lib.h"
X---
X> #include "lib.h"
+ END-OF-FILE unlink.c.diff
chmod 'u=rw,g=rw,o=rw' 'unlink.c.diff'
set `wc -c 'unlink.c.diff'`
count=$1
case $count in
57) :;;
*) echo 'Bad character count in ''unlink.c.diff' >&2
echo 'Count should be 57' >&2
esac
echo Extracting 'utime.c.diff'
sed 's/^X//' > 'utime.c.diff' << '+ END-OF-FILE ''utime.c.diff'
X1c1
X< #include "../include/lib.h"
X---
X> #include "lib.h"
+ END-OF-FILE utime.c.diff
chmod 'u=rw,g=rw,o=rw' 'utime.c.diff'
set `wc -c 'utime.c.diff'`
count=$1
case $count in
57) :;;
*) echo 'Bad character count in ''utime.c.diff' >&2
echo 'Count should be 57' >&2
esac
echo Extracting 'wait.c.diff'
sed 's/^X//' > 'wait.c.diff' << '+ END-OF-FILE ''wait.c.diff'
X1c1
X< #include "../include/lib.h"
X---
X> #include "lib.h"
X8c8
X< *status = M.m2_i1;
X---
X> if (status != 0) *status = M.m2_i1;
+ END-OF-FILE wait.c.diff
chmod 'u=rw,g=rw,o=rw' 'wait.c.diff'
set `wc -c 'wait.c.diff'`
count=$1
case $count in
128) :;;
*) echo 'Bad character count in ''wait.c.diff' >&2
echo 'Count should be 128' >&2
esac
echo Extracting 'write.c.diff'
sed 's/^X//' > 'write.c.diff' << '+ END-OF-FILE ''write.c.diff'
X1c1
X< #include "../include/lib.h"
X---
X> #include "lib.h"
+ END-OF-FILE write.c.diff
chmod 'u=rw,g=rw,o=rw' 'write.c.diff'
set `wc -c 'write.c.diff'`
count=$1
case $count in
57) :;;
*) echo 'Bad character count in ''write.c.diff' >&2
echo 'Count should be 57' >&2
esac
exit 0