<feed xmlns='http://www.w3.org/2005/Atom'>
<title>src/lib/msun/src, branch main</title>
<subtitle>FreeBSD source tree</subtitle>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/'/>
<entry>
<title>lib/msun: Added fmaximum_mag and fmaximum_num families</title>
<updated>2026-04-11T18:09:13+00:00</updated>
<author>
<name>Jesús Blázquez</name>
<email>jesuscblazquez@gmail.com</email>
</author>
<published>2026-04-11T08:11:44+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=4e30c12973c73539bef01be3870a90b6346141e8'/>
<id>4e30c12973c73539bef01be3870a90b6346141e8</id>
<content type='text'>
Added support for the f{maximum,minimum}_{mag,num} families, the new
C23 standard functions for maximum magnitude and number-preferring
maximum.  This includes modifying fmax.3, on top of D56230, to
recommend the use of fmaximum_num and fminimum_num.

Reviewed by:	fuz, kargl
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D56236
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Added support for the f{maximum,minimum}_{mag,num} families, the new
C23 standard functions for maximum magnitude and number-preferring
maximum.  This includes modifying fmax.3, on top of D56230, to
recommend the use of fmaximum_num and fminimum_num.

Reviewed by:	fuz, kargl
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D56236
</pre>
</div>
</content>
</entry>
<entry>
<title>lib/msun: Added fmaximum and fminimum family. Tests and man page</title>
<updated>2026-04-04T16:52:40+00:00</updated>
<author>
<name>Jesús Blázquez</name>
<email>jesuscblazquez@gmail.com</email>
</author>
<published>2026-03-31T16:31:15+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=e55db843ef45a8788f69e110d97210fb3968b92f'/>
<id>e55db843ef45a8788f69e110d97210fb3968b92f</id>
<content type='text'>
Starting from the existing fmax{,f,l} functions I've added the fmaximum
family, which handles NaN according to the newest standard (propagating
it).

This commit is a PoC for GSoC 2026.

Reviewed by:	fuz, kargl
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D55834
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Starting from the existing fmax{,f,l} functions I've added the fmaximum
family, which handles NaN according to the newest standard (propagating
it).

This commit is a PoC for GSoC 2026.

Reviewed by:	fuz, kargl
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D55834
</pre>
</div>
</content>
</entry>
<entry>
<title>msun: expose the C23 functions we already support in &lt;math.h&gt;</title>
<updated>2025-11-17T17:18:46+00:00</updated>
<author>
<name>Robert Clausecker</name>
<email>fuz@FreeBSD.org</email>
</author>
<published>2025-11-17T17:09:11+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=37fa5b36abb15b322493aba20146709d48359507'/>
<id>37fa5b36abb15b322493aba20146709d48359507</id>
<content type='text'>
This is the *pi family of trigonometric functions. Quite a few C23
functions are still missing.  These seem to be:
acospi, acospif, acospil, asinpi, asinpif, asinpil, atan2pi, atan2pif,
atan2pil, atanpi, atanpif, atanpil, canonicalize, canonicalizef,
canonicalizel, compoundn, compoundnf, compoundnl, daddl, ddivl, dfmal,
dmull, dsqrtl, dsubl, exp10, exp10f, exp10l, exp10m1, exp10m1f,
exp10m1l, exp2m1, exp2m1f, exp2m1l, fadd, faddl, fdiv, fdivl, ffma,
ffmal, fmaximum, fmaximum_mag, fmaximum_mag_num, fmaximum_mag_numf,
fmaximum_mag_numl, fmaximum_magf, fmaximum_magl, fmaximum_num,
fmaximum_numf, fmaximum_numl, fmaximumf, fmaximuml, fminimum,
fminimum_mag, fminimum_mag_num, fminimum_mag_numf, fminimum_mag_numl,
fminimum_magf, fminimum_magl, fminimum_num, fminimum_numf,
fminimum_numl, fminimumf, fminimuml, fmul, fmull, fromfp, fromfpf,
fromfpl, fromfpx, fromfpxf, fromfpxl, fsqrt, fsqrtl, fsub, fsubl,
iscanonical, iseqsig, issignaling, issubnormal, iszero, nextdown,
nextdownf, nextdownl, nextup, nextupf, nextupl, pown, pownf, pownl,
powr, powrf, powrl, rootf, rootl, rootn, roundeven, roundevenf,
roundevenl, rsqrt, rsqrtf, rsqrtl, ufromfp, ufromfpf, ufromfpl,
ufromfpx, ufromfpxf, ufromfpxl.

