Move the string-to-float functions into core, after marking them as

ACKCONF_WANT_FLOAT.
This commit is contained in:
David Given 2018-06-23 11:14:24 +02:00
parent 94ffa3ba88
commit 5fd8d772fd
7 changed files with 38 additions and 24 deletions

View file

@ -57,8 +57,8 @@ for _, plat in ipairs(vars.plats) do
"plat/"..plat.."/include+pkg",
"./malloc/malloc.h",
"./core/math/localmath.h",
"./core/stdlib/ext_fmt.h",
"./stdio/loc_incl.h",
"./stdlib/ext_fmt.h",
"./time/loc_time.h",
},
vars = { plat = plat }

View file

@ -6,6 +6,9 @@
#include <stdlib.h>
#include <errno.h>
#include <ack/config.h>
#if ACKCONF_WANT_FLOAT
double(atof)(const char* nptr)
{
@ -16,3 +19,5 @@ double(atof)(const char* nptr)
errno = e;
return d;
}
#endif

View file

@ -1,12 +1,11 @@
/* $Id$ */
#include "loc_incl.h"
#include <math.h>
#include <ack/config.h>
#if ACKCONF_WANT_STDIO_FLOAT
#include "../stdlib/ext_fmt.h"
void _dbl_ext_cvt(double value, struct EXTEND* e);
char* _ext_str_cvt(struct EXTEND* e, int ndigit, int* decpt, int* sign, int ecvtflag);
#include "ext_fmt.h"
static char*
cvt(long double value, int ndigit, int* decpt, int* sign, int ecvtflag)

View file

@ -17,6 +17,8 @@
#include <ctype.h>
#include <ack/config.h>
#if ACKCONF_WANT_FLOAT
static int b64_add(struct mantissa* e1, struct mantissa* e2);
static b64_sft(struct mantissa* e1, int n);
@ -494,7 +496,7 @@ static add_exponent(struct EXTEND* e, int exp)
}
}
_str_ext_cvt(const char* s, char** ss, struct EXTEND* e)
void _str_ext_cvt(const char* s, char** ss, struct EXTEND* e)
{
/* Like strtod, but for extended precision */
register int c;
@ -781,7 +783,7 @@ char* _ext_str_cvt(struct EXTEND* e, int ndigit, int* decpt, int* sign, int ecvt
return buf;
}
_dbl_ext_cvt(double value, struct EXTEND* e)
void _dbl_ext_cvt(double value, struct EXTEND* e)
{
/* Convert double to extended
*/
@ -833,3 +835,5 @@ _ext_dbl_cvt(struct EXTEND* e)
}
return f;
}
#endif

View file

@ -0,0 +1,22 @@
#ifndef _EXT_FMT_H
#define _EXT_FMT_H
struct mantissa {
unsigned long h_32;
unsigned long l_32;
};
struct EXTEND {
short sign;
short exp;
struct mantissa mantissa;
#define m1 mantissa.h_32
#define m2 mantissa.l_32
};
extern void _str_ext_cvt(const char* s, char** ss, struct EXTEND* e);
extern double _ext_dbl_cvt(struct EXTEND* e);
extern void _dbl_ext_cvt(double value, struct EXTEND* e);
extern char* _ext_str_cvt(struct EXTEND* e, int ndigit, int* decpt, int* sign, int ecvtflag);
#endif

View file

@ -4,10 +4,7 @@
#include <ack/config.h>
#include "ext_fmt.h"
#if ACKCONF_WANT_STDIO_FLOAT
void _str_ext_cvt(const char* s, char** ss, struct EXTEND* e);
double _ext_dbl_cvt(struct EXTEND* e);
#if ACKCONF_WANT_FLOAT
double
strtod(const char* p, char** pp)

View file

@ -1,13 +0,0 @@
struct mantissa {
unsigned long h_32;
unsigned long l_32;
};
struct EXTEND {
short sign;
short exp;
struct mantissa mantissa;
#define m1 mantissa.h_32
#define m2 mantissa.l_32
};