Bug #985
closedfloat_t and double_t (C99)
0%
Description
We don't have float_t and double_t typedefs required by C99 in math.h. As
my knowledge about all consequences are limited, I'd take safest path for
now and would commit this patch (btw, OpenBSD has the same code for now):
diff --git a/include/math.h b/include/math.h
--- a/include/math.h
+++ b/include/math.h@ -77,6 +77,11
@
* ISO C99
/
#if __ISO_C_VISIBLE >= 1999
/ 7.12#2 double_t, float_t XXX /
+typedef float float_t;
+typedef double double_t;
#define FLT_EVAL_METHOD (-1)
+
/ 7.12#3 HUGE_VAL, HUGELF, HUGE_VALL */
extern const union __float_u __infinityf;
#ifdef __MATH_BUILTIN_CONSTANTS
Making this change in math.h is maybe wrong as well (cpu/types.h?). For
all not familiar with what standards says:
==========================================================================
2 The types
float_t
double_t
are floating types at least as wide as float and double, respectively,
and such that double_t is at least as wide as float_t. If
FLT_EVAL_METHOD equals 0, float_t and double_t are float and double,
respectively; if FLT_EVAL_METHOD equals 1, they are both double; if
FLT_EVAL_METHOD equals 2, they are both long double; and for other
values of FLT_EVAL_METHOD, they are otherwise implementation-defined.
==========================================================================
The types float_t and double_t are intended to be the implementation’s
most efficient types at least as wide as float and double, respectively.
For FLT_EVAL_METHOD equal 0, 1, or 2, the type float_t is the narrowest
type used by the implementation to evaluate floating expressions.
FreeBSD changed both to long double recently, but looking at commit
message (http://hg.fr.freebsd.org/freebsd-src-head/rev/c60e41c6690f) I'm
afraid that I'm not able to consider all consequences if I'd introduce
similar change in DragonFly.
Files
Updated by hasso over 16 years ago
If you say so ... :)
And there comes a second problem - I'd bring in stuff for amd64 as well
then, but where to put typedefs so that math.h can pick this up?
sys/cpu/xxx/include/math.h? AFAICS FLT_EVAL_METHOD define has to go into
sys/cpu/xxx/include/float.h.
Updated by dillon over 16 years ago
:If you say so ... :)
:
:And there comes a second problem - I'd bring in stuff for amd64 as well
:then, but where to put typedefs so that math.h can pick this up?
:sys/cpu/xxx/include/math.h? AFAICS FLT_EVAL_METHOD define has to go into
:sys/cpu/xxx/include/float.h.
:
:--
:Hasso Tepper
<machine/xxx.h> translates to cpu/blah/include/xxx.h or
platform/blah/include/xxx.h. platform headers override
cpu headers from the point of view of userland's use of
<machine/xxx.h>, but internally a platform header can
directly reference underlying cpu headers.
A little weird but it works. If you look at /usr/include/machine/*.h
you can see the result. Some of the header came from the platform
code and some came directly from the cpu code.
-Matt
Matthew Dillon
<dillon@backplane.com>
Updated by joerg over 16 years ago
It doesn't make sense to define them as float or double on i386. For
AMD64 it effectively depends on whether the compiler wants to implement
floating point on top of SSE or FPU.
Joerg
Updated by corecode over 16 years ago
They had a follow-up discussion on that and it seems that all doubts
were addressed. I'm all for doing the same, because I believe in Bruce
Evans judgement.
cheers
simon
Updated by hasso over 16 years ago
OK, second attempt attached. Obtained-from: FreeBSD with minor
modifications.