Skip to content

Use target pointer width rather than x86 #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
tgross35 opened this issue Apr 5, 2024 · 1 comment · May be fixed by #36
Open

Use target pointer width rather than x86 #26

tgross35 opened this issue Apr 5, 2024 · 1 comment · May be fixed by #36
Labels
question Further information is requested

Comments

@tgross35
Copy link

tgross35 commented Apr 5, 2024

The code

/// A word.
#[cfg(not(target_arch = "x86"))]
pub type Word = u64;
/// Doubled word.
#[cfg(not(target_arch = "x86"))]
pub type DoubleWord = u128;
/// Word with sign.
#[cfg(not(target_arch = "x86"))]
pub type SignedWord = i128;
/// A word.
#[cfg(target_arch = "x86")]
pub type Word = u32;
/// Doubled word.
#[cfg(target_arch = "x86")]
pub type DoubleWord = u64;
/// Word with sign.
#[cfg(target_arch = "x86")]
pub type SignedWord = i64;
has a lot of code that is configured based on x86 or not(x86). Is there a reason that x86 is special, or could this instead use #[cfg(target_pointer_width = 64)]/#[cfg(target_pointer_width = 32)]?

@stencillogic
Copy link
Owner

Basically, the library only supports x64 and x86. Hence it uses just x86 and not(x86) here and there. It was tested for ARM once, but in general ARM is not supported at the moment.

@stencillogic stencillogic added the question Further information is requested label Apr 6, 2024
tgross35 added a commit to tgross35/astro-float that referenced this issue May 30, 2025
Currently a lot of things are gated on `cfg(target_arch = "x86")`, which
is used to indicate systems with 32-bit words. Apply the following
changes to make this less specific:

* Replace x86-32 configuration with configuration based on
  `target_pointer_width`.
* Where possible, replace `#[cfg]` with `cfg!` or eliminate the check,
  to increase the percentage of code that gets validated on any
  platform.
* Remove some configuration that was unneeded, for the same reason. This
  includes things like `#[cfg(target_arch = "x86")]` on comparisons to
  `EXPONENT_MIN` or `EXPONENT_MAX`. The checks are only useful on 32-bit
  platforms, but this is a trivial compiler optimization so not much is
  gained by keeping the config.

I have verified that the crate builds on armv7 targets (but have not
tested).

Fixes: stencillogic#26
tgross35 added a commit to tgross35/astro-float that referenced this issue May 30, 2025
Currently a lot of things are gated on `cfg(target_arch = "x86")`, which
is used to indicate systems with 32-bit words. Apply the following
changes to make this less specific:

* Replace x86-32 configuration with configuration based on
  `target_pointer_width`.
* Where possible, replace `#[cfg]` with `cfg!` or eliminate the check,
  to increase the percentage of code that gets validated on any
  platform.
* Remove some configuration that was unneeded, for the same reason. This
  includes things like `#[cfg(target_arch = "x86")]` on comparisons to
  `EXPONENT_MIN` or `EXPONENT_MAX`. The checks are only useful on 32-bit
  platforms, but this is a trivial compiler optimization so not much is
  gained by keeping the config.

I have verified that the crate builds on armv7 targets (but have not
tested).

Fixes: stencillogic#26
@tgross35 tgross35 linked a pull request May 30, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants