Skip to content

Commit 0e8dc73

Browse files
agattiprojectgus
authored andcommitted
libm/libm: Do not force 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>
1 parent 3af006e commit 0e8dc73

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

lib/libm/libm.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@
1919
#include <stdint.h>
2020
#include <math.h>
2121

22-
#define FLT_EVAL_METHOD 0
22+
// These lines verify that FLT_EVAL_METHOD==0, MicroPython's libm requires this.
23+
// If compilation fails here then check the host compiler's FLT_EVAL_METHOD.
24+
typedef float float_t;
25+
typedef double double_t;
2326

2427
#define FORCE_EVAL(x) do { \
2528
if (sizeof(x) == sizeof(float)) { \

lib/libm_dbl/libm.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@
1515
#include <stdint.h>
1616
#include <math.h>
1717

18-
#define FLT_EVAL_METHOD 0
18+
// These lines verify that FLT_EVAL_METHOD==0, MicroPython's libm requires this.
19+
// If compilation fails here then check the host compiler's FLT_EVAL_METHOD.
20+
typedef float float_t;
21+
typedef double double_t;
1922

2023
#define FORCE_EVAL(x) do { \
2124
if (sizeof(x) == sizeof(float)) { \

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy