From aed615e1730d17a3da77ea22d5af43440cc4d873 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Fri, 6 Jan 2023 00:47:31 +0200 Subject: libcamera: base: utils: Support C libraries lacking locale support Not all C libraries include support for locale objects (locale_t) and the strto*_l() family of functions. A notable example is uClibc that can be compiled with a hardcoded "C" locale. Compilation then fails as the newlocale(), freelocale() and strtod_l() functions are not defined. Fix the compilation breakage by checking for the availability of the locale_t type, and fall back to strtod() when the type isn't available. This may not lead to the correct result if support for locale objects isn't available and the locale isn't hardcoded to "C", but that is such a corner case that we will likely never encounter it. Fixes: e8ae254970cf ("libcamera: yaml_parser: Use C locale") Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham Reviewed-by: Jacopo Mondi --- meson.build | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'meson.build') diff --git a/meson.build b/meson.build index e86673dd..389c5472 100644 --- a/meson.build +++ b/meson.build @@ -72,6 +72,10 @@ if cc.has_header_symbol('unistd.h', 'issetugid') config_h.set('HAVE_ISSETUGID', 1) endif +if cc.has_header_symbol('locale.h', 'locale_t', prefix : '#define _GNU_SOURCE') + config_h.set('HAVE_LOCALE_T', 1) +endif + if cc.has_header_symbol('stdlib.h', 'secure_getenv', prefix : '#define _GNU_SOURCE') config_h.set('HAVE_SECURE_GETENV', 1) endif -- cgit v1.2.1