Reviewed by:	imp
Approved by:	markj (mentor)
MFC after:	1 month
Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D53783
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This is the *pi family of trigonometric functions. Quite a few C23
functions are still missing.  These seem to be:
acospi, acospif, acospil, asinpi, asinpif, asinpil, atan2pi, atan2pif,
atan2pil, atanpi, atanpif, atanpil, canonicalize, canonicalizef,
canonicalizel, compoundn, compoundnf, compoundnl, daddl, ddivl, dfmal,
dmull, dsqrtl, dsubl, exp10, exp10f, exp10l, exp10m1, exp10m1f,
exp10m1l, exp2m1, exp2m1f, exp2m1l, fadd, faddl, fdiv, fdivl, ffma,
ffmal, fmaximum, fmaximum_mag, fmaximum_mag_num, fmaximum_mag_numf,
fmaximum_mag_numl, fmaximum_magf, fmaximum_magl, fmaximum_num,
fmaximum_numf, fmaximum_numl, fmaximumf, fmaximuml, fminimum,
fminimum_mag, fminimum_mag_num, fminimum_mag_numf, fminimum_mag_numl,
fminimum_magf, fminimum_magl, fminimum_num, fminimum_numf,
fminimum_numl, fminimumf, fminimuml, fmul, fmull, fromfp, fromfpf,
fromfpl, fromfpx, fromfpxf, fromfpxl, fsqrt, fsqrtl, fsub, fsubl,
iscanonical, iseqsig, issignaling, issubnormal, iszero, nextdown,
nextdownf, nextdownl, nextup, nextupf, nextupl, pown, pownf, pownl,
powr, powrf, powrl, rootf, rootl, rootn, roundeven, roundevenf,
roundevenl, rsqrt, rsqrtf, rsqrtl, ufromfp, ufromfpf, ufromfpl,
ufromfpx, ufromfpxf, ufromfpxl.

Reviewed by:	imp
Approved by:	markj (mentor)
MFC after:	1 month
Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D53783
</pre>
</div>
</content>
</entry>
<entry>
<title>libm: remainder: make sure x is zero</title>
<updated>2025-10-11T10:13:19+00:00</updated>
<author>
<name>Ahmad Khalifa</name>
<email>vexeduxr@FreeBSD.org</email>
</author>
<published>2025-10-10T09:30:52+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=25cca51ed294890d20a3c0290814cd26875db686'/>
<id>25cca51ed294890d20a3c0290814cd26875db686</id>
<content type='text'>
Make sure the entirety of x is zero before flipping the sign bit.
Otherwise the sign would be wrong for small values of x when x is
negative and |n*y| &gt; |x|

Reported by:	alfredo
PR:		251091
Reviewed by:	kargl
MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D53023
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Make sure the entirety of x is zero before flipping the sign bit.
Otherwise the sign would be wrong for small values of x when x is
negative and |n*y| &gt; |x|

