Page MenuHomeFreeBSD

Fix fabs() for MIPS when used on -0.0
ClosedPublic

Authored by arichardson on Nov 17 2017, 5:09 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Nov 24, 6:12 PM
Unknown Object (File)
Sat, Nov 23, 8:29 AM
Unknown Object (File)
Nov 6 2024, 8:43 AM
Unknown Object (File)
Oct 1 2024, 1:31 PM
Unknown Object (File)
Sep 27 2024, 7:26 PM
Unknown Object (File)
Sep 26 2024, 4:34 PM
Unknown Object (File)
Sep 26 2024, 4:30 PM
Unknown Object (File)
Sep 26 2024, 4:30 PM
Subscribers

Details

Summary

It would previously return negative zero for -0.0 since -0.0 does not
compare less than 0. The issue was discovered when running the libc++
test suite on softfloat MIPS64.

I have verified that both clang and GCC generate sensible code for the
builtin. For soft float they clear the sign bit using integer operations
and in hard float mode they use abs.d.

Diff Detail

Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 12814
Build 13081: arc lint + arc unit

Event Timeline

My only question is if we should do the same for the arm C version.

In D13135#274569, @jhb wrote:

My only question is if we should do the same for the arm C version.

https://reviews.freebsd.org/D13131

This revision is now accepted and ready to land.Nov 21 2017, 8:05 PM

FreeBSD's style is to put ()'s around return values, so it should probably be 'return (__builtin_fabs(x));'

This is honestly fine as it is. Two minor nits, but they are uber nits and can be ignored perhaps...

lib/libc/mips/gen/fabs.c
43

The nit-pikcer's parade:
(1) should have a blank line after the { since there's no local variables.
(2) () around the return value.

These are documented in style(9), but customs are often observed in their breech rather than their adherence.

This revision was automatically updated to reflect the committed changes.