1
mirror of https://github.com/DarkFlippers/unleashed-firmware.git synced 2025-12-12 04:34:43 +04:00

Reduced ieee754 parser size (#4154)

Co-authored-by: hedger <hedger@users.noreply.github.com>
This commit is contained in:
Anna Antonenko
2025-03-31 08:24:27 +04:00
committed by GitHub
parent 54adc38b3a
commit 79bb24406e
8 changed files with 74 additions and 6 deletions

View File

@@ -43,6 +43,7 @@ libs = env.BuildModules(
"ble_profile",
"bit_lib",
"datetime",
"ieee754_parse_wrap",
],
)

View File

@@ -0,0 +1,31 @@
Import("env")
wrapped_fn_list = [
"strtof",
"strtod",
]
for wrapped_fn in wrapped_fn_list:
env.Append(
LINKFLAGS=[
"-Wl,--wrap," + wrapped_fn,
]
)
env.Append(
SDK_HEADERS=[
File("wrappers.h"),
],
LINT_SOURCES=[
Dir("."),
],
)
libenv = env.Clone(FW_LIB_NAME="ieee754_parse_wrap")
libenv.ApplyLibFlags()
sources = libenv.GlobRecursive("*.c*", ".")
lib = libenv.StaticLibrary("${FW_LIB_NAME}", sources)
libenv.Install("${LIB_DIST_DIR}", lib)
Return("lib")

View File

@@ -0,0 +1,14 @@
#include "wrappers.h"
// Based on the disassembly, providing NULL as `locale` is fine.
// The default `strtof` and `strtod` provided in the same libc_nano also just
// call these functions, but with an actual locale structure which was taking up
// lots of .data space (364 bytes).
float __wrap_strtof(const char* in, char** tail) {
return strtof_l(in, tail, NULL);
}
double __wrap_strtod(const char* in, char** tail) {
return strtod_l(in, tail, NULL);
}

View File

@@ -0,0 +1,14 @@
#pragma once
#include <stdlib.h>
#ifdef __cplusplus
extern "C" {
#endif
float __wrap_strtof(const char* in, char** tail);
double __wrap_strtod(const char* in, char** tail);
#ifdef __cplusplus
}
#endif

View File

