* [PATCH] iio: tools: Use proper macro to detect _Float16 support
@ 2026-09-18 16:13 Ivan A. Melnikov
2026-09-19 9:39 ` Joshua Crofts
2026-09-19 14:04 ` Andy Shevchenko
0 siblings, 2 replies; 4+ messages in thread
From: Ivan A. Melnikov @ 2026-09-18 16:13 UTC (permalink / raw)
To: Jonathan Cameron
Cc: Ivan A. Melnikov, David Lechner, Nuno Sá,
Andy Shevchenko, Jonathan Cameron, Francesco Lavra, linux-iio,
linux-kernel
__FLT16_MAX__ is an internal compiler macro. GCC defines it if
_Float16 is supported by the target in general, but the support
may depend on the exact target options. For example, on i586
without -msse2 I get the following error from GCC15:
iio_generic_buffer.c: In function 'print2byte':
iio_generic_buffer.c:141:17: error: invalid conversion from type '_Float16' without option '-msse2'
141 | printf("%05f ", ((float)converter.f + info->offset) * info->scale);
| ^~~~~~
To fix that, use the public macro without double underscores.
Fixes: cdd445d4b2a9 ("iio: tools: Add support for floating-point types in buffer scan elements")
Signed-off-by: Ivan A. Melnikov <iv@altlinux.org>
---
tools/iio/iio_generic_buffer.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/iio/iio_generic_buffer.c b/tools/iio/iio_generic_buffer.c
index 000193612aad..9ea93984e0e9 100644
--- a/tools/iio/iio_generic_buffer.c
+++ b/tools/iio/iio_generic_buffer.c
@@ -131,7 +131,7 @@ static void print2byte(uint16_t input, struct iio_channel_info *info)
printf("%05f ", ((float)input + info->offset) * info->scale);
break;
case 'f': {
-#if defined(__FLT16_MAX__)
+#if defined(FLT16_MAX)
union {
uint16_t u;
_Float16 f;
--
2.50.1
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] iio: tools: Use proper macro to detect _Float16 support 2026-09-18 16:13 [PATCH] iio: tools: Use proper macro to detect _Float16 support Ivan A. Melnikov @ 2026-09-19 9:39 ` Joshua Crofts 2026-09-21 11:33 ` Ivan A. Melnikov 2026-09-19 14:04 ` Andy Shevchenko 1 sibling, 1 reply; 4+ messages in thread From: Joshua Crofts @ 2026-09-19 9:39 UTC (permalink / raw) To: Ivan A. Melnikov Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko, Jonathan Cameron, Francesco Lavra, linux-iio, linux-kernel On Fri, 18 Sep 2026 20:13:02 +0400 "Ivan A. Melnikov" <iv@altlinux.org> wrote: > __FLT16_MAX__ is an internal compiler macro. GCC defines it if > _Float16 is supported by the target in general, but the support > may depend on the exact target options. For example, on i586 > without -msse2 I get the following error from GCC15: > > iio_generic_buffer.c: In function 'print2byte': > iio_generic_buffer.c:141:17: error: invalid conversion from type '_Float16' without option '-msse2' > 141 | printf("%05f ", ((float)converter.f + info->offset) * info->scale); > | ^~~~~~ > > To fix that, use the public macro without double underscores. > > Fixes: cdd445d4b2a9 ("iio: tools: Add support for floating-point types in buffer scan elements") > Signed-off-by: Ivan A. Melnikov <iv@altlinux.org> > --- > tools/iio/iio_generic_buffer.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/tools/iio/iio_generic_buffer.c b/tools/iio/iio_generic_buffer.c > index 000193612aad..9ea93984e0e9 100644 > --- a/tools/iio/iio_generic_buffer.c > +++ b/tools/iio/iio_generic_buffer.c > @@ -131,7 +131,7 @@ static void print2byte(uint16_t input, struct iio_channel_info *info) > printf("%05f ", ((float)input + info->offset) * info->scale); > break; > case 'f': { > -#if defined(__FLT16_MAX__) > +#if defined(FLT16_MAX) > union { > uint16_t u; > _Float16 f; One Sashiko issue: Does this unintentionally disable _Float16 support for all architectures? Since the tools build environment uses gnu11 compilation flags without explicitly defining __STDC_WANT_IEC_60559_TYPES_EXT__, FLT16_MAX is undefined across all architectures. This causes the preprocessor to skip this block entirely, causing the tool to always print <unsupported 2-byte float> for 16-bit float data, even on platforms where native support previously worked. If FLT16_MAX were actually defined, the compiler would still parse the _Float16 block and throw the same missing -msse2 compilation error mentioned in the commit message. Is there an alternative way to check for hardware support without completely disabling the feature? -- Kind regards, Joshua Crofts ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] iio: tools: Use proper macro to detect _Float16 support 2026-09-19 9:39 ` Joshua Crofts @ 2026-09-21 11:33 ` Ivan A. Melnikov 0 siblings, 0 replies; 4+ messages in thread From: Ivan A. Melnikov @ 2026-09-21 11:33 UTC (permalink / raw) To: Joshua Crofts Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko, Jonathan Cameron, Francesco Lavra, linux-iio, linux-kernel On Sat, Sep 19, 2026 at 11:39:45AM +0200, Joshua Crofts wrote: > On Fri, 18 Sep 2026 20:13:02 +0400 > "Ivan A. Melnikov" <iv@altlinux.org> wrote: > > > __FLT16_MAX__ is an internal compiler macro. GCC defines it if > > _Float16 is supported by the target in general, but the support > > may depend on the exact target options. For example, on i586 > > without -msse2 I get the following error from GCC15: > > > > iio_generic_buffer.c: In function 'print2byte': > > iio_generic_buffer.c:141:17: error: invalid conversion from type '_Float16' without option '-msse2' > > 141 | printf("%05f ", ((float)converter.f + info->offset) * info->scale); > > | ^~~~~~ > > > > To fix that, use the public macro without double underscores. > > > > Fixes: cdd445d4b2a9 ("iio: tools: Add support for floating-point types in buffer scan elements") > > Signed-off-by: Ivan A. Melnikov <iv@altlinux.org> > > --- > > tools/iio/iio_generic_buffer.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/tools/iio/iio_generic_buffer.c b/tools/iio/iio_generic_buffer.c > > index 000193612aad..9ea93984e0e9 100644 > > --- a/tools/iio/iio_generic_buffer.c > > +++ b/tools/iio/iio_generic_buffer.c > > @@ -131,7 +131,7 @@ static void print2byte(uint16_t input, struct iio_channel_info *info) > > printf("%05f ", ((float)input + info->offset) * info->scale); > > break; > > case 'f': { > > -#if defined(__FLT16_MAX__) > > +#if defined(FLT16_MAX) > > union { > > uint16_t u; > > _Float16 f; > > One Sashiko issue: > > Does this unintentionally disable _Float16 support for all architectures? Indeed, it does. Sorry, my patch is incorrect. I must have completely messed up all my checks on Friday. > Since the tools build environment uses gnu11 compilation flags without > explicitly defining __STDC_WANT_IEC_60559_TYPES_EXT__, FLT16_MAX is > undefined across all architectures. This causes the preprocessor to skip > this block entirely, causing the tool to always print > <unsupported 2-byte float> for 16-bit float data, even on platforms where > native support previously worked. > > If FLT16_MAX were actually defined, the compiler would still parse the > _Float16 block and throw the same missing -msse2 compilation error mentioned > in the commit message. Is there an alternative way to check for hardware > support without completely disabling the feature? Apparently, the only correct way to detect _Float16 is to try compiling some code that uses it. For that, a feature can be added to tools/build. On other hand, x86 without SSE2 is the only platform I could find where __FLT16_MAX__ is defined, but _Float16 does not work, so a simple platform-specific workaround would also work and would be much less elaborate. WDYT? -- wbr, iv m. ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] iio: tools: Use proper macro to detect _Float16 support 2026-09-18 16:13 [PATCH] iio: tools: Use proper macro to detect _Float16 support Ivan A. Melnikov 2026-09-19 9:39 ` Joshua Crofts @ 2026-09-19 14:04 ` Andy Shevchenko 1 sibling, 0 replies; 4+ messages in thread From: Andy Shevchenko @ 2026-09-19 14:04 UTC (permalink / raw) To: Ivan A. Melnikov Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko, Jonathan Cameron, Francesco Lavra, linux-iio, linux-kernel On Fri, Sep 18, 2026 at 08:13:02PM +0400, Ivan A. Melnikov wrote: > __FLT16_MAX__ is an internal compiler macro. GCC defines it if > _Float16 is supported by the target in general, but the support > may depend on the exact target options. For example, on i586 > without -msse2 I get the following error from GCC15: > > iio_generic_buffer.c: In function 'print2byte': > iio_generic_buffer.c:141:17: error: invalid conversion from type '_Float16' without option '-msse2' > 141 | printf("%05f ", ((float)converter.f + info->offset) * info->scale); > | ^~~~~~ > > To fix that, use the public macro without double underscores. What about clang? -- With Best Regards, Andy Shevchenko ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-09-21 11:33 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2026-09-18 16:13 [PATCH] iio: tools: Use proper macro to detect _Float16 support Ivan A. Melnikov 2026-09-19 9:39 ` Joshua Crofts 2026-09-21 11:33 ` Ivan A. Melnikov 2026-09-19 14:04 ` Andy Shevchenko
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®