libc floating point and stdio floating point can now be turned on and off using

ACKCONF variables.
This commit is contained in:
David Given 2018-06-23 00:04:14 +02:00
parent 9bf1d548fc
commit 94ffa3ba88
31 changed files with 153 additions and 22 deletions

View file

@ -8,8 +8,11 @@
#include <math.h> #include <math.h>
#include <errno.h> #include <errno.h>
#include <ack/config.h>
#include "localmath.h" #include "localmath.h"
#if ACKCONF_WANT_FLOAT
static double static double
asin_acos(double x, int cosfl) asin_acos(double x, int cosfl)
{ {
@ -90,3 +93,5 @@ acos(double x)
{ {
return asin_acos(x, 1); return asin_acos(x, 1);
} }
#endif

View file

@ -9,8 +9,11 @@
#include <float.h> #include <float.h>
#include <math.h> #include <math.h>
#include <errno.h> #include <errno.h>
#include <ack/config.h>
#include "localmath.h" #include "localmath.h"
#if ACKCONF_WANT_FLOAT
double double
atan(double x) atan(double x)
{ {
@ -75,3 +78,6 @@ atan(double x)
x += a[n]; x += a[n];
return neg ? -x : x; return neg ? -x : x;
} }
#endif

View file

@ -8,8 +8,11 @@
#include <math.h> #include <math.h>
#include <errno.h> #include <errno.h>
#include <ack/config.h>
#include "localmath.h" #include "localmath.h"
#if ACKCONF_WANT_FLOAT
double double
atan2(double y, double x) atan2(double y, double x)
{ {
@ -46,3 +49,6 @@ atan2(double y, double x)
} }
return val + M_PI; return val + M_PI;
} }
#endif

View file

@ -7,6 +7,9 @@
/* $Id$ */ /* $Id$ */
#include <math.h> #include <math.h>
#include <ack/config.h>
#if ACKCONF_WANT_FLOAT
double double
ceil(double x) ceil(double x)
@ -18,3 +21,6 @@ ceil(double x)
fractional part fractional part
*/ */
} }
#endif

View file

@ -9,8 +9,11 @@
#include <math.h> #include <math.h>
#include <float.h> #include <float.h>
#include <errno.h> #include <errno.h>
#include <ack/config.h>
#include "localmath.h" #include "localmath.h"
#if ACKCONF_WANT_FLOAT
double double
exp(double x) exp(double x)
{ {
@ -74,3 +77,6 @@ exp(double x)
n += 1; n += 1;
return (ldexp(0.5 + x / (POLYNOM3(xn, q) - x), n)); return (ldexp(0.5 + x / (POLYNOM3(xn, q) - x), n));
} }
#endif

View file

@ -5,9 +5,15 @@
* Author: Ceriel J.H. Jacobs * Author: Ceriel J.H. Jacobs
*/ */
/* $Id$ */ /* $Id$ */
#include <ack/config.h>
#if ACKCONF_WANT_FLOAT
double double
fabs(double x) fabs(double x)
{ {
return x < 0 ? -x : x; return x < 0 ? -x : x;
} }
#endif

View file

@ -7,6 +7,9 @@
/* $Id$ */ /* $Id$ */
#include <math.h> #include <math.h>
#include <ack/config.h>
#if ACKCONF_WANT_FLOAT
double double
floor(double x) floor(double x)
@ -18,3 +21,6 @@ floor(double x)
fractional part fractional part
*/ */
} }
#endif

View file

@ -5,6 +5,9 @@
#include <math.h> #include <math.h>
#include <errno.h> #include <errno.h>
#include <ack/config.h>
#if ACKCONF_WANT_FLOAT
double(fmod)(double x, double y) double(fmod)(double x, double y)
{ /* compute fmod(x, y) */ { /* compute fmod(x, y) */
@ -37,3 +40,6 @@ double(fmod)(double x, double y)
} }
return (neg ? -x : x); return (neg ? -x : x);
} }
#endif

View file

@ -5,7 +5,11 @@
*/ */
/* $Id$ */ /* $Id$ */
#include <ack/config.h>
mes 2,_EM_WSIZE,_EM_PSIZE mes 2,_EM_WSIZE,_EM_PSIZE
#if ACKCONF_WANT_FLOAT
exp $frexp exp $frexp
pro $frexp,0 pro $frexp,0
lal 0 lal 0
@ -16,3 +20,5 @@
sti _EM_WSIZE sti _EM_WSIZE
ret _EM_DSIZE ret _EM_DSIZE
end end
#endif