Reported by:	alfredo
PR:		251091
Reviewed by:	kargl
MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D53023
</pre>
</div>
</content>
</entry>
<entry>
<title>lib/msun: cpow{,f,l}(CMLX(0.0, 0.0)) should return 1.0</title>
<updated>2025-09-12T02:36:27+00:00</updated>
<author>
<name>Steve Kargl</name>
<email>kargl@FreeBSD.org</email>
</author>
<published>2025-09-11T16:38:17+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=8b41ba845c7e10b5f241a1f944fe9a8e19ad75a9'/>
<id>8b41ba845c7e10b5f241a1f944fe9a8e19ad75a9</id>
<content type='text'>
PR:	289447
MFC after:	1 week
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
PR:	289447
MFC after:	1 week
</pre>
</div>
</content>
</entry>
<entry>
<title>[libm] Avoid left shift of signed integer entities</title>
<updated>2025-08-14T18:38:41+00:00</updated>
<author>
<name>Steve Kargl</name>
<email>kargl@FreeBSD.org</email>
</author>
<published>2025-08-14T18:38:41+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=c58c77246f88da87f309e8c449e98195d43e2c76'/>
<id>c58c77246f88da87f309e8c449e98195d43e2c76</id>
<content type='text'>
Follow-up commit d180086e6eae by fixing the left shift of signed integer
entities through the use of a helper function. Specific per file changes
are:

* lib/msun/src/e_fmodf.c:
* lib/msun/src/s_remquof.c:
  . Eliminate now unused variable 'i'.
  . Sort declaration statement.
  . Use subnormal_ilogbf() to avoid left shift of signed integer.

* lib/msun/src/math_private.h b/lib/msun/src/math_private.h:
  . Implement subnormal_ilogbf() to extract an exponent of a subnormal
    float.  This avoids left shifts of signed integers.
  . Update nearby comment.

* lib/msun/src/s_ilogbf.c
  . Fix declaration of the function statement in accordance with style(9).
  . Use subnormal_ilogbf() to avoid left shift of signed integer.

PR:		288850
MFC after:	1 week
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Follow-up commit d180086e6eae by fixing the left shift of signed integer
entities through the use of a helper function. Specific per file changes
are:

* lib/msun/src/e_fmodf.c:
* lib/msun/src/s_remquof.c:
  . Eliminate now unused variable 'i'.
  . Sort declaration statement.
  . Use subnormal_ilogbf() to avoid left shift of signed integer.

* lib/msun/src/math_private.h b/lib/msun/src/math_private.h:
  . Implement subnormal_ilogbf() to extract an exponent of a subnormal
    float.  This avoids left shifts of signed integers.
  . Update nearby comment.

* lib/msun/src/s_ilogbf.c
  . Fix declaration of the function statement in accordance with style(9).
  . Use subnormal_ilogbf() to avoid left shift of signed integer.

PR:		288850
MFC after:	1 week
</pre>
</div>
</content>
</entry>
<entry>
<title>[libm] Fix undefined behavior of a left shifted of a signed integer</title>
<updated>2025-08-12T05:31:03+00:00</updated>
<author>
<name>Steve Kargl</name>
<email>kargl@FreeBSD.org</email>
</author>
<published>2025-08-12T04:26:29+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=d180086e6eae2e152e803ed6cf13775a7c006dc7'/>
<id>d180086e6eae2e152e803ed6cf13775a7c006dc7</id>
<content type='text'>
The patch fixes a few instances of left shifts on
signed integer entities.  A 'static inline' helper function
'subnormal_ilogb()' has been added to math_private.h.  This
function is then used e_fmod.c, s_ilogb(), and s_remquo.c.

The change in s_remquo.c has only been compile tested.

The change to e_fmod.c has been test on over 3 billion pairs
of subnormal numbers where testing included x &gt; y and x &lt; y
pairs.  The test compared the output from fmod() with the
output from mpfr_fmod() from MPFR.  There were no difference.

The change to s_ilogb() has had limited testing where its
output was compared against frexp().  In this testing, no
differences in output were detected.

PR:	288778
MFC after:	1 week
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The patch fixes a few instances of left shifts on
signed integer entities.  A 'static inline' helper function
'subnormal_ilogb()' has been added to math_private.h.  This
function is then used e_fmod.c, s_ilogb(), and s_remquo.c.

The change in s_remquo.c has only been compile tested.

The change to e_fmod.c has been test on over 3 billion pairs
of subnormal numbers where testing included x &gt; y and x &lt; y
pairs.  The test compared the output from fmod() with the
output from mpfr_fmod() from MPFR.  There were no difference.

The change to s_ilogb() has had limited testing where its
output was compared against frexp().  In this testing, no
differences in output were detected.