@@ -1,5 +1,5 @@
entry,status,name,type,params
Version,+,82.1,,
Version,+,82.2,,
Header,+,applications/services/bt/bt_service/bt.h,,
Header,+,applications/services/bt/bt_service/bt_keys_storage.h,,
Header,+,applications/services/cli/cli.h,,
@@ -57,6 +57,7 @@ Header,+,lib/flipper_application/plugins/plugin_manager.h,,
Header,+,lib/flipper_format/flipper_format.h,,
Header,+,lib/flipper_format/flipper_format_i.h,,
Header,+,lib/flipper_format/flipper_format_stream.h,,
Header,+,lib/ieee754_parse_wrap/wrappers.h,,
Header,+,lib/libusb_stm32/inc/hid_usage_button.h,,
Header,+,lib/libusb_stm32/inc/hid_usage_consumer.h,,
Header,+,lib/libusb_stm32/inc/hid_usage_desktop.h,,
@@ -382,6 +383,8 @@ Function,+,__wrap_putc,int,"int, FILE*"
Function,+,__wrap_putchar,int,int
Function,+,__wrap_puts,int,const char*
Function,+,__wrap_snprintf,int,"char*, size_t, const char*, ..."
Function,+,__wrap_strtod,double,"const char*, char**"
Function,+,__wrap_strtof,float,"const char*, char**"
Function,+,__wrap_ungetc,int,"int, FILE*"
Function,+,__wrap_vsnprintf,int,"char*, size_t, const char*, va_list"
Function,-,_asiprintf_r,int,"_reent*, char**, const char*, ..."
@@ -2361,13 +2364,13 @@ Function,-,pow,double,"double, double"
Function,-,pow10,double,double
Function,-,pow10f,float,float
Function,+,power_enable_low_battery_level_notification,void,"Power*, _Bool"
Function,+,power_enable_otg,void,"Power*, _Bool"
Function,+,power_get_info,void,"Power*, PowerInfo*"
Function,+,power_get_pubsub,FuriPubSub*,Power*
Function,+,power_is_battery_healthy,_Bool,Power*
Function,+,power_is_otg_enabled,_Bool,Power*
Function,+,power_off,void,Power*
Function,+,power_reboot,void,"Power*, PowerBootMode"
Function,+,power_enable_otg,void,"Power*, _Bool"
Function,+,powf,float,"float, float"
Function,-,powl,long double,"long double, long double"
Function,+,pretty_format_bytes_hex_canonical,void,"FuriString*, size_t, const char*, const uint8_t*, size_t"
1 entry status name type params
2 Version + 82.1 82.2
3 Header + applications/services/bt/bt_service/bt.h
4 Header + applications/services/bt/bt_service/bt_keys_storage.h
5 Header + applications/services/cli/cli.h
57 Header + lib/flipper_format/flipper_format.h
58 Header + lib/flipper_format/flipper_format_i.h
59 Header + lib/flipper_format/flipper_format_stream.h
60 Header + lib/ieee754_parse_wrap/wrappers.h
61 Header + lib/libusb_stm32/inc/hid_usage_button.h
62 Header + lib/libusb_stm32/inc/hid_usage_consumer.h
63 Header + lib/libusb_stm32/inc/hid_usage_desktop.h
383 Function + __wrap_putchar int int
384 Function + __wrap_puts int const char*
385 Function + __wrap_snprintf int char*, size_t, const char*, ...
386 Function + __wrap_strtod double const char*, char**
387 Function + __wrap_strtof float const char*, char**
388 Function + __wrap_ungetc int int, FILE*
389 Function + __wrap_vsnprintf int char*, size_t, const char*, va_list
390 Function - _asiprintf_r int _reent*, char**, const char*, ...
2364 Function - pow10 double double
2365 Function - pow10f float float
2366 Function + power_enable_low_battery_level_notification void Power*, _Bool
2367 Function + power_enable_otg void Power*, _Bool
2368 Function + power_get_info void Power*, PowerInfo*
2369 Function + power_get_pubsub FuriPubSub* Power*
2370 Function + power_is_battery_healthy _Bool Power*
2371 Function + power_is_otg_enabled _Bool Power*
2372 Function + power_off void Power*
2373 Function + power_reboot void Power*, PowerBootMode
Function + power_enable_otg void Power*, _Bool
2374 Function + powf float float, float
2375 Function - powl long double long double, long double
2376 Function + pretty_format_bytes_hex_canonical void FuriString*, size_t, const char*, const uint8_t*, size_t

View File