View file

@ -7,5 +7,11 @@
/* $Id$ */ /* $Id$ */
#include <math.h> #include <math.h>
#include <ack/config.h>
#if ACKCONF_WANT_FLOAT
double __huge_val = 1.0e+1000; /* This will generate a warning */ double __huge_val = 1.0e+1000; /* This will generate a warning */
#endif

View file

@ -6,6 +6,9 @@
*/ */
#include <math.h> #include <math.h>
#include <ack/config.h>
#if ACKCONF_WANT_FLOAT
/* $Id$ */ /* $Id$ */
@ -41,3 +44,6 @@ cabs(struct complex p_compl)
{ {
return hypot(p_compl.r, p_compl.i); return hypot(p_compl.r, p_compl.i);
} }
#endif

View file

@ -1,3 +1,8 @@
#include <math.h>
#include <ack/config.h>
#if ACKCONF_WANT_FLOAT
__IsNan(double d) __IsNan(double d)
{ {
#if defined(__vax) || defined(__pdp) #if defined(__vax) || defined(__pdp)
@ -9,3 +14,6 @@ __IsNan(double d)
#endif #endif
return 0; return 0;
} }
#endif

View file

@ -7,6 +7,9 @@
#include <math.h> #include <math.h>
#include <float.h> #include <float.h>
#include <errno.h> #include <errno.h>
#include <ack/config.h>
#if ACKCONF_WANT_FLOAT
double double
ldexp(double fl, int exp) ldexp(double fl, int exp)
@ -63,3 +66,6 @@ ldexp(double fl, int exp)
} }
return sign * fl; return sign * fl;
} }
#endif

View file

@ -9,8 +9,11 @@
#include <math.h> #include <math.h>
#include <float.h> #include <float.h>
#include <errno.h> #include <errno.h>
#include <ack/config.h>
#include "localmath.h" #include "localmath.h"
#if ACKCONF_WANT_FLOAT
double double
log(double x) log(double x)
{ {
@ -73,3 +76,6 @@ log(double x)
x += z * (-2.121944400546905827679e-4); x += z * (-2.121944400546905827679e-4);
return x + z * 0.693359375; return x + z * 0.693359375;
} }
#endif

View file

@ -8,8 +8,11 @@
#include <math.h> #include <math.h>
#include <errno.h> #include <errno.h>
#include <ack/config.h>
#include "localmath.h" #include "localmath.h"
#if ACKCONF_WANT_FLOAT
double double
log10(double x) log10(double x)
{ {
@ -31,3 +34,6 @@ log10(double x)
return log(x) / M_LN10; return log(x) / M_LN10;
} }
#endif

View file

@ -4,8 +4,11 @@
* See the copyright notice in the ACK home directory, in the file "Copyright". * See the copyright notice in the ACK home directory, in the file "Copyright".
*/ */
/* $Id$ */ /* $Id$ */
#include <ack/config.h>
mes 2,_EM_WSIZE,_EM_PSIZE mes 2,_EM_WSIZE,_EM_PSIZE
#if ACKCONF_WANT_FLOAT
exp $modf exp $modf
pro $modf,0 pro $modf,0
lal 0 lal 0
@ -20,3 +23,4 @@
sti _EM_DSIZE sti _EM_DSIZE
ret _EM_DSIZE ret _EM_DSIZE
end end
#endif

View file

@ -10,6 +10,9 @@
#include <float.h> #include <float.h>
#include <errno.h> #include <errno.h>
#include <limits.h> #include <limits.h>
#include <ack/config.h>
#if ACKCONF_WANT_FLOAT
double double
pow(double x, double y) pow(double x, double y)
@ -120,3 +123,6 @@ pow(double x, double y)
} }
return ldexp(fp, newexp); return ldexp(fp, newexp);
} }
#endif

View file

@ -9,8 +9,11 @@
#include <math.h> #include <math.h>
#include <float.h> #include <float.h>
#include <errno.h> #include <errno.h>
#include <ack/config.h>
#include "localmath.h" #include "localmath.h"
#if ACKCONF_WANT_FLOAT
static double static double
sinus(double x, int cos_flag) sinus(double x, int cos_flag)
{ {
@ -106,3 +109,6 @@ cos(double x)
x = -x; x = -x;
return sinus(x, 1); return sinus(x, 1);
} }
#endif

View file

