From: ast@cs.vu.nl (Andy Tanenbaum)
Subject: some 1.6.24b files
Organization: Fac. Wiskunde & Informatica, VU, Amsterdam
Date: Thu, 7 Jan 1993 22:25:44 GMT

There were apparently some problems with the following 1.6.24b files.
Here are the files in full.

Andy Tanenbaum (ast@cs.vu.nl)

echo x - lib/ansi/malloc.c
sed '/^X/s///' > lib/ansi/malloc.c << '/'
X/* $Header$ */
X
X/* replace undef by define */
X#undef	 DEBUG		/* check assertions */
X#undef	 SLOWDEBUG	/* some extra test loops (requires DEBUG) */
X
X#include	<stdlib.h>
X#include	<string.h>
X
X#ifdef DEBUG
X#define	ASSERT(b)	if (!(b)) assert_failed();
X#else
X#define	ASSERT(b)	/* empty */
X#endif
X
X#if _EM_WSIZE == _EM_PSIZE
X#define	ptrint		int
X#else
X#define	ptrint		long
X#endif
X
X#if	_EM_PSIZE == 2
X#define BRKSIZE		1024
X#else
X#define BRKSIZE		4096
X#endif
X#define	PTRSIZE		((int) sizeof(void *))
X#define Align(x,a)	(((x) + (a - 1)) & ~(a - 1))
X#define NextSlot(p)	(* (void **) ((p) - PTRSIZE))
X#define NextFree(p)	(* (void **) (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
Xextern void *_sbrk(size_t);
Xextern int _brk(void *);
Xstatic void *_bottom, *_top, *_empty;
X
Xstatic grow(size_t len)
X{
X  register char *p;
X
X  ASSERT(NextSlot((char *)_top) == 0);
X  p = (char *) Align((ptrint)_top + len, BRKSIZE);
X  if (p < (char *) _top || _brk(p) != 0)
X	return 0;
X  NextSlot((char *)_top) = p;
X  NextSlot(p) = 0;
X  free(_top);
X  _top = p;
X  return 1;
X}
X
Xvoid *
Xmalloc(size_t size)
X{
X  register char *prev, *p, *next, *new;
X  register unsigned len, ntries;
X
X  if (size == 0) return NULL;
X  for (ntries = 0; ntries < 2; ntries++) {
X	if ((len = Align(size, PTRSIZE) + PTRSIZE) < 2 * PTRSIZE)
X		return NULL;
X	if (_bottom == 0) {
X		if ((p = _sbrk(2 * PTRSIZE)) == (char *) -1)
X			return NULL;
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;	/* easily overflows!! */
X		if (new > next || new <= p)
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;
X		}
X		if (prev)
X			NextFree(prev) = NextFree(p);
X		else
X			_empty = NextFree(p);
X		return p;
X	}
X	if (grow(len) == 0)
X		break;
X  }
X  ASSERT(ntries != 2);
X  return NULL;
X}
X
Xvoid *
Xrealloc(void *oldp, size_t size)
X{
X  register char *prev, *p, *next, *new;
X  char *old = oldp;
X  register size_t len, n;
X
X  if (!old) return malloc(size);
X  else if (!size) {
X	free(oldp);
X	return NULL;
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;
X	}
X  }
X  new = old + len;
X  /*
X   * Can we use the old, possibly extended slot?
X   */
X  if (new <= next && new >= old) {		/* 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	}
X	return old;
X  }
X  if ((new = malloc(size)) == NULL)		/* it didn't fit */
X	return NULL;
X  memcpy(new, old, n);				/* n < size */
X  free(old);
X  return new;
X}
X
Xvoid
Xfree(void *ptr)
X{
X  register char *prev, *next;
X  char *p = ptr;
X
X  if (!p) return;
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  }
X}
X
X#ifdef DEBUG
Xstatic assert_failed()
X{
X	write(2, "assert failed in lib/malloc.c\n", 30);
X	abort();
X}
X#endif
/
echo x - lib/ansi/wctomb.c
sed '/^X/s///' > lib/ansi/wctomb.c << '/'
X/*
X * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
X * See the copyright notice in the ACK home directory, in the file "Copyright".
X */
X/* $Header: wctomb.c,v 1.4 91/01/15 11:55:33 ceriel Exp $ */
X
X#include	<stdlib.h>
X#include	<limits.h>
X
Xint
X/* was: wctomb(char *s, wchar_t wchar) 
X * This conflicts with prototype, so it was changed to:
X */
Xwctomb(char *s, wchar_t wchar)
X{
X	if (!s) return 0;		/* no state dependent codings */
X
X	*s = wchar;
X	return 1;
X}
/
echo x - lib/em/Makefile
sed '/^X/s///' > lib/em/Makefile << '/'
X.s.o:
X	$(CC) $(CFLAGS) $<
X
XCC=exec cc
XCFLAGS= -c -O -D_MINIX -D_POSIX_SOURCE
X
X
Xall:	
X	@$(CC) $(CFLAGS) *.c *.s
X
X
Xclean:	
X	@rm -rf *.o *.bak stb.s
X
/
echo x - lib/em/adi.s
sed '/^X/s///' > lib/em/adi.s << '/'
X.define .adi
X
X	.text
X.adi:
X	pop     bx 
X	cmp     cx,#2
X	jne     1f
X	pop     cx
X	add     ax,cx
X	jmp     (bx)
X1:
X	cmp     cx,#4
X	jne     9f
X	pop     dx
X	pop     cx
X	add     ax,cx
X	pop     cx
X	adc     dx,cx
X	push    dx
X	jmp     (bx)
X9:
X.extern .trpilin
X	push	bx
X	jmp     .trpilin
/
echo x - lib/em/stb.c
sed '/^X/s///' > lib/em/stb.c << '/'
X/*
X * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
X * See the copyright notice in the ACK home directory, in the file "Copyright".
X */
X/* $Header: stb.c,v 1.1 89/02/07 11:01:46 ceriel Exp $ */
X/* library routine for copying structs */
X
X#include <ansi.h>
X
X_PROTOTYPE(int __stb, (int n, char *f, char *t ));
X__stb(n, f, t)
Xregister int n;
Xregister char *f, *t;
X{
X	if (n > 0)
X		do
X			*t++ = *f++;
X		while (--n);
X}
/
echo x - lib/float/Makefile
sed '/^X/s///' > lib/float/Makefile << '/'
XCC=exec cc
XCFLAGS=-O -I. -D_MINIX -D_POSIX_SOURCE -wo
X
XOBJ=add_ext.o adder.o adf4.o adf8.o cff4.o cff8.o cfi.o cfu.o cif4.o cif8.o \
X    cmf4.o cmf8.o compact.o cuf4.o cuf8.o div_ext.o dvf4.o dvf8.o extend.o \
X    fef4.o fef8.o fif4.o fif8.o mlf4.o mlf8.o mul_ext.o ngf4.o \
X    ngf8.o nrm_ext.o sbf4.o sbf8.o sft_ext.o shifter.o sub_ext.o zrf4.o \
X    zrf8.o zrf_ext.o
X
X
X.SUFFIXES: .o .c .s
X.c.o:
X	$(CC) $(CFLAGS) -S $<
X	@mv $*.s $*.s.tmp
X	@sed -f FP.script < $*.s.tmp > $*.s;   rm $*.s.tmp
X	@$(CC) $(CFLAGS) -c $*.s
X	@rm $*.s
X.s.o:
X	$(CC) $(CFLAGS) -c $<
X
Xall: $(OBJ)
X
Xclean:	
X	@rm -f *.s *.o *.bak
X
/
echo x - lib/math/Makefile
sed '/^X/s///' > lib/math/Makefile << '/'
X.s.o:
X	$(CC) $(CFLAGS) -c $<
X
XCC=exec cc
XCFLAGS= -c -O -D_MINIX -D_POSIX_SOURCE
XS=asin.s atan.s atan2.s ceil.s exp.s fabs.s floor.s fmod.s hugeval.s isnan.s \
X  ldexp.s log.s log10.s pow.s sin.s sinh.s sqrt.s tan.s tanh.s 
X
Xall:	
X	@$(CC) $(CFLAGS) *.c *s
X
X
Xclean:	
X	@rm -rf *.o *.bak $S
X
/
echo x - lib/rts/Makefile.ansi
sed '/^X/s///' > lib/rts/Makefile.ansi << '/'
XCC=exec cc
XCFLAGS= -c -O -D_MINIX -D_POSIX_SOURCE
XSRC=fphook.c
Xall:
X	$(CC) $(CFLAGS) $(SRC)
X
Xclean:	
X	@rm -rf *.o *.bak
X
/
echo x - lib/rts/Makefile.kr
sed '/^X/s///' > lib/rts/Makefile.kr << '/'
XCC=exec cc
XCFLAGS= -c -O -D_MINIX -D_POSIX_SOURCE -LIB
XSRC=fphook.c head.s crtso.s
Xall:
X	$(CC) $(CFLAGS) $(SRC)
X
Xclean:	
X	@rm -rf *.o *.bak
X
/
echo x - lib/rts/fphook.c
sed '/^X/s///' > lib/rts/fphook.c << '/'
X/*
X * fltpr.c - print floating point numbers
X */
X/* $Header: fltpr.c,v 1.4 90/02/27 16:47:40 eck Exp $ */
X
X#ifndef	NOFLOAT
X#include	<string.h>
X#include	<stdarg.h>
X#include	"../stdio/loc_incl.h"
Xint _fp_hook = 1;
X
Xstatic char *
X_pfloat(long double r, register char *s, int n, int flags)
X{
X	register char *s1;
X	int sign, dp;
X	register int i;
X
X	s1 = _fcvt(r, n, &dp, &sign);
X	if (sign)
X		*s++ = '-';
X	else if (flags & FL_SIGN)
X		*s++ = '+';
X	else if (flags & FL_SPACE)
X		*s++ = ' ';
X
X	if (dp<=0)
X		*s++ = '0';
X	for (i=dp; i>0; i--)
X		if (*s1) *s++ = *s1++;
X		else *s++ = '0';
X	if (((i=n) > 0) || (flags & FL_ALT))
X		*s++ = '.';
X	while (++dp <= 0) {
X		if (--i<0)
X			break;
X		*s++ = '0';
X	}
X	while (--i >= 0)
X		if (*s1) *s++ = *s1++;
X		else *s++ = '0';
X	return s;
X}
X
Xstatic char *
X_pscien(long double r, register char *s, int n, int flags)
X{
X	int sign, dp; 
X	register char *s1;
X
X	s1 = _ecvt(r, n + 1, &dp, &sign);
X	if (sign)
X		*s++ = '-';
X	else if (flags & FL_SIGN)
X		*s++ = '+';
X	else if (flags & FL_SPACE)
X		*s++ = ' ';
X
X	*s++ = *s1++;
X	if ((n > 0) || (flags & FL_ALT))
X		*s++ = '.';
X	while (--n >= 0)
X		if (*s1) *s++ = *s1++;
X		else *s++ = '0';
X	*s++ = 'e';
X	if ( r != 0 ) --dp ;
X	if ( dp<0 ) {
X		*s++ = '-' ; dp= -dp ;
X	} else {
X		*s++ = '+' ;
X	}
X	if (dp >= 100) {
X		*s++ = '0' + (dp / 100);
X		dp %= 100;
X	}
X	*s++ = '0' + (dp/10);
X	*s++ = '0' + (dp%10);
X	return s;
X}
X
X#define	NDIGINEXP(exp)		(((exp) >= 100 || (exp) <= -100) ? 3 : 2)
X#define	LOW_EXP			-4
X#define	USE_EXP(exp, ndigits)	(((exp) < LOW_EXP + 1) || (exp >= ndigits + 1))
X
Xstatic char *
X_gcvt(long double value, int ndigit, char *s, int flags)
X{
X	int sign, dp;
X	register char *s1, *s2;
X	register int i;
X	register int nndigit = ndigit;
X
X	s1 = _ecvt(value, ndigit, &dp, &sign);
X	s2 = s;
X	if (sign) *s2++ = '-';
X	else if (flags & FL_SIGN)
X		*s2++ = '+';
X	else if (flags & FL_SPACE)
X		*s2++ = ' ';
X
X	if (!(flags & FL_ALT))
X		for (i = nndigit - 1; i > 0 && s1[i] == '0'; i--)
X			nndigit--;
X
X	if (USE_EXP(dp,ndigit))	{
X		/* Use E format */
X		dp--;
X		*s2++ = *s1++;
X		if ((nndigit > 1) || (flags & FL_ALT)) *s2++ = '.';
X		while (--nndigit > 0) *s2++ = *s1++;
X		*s2++ = 'e';
X		if (dp < 0) {
X			*s2++ = '-';
X			dp = -dp;
X		}
X		else	 *s2++ = '+';
X		s2 += NDIGINEXP(dp);
X		*s2 = 0;
X		for (i = NDIGINEXP(dp); i > 0; i--) {
X			*--s2 = dp % 10 + '0';
X			dp /= 10;
X		}
X		return s;
X	}
X	/* Use f format */
X	if (dp <= 0) {
X		if (*s1 != '0')	{
X			/* otherwise the whole number is 0 */
X			*s2++ = '0';
X			*s2++ = '.';
X		}
X		while (dp < 0) {
X			dp++;
X			*s2++ = '0';
X		}
X	}
X	for (i = 1; i <= nndigit; i++) {
X		*s2++ = *s1++;
X		if (i == dp) *s2++ = '.';
X	}
X	if (i <= dp) {
X		while (i++ <= dp) *s2++ = '0';
X		*s2++ = '.';
X	}
X	if ((s2[-1]=='.') && !(flags & FL_ALT)) s2--;
X	*s2 = '\0';
X	return s;
X}
X
Xchar *
X_f_print(va_list *ap, int flags, char *s, char c, int precision)
X{
X	register char *old_s = s;
X	long double ld_val;
X
X	if (flags & FL_LONGDOUBLE) ld_val = va_arg(*ap, long double);
X	else ld_val = (long double) va_arg(*ap, double);
X
X	switch(c) {
X	case 'f':
X		s = _pfloat(ld_val, s, precision, flags);
X		break;
X	case 'e':
X	case 'E':
X		s = _pscien(ld_val, s, precision , flags);
X		break;
X	case 'g':
X	case 'G':
X		s = _gcvt(ld_val, precision, s, flags);
X		s += strlen(s);
X		break;
X	}
X	if ( c == 'E' || c == 'G') {
X		while (*old_s && *old_s != 'e') old_s++;
X		if (*old_s == 'e') *old_s = 'E';
X	}
X	return s;
X}
X#endif	/* NOFLOAT */
X/* $Header: strtod.c,v 1.3 90/09/07 11:00:24 eck Exp $ */
X
X#include <stdlib.h>
X#include "../ansi/ext_fmt.h"
X
Xvoid _str_ext_cvt(const char *s, char **ss, struct EXTEND *e);
Xdouble _ext_dbl_cvt(struct EXTEND *e);
X
Xdouble
Xstrtod(const char *p, char **pp)
X{
X	struct EXTEND e;
X
X	_str_ext_cvt(p, pp, &e);
X	return _ext_dbl_cvt(&e);
X}
/
echo x - lib/stdio/Makefile
sed '/^X/s///' > lib/stdio/Makefile << '/'
XCC=exec cc
XCFLAGS= -c -O -D_MINIX -D_POSIX_SOURCE
X
X
Xall:	
X	@$(CC) $(CFLAGS) *.c
X
X
Xclean:	
X	@rm -rf *.o *.s *.bak
X
/
echo x - lib/stdio/ecvt.c
sed '/^X/s///' > lib/stdio/ecvt.c << '/'
X/* $Header: ecvt.c,v 1.4 90/02/27 16:47:28 eck Exp $ */
X
X#ifndef NOFLOAT
X
X#include	"../ansi/ext_fmt.h"
Xvoid _dbl_ext_cvt(double value, struct EXTEND *e);
Xchar *_ext_str_cvt(struct EXTEND *e, int ndigit, int *decpt, int * sign, int ecvtflag);
X
Xstatic char *
Xcvt(long double value, int ndigit, int *decpt, int *sign, int ecvtflag)
X{
X	struct EXTEND e;
X
X	_dbl_ext_cvt(value, &e);
X	return _ext_str_cvt(&e, ndigit, decpt, sign, ecvtflag);
X}
X
Xchar *
X_ecvt(long double value, int ndigit, int *decpt, int *sign)
X{
X
X	return cvt(value, ndigit, decpt, sign, 1);
X}
X
Xchar *
X_fcvt(long double value, int ndigit, int *decpt, int *sign)
X{
X	return cvt(value, ndigit, decpt, sign, 0);
X}
X
X#endif	/* NOFLOAT */
/