Should we add f80? Even if it is not often used.
I think this issue is under-specified, can you please clarify?
I agree that some more details are definitely needed.
@3442853561 are you looking for a primitive type that is FFI-compatible with long double in C or for higher-precision floating point types?
@ranma42 Yes, I'm looking for a primitive type which like long double in C
We can build it as a crate, however I think it should in stdlib instead of other crate.
So, what should we do now? Should we create a crate for the f80 type first, and talk about it should enter the standard library later?
AFAIU support for a type that is compatible with long double in C would not be possible in an external crate, as it needs to be passed in specific ways across function boundaries (depending on the target ABI).
Moreover, f80 is the x86 version of C long double, but other targets behave in a different way (according to https://en.wikipedia.org/wiki/Long_double on SPARC and HP-UX it means f128).
I believe that the main cause for the lack of support in Rust is that long double is not commonly used across language boundaries and there has been little interest in using higher precision floating point numbers in Rust (except maybe through software support).
Some concrete use cases would probably be the first step towards making this issue into a complete RFC.
@ranma42 Honestly, that to me means that implementing both f80 and f128 could help with implementing a c_longdouble for platforms with IEEE 754 support. Although, that'd also mean implementing f16 for completeness and at that point you really start to wonder if all of this is necessary.
That said, all of these types are rigourously defined, which would technically not rule them out for FFI.
I know of at least one C library that has a long double in its API that I've had to work around:
https://github.com/libunwind/libunwind/blob/7c079200d024d5868073246c4ec8f80446b0a4c0/include/libunwind-x86_64.h#L54
https://github.com/sfackler/rstack/blob/master/unwind-sys/src/lib.rs#L108-L109
FWIW We have already added architecture-specific types, like the SIMD vector types, to std::arch which is in beta. We could probably exposef80 through std::arch as well on those architectures in which it is available.
Most helpful comment
AFAIU support for a type that is compatible with
long doublein C would not be possible in an external crate, as it needs to be passed in specific ways across function boundaries (depending on the target ABI).Moreover,
f80is the x86 version of Clong double, but other targets behave in a different way (according to https://en.wikipedia.org/wiki/Long_double on SPARC and HP-UX it meansf128).I believe that the main cause for the lack of support in Rust is that
long doubleis not commonly used across language boundaries and there has been little interest in using higher precision floating point numbers in Rust (except maybe through software support).Some concrete use cases would probably be the first step towards making this issue into a complete RFC.