@ -9,8 +9,11 @@
#include <math.h> #include <math.h>
#include <float.h> #include <float.h>
#include <errno.h> #include <errno.h>
#include <ack/config.h>
#include "localmath.h" #include "localmath.h"
#if ACKCONF_WANT_FLOAT
static double static double
sinh_cosh(double x, int cosh_flag) sinh_cosh(double x, int cosh_flag)
{ {
@ -86,3 +89,6 @@ cosh(double x)
x = -x; x = -x;
return sinh_cosh(x, 1); return sinh_cosh(x, 1);
} }
#endif

View file

@ -9,6 +9,9 @@
#include <math.h> #include <math.h>
#include <float.h> #include <float.h>
#include <errno.h> #include <errno.h>
#include <ack/config.h>
#if ACKCONF_WANT_FLOAT
#define NITER 5 #define NITER 5
@ -47,3 +50,6 @@ sqrt(double x)
} }
return val; return val;
} }
#endif

View file

@ -9,8 +9,11 @@
#include <math.h> #include <math.h>
#include <float.h> #include <float.h>
#include <errno.h> #include <errno.h>
#include <ack/config.h>
#include "localmath.h" #include "localmath.h"
#if ACKCONF_WANT_FLOAT
double double
tan(double x) tan(double x)
{ {
@ -79,3 +82,6 @@ tan(double x)
x = -x; x = -x;
return invert ? -y / x : x / y; return invert ? -y / x : x / y;
} }
#endif

View file

@ -9,8 +9,11 @@
#include <float.h> #include <float.h>
#include <math.h> #include <math.h>
#include <errno.h> #include <errno.h>
#include <ack/config.h>
#include "localmath.h" #include "localmath.h"
#if ACKCONF_WANT_FLOAT
double double
tanh(double x) tanh(double x)
{ {
@ -58,3 +61,6 @@ tanh(double x)
} }
return negative ? -x : x; return negative ? -x : x;
} }
#endif

View file

@ -3,4 +3,12 @@
#include <ack/plat.h> #include <ack/plat.h>
#ifndef ACKCONF_WANT_FLOAT
#define ACKCONF_WANT_FLOAT 1
#endif
#ifndef ACKCONF_WANT_STDIO_FLOAT
#define ACKCONF_WANT_STDIO_FLOAT ACKCONF_WANT_FLOAT
#endif
#endif #endif

View file

@ -311,7 +311,7 @@ int _doprnt(register const char* fmt, va_list ap, FILE* stream)
case 'c': case 'c':
*s++ = va_arg(ap, int); *s++ = va_arg(ap, int);
break; break;
#ifndef ACKCONF_NO_STDIO_FLOAT #if ACKCONF_WANT_STDIO_FLOAT
case 'G': case 'G':
case 'g': case 'g':
if ((flags & FL_PRECSPEC) && (precision == 0)) if ((flags & FL_PRECSPEC) && (precision == 0))
@ -328,7 +328,7 @@ int _doprnt(register const char* fmt, va_list ap, FILE* stream)
flags |= FL_SIGNEDCONV; flags |= FL_SIGNEDCONV;
s = _f_print(&ap, flags, s, c, precision); s = _f_print(&ap, flags, s, c, precision);
break; break;
#endif /* ACKCONF_NO_STDIO_FLOAT */ #endif
case 'r': case 'r':
ap = va_arg(ap, va_list); ap = va_arg(ap, va_list);
fmt = va_arg(ap, char*); fmt = va_arg(ap, char*);

View file

@ -108,7 +108,7 @@ o_collect(register int c, register FILE* stream, char type,
return bufp - 1; return bufp - 1;
} }
#ifndef ACKCONF_NO_STDIO_FLOAT #if ACKCONF_WANT_STDIO_FLOAT
/* The function f_collect() reads a string that has the format of a /* The function f_collect() reads a string that has the format of a
* floating-point number. The function returns as soon as a format-error * floating-point number. The function returns as soon as a format-error
* is encountered, leaving the offending character in the input. This means * is encountered, leaving the offending character in the input. This means
@ -191,7 +191,7 @@ f_collect(register int c, register FILE* stream, register int width)
*bufp = '\0'; *bufp = '\0';
return bufp - 1; return bufp - 1;
} }
#endif /* ACKCONF_NO_STDIO_FLOAT */ #endif
/* /*
* the routine that does the scanning * the routine that does the scanning
@ -211,7 +211,7 @@ int _doscan(register FILE* stream, const char* format, va_list ap)
int reverse; /* reverse the checking in [...] */ int reverse; /* reverse the checking in [...] */
int kind; int kind;
register int ic; /* the input character */ register int ic; /* the input character */
#ifndef ACKCONF_NO_STDIO_FLOAT #if ACKCONF_WANT_STDIO_FLOAT
long double ld_val; long double ld_val;
#endif #endif
@ -495,7 +495,7 @@ int _doscan(register FILE* stream, const char* format, va_list ap)
*str = '\0'; *str = '\0';
} }
break; break;
#ifndef ACKCONF_NO_STDIO_FLOAT #if ACKCONF_WANT_STDIO_FLOAT
case 'e': case 'e':
case 'E': case 'E':
case 'f': case 'f':

