Align musl long-double limits with the active Linx compiler model#7
Align musl long-double limits with the active Linx compiler model#7zhoubot wants to merge 1 commit into
Conversation
The arch float header now takes compiler-provided long-double macros directly instead of hardcoding a mismatched binary128 profile. That keeps musl configure-time probing aligned with the live toolchain contract. Constraint: musl configure rejects unsupported long double layouts during bring-up Rejected: Keep hardcoded binary128 constants | they diverge from the active compiler macro model Confidence: high Scope-risk: narrow Directive: Compare clang -dM output against arch/linx64/bits/float.h before changing long-double constants again Tested: git diff --check Not-tested: musl configure, libc smoke Co-authored-by: OmX <omx@oh-my-codex.dev>
There was a problem hiding this comment.
Code Review
This pull request updates arch/linx64/bits/float.h to define floating-point and long double limits using compiler-internal macros instead of hardcoded constants. Feedback suggests wrapping these new definitions in an #ifdef block with a fallback to the original hardcoded constants to prevent compilation failures on alternative compilers or static analysis tools that do not predefine those internal macros.
| #define LDBL_TRUE_MIN __LDBL_DENORM_MIN__ | ||
| #define LDBL_MIN __LDBL_MIN__ | ||
| #define LDBL_MAX __LDBL_MAX__ | ||
| #define LDBL_EPSILON __LDBL_EPSILON__ | ||
|
|
||
| #define LDBL_MANT_DIG 113 | ||
| #define LDBL_MIN_EXP (-16381) | ||
| #define LDBL_MAX_EXP 16384 | ||
| #define LDBL_MANT_DIG __LDBL_MANT_DIG__ | ||
| #define LDBL_MIN_EXP __LDBL_MIN_EXP__ | ||
| #define LDBL_MAX_EXP __LDBL_MAX_EXP__ | ||
|
|
||
| #define LDBL_DIG 33 | ||
| #define LDBL_MIN_10_EXP (-4931) | ||
| #define LDBL_MAX_10_EXP 4932 | ||
| #define LDBL_DIG __LDBL_DIG__ | ||
| #define LDBL_MIN_10_EXP __LDBL_MIN_10_EXP__ | ||
| #define LDBL_MAX_10_EXP __LDBL_MAX_10_EXP__ | ||
|
|
||
| #define DECIMAL_DIG 36 | ||
| #define DECIMAL_DIG __DECIMAL_DIG__ |
There was a problem hiding this comment.
Unconditionally defining these macros using compiler-internal macros (like __LDBL_MIN__) can break compilation when using alternative compilers (such as TinyCC or PCC) or static analysis tools that do not predefine them.
To maintain musl's high standards of portability and robustness, it is recommended to wrap these definitions in an #ifdef __LDBL_MANT_DIG__ block, falling back to the standard 128-bit quad-precision constants if the compiler macros are not defined.
#ifdef __LDBL_MANT_DIG__
#define LDBL_TRUE_MIN __LDBL_DENORM_MIN__
#define LDBL_MIN __LDBL_MIN__
#define LDBL_MAX __LDBL_MAX__
#define LDBL_EPSILON __LDBL_EPSILON__
#define LDBL_MANT_DIG __LDBL_MANT_DIG__
#define LDBL_MIN_EXP __LDBL_MIN_EXP__
#define LDBL_MAX_EXP __LDBL_MAX_EXP__
#define LDBL_DIG __LDBL_DIG__
#define LDBL_MIN_10_EXP __LDBL_MIN_10_EXP__
#define LDBL_MAX_10_EXP __LDBL_MAX_10_EXP__
#define DECIMAL_DIG __DECIMAL_DIG__
#else
#define LDBL_TRUE_MIN 6.47517511943802511092443895822764655e-4966L
#define LDBL_MIN 3.36210314311209350626267781732175260e-4932L
#define LDBL_MAX 1.18973149535723176508575932662800702e+4932L
#define LDBL_EPSILON 1.92592994438723585305597794258492732e-34L
#define LDBL_MANT_DIG 113
#define LDBL_MIN_EXP (-16381)
#define LDBL_MAX_EXP 16384
#define LDBL_DIG 33
#define LDBL_MIN_10_EXP (-4931)
#define LDBL_MAX_10_EXP 4932
#define DECIMAL_DIG 36
#endif
Summary
Testing
git diff --checkNot tested