[libcamera-devel,v1,0/2] libcamera Fix compilation with uClibc
mbox series

Message ID 20230108214357.12641-1-laurent.pinchart@ideasonboard.com
Headers show
Series
  • libcamera Fix compilation with uClibc
Related show

Message

Laurent Pinchart Jan. 8, 2023, 9:43 p.m. UTC
Hello,

This patch series fixes compilation errors with uClibc that were
introduced in commit e8ae254970cf ("libcamera: yaml_parser: Use C
locale").

uClibc can be compiled with different levels of locale support:

- Full locale object (locale_t) support, with strto*_l() functions
- Locale support without locale object and strto*_l() functions
- Hardcoded "C" locale

In the second and third cases, compilation of libcamera fails due to
missing newlocale(), freelocale() and strtod_l() functions.

Patch 1/2 first moves the strtod_l() and the locale_t RAII wrapper from
yaml_parser.h to utils.h, as the fix exceeds the scope of an
implementation private to the YAML parser. Patch 2/2 then fixes the
issue by using strtod() when locale object support isn't available.

This fixes compilation with all the cases described above, but leaves a
runtime issue in the second case if the locale has different numeric
parsing rules. As this is a corner case (locale support without locale
object support) of a corner case (uClibc), I don't expect it to be an
issue in practice. If it turns out to cause problems, a reimplementation
of strtod() in libcamera may be needed.

Laurent Pinchart (2):
  base: utils: Add and use strtod() helper
  libcamera: base: utils: Support C libraries lacking locale support

 include/libcamera/base/utils.h |  2 ++
 meson.build                    |  4 +++
 src/libcamera/base/utils.cpp   | 58 ++++++++++++++++++++++++++++++++++
 src/libcamera/yaml_parser.cpp  | 34 +-------------------
 4 files changed, 65 insertions(+), 33 deletions(-)


base-commit: c15ff6b59de877ab8ee19b09e9315e5eaffdb818