From 94ffa3ba88efbc9e8ecddc83a5b095be4baa7814 Mon Sep 17 00:00:00 2001 From: David Given Date: Sat, 23 Jun 2018 00:04:14 +0200 Subject: [PATCH] libc floating point and stdio floating point can now be turned on and off using ACKCONF variables. --- lang/cem/libcc.ansi/core/math/asin.c | 5 +++++ lang/cem/libcc.ansi/core/math/atan.c | 6 ++++++ lang/cem/libcc.ansi/core/math/atan2.c | 6 ++++++ lang/cem/libcc.ansi/core/math/ceil.c | 6 ++++++ lang/cem/libcc.ansi/core/math/exp.c | 6 ++++++ lang/cem/libcc.ansi/core/math/fabs.c | 6 ++++++ lang/cem/libcc.ansi/core/math/floor.c | 6 ++++++ lang/cem/libcc.ansi/core/math/fmod.c | 6 ++++++ lang/cem/libcc.ansi/core/math/frexp.e | 6 ++++++ lang/cem/libcc.ansi/core/math/hugeval.c | 6 ++++++ lang/cem/libcc.ansi/core/math/hypot.c | 6 ++++++ lang/cem/libcc.ansi/core/math/isnan.c | 8 ++++++++ lang/cem/libcc.ansi/core/math/ldexp.c | 6 ++++++ lang/cem/libcc.ansi/core/math/log.c | 6 ++++++ lang/cem/libcc.ansi/core/math/log10.c | 6 ++++++ lang/cem/libcc.ansi/core/math/modf.e | 4 ++++ lang/cem/libcc.ansi/core/math/pow.c | 6 ++++++ lang/cem/libcc.ansi/core/math/sin.c | 6 ++++++ lang/cem/libcc.ansi/core/math/sinh.c | 6 ++++++ lang/cem/libcc.ansi/core/math/sqrt.c | 6 ++++++ lang/cem/libcc.ansi/core/math/tan.c | 6 ++++++ lang/cem/libcc.ansi/core/math/tanh.c | 6 ++++++ lang/cem/libcc.ansi/headers/ack/config.h | 8 ++++++++ lang/cem/libcc.ansi/stdio/doprnt.c | 4 ++-- lang/cem/libcc.ansi/stdio/doscan.c | 8 ++++---- lang/cem/libcc.ansi/stdio/ecvt.c | 4 ++-- lang/cem/libcc.ansi/stdio/fltpr.c | 4 ++-- lang/cem/libcc.ansi/stdio/loc_incl.h | 4 ++-- lang/cem/libcc.ansi/stdlib/strtod.c | 3 ++- plat/cpm/include/ack/plat.h | 5 ----- plat/linuxppc/include/ack/plat.h | 4 ---- 31 files changed, 153 insertions(+), 22 deletions(-) diff --git a/lang/cem/libcc.ansi/core/math/asin.c b/lang/cem/libcc.ansi/core/math/asin.c index 1e3180086..ffa286e40 100644 --- a/lang/cem/libcc.ansi/core/math/asin.c +++ b/lang/cem/libcc.ansi/core/math/asin.c @@ -8,8 +8,11 @@ #include #include +#include #include "localmath.h" +#if ACKCONF_WANT_FLOAT + static double asin_acos(double x, int cosfl) { @@ -90,3 +93,5 @@ acos(double x) { return asin_acos(x, 1); } + +#endif diff --git a/lang/cem/libcc.ansi/core/math/atan.c b/lang/cem/libcc.ansi/core/math/atan.c index eb04d095f..c1d52f6a3 100644 --- a/lang/cem/libcc.ansi/core/math/atan.c +++ b/lang/cem/libcc.ansi/core/math/atan.c @@ -9,8 +9,11 @@ #include #include #include +#include #include "localmath.h" +#if ACKCONF_WANT_FLOAT + double atan(double x) { @@ -75,3 +78,6 @@ atan(double x) x += a[n]; return neg ? -x : x; } + +#endif + diff --git a/lang/cem/libcc.ansi/core/math/atan2.c b/lang/cem/libcc.ansi/core/math/atan2.c index 6f8362468..ec1b45c7e 100644 --- a/lang/cem/libcc.ansi/core/math/atan2.c +++ b/lang/cem/libcc.ansi/core/math/atan2.c @@ -8,8 +8,11 @@ #include #include +#include #include "localmath.h" +#if ACKCONF_WANT_FLOAT + double atan2(double y, double x) { @@ -46,3 +49,6 @@ atan2(double y, double x) } return val + M_PI; } + +#endif + diff --git a/lang/cem/libcc.ansi/core/math/ceil.c b/lang/cem/libcc.ansi/core/math/ceil.c index 2d06949a2..e5671739b 100644 --- a/lang/cem/libcc.ansi/core/math/ceil.c +++ b/lang/cem/libcc.ansi/core/math/ceil.c @@ -7,6 +7,9 @@ /* $Id$ */ #include +#include + +#if ACKCONF_WANT_FLOAT double ceil(double x) @@ -18,3 +21,6 @@ ceil(double x) fractional part */ } + +#endif + diff --git a/lang/cem/libcc.ansi/core/math/exp.c b/lang/cem/libcc.ansi/core/math/exp.c index 1583d913c..5bbdc1978 100644 --- a/lang/cem/libcc.ansi/core/math/exp.c +++ b/lang/cem/libcc.ansi/core/math/exp.c @@ -9,8 +9,11 @@ #include #include #include +#include #include "localmath.h" +#if ACKCONF_WANT_FLOAT + double exp(double x) { @@ -74,3 +77,6 @@ exp(double x) n += 1; return (ldexp(0.5 + x / (POLYNOM3(xn, q) - x), n)); } + +#endif + diff --git a/lang/cem/libcc.ansi/core/math/fabs.c b/lang/cem/libcc.ansi/core/math/fabs.c index 526d5d63e..5c467e415 100644 --- a/lang/cem/libcc.ansi/core/math/fabs.c +++ b/lang/cem/libcc.ansi/core/math/fabs.c @@ -5,9 +5,15 @@ * Author: Ceriel J.H. Jacobs */ /* $Id$ */ +#include + +#if ACKCONF_WANT_FLOAT double fabs(double x) { return x < 0 ? -x : x; } + +#endif + diff --git a/lang/cem/libcc.ansi/core/math/floor.c b/lang/cem/libcc.ansi/core/math/floor.c index 4f1cd2dc0..bce630bd2 100644 --- a/lang/cem/libcc.ansi/core/math/floor.c +++ b/lang/cem/libcc.ansi/core/math/floor.c @@ -7,6 +7,9 @@ /* $Id$ */ #include +#include + +#if ACKCONF_WANT_FLOAT double floor(double x) @@ -18,3 +21,6 @@ floor(double x) fractional part */ } + +#endif + diff --git a/lang/cem/libcc.ansi/core/math/fmod.c b/lang/cem/libcc.ansi/core/math/fmod.c index 4a784a98f..3329a41b1 100644 --- a/lang/cem/libcc.ansi/core/math/fmod.c +++ b/lang/cem/libcc.ansi/core/math/fmod.c @@ -5,6 +5,9 @@ #include #include +#include + +#if ACKCONF_WANT_FLOAT double(fmod)(double x, double y) { /* compute fmod(x, y) */ @@ -37,3 +40,6 @@ double(fmod)(double x, double y) } return (neg ? -x : x); } + +#endif + diff --git a/lang/cem/libcc.ansi/core/math/frexp.e b/lang/cem/libcc.ansi/core/math/frexp.e index d3ccca819..0e64b4b1b 100644 --- a/lang/cem/libcc.ansi/core/math/frexp.e +++ b/lang/cem/libcc.ansi/core/math/frexp.e @@ -5,7 +5,11 @@ */ /* $Id$ */ +#include + mes 2,_EM_WSIZE,_EM_PSIZE + +#if ACKCONF_WANT_FLOAT exp $frexp pro $frexp,0 lal 0 @@ -16,3 +20,5 @@ sti _EM_WSIZE ret _EM_DSIZE end +#endif + diff --git a/lang/cem/libcc.ansi/core/math/hugeval.c b/lang/cem/libcc.ansi/core/math/hugeval.c index 2d51c2994..6d526f2c8 100644 --- a/lang/cem/libcc.ansi/core/math/hugeval.c +++ b/lang/cem/libcc.ansi/core/math/hugeval.c @@ -7,5 +7,11 @@ /* $Id$ */ #include +#include + +#if ACKCONF_WANT_FLOAT double __huge_val = 1.0e+1000; /* This will generate a warning */ + +#endif + diff --git a/lang/cem/libcc.ansi/core/math/hypot.c b/lang/cem/libcc.ansi/core/math/hypot.c index ad181d157..f3e70819f 100644 --- a/lang/cem/libcc.ansi/core/math/hypot.c +++ b/lang/cem/libcc.ansi/core/math/hypot.c @@ -6,6 +6,9 @@ */ #include +#include + +#if ACKCONF_WANT_FLOAT /* $Id$ */ @@ -41,3 +44,6 @@ cabs(struct complex p_compl) { return hypot(p_compl.r, p_compl.i); } + +#endif + diff --git a/lang/cem/libcc.ansi/core/math/isnan.c b/lang/cem/libcc.ansi/core/math/isnan.c index 7f1b31aed..9203875ce 100644 --- a/lang/cem/libcc.ansi/core/math/isnan.c +++ b/lang/cem/libcc.ansi/core/math/isnan.c @@ -1,3 +1,8 @@ +#include +#include + +#if ACKCONF_WANT_FLOAT + __IsNan(double d) { #if defined(__vax) || defined(__pdp) @@ -9,3 +14,6 @@ __IsNan(double d) #endif return 0; } + +#endif + diff --git a/lang/cem/libcc.ansi/core/math/ldexp.c b/lang/cem/libcc.ansi/core/math/ldexp.c index 7f1b0ee19..683c70e6c 100644 --- a/lang/cem/libcc.ansi/core/math/ldexp.c +++ b/lang/cem/libcc.ansi/core/math/ldexp.c @@ -7,6 +7,9 @@ #include #include #include +#include + +#if ACKCONF_WANT_FLOAT double ldexp(double fl, int exp) @@ -63,3 +66,6 @@ ldexp(double fl, int exp) } return sign * fl; } + +#endif + diff --git a/lang/cem/libcc.ansi/core/math/log.c b/lang/cem/libcc.ansi/core/math/log.c index 3be9c87c7..3c698c10a 100644 --- a/lang/cem/libcc.ansi/core/math/log.c +++ b/lang/cem/libcc.ansi/core/math/log.c @@ -9,8 +9,11 @@ #include #include #include +#include #include "localmath.h" +#if ACKCONF_WANT_FLOAT + double log(double x) { @@ -73,3 +76,6 @@ log(double x) x += z * (-2.121944400546905827679e-4); return x + z * 0.693359375; } + +#endif + diff --git a/lang/cem/libcc.ansi/core/math/log10.c b/lang/cem/libcc.ansi/core/math/log10.c index 9eb270ec2..1c170026c 100644 --- a/lang/cem/libcc.ansi/core/math/log10.c +++ b/lang/cem/libcc.ansi/core/math/log10.c @@ -8,8 +8,11 @@ #include #include +#include #include "localmath.h" +#if ACKCONF_WANT_FLOAT + double log10(double x) { @@ -31,3 +34,6 @@ log10(double x) return log(x) / M_LN10; } + +#endif + diff --git a/lang/cem/libcc.ansi/core/math/modf.e b/lang/cem/libcc.ansi/core/math/modf.e index 8e819a7f5..8f0ea8adb 100644 --- a/lang/cem/libcc.ansi/core/math/modf.e +++ b/lang/cem/libcc.ansi/core/math/modf.e @@ -4,8 +4,11 @@ * See the copyright notice in the ACK home directory, in the file "Copyright". */ /* $Id$ */ +#include mes 2,_EM_WSIZE,_EM_PSIZE + +#if ACKCONF_WANT_FLOAT exp $modf pro $modf,0 lal 0 @@ -20,3 +23,4 @@ sti _EM_DSIZE ret _EM_DSIZE end +#endif diff --git a/lang/cem/libcc.ansi/core/math/pow.c b/lang/cem/libcc.ansi/core/math/pow.c index 0e6d6c99b..3fb40cb7f 100644 --- a/lang/cem/libcc.ansi/core/math/pow.c +++ b/lang/cem/libcc.ansi/core/math/pow.c @@ -10,6 +10,9 @@ #include #include #include +#include + +#if ACKCONF_WANT_FLOAT double pow(double x, double y) @@ -120,3 +123,6 @@ pow(double x, double y) } return ldexp(fp, newexp); } + +#endif + diff --git a/lang/cem/libcc.ansi/core/math/sin.c b/lang/cem/libcc.ansi/core/math/sin.c index a55fa93d0..9a4078c56 100644 --- a/lang/cem/libcc.ansi/core/math/sin.c +++ b/lang/cem/libcc.ansi/core/math/sin.c @@ -9,8 +9,11 @@ #include #include #include +#include #include "localmath.h" +#if ACKCONF_WANT_FLOAT + static double sinus(double x, int cos_flag) { @@ -106,3 +109,6 @@ cos(double x) x = -x; return sinus(x, 1); } + +#endif + diff --git a/lang/cem/libcc.ansi/core/math/sinh.c b/lang/cem/libcc.ansi/core/math/sinh.c index 00ad3fc36..a16535527 100644 --- a/lang/cem/libcc.ansi/core/math/sinh.c +++ b/lang/cem/libcc.ansi/core/math/sinh.c @@ -9,8 +9,11 @@ #include #include #include +#include #include "localmath.h" +#if ACKCONF_WANT_FLOAT + static double sinh_cosh(double x, int cosh_flag) { @@ -86,3 +89,6 @@ cosh(double x) x = -x; return sinh_cosh(x, 1); } + +#endif + diff --git a/lang/cem/libcc.ansi/core/math/sqrt.c b/lang/cem/libcc.ansi/core/math/sqrt.c index 17cfcdc0e..b5a6f71cf 100644 --- a/lang/cem/libcc.ansi/core/math/sqrt.c +++ b/lang/cem/libcc.ansi/core/math/sqrt.c @@ -9,6 +9,9 @@ #include #include #include +#include + +#if ACKCONF_WANT_FLOAT #define NITER 5 @@ -47,3 +50,6 @@ sqrt(double x) } return val; } + +#endif + diff --git a/lang/cem/libcc.ansi/core/math/tan.c b/lang/cem/libcc.ansi/core/math/tan.c index 0d7a32589..b51df5a74 100644 --- a/lang/cem/libcc.ansi/core/math/tan.c +++ b/lang/cem/libcc.ansi/core/math/tan.c @@ -9,8 +9,11 @@ #include #include #include +#include #include "localmath.h" +#if ACKCONF_WANT_FLOAT + double tan(double x) { @@ -79,3 +82,6 @@ tan(double x) x = -x; return invert ? -y / x : x / y; } + +#endif + diff --git a/lang/cem/libcc.ansi/core/math/tanh.c b/lang/cem/libcc.ansi/core/math/tanh.c index 1bf90dd9b..3978c2427 100644 --- a/lang/cem/libcc.ansi/core/math/tanh.c +++ b/lang/cem/libcc.ansi/core/math/tanh.c @@ -9,8 +9,11 @@ #include #include #include +#include #include "localmath.h" +#if ACKCONF_WANT_FLOAT + double tanh(double x) { @@ -58,3 +61,6 @@ tanh(double x) } return negative ? -x : x; } + +#endif + diff --git a/lang/cem/libcc.ansi/headers/ack/config.h b/lang/cem/libcc.ansi/headers/ack/config.h index de714af4e..13a3305c5 100644 --- a/lang/cem/libcc.ansi/headers/ack/config.h +++ b/lang/cem/libcc.ansi/headers/ack/config.h @@ -3,4 +3,12 @@ #include +#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 diff --git a/lang/cem/libcc.ansi/stdio/doprnt.c b/lang/cem/libcc.ansi/stdio/doprnt.c index dca935aad..3e754801d 100644 --- a/lang/cem/libcc.ansi/stdio/doprnt.c +++ b/lang/cem/libcc.ansi/stdio/doprnt.c @@ -311,7 +311,7 @@ int _doprnt(register const char* fmt, va_list ap, FILE* stream) case 'c': *s++ = va_arg(ap, int); break; -#ifndef ACKCONF_NO_STDIO_FLOAT +#if ACKCONF_WANT_STDIO_FLOAT case 'G': case 'g': if ((flags & FL_PRECSPEC) && (precision == 0)) @@ -328,7 +328,7 @@ int _doprnt(register const char* fmt, va_list ap, FILE* stream) flags |= FL_SIGNEDCONV; s = _f_print(&ap, flags, s, c, precision); break; -#endif /* ACKCONF_NO_STDIO_FLOAT */ +#endif case 'r': ap = va_arg(ap, va_list); fmt = va_arg(ap, char*); diff --git a/lang/cem/libcc.ansi/stdio/doscan.c b/lang/cem/libcc.ansi/stdio/doscan.c index 52e957a5d..b53b4666f 100644 --- a/lang/cem/libcc.ansi/stdio/doscan.c +++ b/lang/cem/libcc.ansi/stdio/doscan.c @@ -108,7 +108,7 @@ o_collect(register int c, register FILE* stream, char type, 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 * floating-point number. The function returns as soon as a format-error * 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'; return bufp - 1; } -#endif /* ACKCONF_NO_STDIO_FLOAT */ +#endif /* * 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 kind; register int ic; /* the input character */ -#ifndef ACKCONF_NO_STDIO_FLOAT +#if ACKCONF_WANT_STDIO_FLOAT long double ld_val; #endif @@ -495,7 +495,7 @@ int _doscan(register FILE* stream, const char* format, va_list ap) *str = '\0'; } break; -#ifndef ACKCONF_NO_STDIO_FLOAT +#if ACKCONF_WANT_STDIO_FLOAT case 'e': case 'E': case 'f': diff --git a/lang/cem/libcc.ansi/stdio/ecvt.c b/lang/cem/libcc.ansi/stdio/ecvt.c index 4821fccbc..25243f0a4 100644 --- a/lang/cem/libcc.ansi/stdio/ecvt.c +++ b/lang/cem/libcc.ansi/stdio/ecvt.c @@ -2,7 +2,7 @@ #include "loc_incl.h" -#ifndef ACKCONF_NO_STDIO_FLOAT +#if ACKCONF_WANT_STDIO_FLOAT #include "../stdlib/ext_fmt.h" 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); } -#endif /* ACKCONF_NO_STDIO_FLOAT */ +#endif diff --git a/lang/cem/libcc.ansi/stdio/fltpr.c b/lang/cem/libcc.ansi/stdio/fltpr.c index 091111949..af1ca8728 100644 --- a/lang/cem/libcc.ansi/stdio/fltpr.c +++ b/lang/cem/libcc.ansi/stdio/fltpr.c @@ -7,7 +7,7 @@ #include #include "loc_incl.h" -#ifndef ACKCONF_NO_STDIO_FLOAT +#if ACKCONF_WANT_STDIO_FLOAT static char* _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; } -#endif /* ACKCONF_NO_STDIO_FLOAT */ +#endif diff --git a/lang/cem/libcc.ansi/stdio/loc_incl.h b/lang/cem/libcc.ansi/stdio/loc_incl.h index 126a31faf..52488e0c9 100644 --- a/lang/cem/libcc.ansi/stdio/loc_incl.h +++ b/lang/cem/libcc.ansi/stdio/loc_incl.h @@ -19,10 +19,10 @@ void __cleanup(void); FILE *popen(const char *command, const char *type); 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 *_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_SIGN 0x0002 /* sign in signed conversions */ diff --git a/lang/cem/libcc.ansi/stdlib/strtod.c b/lang/cem/libcc.ansi/stdlib/strtod.c index 48f60e200..d9009bcc6 100644 --- a/lang/cem/libcc.ansi/stdlib/strtod.c +++ b/lang/cem/libcc.ansi/stdlib/strtod.c @@ -1,9 +1,10 @@ /* $Id$ */ #include +#include #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); double _ext_dbl_cvt(struct EXTEND* e); diff --git a/plat/cpm/include/ack/plat.h b/plat/cpm/include/ack/plat.h index 5f785b0e1..cbd879396 100644 --- a/plat/cpm/include/ack/plat.h +++ b/plat/cpm/include/ack/plat.h @@ -11,9 +11,4 @@ #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 diff --git a/plat/linuxppc/include/ack/plat.h b/plat/linuxppc/include/ack/plat.h index e25914574..9145197c4 100644 --- a/plat/linuxppc/include/ack/plat.h +++ b/plat/linuxppc/include/ack/plat.h @@ -11,8 +11,4 @@ /* #define ACKCONF_TIME_IS_A_SYSCALL */ -/* We don't support floating point right now. */ - -/* #define ACKCONF_NO_STDIO_FLOAT */ - #endif