PR:	288778
MFC after:	1 week
</pre>
</div>
</content>
</entry>
<entry>
<title>Updates for ccosh[f] and csinh[f]</title>
<updated>2025-08-09T17:28:07+00:00</updated>
<author>
<name>Steve Kargl</name>
<email>kargl@FreeBSD.org</email>
</author>
<published>2025-08-09T17:28:07+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=a1d051bc878decc761b37cf8771ead100cc05768'/>
<id>a1d051bc878decc761b37cf8771ead100cc05768</id>
<content type='text'>
* lib/msun/src/s_ccosh.c:
  . Update Copyright years.
  . sin() and cos() are needed at the same time, so use sincos() to
    compute values.  This does argument reduction once instead of twice.
  . Replace '* 0.5' with '/ 2'. This reduces diff with s_ccoshf.c.
  . For (LDBL_MANT_DIG == 53), add weak references for ccoshl and ccosl.

* lib/msun/src/s_ccoshf.c:
  . Update Copyright years.
  . sin() and cos() are needed at the same time, so use sincos() to
    compute values.  This does argument reduction once instead of twice.
  . Replace '* 0.5F' with '/ 2'. This reduces diff with s_ccoshf.c.

* lib/msun/src/s_csinh.c:
  . Update Copyright years.
  . sin() and cos() are needed at the same time, so use sincos() to
    compute values.  This does argument reduction once instead of twice.
  . Replace '* 0.5' with '/ 2'. This reduces diff with s_csinhf.c.
  . For (LDBL_MANT_DIG == 53), add weak references for csinhl and csinl.

* lib/msun/src/s_csinhf.c:
  . Update Copyright years.
  . sin() and cos() are needed at the same time, so use sincos() to
    compute values.  This does argument reduction once instead of twice.
  . Replace '* 0.5F' with '/ 2'. This reduces diff with s_ccoshf.c.

PR:		288740
MFC after:	1 week
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* lib/msun/src/s_ccosh.c:
  . Update Copyright years.
  . sin() and cos() are needed at the same time, so use sincos() to
    compute values.  This does argument reduction once instead of twice.
  . Replace '* 0.5' with '/ 2'. This reduces diff with s_ccoshf.c.
  . For (LDBL_MANT_DIG == 53), add weak references for ccoshl and ccosl.

* lib/msun/src/s_ccoshf.c:
  . Update Copyright years.
  . sin() and cos() are needed at the same time, so use sincos() to
    compute values.  This does argument reduction once instead of twice.
  . Replace '* 0.5F' with '/ 2'. This reduces diff with s_ccoshf.c.

* lib/msun/src/s_csinh.c:
  . Update Copyright years.
  . sin() and cos() are needed at the same time, so use sincos() to
    compute values.  This does argument reduction once instead of twice.
  . Replace '* 0.5' with '/ 2'. This reduces diff with s_csinhf.c.
  . For (LDBL_MANT_DIG == 53), add weak references for csinhl and csinl.

* lib/msun/src/s_csinhf.c:
  . Update Copyright years.
  . sin() and cos() are needed at the same time, so use sincos() to
    compute values.  This does argument reduction once instead of twice.
  . Replace '* 0.5F' with '/ 2'. This reduces diff with s_ccoshf.c.

PR:		288740
MFC after:	1 week
</pre>
</div>
</content>
</entry>
<entry>
<title>Don't rely on sys/_types.h including sys/cdefs.h</title>
<updated>2025-06-11T16:39:01+00:00</updated>
<author>
<name>Brooks Davis</name>
<email>brooks@FreeBSD.org</email>
</author>
<published>2025-06-11T16:39:01+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=b01e971fd39d10273a387788019457792873e81c'/>
<id>b01e971fd39d10273a387788019457792873e81c</id>
<content type='text'>
These headers relied in __BEGIN_DECS/__END_DECLS being defined when
sys/_types.h was included, but there's not a requirement that this be
the case.