@@ -36,7 +36,8 @@
"flipper18",
"bit_lib",
"toolbox",
"datetime"
"datetime",
"ieee754_parse_wrap"
],
"excluded_sources": [
"furi_hal_infrared.c",

View File

@@ -1,5 +1,5 @@
entry,status,name,type,params
Version,+,82.1,,
Version,+,82.2,,
Header,+,applications/drivers/subghz/cc1101_ext/cc1101_ext_interconnect.h,,
Header,+,applications/services/bt/bt_service/bt.h,,
Header,+,applications/services/bt/bt_service/bt_keys_storage.h,,
@@ -61,6 +61,7 @@ Header,+,lib/flipper_format/flipper_format_stream.h,,
Header,+,lib/ibutton/ibutton_key.h,,
Header,+,lib/ibutton/ibutton_protocols.h,,
Header,+,lib/ibutton/ibutton_worker.h,,
Header,+,lib/ieee754_parse_wrap/wrappers.h,,
Header,+,lib/infrared/encoder_decoder/infrared.h,,
Header,+,lib/infrared/worker/infrared_transmit.h,,
Header,+,lib/infrared/worker/infrared_worker.h,,
@@ -459,6 +460,8 @@ Function,+,__wrap_putc,int,"int, FILE*"
Function,+,__wrap_putchar,int,int
Function,+,__wrap_puts,int,const char*
Function,+,__wrap_snprintf,int,"char*, size_t, const char*, ..."
Function,+,__wrap_strtod,double,"const char*, char**"
Function,+,__wrap_strtof,float,"const char*, char**"
Function,+,__wrap_ungetc,int,"int, FILE*"
Function,+,__wrap_vsnprintf,int,"char*, size_t, const char*, va_list"
Function,-,_asiprintf_r,int,"_reent*, char**, const char*, ..."
@@ -2999,13 +3002,13 @@ Function,-,pow,double,"double, double"
Function,-,pow10,double,double
Function,-,pow10f,float,float
Function,+,power_enable_low_battery_level_notification,void,"Power*, _Bool"
Function,+,power_enable_otg,void,"Power*, _Bool"
Function,+,power_get_info,void,"Power*, PowerInfo*"
Function,+,power_get_pubsub,FuriPubSub*,Power*
Function,+,power_is_battery_healthy,_Bool,Power*
Function,+,power_is_otg_enabled,_Bool,Power*
Function,+,power_off,void,Power*
Function,+,power_reboot,void,"Power*, PowerBootMode"
Function,+,power_enable_otg,void,"Power*, _Bool"
Function,+,powf,float,"float, float"
Function,-,powl,long double,"long double, long double"
Function,+,pretty_format_bytes_hex_canonical,void,"FuriString*, size_t, const char*, const uint8_t*, size_t"
1 entry status name type params
2 Version + 82.1 82.2
3 Header + applications/drivers/subghz/cc1101_ext/cc1101_ext_interconnect.h
4 Header + applications/services/bt/bt_service/bt.h
5 Header + applications/services/bt/bt_service/bt_keys_storage.h
61 Header + lib/ibutton/ibutton_key.h
62 Header + lib/ibutton/ibutton_protocols.h
63 Header + lib/ibutton/ibutton_worker.h
64 Header + lib/ieee754_parse_wrap/wrappers.h
65 Header + lib/infrared/encoder_decoder/infrared.h
66 Header + lib/infrared/worker/infrared_transmit.h
67 Header + lib/infrared/worker/infrared_worker.h
460 Function + __wrap_putchar int int
461 Function + __wrap_puts int const char*
462 Function + __wrap_snprintf int char*, size_t, const char*, ...
463 Function + __wrap_strtod double const char*, char**
464 Function + __wrap_strtof float const char*, char**
465 Function + __wrap_ungetc int int, FILE*
466 Function + __wrap_vsnprintf int char*, size_t, const char*, va_list
467 Function - _asiprintf_r int _reent*, char**, const char*, ...
3002 Function - pow10 double double
3003 Function - pow10f float float
3004 Function + power_enable_low_battery_level_notification void Power*, _Bool
3005 Function + power_enable_otg void Power*, _Bool
3006 Function + power_get_info void Power*, PowerInfo*
3007 Function + power_get_pubsub FuriPubSub* Power*
3008 Function + power_is_battery_healthy _Bool Power*
3009 Function + power_is_otg_enabled _Bool Power*
3010 Function + power_off void Power*
3011 Function + power_reboot void Power*, PowerBootMode
Function + power_enable_otg void Power*, _Bool
3012 Function + powf float float, float
3013 Function - powl long double long double, long double
3014 Function + pretty_format_bytes_hex_canonical void FuriString*, size_t, const char*, const uint8_t*, size_t

View File

@@ -50,6 +50,7 @@
"flipper7",
"bit_lib",
"toolbox",
"datetime"
"datetime",
"ieee754_parse_wrap"
]
}