housel@en.ecn.purdue.edu (Peter S. Housel) (07/29/89)
#! /bin/sh # This is a shell archive. Remove anything before this line, then feed it # into a shell via "sh file" or similar. To overwrite existing files, # type "sh file -c". # The tool that generated this appeared in the comp.sources.unix newsgroup; # send mail to comp-sources-unix@uunet.uu.net if you want that tool. # If this archive is complete, you will see the following message at the end: # "End of archive 3 (of 3)." # Contents: CRCLIST INSTALL PATCHDATES _mult.c _poly.c atof.c ceil.c # cmf8.x fabs.c fat.x floor.c fprintf.c frexp.x ldexp.x log.c # log10.c math.h ngf8.x pow.c printf.c ret8.x return.x sprintf.c # sqrt.c stdarg.h stddef.h vprintf.c vsprintf.c zrf4.x zrf8.x # Wrapped by housel@en.ecn.purdue.edu on Fri Jul 28 13:35:06 1989 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f 'CRCLIST' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'CRCLIST'\" else echo shar: Extracting \"'CRCLIST'\" \(1062 characters\) sed "s/^X//" >'CRCLIST' <<'END_OF_FILE' X35755 1463 README X08768 959 INSTALL X64828 23050 NOTES X00000 0 PATCHDATES X17937 2672 Makefile X54306 237 _mult.c X36358 422 _poly.c X35521 3165 addsub.x X17705 228 atof.c X40376 4500 cc.c.cdif X30759 185 ceil.c X22574 2066 cff.x X20972 3518 cfi.x X46705 3044 cfu.x X11728 1680 cif.x X19132 1066 cmf8.x X38279 1303 cuf.x X32884 2526 dvf8.x X01999 1386 exp.c X45566 164 fabs.c X06685 83 fat.x X61104 747 float.h X53954 187 floor.c X00541 13586 fpp.c X00824 334 fprintf.c X23491 778 frexp.x X39546 1162 ldexp.x X44140 1009 log.c X04771 223 log10.c X18095 963 math.h X33392 5794 mlf8.x X29029 1734 modf.x X24283 139 ngf8.x X64390 1618 norm4.x X47306 1780 norm8.x X20650 843 pow.c X45663 319 printf.c X31076 135 ret8.x X11663 157 return.x X23916 237 sprintf.c X60563 693 sqrt.c X44177 266 stdarg.h X29042 108 stddef.h X06321 1737 strtod.c X52690 3370 strtod_aux.x X46583 2041 trp.x X37342 15492 vfprintf.c X09137 138 vprintf.c X25571 364 vsprintf.c X09483 198 zrf4.x X15137 219 zrf8.x END_OF_FILE if test 1062 -ne `wc -c <'CRCLIST'`; then echo shar: \"'CRCLIST'\" unpacked with wrong size! fi # end of 'CRCLIST' fi if test -f 'INSTALL' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'INSTALL'\" else echo shar: Extracting \"'INSTALL'\" \(959 characters\) sed "s/^X//" >'INSTALL' <<'END_OF_FILE' XInstructions for installing the floating point package: X X1. Install all of the following include files in /usr/include: X Xmath.h stdarg.h stddef.h float.h X X2. If you are still using the 1.1 compiler, a) you shouldn't be, Xb) uncomment the "MINIX1_1OBJS =" line in the Makefile. Much of Xthe development work was done using the 1.1 compiler, but I switched Xin mid-project and so am unable to test this. If there are any Xproblems I will try to fix them. X X3. Make and install the floating point preprocessor: X X # make fpp X # chmem =4096 fpp X # mv fpp /usr/lib X X4. Patch the C compiler-driver using the enclosed "cc.c.cdif". This Xfile is relative to the 1.3 release, and includes the 1.4a patches. XMake a new binary for "cc", and install it. This patch adds the X"-f" flag to the compiler driver, which must be used whenever Xa program uses floating point math. X X5. Make and install the floating point library, libfp.a: X X # make libfp.a X # mv libfp.a /usr/lib END_OF_FILE if test 959 -ne `wc -c <'INSTALL'`; then echo shar: \"'INSTALL'\" unpacked with wrong size! fi # end of 'INSTALL' fi if test -f 'PATCHDATES' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'PATCHDATES'\" else echo shar: Extracting \"'PATCHDATES'\" \(0 characters\) sed "s/^X//" >'PATCHDATES' <<'END_OF_FILE' END_OF_FILE if test 0 -ne `wc -c <'PATCHDATES'`; then echo shar: \"'PATCHDATES'\" unpacked with wrong size! fi # end of 'PATCHDATES' fi if test -f '_mult.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'_mult.c'\" else echo shar: Extracting \"'_mult.c'\" \(237 characters\) sed "s/^X//" >'_mult.c' <<'END_OF_FILE' X/* _mult.c */ X X#include <math.h> X X/* "safe" multiply. Returns x * y if in range, and HUGE_VAL with proper X * sign if not. X */ Xdouble _mult(x, y) Xdouble x, y; X{ X int exponent; X X x = frexp(x, &exponent); X return ldexp(x * y, exponent); X} END_OF_FILE if test 237 -ne `wc -c <'_mult.c'`; then echo shar: \"'_mult.c'\" unpacked with wrong size! fi # end of '_mult.c' fi if test -f '_poly.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'_poly.c'\" else echo shar: Extracting \"'_poly.c'\" \(422 characters\) sed "s/^X//" >'_poly.c' <<'END_OF_FILE' X/* _poly.c */ X X#include <math.h> X X/* Polynomial evaluation using Horner's method. Should be called with X * restricted-range |z| arguments, because no overflow checking is done. X */ Xdouble _poly(z, coeff, ncoeff) Xdouble z; Xregister double *coeff; Xregister int ncoeff; X{ X double result; X X coeff += ncoeff; X result = *--coeff; X X while(--ncoeff > 0) X { X result = *--coeff + (z * result); X } X X return result; X} END_OF_FILE if test 422 -ne `wc -c <'_poly.c'`; then echo shar: \"'_poly.c'\" unpacked with wrong size! fi # end of '_poly.c' fi if test -f 'atof.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'atof.c'\" else echo shar: Extracting \"'atof.c'\" \(228 characters\) sed "s/^X//" >'atof.c' <<'END_OF_FILE' X/* file: atof.c */ X X/* #include <stddef.h> */ X/* #include <stdlib.h> */ X X#ifndef NULL X#define NULL 0 X#endif X Xextern double strtod(/* const char *s, char **endp */); X Xdouble atof(s) Xchar *s; X{ X return strtod(s, (char **)NULL); X} END_OF_FILE if test 228 -ne `wc -c <'atof.c'`; then echo shar: \"'atof.c'\" unpacked with wrong size! fi # end of 'atof.c' fi if test -f 'ceil.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'ceil.c'\" else echo shar: Extracting \"'ceil.c'\" \(185 characters\) sed "s/^X//" >'ceil.c' <<'END_OF_FILE' X/* ceil.c */ X X#include <math.h> X Xdouble ceil(x) Xdouble x; X{ X double fract; X double ipart; X X fract = modf(x, &ipart); X X if(fract > 0.0) X return ipart + 1.0; X else X return ipart; X} END_OF_FILE if test 185 -ne `wc -c <'ceil.c'`; then echo shar: \"'ceil.c'\" unpacked with wrong size! fi # end of 'ceil.c' fi if test -f 'cmf8.x' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'cmf8.x'\" else echo shar: Extracting \"'cmf8.x'\" \(1066 characters\) sed "s/^X//" >'cmf8.x' <<'END_OF_FILE' X.define .cmf8 X| X| floating point compare routine X| author: Peter S. Housel 6/3/89 X| X XV = 4 | offset of second operand XU = V + 8 | offset of first operand X X .text X .globl .cmf8 X.cmf8: X push si X mov si,sp X X mov ax,6+U(si) X test ax,ax | check sign bit X jns 1f X not 0+U(si) | negate X add 0+U(si),#1 X not 2+U(si) X adc 2+U(si),#1 X not 4+U(si) X adc 4+U(si),#1 X not 6+U(si) X adc 6+U(si),#1 X xorb 7+U(si),*128 | toggle sign bit X1: X mov ax,6+V(si) X test ax,ax | check sign bit X jns 2f X not 0+V(si) | negate X add 0+V(si),#1 X not 2+V(si) X adc 2+V(si),#1 X not 4+V(si) X adc 4+V(si),#1 X not 6+V(si) X adc 6+V(si),#1 X xorb 7+V(si),*128 | toggle sign bit X2: X mov ax,6+U(si) X cmp ax,6+V(si) X jg gt X jl lt X mov ax,4+U(si) X cmp ax,4+V(si) X ja gt X jb lt X mov ax,2+U(si) X cmp ax,2+V(si) X ja gt X jb lt X mov ax,0+U(si) X cmp ax,0+V(si) X ja gt X jb lt Xeq: X xor ax,ax X jmp 9f Xlt: X mov ax,#-1 X jmp 9f Xgt: X mov ax,#1 X X9: pop si | restore register variable X pop bx | bx = return address X add sp,#16 | remove arguments X push ax | put flag on stack X push bx | restore return address X ret END_OF_FILE if test 1066 -ne `wc -c <'cmf8.x'`; then echo shar: \"'cmf8.x'\" unpacked with wrong size! fi # end of 'cmf8.x' fi if test -f 'fabs.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'fabs.c'\" else echo shar: Extracting \"'fabs.c'\" \(164 characters\) sed "s/^X//" >'fabs.c' <<'END_OF_FILE' X/* fabs.c */ X X#include <math.h> X X/* this could be done even more cheaply in assembly */ X Xdouble fabs(x) Xdouble x; X{ X if(x < 0) X return -x; X else X return x; X} END_OF_FILE if test 164 -ne `wc -c <'fabs.c'`; then echo shar: \"'fabs.c'\" unpacked with wrong size! fi # end of 'fabs.c' fi if test -f 'fat.x' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'fat.x'\" else echo shar: Extracting \"'fat.x'\" \(83 characters\) sed "s/^X//" >'fat.x' <<'END_OF_FILE' X.define .fat X X .text X .globl .fat X .globl .trp,.stop X.fat: X call .trp X call .stop X END_OF_FILE if test 83 -ne `wc -c <'fat.x'`; then echo shar: \"'fat.x'\" unpacked with wrong size! fi # end of 'fat.x' fi if test -f 'floor.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'floor.c'\" else echo shar: Extracting \"'floor.c'\" \(187 characters\) sed "s/^X//" >'floor.c' <<'END_OF_FILE' X/* floor.c */ X X#include <math.h> X Xdouble floor(x) Xdouble x; X{ X double fract; X double ipart; X X fract = modf(x, &ipart); X X if(fract < 0.0) X return ipart - 1.0; X else X return ipart; X} END_OF_FILE if test 187 -ne `wc -c <'floor.c'`; then echo shar: \"'floor.c'\" unpacked with wrong size! fi # end of 'floor.c' fi if test -f 'fprintf.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'fprintf.c'\" else echo shar: Extracting \"'fprintf.c'\" \(334 characters\) sed "s/^X//" >'fprintf.c' <<'END_OF_FILE' X#include <stdio.h> X#include <stdarg.h> X Xint fprintf(file, format /* , ... */) XFILE *file; Xchar *format; X{ X register va_list argp; X int count; X X va_start(argp, format); X count = vfprintf(file, format, argp); X va_end(argp); X X#ifdef PERPRINTF /* for Minix */ X if(testflag(file, PERPRINTF)) X fflush(file); X#endif X X return count; X} X END_OF_FILE if test 334 -ne `wc -c <'fprintf.c'`; then echo shar: \"'fprintf.c'\" unpacked with wrong size! fi # end of 'fprintf.c' fi if test -f 'frexp.x' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'frexp.x'\" else echo shar: Extracting \"'frexp.x'\" \(778 characters\) sed "s/^X//" >'frexp.x' <<'END_OF_FILE' X.define _frexp X XBIAS8 = 0x3ff - 1 X X .globl _frexp X .text X_frexp: X push bp X mov bp,sp X lea bx,4(bp) X mov cx,#8 | copy value onto stack X call .loi X X mov cx,-2(bp) | extract value.exp X shr cx,*1 X shr cx,*1 X shr cx,*1 X shr cx,*1 X and cx,#2047 | kill sign bit X X mov ax,-2(bp) | remove exponent from value.mantissa X and ax,#0x0F X test cx,cx | check for zero exponent - no leading "1" X jz 0f | for denormalized numbers X or ax,#0x10 | restore implied leading "1" X0: mov -2(bp),ax X X sub cx,#BIAS8 | remove bias X X or ax,-4(bp) | check for zero X or ax,-6(bp) X or ax,-8(bp) X jnz 1f X xor cx,cx | if zero, exponent is zero X1: X mov bx,12(bp) | store exponent X mov (bx),cx X X mov bx,#BIAS8 | set bias for return value X xor dx,dx | sign = 0, rounding = 0 X call .norm8 X call .ret8 X jmp .cret END_OF_FILE if test 778 -ne `wc -c <'frexp.x'`; then echo shar: \"'frexp.x'\" unpacked with wrong size! fi # end of 'frexp.x' fi if test -f 'ldexp.x' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'ldexp.x'\" else echo shar: Extracting \"'ldexp.x'\" \(1162 characters\) sed "s/^X//" >'ldexp.x' <<'END_OF_FILE' X.define _ldexp X X .globl _ldexp X .text X_ldexp: X push bp X mov bp,sp X lea bx,4(bp) | push value onto the stack X mov cx,#8 X call .loi X X mov bx,-2(bp) | extract value.exp X movb dh,bh | extract value.sign X shr bx,*1 X shr bx,*1 X shr bx,*1 X shr bx,*1 X and bx,#2047 | kill sign bit X X mov ax,-2(bp) | remove exponent from value.mantissa X and ax,#0x0F X test bx,bx | check for zero exponent - no leading "1" X jz 0f | for denormalized numbers X or ax,#0x10 | restore implied leading "1" X0: mov -2(bp),ax X X add bx,12(bp) | add in exponent X cmp bx,#0 X jl retz | range error - underflow X cmp bx,#2047 X jge rangerr | range error - overflow X X xorb dl,dl | zero rounding bits X X call .norm8 | normalize X X1: call .ret8 X jmp .cret X XERANGE = 34 | from <errno.h> X .globl _errno X Xretz: X mov _errno,#ERANGE | set errno X add sp,#8 | remove mantissa X call .zrf8 | return zero X jmp 1b Xrangerr: X mov _errno,#ERANGE | set errno X add sp,#8 | remove mantissa X mov bx,#huge_val | same as HUGE_VAL in <math.h> X mov cx,#8 X call .loi X andb dh,*128 | get the sign bit of the argument, X orb -1(bp),dh | set the sign of HUGE_VAL X jmp 1b X X .data Xhuge_val: X .word 0xffff,0xffff,0xffff,0x7fff END_OF_FILE if test 1162 -ne `wc -c <'ldexp.x'`; then echo shar: \"'ldexp.x'\" unpacked with wrong size! fi # end of 'ldexp.x' fi if test -f 'log.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'log.c'\" else echo shar: Extracting \"'log.c'\" \(1009 characters\) sed "s/^X//" >'log.c' <<'END_OF_FILE' X/* log.c */ X X#include <math.h> X#include <errno.h> Xextern int errno; X Xextern double _poly(/* double z, double coeff[], int ncoeff */); X X/* the commented out number is the real answer, and the other is the X * answer that makes log(1.0) come out to zero. Bleah! X */ X/* #define LOG2 6.9314718055994530942705877E-1 */ X#define LOG2 6.931471802121982E-1 X X/* These coefficients came from the BSD libm's log__L.c file */ Xstatic double logcoeff[] = X { X 2.0, X 6.6666666666667340202E-1, X 3.9999999999416702146E-1, X 2.8571428742008753154E-1, X 2.2222198607186277597E-1, X 1.8183562745289935658E-1, X 1.5314087275331442206E-1, X 1.4795612545334174692E-1 X }; X X#define NCOEFF ((sizeof logcoeff) / sizeof(double)) X Xdouble log(x) Xdouble x; X{ X double fract; X double ratio; X int exponent; X X if(x <= 0.0) X { X errno = EDOM; X return -HUGE_VAL; X } X X fract = frexp(x, &exponent); X X ratio = (fract - 1.0) / (fract + 1.0); X X x = exponent + ratio * _poly(ratio * ratio, logcoeff, NCOEFF) / LOG2; X X return x * LOG2; X} END_OF_FILE if test 1009 -ne `wc -c <'log.c'`; then echo shar: \"'log.c'\" unpacked with wrong size! fi # end of 'log.c' fi if test -f 'log10.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'log10.c'\" else echo shar: Extracting \"'log10.c'\" \(223 characters\) sed "s/^X//" >'log10.c' <<'END_OF_FILE' X/* log10.c */ X X#include <math.h> X X#define LOG10 2.3025850929940456790E0 X Xdouble log10(x) Xdouble x; X{ X double alog; X X if((alog = log(x)) == -HUGE_VAL) X return alog; /* with errno set to EDOM */ X return alog * LOG10; X} END_OF_FILE if test 223 -ne `wc -c <'log10.c'`; then echo shar: \"'log10.c'\" unpacked with wrong size! fi # end of 'log10.c' fi if test -f 'math.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'math.h'\" else echo shar: Extracting \"'math.h'\" \(963 characters\) sed "s/^X//" >'math.h' <<'END_OF_FILE' X/* math.h */ X X#ifndef _MATH_H X#define _MATH_H X X#define HUGE_VAL 1.7976931348623159E+308 X Xextern double sin(/* double theta */); Xextern double cos(/* double theta */); Xextern double tan(/* double theta */); Xextern double asin(/* double x */); Xextern double acos(/* double x */); Xextern double atan(/* double x */); Xextern double atan2(/* double x, double y */); Xextern double sinh(/* double x */); Xextern double cosh(/* double x */); Xextern double tanh(/* double x */); Xextern double exp(/* double x */); Xextern double log(/* double x */); Xextern double log10(/* double x */); Xextern double pow(/* double x */); Xextern double sqrt(/* double x */); Xextern double ceil(/* double x */); Xextern double floor(/* double x */); Xextern double fabs(/* double x */); Xextern double ldexp(/* double x, int n */); Xextern double frexp(/* double x, int *exp */); Xextern double modf(/* double x, double *ip */); Xextern double fmod(/* double x, double y */); X X#endif /* _MATH_H */ END_OF_FILE if test 963 -ne `wc -c <'math.h'`; then echo shar: \"'math.h'\" unpacked with wrong size! fi # end of 'math.h' fi if test -f 'ngf8.x' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'ngf8.x'\" else echo shar: Extracting \"'ngf8.x'\" \(139 characters\) sed "s/^X//" >'ngf8.x' <<'END_OF_FILE' X.define .ngf8 X X .globl .ngf8 X .text X.ngf8: | floating point negate X push si X mov si,sp X xorb 7+4(si),*0x80 | flip sign bit X pop si X ret END_OF_FILE if test 139 -ne `wc -c <'ngf8.x'`; then echo shar: \"'ngf8.x'\" unpacked with wrong size! fi # end of 'ngf8.x' fi if test -f 'pow.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'pow.c'\" else echo shar: Extracting \"'pow.c'\" \(843 characters\) sed "s/^X//" >'pow.c' <<'END_OF_FILE' X/* pow.c */ X X#include <limits.h> X#include <math.h> X#include <errno.h> Xextern int errno; X Xextern double _mult(/* double x, double y */); X Xdouble pow(x, y) Xdouble x, y; X{ X int sign = 0; X double power, result; X X if(x == 0) X { X if(y <= 0) X { X errno = EDOM; X return HUGE_VAL; X } X else X return 0; X } X else if(x < 0) X { X if(floor(y) != y || y < (double) INT_MIN || y > (double) INT_MAX) X { X errno = EDOM; X return HUGE_VAL; X } X if(((int) y) & 1) /* odd power */ X sign = 1; X x = -x; X } X X /* we could save two multiplications (or so) by 'inlining' the code for X * exp() and log() at this point. It's not worth it. */ X X if((power = _mult(y, log(x))) == HUGE_VAL) X { X return HUGE_VAL; /* with errno = ERANGE */ X } X X result = exp(power); X X return sign ? -result : result; X} END_OF_FILE if test 843 -ne `wc -c <'pow.c'`; then echo shar: \"'pow.c'\" unpacked with wrong size! fi # end of 'pow.c' fi if test -f 'printf.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'printf.c'\" else echo shar: Extracting \"'printf.c'\" \(319 characters\) sed "s/^X//" >'printf.c' <<'END_OF_FILE' X#include <stdio.h> X#include <stdarg.h> X Xint printf(format /* , ... */) Xchar *format; X{ X register va_list argp; X int count; X X va_start(argp, format); X count = vfprintf(stdout, format, argp); X va_end(argp); X X#ifdef PERPRINTF /* for Minix */ X if(testflag(stdout, PERPRINTF)) X fflush(stdout); X#endif X X return count; X} END_OF_FILE if test 319 -ne `wc -c <'printf.c'`; then echo shar: \"'printf.c'\" unpacked with wrong size! fi # end of 'printf.c' fi if test -f 'ret8.x' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'ret8.x'\" else echo shar: Extracting \"'ret8.x'\" \(135 characters\) sed "s/^X//" >'ret8.x' <<'END_OF_FILE' X.define .ret8 X X .globl .ret8 X .text X.ret8: X push bp X mov bp,sp X mov ax,4(bp) X mov dx,6(bp) X mov bx,8(bp) X mov cx,10(bp) X pop bp X ret 8 END_OF_FILE if test 135 -ne `wc -c <'ret8.x'`; then echo shar: \"'ret8.x'\" unpacked with wrong size! fi # end of 'ret8.x' fi if test -f 'return.x' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'return.x'\" else echo shar: Extracting \"'return.x'\" \(157 characters\) sed "s/^X//" >'return.x' <<'END_OF_FILE' X.define .sdret, .dsret, .sret, .dret, .cret X.text X X.dsret: X pop di X.sret: X pop si X.cret: X mov sp,bp X pop bp X ret X X.sdret: X pop si X.dret: X pop di X jmp .cret END_OF_FILE if test 157 -ne `wc -c <'return.x'`; then echo shar: \"'return.x'\" unpacked with wrong size! fi # end of 'return.x' fi if test -f 'sprintf.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'sprintf.c'\" else echo shar: Extracting \"'sprintf.c'\" \(237 characters\) sed "s/^X//" >'sprintf.c' <<'END_OF_FILE' X#include <stdio.h> X#include <stdarg.h> X Xint sprintf(buf, format /* , ... */) Xchar *buf; Xchar *format; X{ X register va_list argp; X int count; X X va_start(argp, format); X count = vsprintf(buf, format, argp); X va_end(argp); X X return count; X} END_OF_FILE if test 237 -ne `wc -c <'sprintf.c'`; then echo shar: \"'sprintf.c'\" unpacked with wrong size! fi # end of 'sprintf.c' fi if test -f 'sqrt.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'sqrt.c'\" else echo shar: Extracting \"'sqrt.c'\" \(693 characters\) sed "s/^X//" >'sqrt.c' <<'END_OF_FILE' X/* sqrt.c */ X X#include <math.h> X#include <errno.h> Xextern int errno; X X#define SQRT2 1.4142135623730951455E0 X X/* initial minimum mean-squared-error linear approximation constants */ X#define C1 .582905362174731941742E0 X#define C0 .424749790911252694093E0 X Xdouble sqrt(x) Xdouble x; X{ X int exponent; X double y; X X if(x < 0.0) X { X errno = EDOM; X return 0; X } X X if(x == 0) X return 0; X X x = frexp(x, &exponent); /* work in interval [.5,1) */ X X y = C1 * x + C0; /* start with linear approximation */ X X y += x / y; /* iterate twice */ X y = (0.25 * y) + (x / y); X X y += x / y; X y = (0.25 * y) + (x / y); X X if(exponent & 1) X y *= SQRT2; X X return ldexp(y, exponent >> 1); X} END_OF_FILE if test 693 -ne `wc -c <'sqrt.c'`; then echo shar: \"'sqrt.c'\" unpacked with wrong size! fi # end of 'sqrt.c' fi if test -f 'stdarg.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'stdarg.h'\" else echo shar: Extracting \"'stdarg.h'\" \(266 characters\) sed "s/^X//" >'stdarg.h' <<'END_OF_FILE' X/* stdarg.h */ X X#ifndef _STDARG_H X#define _STDARG_H X Xtypedef char *va_list; X X#define va_start(argp, lastarg) ((argp) = (char *)&(lastarg)+sizeof(lastarg)) X#define va_arg(argp, type) ((type *)((argp) += sizeof(type)))[-1] X#define va_end(argp) X X#endif /* _STDARG_H */ END_OF_FILE if test 266 -ne `wc -c <'stdarg.h'`; then echo shar: \"'stdarg.h'\" unpacked with wrong size! fi # end of 'stdarg.h' fi if test -f 'stddef.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'stddef.h'\" else echo shar: Extracting \"'stddef.h'\" \(109 characters\) sed "s/^X//" >'stddef.h' <<'END_OF_FILE' X/* stddef.h */ X X#ifndef _STDDEF_H X#define _STDDEF_H X X#ifndef NULL X#define NULL ((void *) 0) X#endif X X X X#endif END_OF_FILE if test 109 -ne `wc -c <'stddef.h'`; then echo shar: \"'stddef.h'\" unpacked with wrong size! fi # end of 'stddef.h' fi if test -f 'vprintf.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'vprintf.c'\" else echo shar: Extracting \"'vprintf.c'\" \(138 characters\) sed "s/^X//" >'vprintf.c' <<'END_OF_FILE' X#include <stdio.h> X#include <stdarg.h> X Xint vprintf(format, argp) Xchar *format; Xva_list argp; X{ X return vfprintf(stdout, format, argp); X} END_OF_FILE if test 138 -ne `wc -c <'vprintf.c'`; then echo shar: \"'vprintf.c'\" unpacked with wrong size! fi # end of 'vprintf.c' fi if test -f 'vsprintf.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'vsprintf.c'\" else echo shar: Extracting \"'vsprintf.c'\" \(364 characters\) sed "s/^X//" >'vsprintf.c' <<'END_OF_FILE' X#include <stdio.h> X#include <stdarg.h> X Xint vsprintf(buf, format, argp) Xchar *buf; Xchar *format; Xregister va_list argp; X{ X int count; X FILE stringfile; X X stringfile._fd = -1; X stringfile._flags = WRITEMODE|STRINGS; X stringfile._buf = buf; X stringfile._ptr = buf; X X count = vfprintf(&stringfile, format, argp); X X *(stringfile._ptr) = '\0'; X X return count; X} END_OF_FILE if test 364 -ne `wc -c <'vsprintf.c'`; then echo shar: \"'vsprintf.c'\" unpacked with wrong size! fi # end of 'vsprintf.c' fi if test -f 'zrf4.x' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'zrf4.x'\" else echo shar: Extracting \"'zrf4.x'\" \(198 characters\) sed "s/^X//" >'zrf4.x' <<'END_OF_FILE' X.define .zrf4 X X .globl .zrf4 X .text X.zrf4: | push (float) 0.0 X pop bx | save return address X xor ax,ax | ax = 0 X push ax | push two zero words X push ax X push bx | restore return address X ret END_OF_FILE if test 198 -ne `wc -c <'zrf4.x'`; then echo shar: \"'zrf4.x'\" unpacked with wrong size! fi # end of 'zrf4.x' fi if test -f 'zrf8.x' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'zrf8.x'\" else echo shar: Extracting \"'zrf8.x'\" \(219 characters\) sed "s/^X//" >'zrf8.x' <<'END_OF_FILE' X.define .zrf8 X X .globl .zrf8 X .text X.zrf8: | push (double) +0.0 X pop bx | save return address X xor ax,ax | ax = 0 X push ax | push four zero words X push ax X push ax X push ax X push bx | restore return address X ret END_OF_FILE if test 219 -ne `wc -c <'zrf8.x'`; then echo shar: \"'zrf8.x'\" unpacked with wrong size! fi # end of 'zrf8.x' fi echo shar: End of archive 3 \(of 3\). cp /dev/null ark3isdone MISSING="" for I in 1 2 3 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have unpacked all 3 archives. rm -f ark[1-9]isdone else echo You still need to unpack the following archives: echo " " ${MISSING} fi ## End of shell archive. exit 0