8000 restore dtostrf when floats are disabled in printf/scanf + round fix by d-a-v · Pull Request #7093 · esp8266/Arduino · GitHub
[go: up one dir, main page]

Skip to content

restore dtostrf when floats are disabled in printf/scanf + round fix #7093

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Feb 22, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix with proposal per review
  • Loading branch information
d-a-v committed Feb 19, 2020
commit c646c7ea05aa5f536c403ca9054d3e3bf1d95e6c
26 changes: 12 additions & 14 deletions cores/esp8266/core_esp8266_noniso.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,18 @@ char* ultoa(unsigned long value, char* result, int base) {
8000 return utoa((unsigned int)value, result, base);
}

#ifdef NOPRINTFLOAT

char * dtostrf(double number, signed char width, unsigned char prec, char *s) {
if (!_printf_float) {
return __dtostrf(number, width, prec, s);
} else {
char fmt[32];
sprintf(fmt, "%%%d.%df", width, prec);
sprintf(s, fmt, number);
return s;
}
}

static char * __dtostrf(double number, signed char width, unsigned char prec, char *s) {
bool negative = false;

if (isnan(number)) {
Expand Down Expand Up @@ -87,7 +96,7 @@ char * dtostrf(double number, signed char width, unsigned char prec, char *s) {
digitcount++;
}

// minimal compensation for possible lack of precision
// minimal compensation for possible lack of precision (#7087 addition)
number *= 1 + std::numeric_limits<decltype(number)>::epsilon();

number /= tenpow;
Expand Down Expand Up @@ -120,15 +129,4 @@ char * dtostrf(double number, signed char width, unsigned char prec, char *s) {
return s;
}

#else // !NOPRINTFLOAT

char * dtostrf(double number, signed char width, unsigned char prec, char *s) {
char fmt[32];
sprintf(fmt, "%%%d.%df", width, prec);
sprintf(s, fmt, number);
return s;
}

#endif // !NOPRINTFLOAT

};
5 changes: 2 additions & 3 deletions platform.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ build.stdcpp_lib=-lstdc++
build.stdcpp_level=-std=gnu++11

build.float=-u _printf_float -u _scanf_float
build.floatflags=
build.led=

# default SDK for all boards
Expand All @@ -54,7 +53,7 @@ compiler.libc.path={runtime.platform.path}/tools/sdk/libc/xtensa-lx106-elf
compiler.cpreprocessor.flags=-D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ "-I{compiler.sdk.path}/include" "-I{compiler.sdk.path}/{build.lwip_include}" "-I{compiler.libc.path}/include" "-I{build.path}/core"

compiler.c.cmd=xtensa-lx106-elf-gcc
compiler.c.flags=-c {compiler.warning_flags} -Os -g -Wpointer-arith -Wno-implicit-function-declaration -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mtext-section-literals -falign-functions=4 -MMD -std=gnu99 -ffunction-sections -fdata-sections {build.exception_flags} {build.sslflags} {build.floatflags}
compiler.c.flags=-c {compiler.warning_flags} -Os -g -Wpointer-arith -Wno-implicit-function-declaration -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mtext-section-literals -falign-functions=4 -MMD -std=gnu99 -ffunction-sections -fdata-sections {build.exception_flags} {build.sslflags}

compiler.S.cmd=xtensa-lx106-elf-gcc
compiler.S.flags=-c -g -x assembler-with-cpp -MMD -mlongcalls
Expand All @@ -65,7 +64,7 @@ compiler.c.elf.cmd=xtensa-lx106-elf-gcc
compiler.c.elf.libs=-lhal -lphy -lpp -lnet80211 {build.lwip_lib} -lwpa -lcrypto -lmain -lwps -lbearssl -laxtls -lespnow -lsmartconfig -lairkiss -lwpa2 {build.stdcpp_lib} -lm -lc -lgcc

compiler.cpp.cmd=xtensa-lx106-elf-g++
compiler.cpp.flags=-c {compiler.warning_flags} -Os -g -mlongcalls -mtext-section-literals -fno-rtti -falign-functions=4 {build.stdcpp_level} -MMD -ffunction-sections -fdata-sections {build.exception_flags} {build.sslflags} {build.floatflags}
compiler.cpp.flags=-c {compiler.warning_ 9CCC flags} -Os -g -mlongcalls -mtext-section-literals -fno-rtti -falign-functions=4 {build.stdcpp_level} -MMD -ffunction-sections -fdata-sections {build.exception_flags} {build.sslflags}

compiler.as.cmd=xtensa-lx106-elf-as

Expand Down
1 change: 0 additions & 1 deletion tools/boards.txt.py
Original file line number Diff line number Diff line change
Expand Up @@ -1588,7 +1588,6 @@ def all_boards ():

if nofloat:
print(id + '.build.float=')
print(id + '.build.floatflags=-DNOPRINTFLOAT')

print('')

Expand Down
0