mirror of
https://github.com/flipperdevices/flipperzero-firmware.git
synced 2025-12-12 04:41:26 +04:00
Reduced ieee754 parser size (#4154)
Co-authored-by: hedger <hedger@users.noreply.github.com>
This commit is contained in:
@@ -43,6 +43,7 @@ libs = env.BuildModules(
|
||||
"ble_profile",
|
||||
"bit_lib",
|
||||
"datetime",
|
||||
"ieee754_parse_wrap",
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
31
lib/ieee754_parse_wrap/SConscript
Normal file
31
lib/ieee754_parse_wrap/SConscript
Normal 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")
|
||||
14
lib/ieee754_parse_wrap/wrappers.c
Normal file
14
lib/ieee754_parse_wrap/wrappers.c
Normal 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);
|
||||
}
|
||||
14
lib/ieee754_parse_wrap/wrappers.h
Normal file
14
lib/ieee754_parse_wrap/wrappers.h
Normal 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
|
||||
Reference in New Issue
Block a user