[libcamera-devel] [PATCH v1 0/2] libcamera Fix compilation with uClibc

Laurent Pinchart laurent.pinchart at ideasonboard.com
Sun Jan 8 22:43:55 CET 2023


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
-- 
Regards,

Laurent Pinchart



More information about the libcamera-devel mailing list