od: support half precision floating point
commit76604db7d2da0ceb4de4542ebf315b3d6415f972
authorPádraig Brady <P@draigBrady.com>
Thu, 1 Feb 2024 17:59:51 +0000 (1 17:59 +0000)
committerPádraig Brady <P@draigBrady.com>
Mon, 5 Feb 2024 13:30:45 +0000 (5 13:30 +0000)
tree84f4241b1c768fb3d56f4ca9357dd2b56163dd1f
parent6ec1fb46aba4b72623e4aab1a682466f68f5fdf3
od: support half precision floating point

Rely on compiler support for _Float16 and __bf16
to support -fH and -fB formats respectively.
I.e. IEEE 16 bit, and brain 16 bit floats respectively.
Modern GCC and LLVM compilers support both types.

clang-sect=half-precision-floating-point
https://gcc.gnu.org/onlinedocs/gcc/Half-Precision.html
https://clang.llvm.org/docs/LanguageExtensions.html#$clang-sect
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0192r4.html
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p1467r9.html

This was tested on:
gcc 13, clang 17 x86 (Both types supported)
gcc 7 aarch64 (Only -fH supported)
gcc 13 ppc(be) (Neither supported. Both will be with GCC 14)

* src/od.c: Support -tf2 or -tfH to print IEEE 16 bit floating point,
or -tfB to print Brain 16 bit floating point.
* configure.ac: Check for _Float16 and __bf16 types.
* doc/coreutils.texi (od invocation): Mention the new -f types.
* tests/od/od-float.sh: Add test cases.
* NEWS: Mention the new feature.
Addresses https://bugs.gnu.org/68871
NEWS
configure.ac
doc/coreutils.texi
src/od.c
tests/od/od-float.sh