Skip to content

Align musl long-double limits with the active Linx compiler model#7

Draft
zhoubot wants to merge 1 commit into
masterfrom
codex/model-polish-20260530
Draft

Align musl long-double limits with the active Linx compiler model#7
zhoubot wants to merge 1 commit into
masterfrom
codex/model-polish-20260530

Conversation

@zhoubot

@zhoubot zhoubot commented May 30, 2026

Copy link
Copy Markdown

Summary

  • package the current model-generated musl change from the existing checkout
  • replace hardcoded long-double constants with compiler-provided macros
  • keep musl configure probing aligned with the active Linx toolchain contract

Testing

  • git diff --check

Not tested

  • musl configure
  • libc smoke

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>

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread arch/linx64/bits/float.h
Comment on lines +7 to +20
#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__

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant