diff options
| author | Alessandro Gatti <a.gatti@frob.it> | 2024-05-09 06:33:57 +0200 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2024-05-31 17:04:24 +1000 |
| commit | 3613ad96244ecaa67e8d45b637dc6b24fd2942be (patch) | |
| tree | e04b93cda6a2f5ceb9197a5472eb8f9066c942de | |
| parent | 3af006efb39ad0b7aa7c0401c93329b654bca617 (diff) | |
lib/libm: Do not force floating point type size evaluation.
Since C99, `FLT_EVAL_METHOD` should be left for the compiler/libc to
define. Its redefinition breaks compilation with picolibc as the
target's libc, since it defines said symbol in math.h before the libm
define is evaluated by the compiler.
In its place, there is a check to make sure floating point type sizes
are what are expected to be, triggering a compilation error if those
assumptions are no longer valid.
Co-authored-by: Angus Gratton <angus@redyak.com.au>
Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
| -rw-r--r-- | lib/libm/libm.h | 5 | ||||
| -rw-r--r-- | lib/libm_dbl/libm.h | 5 |
2 files changed, 8 insertions, 2 deletions
diff --git a/lib/libm/libm.h b/lib/libm/libm.h index f782249e5..78de4c3ee 100644 --- a/lib/libm/libm.h +++ b/lib/libm/libm.h @@ -19,7 +19,10 @@ #include <stdint.h> #include <math.h> -#define FLT_EVAL_METHOD 0 +// These lines verify that FLT_EVAL_METHOD==0, MicroPython's libm requires this. +// If compilation fails here then check the host compiler's FLT_EVAL_METHOD. +typedef float float_t; +typedef double double_t; #define FORCE_EVAL(x) do { \ if (sizeof(x) == sizeof(float)) { \ diff --git a/lib/libm_dbl/libm.h b/lib/libm_dbl/libm.h index dc0b431a4..cbae69166 100644 --- a/lib/libm_dbl/libm.h +++ b/lib/libm_dbl/libm.h @@ -15,7 +15,10 @@ #include <stdint.h> #include <math.h> -#define FLT_EVAL_METHOD 0 +// These lines verify that FLT_EVAL_METHOD==0, MicroPython's libm requires this. +// If compilation fails here then check the host compiler's FLT_EVAL_METHOD. +typedef float float_t; +typedef double double_t; #define FORCE_EVAL(x) do { \ if (sizeof(x) == sizeof(float)) { \ |
