Skip to content
This repository was archived by the owner on Apr 28, 2025. It is now read-only.

Commit c3c363f

Browse files
committed
Combine the source files for fmod
Since `fmod` is generic, there isn't any need to have the small wrappers in separate files. Most operations was done in [1] but `fmod` was omitted until now. [1]: #537
1 parent eda2148 commit c3c363f

File tree

7 files changed

+27
-31
lines changed

7 files changed

+27
-31
lines changed

libm/etc/function-definitions.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -537,21 +537,21 @@
537537
},
538538
"fmodf": {
539539
"sources": [
540-
"src/math/fmodf.rs",
540+
"src/math/fmod.rs",
541541
"src/math/generic/fmod.rs"
542542
],
543543
"type": "f32"
544544
},
545545
"fmodf128": {
546546
"sources": [
547-
"src/math/fmodf128.rs",
547+
"src/math/fmod.rs",
548548
"src/math/generic/fmod.rs"
549549
],
550550
"type": "f128"
551551
},
552552
"fmodf16": {
553553
"sources": [
554-
"src/math/fmodf16.rs",
554+
"src/math/fmod.rs",
555555
"src/math/generic/fmod.rs"
556556
],
557557
"type": "f16"

libm/src/math/fmod.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,25 @@
1+
/// Calculate the remainder of `x / y`, the precise result of `x - trunc(x / y) * y`.
2+
#[cfg(f16_enabled)]
3+
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
4+
pub fn fmodf16(x: f16, y: f16) -> f16 {
5+
super::generic::fmod(x, y)
6+
}
7+
8+
/// Calculate the remainder of `x / y`, the precise result of `x - trunc(x / y) * y`.
9+
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
10+
pub fn fmodf(x: f32, y: f32) -> f32 {
11+
super::generic::fmod(x, y)
12+
}
13+
114
/// Calculate the remainder of `x / y`, the precise result of `x - trunc(x / y) * y`.
215
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
316
pub fn fmod(x: f64, y: f64) -> f64 {
417
super::generic::fmod(x, y)
518
}
19+
20+
/// Calculate the remainder of `x / y`, the precise result of `x - trunc(x / y) * y`.
21+
#[cfg(f128_enabled)]
22+
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
23+
pub fn fmodf128(x: f128, y: f128) -> f128 {
24+
super::generic::fmod(x, y)
25+
}

libm/src/math/fmodf.rs

Lines changed: 0 additions & 5 deletions
This file was deleted.

libm/src/math/fmodf128.rs

Lines changed: 0 additions & 5 deletions
This file was deleted.

libm/src/math/fmodf16.rs

Lines changed: 0 additions & 5 deletions
This file was deleted.

libm/src/math/frexp.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
12
pub fn frexp(x: f64) -> (f64, i32) {
23
let mut y = x.to_bits();
34
let ee = ((y >> 52) & 0x7ff) as i32;

libm/src/math/mod.rs

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,6 @@ mod fmin_fmax;
164164
mod fminimum_fmaximum;
165165
mod fminimum_fmaximum_num;
166166
mod fmod;
167-
mod fmodf;
168167
mod frexp;
169168
mod frexpf;
170169
mod hypot;
@@ -260,8 +259,7 @@ pub use self::fma_wide::fmaf;
260259
pub use self::fmin_fmax::{fmax, fmaxf, fmin, fminf};
261260
pub use self::fminimum_fmaximum::{fmaximum, fmaximumf, fminimum, fminimumf};
262261
pub use self::fminimum_fmaximum_num::{fmaximum_num, fmaximum_numf, fminimum_num, fminimum_numf};
263-
pub use self::fmod::fmod;
264-
pub use self::fmodf::fmodf;
262+
pub use self::fmod::{fmod, fmodf};
265263
pub use self::frexp::frexp;
266264
pub use self::frexpf::frexpf;
267265
pub use self::hypot::hypot;
@@ -318,10 +316,6 @@ pub use self::trunc::{trunc, truncf};
318316

319317
cfg_if! {
320318
if #[cfg(f16_enabled)] {
321-
// verify-sorted-start
322-
mod fmodf16;
323-
// verify-sorted-end
324-
325319
// verify-sorted-start
326320
pub use self::ceil::ceilf16;
327321
pub use self::copysign::copysignf16;
@@ -331,7 +325,7 @@ cfg_if! {
331325
pub use self::fmin_fmax::{fmaxf16, fminf16};
332326
pub use self::fminimum_fmaximum::{fmaximumf16, fminimumf16};
333327
pub use self::fminimum_fmaximum_num::{fmaximum_numf16, fminimum_numf16};
334-
pub use self::fmodf16::fmodf16;
328+
pub use self::fmod::fmodf16;
335329
pub use self::ldexp::ldexpf16;
336330
pub use self::rint::rintf16;
337331
pub use self::round::roundf16;
@@ -348,10 +342,6 @@ cfg_if! {
348342

349343
cfg_if! {
350344
if #[cfg(f128_enabled)] {
351-
// verify-sorted-start
352-
mod fmodf128;
353-
// verify-sorted-end
354-
355345
// verify-sorted-start
356346
pub use self::ceil::ceilf128;
357347
pub use self::copysign::copysignf128;
@@ -362,7 +352,7 @@ cfg_if! {
362352
pub use self::fmin_fmax::{fmaxf128, fminf128};
363353
pub use self::fminimum_fmaximum::{fmaximumf128, fminimumf128};
364354
pub use self::fminimum_fmaximum_num::{fmaximum_numf128, fminimum_numf128};
365-
pub use self::fmodf128::fmodf128;
355+
pub use self::fmod::fmodf128;
366356
pub use self::ldexp::ldexpf128;
367357
pub use self::rint::rintf128;
368358
pub use self::round::roundf128;

0 commit comments

Comments
 (0)