View file

@ -2,7 +2,7 @@
#include "loc_incl.h" #include "loc_incl.h"
#ifndef ACKCONF_NO_STDIO_FLOAT #if ACKCONF_WANT_STDIO_FLOAT
#include "../stdlib/ext_fmt.h" #include "../stdlib/ext_fmt.h"
void _dbl_ext_cvt(double value, struct EXTEND* e); void _dbl_ext_cvt(double value, struct EXTEND* e);
@ -28,4 +28,4 @@ char* _fcvt(long double value, int ndigit, int* decpt, int* sign)
return cvt(value, ndigit, decpt, sign, 0); return cvt(value, ndigit, decpt, sign, 0);
} }
#endif /* ACKCONF_NO_STDIO_FLOAT */ #endif

View file

@ -7,7 +7,7 @@
#include <stdarg.h> #include <stdarg.h>
#include "loc_incl.h" #include "loc_incl.h"
#ifndef ACKCONF_NO_STDIO_FLOAT #if ACKCONF_WANT_STDIO_FLOAT
static char* static char*
_pfloat(long double r, register char* s, int n, int flags) _pfloat(long double r, register char* s, int n, int flags)
@ -209,4 +209,4 @@ char* _f_print(va_list* ap, int flags, char* s, char c, int precision)
} }
return s; return s;
} }
#endif /* ACKCONF_NO_STDIO_FLOAT */ #endif

View file

@ -19,10 +19,10 @@ void __cleanup(void);
FILE *popen(const char *command, const char *type); FILE *popen(const char *command, const char *type);
FILE *fdopen(int fd, const char *mode); FILE *fdopen(int fd, const char *mode);
#ifndef ACKCONF_NO_STDIO_FLOAT #if ACKCONF_WANT_STDIO_FLOAT
char *_ecvt(long double value, int ndigit, int *decpt, int *sign); char *_ecvt(long double value, int ndigit, int *decpt, int *sign);
char *_fcvt(long double value, int ndigit, int *decpt, int *sign); char *_fcvt(long double value, int ndigit, int *decpt, int *sign);
#endif /* ACKCONF_NO_STDIO_FLOAT */ #endif
#define FL_LJUST 0x0001 /* left-justify field */ #define FL_LJUST 0x0001 /* left-justify field */
#define FL_SIGN 0x0002 /* sign in signed conversions */ #define FL_SIGN 0x0002 /* sign in signed conversions */

View file

@ -1,9 +1,10 @@
/* $Id$ */ /* $Id$ */
#include <stdlib.h> #include <stdlib.h>
#include <ack/config.h>
#include "ext_fmt.h" #include "ext_fmt.h"
#ifndef ACKCONF_NO_STDIO_FLOAT #if ACKCONF_WANT_STDIO_FLOAT
void _str_ext_cvt(const char* s, char** ss, struct EXTEND* e); void _str_ext_cvt(const char* s, char** ss, struct EXTEND* e);
double _ext_dbl_cvt(struct EXTEND* e); double _ext_dbl_cvt(struct EXTEND* e);

View file

@ -11,9 +11,4 @@
#define ACKCONF_TIME_IS_A_SYSCALL #define ACKCONF_TIME_IS_A_SYSCALL
/* Since the i80 code generator doesn't support floating point, don't include
* it in the stdio libraries. */
#define ACKCONF_NO_STDIO_FLOAT
#endif #endif

View file

@ -11,8 +11,4 @@
/* #define ACKCONF_TIME_IS_A_SYSCALL */ /* #define ACKCONF_TIME_IS_A_SYSCALL */
/* We don't support floating point right now. */
/* #define ACKCONF_NO_STDIO_FLOAT */
#endif #endif