Reviewed by:	imp
Exp-run by:	antoine (PR 286274)
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1595
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
These headers relied in __BEGIN_DECS/__END_DECLS being defined when
sys/_types.h was included, but there's not a requirement that this be
the case.

Reviewed by:	imp
Exp-run by:	antoine (PR 286274)
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1595
</pre>
</div>
</content>
</entry>
<entry>
<title>msun: fix cbrt iterations from Newton to Halley method</title>
<updated>2025-05-05T04:52:49+00:00</updated>
<author>
<name>Clément Bœsch</name>
<email>u@pkh.me</email>
</author>
<published>2025-05-01T17:19:36+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=f887d0215fb48e682acccf4cb95f3794974e1a9d'/>
<id>f887d0215fb48e682acccf4cb95f3794974e1a9d</id>
<content type='text'>
Since we're inverting a cube, we have:
    f(Tₙ)=Tₙ³-x    (1)

Its first and second derivatives are:
    f'(Tₙ)=3Tₙ²    (2)
    f"(Tₙ)=6Tₙ     (3)

Halley iteration[1] uses:
    Tₙ₊₁=Tₙ-2f(Tₙ)f'(Tₙ)/(2f'(Tₙ)²-f(Tₙ)f"(Tₙ))    (4)

Replacing the terms of (4) using (1), (2) and (3):

Tₙ₊₁ = Tₙ-2f(Tₙ)f'(Tₙ)/(2f'(Tₙ)²-f(Tₙ)f"(Tₙ))
     = Tₙ-2(Tₙ³-x)3Tₙ²/(2(3Tₙ²)²-(Tₙ³-x)6Tₙ)
     = &lt;snip, see WolframAlpha[2] alternate forms&gt;
     = Tₙ(2x+Tₙ³)/(x+2Tₙ³)

This formula corresponds to the exact expression used in the code.

Newton formula is Tₙ-f(Tₙ)/f'(Tₙ) which would have simplified to
(2Tₙ³+x)/(3Tₙ²) instead.

[1] https://en.wikipedia.org/wiki/Halley's_method
[2] https://www.wolframalpha.com/input?i=T-2%28T%5E3-x%293T%5E2%2F%282%283T%5E2%29%5E2-%28T%5E3-x%296T%29

Note: UTF8 in commit message due to the heavy math being hard to
recreate w/o it. -- imp

Signed-off-by: Clément Bœsch &lt;u@pkh.me&gt;
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1684
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Since we're inverting a cube, we have:
    f(Tₙ)=Tₙ³-x    (1)

Its first and second derivatives are:
    f'(Tₙ)=3Tₙ²    (2)
    f"(Tₙ)=6Tₙ     (3)

Halley iteration[1] uses:
    Tₙ₊₁=Tₙ-2f(Tₙ)f'(Tₙ)/(2f'(Tₙ)²-f(Tₙ)f"(Tₙ))    (4)

Replacing the terms of (4) using (1), (2) and (3):

Tₙ₊₁ = Tₙ-2f(Tₙ)f'(Tₙ)/(2f'(Tₙ)²-f(Tₙ)f"(Tₙ))
     = Tₙ-2(Tₙ³-x)3Tₙ²/(2(3Tₙ²)²-(Tₙ³-x)6Tₙ)
     = &lt;snip, see WolframAlpha[2] alternate forms&gt;
     = Tₙ(2x+Tₙ³)/(x+2Tₙ³)

This formula corresponds to the exact expression used in the code.

Newton formula is Tₙ-f(Tₙ)/f'(Tₙ) which would have simplified to
(2Tₙ³+x)/(3Tₙ²) instead.

[1] https://en.wikipedia.org/wiki/Halley's_method
[2] https://www.wolframalpha.com/input?i=T-2%28T%5E3-x%293T%5E2%2F%282%283T%5E2%29%5E2-%28T%5E3-x%296T%29

Note: UTF8 in commit message due to the heavy math being hard to
recreate w/o it. -- imp

Signed-off-by: Clément Bœsch &lt;u@pkh.me&gt;
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1684
</pre>
</div>
</content>
</entry>
</feed>
