Skip to content

Commit bdfb665

Browse files
committed
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]>
1 parent a365cb1 commit bdfb665

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

sys/config/src/config.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,9 @@ conf_value_from_str(char *val_str, enum conf_type type, void *vp, int maxlen)
156156
{
157157
int64_t val;
158158
uint64_t uval;
159+
#if MYNEWT_VAL(CONFIG_FLOAT_SUPPORT)
159160
float fval;
161+
#endif
160162
char *eptr;
161163

162164
if (!val_str) {
@@ -223,13 +225,15 @@ conf_value_from_str(char *val_str, enum conf_type type, void *vp, int maxlen)
223225
*(uint64_t *)vp = uval;
224226
}
225227
break;
228+
#if MYNEWT_VAL(CONFIG_FLOAT_SUPPORT)
226229
case CONF_FLOAT:
227230
fval = strtof(val_str, &eptr);
228231
if (*eptr != '\0') {
229232
goto err;
230233
}
231234
*(float *)vp = fval;
232235
break;
236+
#endif
233237
case CONF_STRING:
234238
val = strlen(val_str);
235239
if (val + 1 > maxlen) {

sys/config/syscfg.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,15 @@ syscfg.defs:
9393
description: >
9494
Max length of a value stored in the config FCB.
9595
value: 256
96+
CONFIG_FLOAT_SUPPORT:
97+
description: >
98+
Enable float support in config.
99+
For MCU without hardware support for enabling this if no other
100+
function use floating point may increase image size 20kB or more.
101+
value: 0
102+
103+
syscfg.vals.HARDFLOAT:
104+
value: 1
96105

97106
syscfg.defs.(CONFIG_FCB || CONFIG_FCB2):
98107
CONFIG_FCB_FLASH_AREA:

0 commit comments

Comments
 (0)