From 0375f0417a4ecd099e2ba7fc3db8ee0fd7dda442 Mon Sep 17 00:00:00 2001 From: Jerzy Kasenberg Date: Mon, 15 Apr 2024 13:01:49 +0200 Subject: [PATCH] sys/config: Make floating point support optional Adding CONF_FLOAT support could increase code size significantly if floating point are not used otherwise. This makes float support optional (enabled by default when HARDFLOAT is present). Signed-off-by: Jerzy Kasenberg --- sys/config/src/config.c | 4 ++++ sys/config/syscfg.yml | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/sys/config/src/config.c b/sys/config/src/config.c index 827c9b7e54..d10a77abc7 100644 --- a/sys/config/src/config.c +++ b/sys/config/src/config.c @@ -156,7 +156,9 @@ conf_value_from_str(char *val_str, enum conf_type type, void *vp, int maxlen) { int64_t val; uint64_t uval; +#if MYNEWT_VAL(CONFIG_FLOAT_SUPPORT) float fval; +#endif char *eptr; if (!val_str) { @@ -223,6 +225,7 @@ conf_value_from_str(char *val_str, enum conf_type type, void *vp, int maxlen) *(uint64_t *)vp = uval; } break; +#if MYNEWT_VAL(CONFIG_FLOAT_SUPPORT) case CONF_FLOAT: fval = strtof(val_str, &eptr); if (*eptr != '\0') { @@ -230,6 +233,7 @@ conf_value_from_str(char *val_str, enum conf_type type, void *vp, int maxlen) } *(float *)vp = fval; break; +#endif case CONF_STRING: val = strlen(val_str); if (val + 1 > maxlen) { diff --git a/sys/config/syscfg.yml b/sys/config/syscfg.yml index b9994c09a7..60761d5fba 100644 --- a/sys/config/syscfg.yml +++ b/sys/config/syscfg.yml @@ -93,6 +93,15 @@ syscfg.defs: description: > Max length of a value stored in the config FCB. value: 256 + CONFIG_FLOAT_SUPPORT: + description: > + Enable float support in config. + For MCU without hardware support for enabling this if no other + function use floating point may increase image size 20kB or more. + value: 0 + +syscfg.vals.HARDFLOAT: + value: 1 syscfg.defs.(CONFIG_FCB || CONFIG_FCB2): CONFIG_FCB_FLASH_AREA: