This is an automated email from the ASF dual-hosted git repository.

jerzy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git


The following commit(s) were added to refs/heads/master by this push:
     new bdfb66500 sys/config: Make floating point support optional
bdfb66500 is described below

commit bdfb66500713effa5e5d4a90ffd0b22a714e82ea
Author: Jerzy Kasenberg <[email protected]>
AuthorDate: Mon Apr 15 13:01:49 2024 +0200

    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 <[email protected]>
---
 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 827c9b7e5..d10a77abc 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 b9994c09a..60761d5fb 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:

Reply via email to