Skip to content
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

[cmath] Only use ISO math functions in avr-libm #1

Merged
merged 1 commit into from
Apr 25, 2020
Merged

Conversation

salkinium
Copy link
Member

@salkinium salkinium commented Apr 23, 2020

avr-libm does not provide float or long overloads of math functions, so linking against __builtin_sinf resolving to just ::sinf will fail.

I discovered this when compiling the modm math unittests for avr, which uses float types and therefore calls std::sin(float), which the stdlibc++ overloads to use __builtin_sinf instead of just forwarding everything to __builtin_sin.

avr-libm is not very consistent about what overloads it provides though, and I'm not sure if this is the right fix, but it makes the unittests link and pass.

 $ avr-nm path/to/avr-gcc/9.x.y/avr/lib/avr4/libm.a --defined-only # => output cleaned up
acos
asin
atan
atan2
cbrt
ceil
copysign
cos
cosh
exp
fdim
floor
fma
fmax
fmin
fmod
frexp
hypot
inverse
isfinite
isinf
isnan
ldexp
log
log10
lrint
lround
modf
modff
pow
round
signbit
sin
sinh
sqrt
sqrtf
square
tan
tanh
trunc

cc @chris-durand

avr-libm does not provide float or long overloads of math functions, so
linking against __builtin_sinf resolving to just sinf will fail.
@salkinium
Copy link
Member Author

(I'll add an example later)

@chris-durand
Copy link
Member

The C99 float versions partially exist in the avr libc but are macro defines for the double variants. float and double are both 32 bit floats anyway for avr. I don't know what this __CORRECT_ISO_CPP_MATH_H_PROTO is orignally intended for but if it works it's fine.

@salkinium salkinium deleted the fix/cmath branch April 25, 2020 17:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants