From 84d886641d2f15611144a5c1d84f69a17e7b3fc9 Mon Sep 17 00:00:00 2001 From: Maxim Prokhorov Date: Sun, 14 Jun 2020 18:10:58 +0300 Subject: [PATCH 01/16] Allow test framework to use cores/esp8266/Arduino.h directly --- cores/esp8266/Arduino.h | 48 ++-- cores/esp8266/Esp.cpp | 2 + cores/esp8266/Esp.h | 14 +- cores/esp8266/core_esp8266_features.h | 13 +- cores/esp8266/esp8266_peri.h | 5 + cores/esp8266/libc_replacements.cpp | 1 + libraries/esp8266/examples/math/math.ino | 30 +++ tests/host/Makefile | 1 + tests/host/common/Arduino.h | 272 ----------------------- tests/host/common/esp8266_peri.h | 2 +- tests/host/common/mock.h | 18 +- 11 files changed, 89 insertions(+), 317 deletions(-) create mode 100644 libraries/esp8266/examples/math/math.ino delete mode 100644 tests/host/common/Arduino.h diff --git a/cores/esp8266/Arduino.h b/cores/esp8266/Arduino.h index edb6bdd5c4..600b7099f4 100644 --- a/cores/esp8266/Arduino.h +++ b/cores/esp8266/Arduino.h @@ -37,6 +37,7 @@ extern "C" { #include "binary.h" #include "esp8266_peri.h" #include "twi.h" + #include "core_esp8266_features.h" #include "core_esp8266_version.h" @@ -127,21 +128,26 @@ void timer0_isr_init(void); void timer0_attachInterrupt(timercallback userFunc); void timer0_detachInterrupt(void); -// undefine stdlib's abs if encountered +// undefine stdlib's definitions when encountered, provide abs that supports floating point for C code +// in case we are using c++, these will either be: +// - undef'ed by the algorithm include down below, implicitly including cstdlib +// - undef'ed by the stdlib.h header up above in a more recent versions of gcc #ifdef abs #undef abs +#define abs(x) ((x)>0?(x):-(x)) #endif -#define abs(x) ((x)>0?(x):-(x)) +#ifdef round +#undef round +#define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5)) +#endif + +// the rest of math definitions are from Arduino #define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt))) -#define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5)) #define radians(deg) ((deg)*DEG_TO_RAD) #define degrees(rad) ((rad)*RAD_TO_DEG) #define sq(x) ((x)*(x)) -void ets_intr_lock(); -void ets_intr_unlock(); - #define interrupts() xt_rsil(0) #define noInterrupts() xt_rsil(15) @@ -170,11 +176,12 @@ typedef uint16_t word; typedef bool boolean; typedef uint8_t byte; +void ets_intr_lock(); +void ets_intr_unlock(); + void init(void); void initVariant(void); -int atexit(void (*func)()) __attribute__((weak)); - void pinMode(uint8_t pin, uint8_t mode); void digitalWrite(uint8_t pin, uint8_t val); int digitalRead(uint8_t pin); @@ -233,25 +240,22 @@ const int TIM_DIV265 __attribute__((deprecated, weak)) = TIM_DIV256; +// from this point onward, we need to configure the c++ environment #ifdef __cplusplus #include +#include #include -#include - -#include "WCharacter.h" -#include "WString.h" - -#include "HardwareSerial.h" -#include "Esp.h" -#include "Updater.h" -#include "debug.h" using std::min; using std::max; using std::isinf; using std::isnan; +// these are important, as we may end up using C versions otherwise +using std::abs; +using std::round; + #define _min(a,b) ({ decltype(a) _a = (a); decltype(b) _b = (b); _a < _b? _a : _b; }) #define _max(a,b) ({ decltype(a) _a = (a); decltype(b) _b = (b); _a > _b? _a : _b; }) @@ -291,6 +295,16 @@ inline void configTzTime(const char* tz, const char* server1, configTime(tz, server1, server2, server3); } +// Everything we expect to be implicitly loaded for the sketch +#include + +#include "WCharacter.h" +#include "WString.h" + +#include "HardwareSerial.h" +#include "Esp.h" +#include "Updater.h" + #endif // __cplusplus #include "pins_arduino.h" diff --git a/cores/esp8266/Esp.cpp b/cores/esp8266/Esp.cpp index 1127eef80e..9c8be8d89c 100644 --- a/cores/esp8266/Esp.cpp +++ b/cores/esp8266/Esp.cpp @@ -26,7 +26,9 @@ #include "MD5Builder.h" #include "umm_malloc/umm_malloc.h" #include "cont.h" + #include "coredecls.h" +#include extern "C" { #include "user_interface.h" diff --git a/cores/esp8266/Esp.h b/cores/esp8266/Esp.h index 4ad59e2237..e3398ed53b 100644 --- a/cores/esp8266/Esp.h +++ b/cores/esp8266/Esp.h @@ -22,6 +22,7 @@ #define ESP_H #include +#include "core_esp8266_features.h" #include "spi_vendors.h" /** @@ -168,21 +169,14 @@ class EspClass { uint32_t random() const; #ifndef CORE_MOCK - inline uint32_t getCycleCount() __attribute__((always_inline)); + uint32_t getCycleCount() __attribute__((always_inline)) { + return esp_get_cycle_count(); + } #else uint32_t getCycleCount(); #endif }; -#ifndef CORE_MOCK - -uint32_t EspClass::getCycleCount() -{ - return esp_get_cycle_count(); -} - -#endif // !defined(CORE_MOCK) - extern EspClass ESP; #endif //ESP_H diff --git a/cores/esp8266/core_esp8266_features.h b/cores/esp8266/core_esp8266_features.h index d3b70f3dcc..fbf0fb57c3 100644 --- a/cores/esp8266/core_esp8266_features.h +++ b/cores/esp8266/core_esp8266_features.h @@ -38,6 +38,8 @@ #ifdef __cplusplus +#include + namespace arduino { extern "C++" @@ -82,7 +84,13 @@ namespace arduino // level 15 will disable ALL interrupts, // level 0 will enable ALL interrupts, // -#ifndef CORE_MOCK +#ifdef CORE_MOCK + +#define xt_rsil(level) (level) +#define xt_wsr_ps(state) do { (void)(state); } while (0) + +#else + #define xt_rsil(level) (__extension__({uint32_t state; __asm__ __volatile__("rsil %0," __STRINGIFY(level) : "=a" (state) :: "memory"); state;})) #define xt_wsr_ps(state) __asm__ __volatile__("wsr %0,ps; isync" :: "a" (state) : "memory") @@ -92,7 +100,8 @@ inline uint32_t esp_get_cycle_count() { __asm__ __volatile__("rsr %0,ccount":"=a"(ccount)); return ccount; } -#endif // not CORE_MOCK + +#endif // ifdef CORE_MOCK // Tools for preloading code into the flash cache diff --git a/cores/esp8266/esp8266_peri.h b/cores/esp8266/esp8266_peri.h index 1445b22dba..6ed20dfffd 100644 --- a/cores/esp8266/esp8266_peri.h +++ b/cores/esp8266/esp8266_peri.h @@ -21,6 +21,9 @@ #ifndef ESP8266_PERI_H_INCLUDED #define ESP8266_PERI_H_INCLUDED +// we expect mocking framework to provide these +#ifndef CORE_MOCK + #include "c_types.h" #include "esp8266_undocumented.h" @@ -847,4 +850,6 @@ extern volatile uint32_t* const esp8266_gpioToFn[16]; **/ #define RANDOM_REG32 ESP8266_DREG(0x20E44) +#endif // ifndef CORE_MOCK + #endif diff --git a/cores/esp8266/libc_replacements.cpp b/cores/esp8266/libc_replacements.cpp index 0ccf5e04b2..f9aa13d550 100644 --- a/cores/esp8266/libc_replacements.cpp +++ b/cores/esp8266/libc_replacements.cpp @@ -127,6 +127,7 @@ void _exit(int status) { abort(); } +int atexit(void (*func)()) __attribute__((weak)); int atexit(void (*func)()) { (void) func; return 0; diff --git a/libraries/esp8266/examples/math/math.ino b/libraries/esp8266/examples/math/math.ino new file mode 100644 index 0000000000..86c007e921 --- /dev/null +++ b/libraries/esp8266/examples/math/math.ino @@ -0,0 +1,30 @@ +/* + Small math example, checking whether we can support various Arduino math operations. + Meant for debugging **only** + + Released to public domain +*/ + +void setup() { + Serial.begin(115200); + + // checking if we can support Arduino functions + Serial.printf("abs(-3)\n = %d", abs(-3)); + Serial.printf("abs(+3)\n = %d", abs(3)); + Serial.printf("abs(-3.5)\n = %f", abs(-3.5)); + Serial.printf("abs(+3.5)\n = %f", abs(3.5)); + Serial.printf("round(2.9)\n = %f", round(2.9)); + Serial.printf("constrain(5, 1, 15) = %d\n", constrain(5, 1, 15)); + Serial.printf("constrain(16, 1, 15) = %d\n", constrain(16, 1, 15)); + + // the same thing, but with c++ std::..., which should not cause any conflicts + Serial.printf("std::abs(-3) = %d\n", std::abs(-3)); + Serial.printf("std::abs(+3) = %d\n", std::abs(3)); + Serial.printf("std::abs(-3.5) = %f\n", std::abs(-3.5)); + Serial.printf("std::abs(+3.5) = %f\n", std::abs(3.5)); + Serial.printf("std::round(2.9) = %f\n", std::round(2.9)); +} + +void loop() { +} + diff --git a/tests/host/Makefile b/tests/host/Makefile index f6361f36aa..ea4cc6841d 100644 --- a/tests/host/Makefile +++ b/tests/host/Makefile @@ -157,6 +157,7 @@ FLAGS += -DHTTPCLIENT_1_1_COMPATIBLE=0 FLAGS += -DLWIP_IPV6=0 FLAGS += -DHOST_MOCK=1 FLAGS += -DNONOSDK221=1 +FLAGS += -DF_CPU=80000000 FLAGS += $(MKFLAGS) FLAGS += -Wimplicit-fallthrough=2 # allow "// fall through" comments to stop spurious warnings CXXFLAGS += -std=c++11 -fno-rtti $(FLAGS) -funsigned-char diff --git a/tests/host/common/Arduino.h b/tests/host/common/Arduino.h deleted file mode 100644 index 4c0a8c6765..0000000000 --- a/tests/host/common/Arduino.h +++ /dev/null @@ -1,272 +0,0 @@ -/* - Arduino.h - Main include file for the Arduino SDK - Copyright (c) 2005-2013 Arduino Team. All right reserved. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef Arduino_h -#define Arduino_h - -#define MOCK "(mock) " - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "binary.h" -#include "twi.h" -#include "core_esp8266_features.h" - -#define HIGH 0x1 -#define LOW 0x0 - -#define PWMRANGE 1023 - - //GPIO FUNCTIONS -#define INPUT 0x00 -#define INPUT_PULLUP 0x02 -#define INPUT_PULLDOWN_16 0x04 // PULLDOWN only possible for pin16 -#define OUTPUT 0x01 -#define OUTPUT_OPEN_DRAIN 0x03 -#define WAKEUP_PULLUP 0x05 -#define WAKEUP_PULLDOWN 0x07 -#define SPECIAL 0xF8 //defaults to the usable BUSes uart0rx/tx uart1tx and hspi -#define FUNCTION_0 0x08 -#define FUNCTION_1 0x18 -#define FUNCTION_2 0x28 -#define FUNCTION_3 0x38 -#define FUNCTION_4 0x48 - -#define PI 3.1415926535897932384626433832795 -#define HALF_PI 1.5707963267948966192313216916398 -#define TWO_PI 6.283185307179586476925286766559 -#define DEG_TO_RAD 0.017453292519943295769236907684886 -#define RAD_TO_DEG 57.295779513082320876798154814105 -#define EULER 2.718281828459045235360287471352 - -#define SERIAL 0x0 -#define DISPLAY 0x1 - -#define LSBFIRST 0 -#define MSBFIRST 1 - - //Interrupt Modes -#define DISABLED 0x00 -#define RISING 0x01 -#define FALLING 0x02 -#define CHANGE 0x03 -#define ONLOW 0x04 -#define ONHIGH 0x05 -#define ONLOW_WE 0x0C -#define ONHIGH_WE 0x0D - -#define DEFAULT 1 -#define EXTERNAL 0 - - //timer dividers -#define TIM_DIV1 0 //80MHz (80 ticks/us - 104857.588 us max) -#define TIM_DIV16 1 //5MHz (5 ticks/us - 1677721.4 us max) -#define TIM_DIV265 3 //312.5Khz (1 tick = 3.2us - 26843542.4 us max) - //timer int_types -#define TIM_EDGE 0 -#define TIM_LEVEL 1 - //timer reload values -#define TIM_SINGLE 0 //on interrupt routine you need to write a new value to start the timer again -#define TIM_LOOP 1 //on interrupt the counter will start with the same value again - -#define timer1_read() (T1V) -#define timer1_enabled() ((T1C & (1 << TCTE)) != 0) -#define timer1_interrupted() ((T1C & (1 << TCIS)) != 0) - - typedef void(*timercallback)(void); - - void timer1_isr_init(void); - void timer1_enable(uint8_t divider, uint8_t int_type, uint8_t reload); - void timer1_disable(void); - void timer1_attachInterrupt(timercallback userFunc); - void timer1_detachInterrupt(void); - void timer1_write(uint32_t ticks); //maximum ticks 8388607 - - // timer0 is a special CPU timer that has very high resolution but with - // limited control. - // it uses CCOUNT (ESP.GetCycleCount()) as the non-resetable timer counter - // it does not support divide, type, or reload flags - // it is auto-disabled when the compare value matches CCOUNT - // it is auto-enabled when the compare value changes -#define timer0_interrupted() (ETS_INTR_PENDING() & (_BV(ETS_COMPARE0_INUM))) -#define timer0_read() ((__extension__({uint32_t count;__asm__ __volatile__("esync; rsr %0,ccompare0":"=a" (count));count;}))) -#define timer0_write(count) __asm__ __volatile__("wsr %0,ccompare0; esync"::"a" (count) : "memory") - - void timer0_isr_init(void); - void timer0_attachInterrupt(timercallback userFunc); - void timer0_detachInterrupt(void); - - // undefine stdlib's abs if encountered -#ifdef abs -#undef abs -#endif - -#define abs(x) ((x)>0?(x):-(x)) -#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt))) -#define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5)) -#define radians(deg) ((deg)*DEG_TO_RAD) -#define degrees(rad) ((rad)*RAD_TO_DEG) -#define sq(x) ((x)*(x)) - - void ets_intr_lock(); - void ets_intr_unlock(); - -#ifndef __STRINGIFY -#define __STRINGIFY(a) #a -#endif - -#define xt_rsil(level) (level) -#define xt_wsr_ps(state) do { (void)(state); } while (0) - -#define interrupts() xt_rsil(0) -#define noInterrupts() xt_rsil(15) - -#define clockCyclesPerMicrosecond() ( F_CPU / 1000000L ) -#define clockCyclesToMicroseconds(a) ( (a) / clockCyclesPerMicrosecond() ) -#define microsecondsToClockCycles(a) ( (a) * clockCyclesPerMicrosecond() ) - -#define lowByte(w) ((uint8_t) ((w) & 0xff)) -#define highByte(w) ((uint8_t) ((w) >> 8)) - -#define bitRead(value, bit) (((value) >> (bit)) & 0x01) -#define bitSet(value, bit) ((value) |= (1UL << (bit))) -#define bitClear(value, bit) ((value) &= ~(1UL << (bit))) -#define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit)) - - // avr-libc defines _NOP() since 1.6.2 -#ifndef _NOP -#define _NOP() do { __asm__ volatile ("nop"); } while (0) -#endif - - typedef unsigned int word; - -#define bit(b) (1UL << (b)) -#define _BV(b) (1UL << (b)) - - typedef uint8_t boolean; - typedef uint8_t byte; - - void init(void); - void initVariant(void); - - void pinMode(uint8_t pin, uint8_t mode); - void digitalWrite(uint8_t pin, uint8_t val); - int digitalRead(uint8_t pin); - int analogRead(uint8_t pin); - void analogReference(uint8_t mode); - void analogWrite(uint8_t pin, int val); - void analogWriteFreq(uint32_t freq); - void analogWriteRange(uint32_t range); - - unsigned long millis(void); - unsigned long micros(void); - void delay(unsigned long); - void delayMicroseconds(unsigned int us); - unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout); - unsigned long pulseInLong(uint8_t pin, uint8_t state, unsigned long timeout); - - void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val); - uint8_t shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder); - - void attachInterrupt(uint8_t pin, void (*)(void), int mode); - void detachInterrupt(uint8_t pin); - - void setup(void); - void loop(void); - - void yield(void); - void esp_yield(void); - void optimistic_yield(uint32_t interval_us); - -#define digitalPinToPort(pin) (0) -#define digitalPinToBitMask(pin) (1UL << (pin)) -#define digitalPinToTimer(pin) (0) -#define portOutputRegister(port) ((volatile uint32_t*) &GPO) -#define portInputRegister(port) ((volatile uint32_t*) &GPI) -#define portModeRegister(port) ((volatile uint32_t*) &GPE) - -#define NOT_A_PIN -1 -#define NOT_A_PORT -1 -#define NOT_AN_INTERRUPT -1 -#define NOT_ON_TIMER 0 - -#ifdef __cplusplus -} // extern "C" -#endif - -#ifdef __cplusplus - -#include - -#include "WCharacter.h" -#include "WString.h" - -#include "HardwareSerial.h" -#include "Esp.h" -#include "Updater.h" -#include "debug.h" - -#if 0 -#ifndef _GLIBCXX_VECTOR -// arduino is not compatible with std::vector -#define min(a,b) ((a)<(b)?(a):(b)) -#define max(a,b) ((a)>(b)?(a):(b)) -#endif -#endif - -#define _min(a,b) ((a)<(b)?(a):(b)) -#define _max(a,b) ((a)>(b)?(a):(b)) - -uint16_t makeWord(uint16_t w); -uint16_t makeWord(byte h, byte l); - -#define word(...) makeWord(__VA_ARGS__) - -unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout = 1000000L); -unsigned long pulseInLong(uint8_t pin, uint8_t state, unsigned long timeout = 1000000L); - -void tone(uint8_t _pin, unsigned int frequency, unsigned long duration = 0); -void noTone(uint8_t _pin); - -// WMath prototypes -long random(long); -long random(long, long); -void randomSeed(unsigned long); -long map(long, long, long, long, long); - -extern "C" void configTime(long timezone, int daylightOffset_sec, - const char* server1, const char* server2 = nullptr, const char* server3 = nullptr); - -#endif - -#include "pins_arduino.h" - -#endif /* Arduino_h */ diff --git a/tests/host/common/esp8266_peri.h b/tests/host/common/esp8266_peri.h index d9dfd50ed4..4a1a3cd031 100644 --- a/tests/host/common/esp8266_peri.h +++ b/tests/host/common/esp8266_peri.h @@ -6,4 +6,4 @@ const int GPI = 0; const int GPO = 0; const int GP16I = 0; -#endif \ No newline at end of file +#endif diff --git a/tests/host/common/mock.h b/tests/host/common/mock.h index 4032d88933..320fd662a8 100644 --- a/tests/host/common/mock.h +++ b/tests/host/common/mock.h @@ -30,20 +30,14 @@ */ #define CORE_MOCK 1 +#define MOCK "(mock) " // TODO: provide common logging API instead of adding this string everywhere? -// include host's STL before any other include file -// because core definition like max() is in the way - -#ifdef __cplusplus -#include -#endif -#include - +#include #ifdef __cplusplus extern "C" { #endif -//#include +// TODO: #include ? char* itoa (int val, char *s, int radix); char* ltoa (long val, char *s, int radix); #ifdef __cplusplus @@ -65,7 +59,6 @@ typedef uint32_t uint32; #define ESP8266 1 #define A0 0 #define LED_BUILTIN 0 -#define F_CPU 80000000 #define LWIP_OPEN_SRC #define TCP_MSS 536 #define LWIP_FEATURES 1 @@ -84,11 +77,6 @@ typedef uint32_t uint32; // -#include - -// - -#include #define RANDOM_REG32 ((uint32_t)random()) // net tweak From c89d0f6bb9f44879d0d75f7063fb78f1017ff421 Mon Sep 17 00:00:00 2001 From: Maxim Prokhorov Date: Sun, 14 Jun 2020 20:09:25 +0300 Subject: [PATCH 02/16] fix wps debugging --- libraries/ESP8266WiFi/src/ESP8266WiFiSTA-WPS.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libraries/ESP8266WiFi/src/ESP8266WiFiSTA-WPS.cpp b/libraries/ESP8266WiFi/src/ESP8266WiFiSTA-WPS.cpp index 99d27ba7a3..d6afd346a5 100644 --- a/libraries/ESP8266WiFi/src/ESP8266WiFiSTA-WPS.cpp +++ b/libraries/ESP8266WiFi/src/ESP8266WiFiSTA-WPS.cpp @@ -28,6 +28,8 @@ #include "ESP8266WiFiSTA.h" #include "coredecls.h" // disable_extra4k_at_link_time() +#include "debug.h" + static void wifi_wps_status_cb(wps_cb_status status); /** From 0e0849db9c42fce7389ae6c3e7583ae02da12a6d Mon Sep 17 00:00:00 2001 From: Maxim Prokhorov Date: Sun, 14 Jun 2020 20:22:04 +0300 Subject: [PATCH 03/16] some more missing debug.h --- libraries/ESP8266WiFi/src/include/ClientContext.h | 1 + libraries/ESP8266WiFi/src/include/SSLContext.h | 1 + libraries/ESP8266WiFi/src/include/UdpContext.h | 1 + libraries/SDFS/src/SDFS.cpp | 1 + libraries/SDFS/src/SDFSFormatter.h | 1 + 5 files changed, 5 insertions(+) diff --git a/libraries/ESP8266WiFi/src/include/ClientContext.h b/libraries/ESP8266WiFi/src/include/ClientContext.h index 8095e402a2..5595254b54 100644 --- a/libraries/ESP8266WiFi/src/include/ClientContext.h +++ b/libraries/ESP8266WiFi/src/include/ClientContext.h @@ -30,6 +30,7 @@ extern "C" void esp_yield(); extern "C" void esp_schedule(); #include "DataSource.h" +#include bool getDefaultPrivateGlobalSyncValue (); diff --git a/libraries/ESP8266WiFi/src/include/SSLContext.h b/libraries/ESP8266WiFi/src/include/SSLContext.h index f7d824fbf9..522d0df33b 100644 --- a/libraries/ESP8266WiFi/src/include/SSLContext.h +++ b/libraries/ESP8266WiFi/src/include/SSLContext.h @@ -39,6 +39,7 @@ extern "C" #include "lwip/netif.h" #include #include +#include #include "c_types.h" namespace axTLS { diff --git a/libraries/ESP8266WiFi/src/include/UdpContext.h b/libraries/ESP8266WiFi/src/include/UdpContext.h index a81384b2a7..e46399c802 100644 --- a/libraries/ESP8266WiFi/src/include/UdpContext.h +++ b/libraries/ESP8266WiFi/src/include/UdpContext.h @@ -31,6 +31,7 @@ void esp_schedule(); } #include +#include #define PBUF_ALIGNER_ADJUST 4 #define PBUF_ALIGNER(x) ((void*)((((intptr_t)(x))+3)&~3)) diff --git a/libraries/SDFS/src/SDFS.cpp b/libraries/SDFS/src/SDFS.cpp index d862ff5d89..d746891fa1 100644 --- a/libraries/SDFS/src/SDFS.cpp +++ b/libraries/SDFS/src/SDFS.cpp @@ -27,6 +27,7 @@ #include "SDFS.h" #include "SDFSFormatter.h" #include +#include using namespace fs; diff --git a/libraries/SDFS/src/SDFSFormatter.h b/libraries/SDFS/src/SDFSFormatter.h index d1fe6c94a7..142a01edb0 100644 --- a/libraries/SDFS/src/SDFSFormatter.h +++ b/libraries/SDFS/src/SDFSFormatter.h @@ -26,6 +26,7 @@ #include "SDFS.h" #include #include +#include namespace sdfs { From 555c272c4b97573ae4696cd1601aff1422ba5451 Mon Sep 17 00:00:00 2001 From: Maxim Prokhorov Date: Sat, 18 Jul 2020 01:34:32 +0300 Subject: [PATCH 04/16] Hunt down debug.h and roll-back TODO: rename it to something else... it is an internal header --- cores/esp8266/Arduino.h | 5 +++-- cores/esp8266/Esp.h | 2 +- cores/esp8266/core_esp8266_features.h | 13 +++++-------- libraries/ESP8266WiFi/src/ESP8266WiFiSTA-WPS.cpp | 2 -- libraries/ESP8266WiFi/src/include/ClientContext.h | 3 ++- libraries/SDFS/src/SDFS.cpp | 1 - libraries/SDFS/src/SDFSFormatter.h | 1 - tests/host/common/include/ClientContext.h | 1 + 8 files changed, 12 insertions(+), 16 deletions(-) diff --git a/cores/esp8266/Arduino.h b/cores/esp8266/Arduino.h index d99339fc6e..d48b4c3b2e 100644 --- a/cores/esp8266/Arduino.h +++ b/cores/esp8266/Arduino.h @@ -231,8 +231,8 @@ using std::round; using std::isinf; using std::isnan; -// Use stdlib abs() and round() to avoid issues with the C++ libraries -// TODO: does C code need Arduino macros? +// Use float-compatible stl abs() and round(), we don't use Arduino macros to avoid issues with the C++ libraries +// TODO: ...does C code need Arduino macros? using std::abs; using std::round; @@ -287,6 +287,7 @@ inline void configTzTime(const char* tz, const char* server1, #endif // __cplusplus +#include "debug.h" #include "pins_arduino.h" #endif diff --git a/cores/esp8266/Esp.h b/cores/esp8266/Esp.h index e3398ed53b..6928d7e91b 100644 --- a/cores/esp8266/Esp.h +++ b/cores/esp8266/Esp.h @@ -174,7 +174,7 @@ class EspClass { } #else uint32_t getCycleCount(); -#endif +#endif // ifndef CORE_MOCK }; extern EspClass ESP; diff --git a/cores/esp8266/core_esp8266_features.h b/cores/esp8266/core_esp8266_features.h index fbf0fb57c3..e2a5d0ab24 100644 --- a/cores/esp8266/core_esp8266_features.h +++ b/cores/esp8266/core_esp8266_features.h @@ -84,13 +84,7 @@ namespace arduino // level 15 will disable ALL interrupts, // level 0 will enable ALL interrupts, // -#ifdef CORE_MOCK - -#define xt_rsil(level) (level) -#define xt_wsr_ps(state) do { (void)(state); } while (0) - -#else - +#ifndef CORE_MOCK #define xt_rsil(level) (__extension__({uint32_t state; __asm__ __volatile__("rsil %0," __STRINGIFY(level) : "=a" (state) :: "memory"); state;})) #define xt_wsr_ps(state) __asm__ __volatile__("wsr %0,ps; isync" :: "a" (state) : "memory") @@ -101,7 +95,10 @@ inline uint32_t esp_get_cycle_count() { return ccount; } -#endif // ifdef CORE_MOCK +#else +#define xt_rsil(level) (level) +#define xt_wsr_ps(state) do { (void)(state); } while (0) +#endif // ifndef CORE_MOCK // Tools for preloading code into the flash cache diff --git a/libraries/ESP8266WiFi/src/ESP8266WiFiSTA-WPS.cpp b/libraries/ESP8266WiFi/src/ESP8266WiFiSTA-WPS.cpp index d6afd346a5..99d27ba7a3 100644 --- a/libraries/ESP8266WiFi/src/ESP8266WiFiSTA-WPS.cpp +++ b/libraries/ESP8266WiFi/src/ESP8266WiFiSTA-WPS.cpp @@ -28,8 +28,6 @@ #include "ESP8266WiFiSTA.h" #include "coredecls.h" // disable_extra4k_at_link_time() -#include "debug.h" - static void wifi_wps_status_cb(wps_cb_status status); /** diff --git a/libraries/ESP8266WiFi/src/include/ClientContext.h b/libraries/ESP8266WiFi/src/include/ClientContext.h index 5595254b54..b3ac5a1c78 100644 --- a/libraries/ESP8266WiFi/src/include/ClientContext.h +++ b/libraries/ESP8266WiFi/src/include/ClientContext.h @@ -29,9 +29,10 @@ typedef void (*discard_cb_t)(void*, ClientContext*); extern "C" void esp_yield(); extern "C" void esp_schedule(); -#include "DataSource.h" #include +#include "DataSource.h" + bool getDefaultPrivateGlobalSyncValue (); class ClientContext diff --git a/libraries/SDFS/src/SDFS.cpp b/libraries/SDFS/src/SDFS.cpp index d746891fa1..d862ff5d89 100644 --- a/libraries/SDFS/src/SDFS.cpp +++ b/libraries/SDFS/src/SDFS.cpp @@ -27,7 +27,6 @@ #include "SDFS.h" #include "SDFSFormatter.h" #include -#include using namespace fs; diff --git a/libraries/SDFS/src/SDFSFormatter.h b/libraries/SDFS/src/SDFSFormatter.h index 142a01edb0..d1fe6c94a7 100644 --- a/libraries/SDFS/src/SDFSFormatter.h +++ b/libraries/SDFS/src/SDFSFormatter.h @@ -26,7 +26,6 @@ #include "SDFS.h" #include #include -#include namespace sdfs { diff --git a/tests/host/common/include/ClientContext.h b/tests/host/common/include/ClientContext.h index 31366ac0dd..0eeeec02a0 100644 --- a/tests/host/common/include/ClientContext.h +++ b/tests/host/common/include/ClientContext.h @@ -28,6 +28,7 @@ extern "C" void esp_yield(); extern "C" void esp_schedule(); #include +#include bool getDefaultPrivateGlobalSyncValue (); From 6b36f6e5ec98c05d6f544846a9659c854b62b854 Mon Sep 17 00:00:00 2001 From: Maxim Prokhorov Date: Sat, 18 Jul 2020 02:51:56 +0300 Subject: [PATCH 05/16] Move abs+round checks to test/device/test_sw --- libraries/esp8266/examples/math/math.ino | 30 ------- .../test_sw_arduino_math_overrides.ino | 82 +++++++++++++++++++ 2 files changed, 82 insertions(+), 30 deletions(-) delete mode 100644 libraries/esp8266/examples/math/math.ino create mode 100644 tests/device/test_sw_arduino_math_overrides/test_sw_arduino_math_overrides.ino diff --git a/libraries/esp8266/examples/math/math.ino b/libraries/esp8266/examples/math/math.ino deleted file mode 100644 index 86c007e921..0000000000 --- a/libraries/esp8266/examples/math/math.ino +++ /dev/null @@ -1,30 +0,0 @@ -/* - Small math example, checking whether we can support various Arduino math operations. - Meant for debugging **only** - - Released to public domain -*/ - -void setup() { - Serial.begin(115200); - - // checking if we can support Arduino functions - Serial.printf("abs(-3)\n = %d", abs(-3)); - Serial.printf("abs(+3)\n = %d", abs(3)); - Serial.printf("abs(-3.5)\n = %f", abs(-3.5)); - Serial.printf("abs(+3.5)\n = %f", abs(3.5)); - Serial.printf("round(2.9)\n = %f", round(2.9)); - Serial.printf("constrain(5, 1, 15) = %d\n", constrain(5, 1, 15)); - Serial.printf("constrain(16, 1, 15) = %d\n", constrain(16, 1, 15)); - - // the same thing, but with c++ std::..., which should not cause any conflicts - Serial.printf("std::abs(-3) = %d\n", std::abs(-3)); - Serial.printf("std::abs(+3) = %d\n", std::abs(3)); - Serial.printf("std::abs(-3.5) = %f\n", std::abs(-3.5)); - Serial.printf("std::abs(+3.5) = %f\n", std::abs(3.5)); - Serial.printf("std::round(2.9) = %f\n", std::round(2.9)); -} - -void loop() { -} - diff --git a/tests/device/test_sw_arduino_math_overrides/test_sw_arduino_math_overrides.ino b/tests/device/test_sw_arduino_math_overrides/test_sw_arduino_math_overrides.ino new file mode 100644 index 0000000000..b0f1860c15 --- /dev/null +++ b/tests/device/test_sw_arduino_math_overrides/test_sw_arduino_math_overrides.ino @@ -0,0 +1,82 @@ +/* + Small math example, checking whether we properly integrate with c++ math + - https://github.com/esp8266/Arduino/issues/5530 + - https://github.com/espressif/arduino-esp32/pull/2738 + + Released to public domain +*/ + +#include +#include + +BS_ENV_DECLARE(); + +void setup() +{ + Serial.begin(115200); + BS_RUN(Serial); +} + +bool pretest() +{ + return true; +} + +#define TEST_MATH_IS_SAME(OP1, OP2) \ + std::is_same::value + +TEST_CASE("std::abs and abs result is the same", "[arduino-math]") +{ + CHECK(TEST_MATH_IS_SAME(abs(-5), std::abs(-5))); + CHECK(TEST_MATH_IS_SAME(abs(-25.0), std::abs(-25.0))); + CHECK(TEST_MATH_IS_SAME(abs(10.0), std::abs(10.0))); + CHECK(! TEST_MATH_IS_SAME(abs(10.0), std::abs(10))); + CHECK(! TEST_MATH_IS_SAME(abs(-5), std::abs(10.0))); +} + +TEST_CASE("abs works with ints", "[arduino-math]") +{ + int a = -3; + int b = 3; + CHECK(TEST_MATH_IS_SAME(abs(a), a)); + CHECK(TEST_MATH_IS_SAME(abs(b), b)); + CHECK(abs(a) == b); + CHECK(abs(b) == b); +} + +bool compare_floats(float a, float b) { + return std::fabs(a - b) < std::numeric_limits::epsilon(); +} + +TEST_CASE("abs works with floats", "[arduino-math]") +{ + float a = -3.5; + float b = 3.5; + CHECK(TEST_MATH_IS_SAME(abs(a), a)); + CHECK(TEST_MATH_IS_SAME(abs(b), b)); + CHECK(compare_floats(abs(a), b)); + CHECK(compare_floats(abs(b), b)); +} + +TEST_CASE("round works with floats", "[arduino-math]") +{ + float a = 2.9; + float b = 3.0; + CHECK(TEST_MATH_IS_SAME(round(a), a)); + CHECK(TEST_MATH_IS_SAME(round(b), b)); + CHECK(compare_floats(round(a), b)); + CHECK(compare_floats(round(b), b)); +} + +TEST_CASE("round result is float", "[arduino-math]") +{ + float a = 2.9; + float b = 3.0; + CHECK(TEST_MATH_IS_SAME(round(a), a)); + CHECK(TEST_MATH_IS_SAME(round(b), b)); + CHECK(compare_floats(round(a), b)); + CHECK(compare_floats(round(b), b)); +} + +void loop(){} + From ffc37444993873ea46d6647da361d420511b8b3a Mon Sep 17 00:00:00 2001 From: Maxim Prokhorov Date: Sat, 18 Jul 2020 02:57:12 +0300 Subject: [PATCH 06/16] Restore macros for C code --- cores/esp8266/Arduino.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cores/esp8266/Arduino.h b/cores/esp8266/Arduino.h index d48b4c3b2e..e9dc5d5ecb 100644 --- a/cores/esp8266/Arduino.h +++ b/cores/esp8266/Arduino.h @@ -216,7 +216,13 @@ void optimistic_yield(uint32_t interval_us); } // extern "C" #endif - +// undefine stdlib's definitions when encountered, provide abs that supports floating point for C code +#ifndef __cplusplus +#undef abs +#define abs(x) ((x)>0?(x):-(x)) +#undef round +#define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5)) +#endif // ifndef __cplusplus // from this point onward, we need to configure the c++ environment #ifdef __cplusplus @@ -232,7 +238,6 @@ using std::isinf; using std::isnan; // Use float-compatible stl abs() and round(), we don't use Arduino macros to avoid issues with the C++ libraries -// TODO: ...does C code need Arduino macros? using std::abs; using std::round; From 6db24f82d094d5f8f39a0dd2e3cbf0ac5b06dd15 Mon Sep 17 00:00:00 2001 From: Maxim Prokhorov Date: Sat, 18 Jul 2020 03:08:47 +0300 Subject: [PATCH 07/16] fixup! Move abs+round checks to test/device/test_sw --- .../test_sw_arduino_math_overrides.ino | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/device/test_sw_arduino_math_overrides/test_sw_arduino_math_overrides.ino b/tests/device/test_sw_arduino_math_overrides/test_sw_arduino_math_overrides.ino index b0f1860c15..80763ecff7 100644 --- a/tests/device/test_sw_arduino_math_overrides/test_sw_arduino_math_overrides.ino +++ b/tests/device/test_sw_arduino_math_overrides/test_sw_arduino_math_overrides.ino @@ -1,5 +1,7 @@ /* Small math example, checking whether we properly integrate with c++ math + + ref: - https://github.com/esp8266/Arduino/issues/5530 - https://github.com/espressif/arduino-esp32/pull/2738 From e59f92653517d1f209905c51640e73fadb9f355c Mon Sep 17 00:00:00 2001 From: Maxim Prokhorov Date: Sat, 18 Jul 2020 03:22:43 +0300 Subject: [PATCH 08/16] Fix bad c/p, actually try round with ints --- .../test_sw_arduino_math_overrides.ino | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/tests/device/test_sw_arduino_math_overrides/test_sw_arduino_math_overrides.ino b/tests/device/test_sw_arduino_math_overrides/test_sw_arduino_math_overrides.ino index 80763ecff7..49496ab7a0 100644 --- a/tests/device/test_sw_arduino_math_overrides/test_sw_arduino_math_overrides.ino +++ b/tests/device/test_sw_arduino_math_overrides/test_sw_arduino_math_overrides.ino @@ -46,7 +46,9 @@ TEST_CASE("abs works with ints", "[arduino-math]") CHECK(abs(b) == b); } -bool compare_floats(float a, float b) { +template +bool compare_floats(T a, T b) { + static_assert(std::is_floating_point::value, ""); return std::fabs(a - b) < std::numeric_limits::epsilon(); } @@ -60,17 +62,17 @@ TEST_CASE("abs works with floats", "[arduino-math]") CHECK(compare_floats(abs(b), b)); } -TEST_CASE("round works with floats", "[arduino-math]") +TEST_CASE("round works with ints", "[arduino-math]") { - float a = 2.9; - float b = 3.0; - CHECK(TEST_MATH_IS_SAME(round(a), a)); - CHECK(TEST_MATH_IS_SAME(round(b), b)); - CHECK(compare_floats(round(a), b)); - CHECK(compare_floats(round(b), b)); + int a = 5; + int b = 10; + CHECK(TEST_MATH_IS_SAME(round(a), std::round(a))); + CHECK(TEST_MATH_IS_SAME(round(b), std::round(b))); + CHECK(compare_floats(round(a), std::round(a))); + CHECK(compare_floats(round(b), std::round(b))); } -TEST_CASE("round result is float", "[arduino-math]") +TEST_CASE("round works with floats", "[arduino-math]") { float a = 2.9; float b = 3.0; From 1f148788071458b6daf32db3d1ed56cf524832cd Mon Sep 17 00:00:00 2001 From: Maxim Prokhorov Date: Mon, 17 Aug 2020 02:34:54 +0300 Subject: [PATCH 09/16] tweak c macros per review --- cores/esp8266/Arduino.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cores/esp8266/Arduino.h b/cores/esp8266/Arduino.h index e9dc5d5ecb..1839d182c3 100644 --- a/cores/esp8266/Arduino.h +++ b/cores/esp8266/Arduino.h @@ -219,9 +219,9 @@ void optimistic_yield(uint32_t interval_us); // undefine stdlib's definitions when encountered, provide abs that supports floating point for C code #ifndef __cplusplus #undef abs -#define abs(x) ((x)>0?(x):-(x)) +#define abs(x) ({ __typeof__(x) _x = (x); _x > 0 ? _x : -_x; }) #undef round -#define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5)) +#define round(x) ({ __typeof__(x) _x = (x); _x >= 0 ? (long)(_x + 0.5) : (long)(_x - 0.5); }) #endif // ifndef __cplusplus // from this point onward, we need to configure the c++ environment From 247c6c3934e7a28ff02350dbc18d95e5db2fff8d Mon Sep 17 00:00:00 2001 From: Maxim Prokhorov Date: Mon, 17 Aug 2020 18:19:20 +0300 Subject: [PATCH 10/16] fix gcc-10 missing cerrno include --- tests/host/common/littlefs_mock.cpp | 1 + tests/host/common/spiffs_mock.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/tests/host/common/littlefs_mock.cpp b/tests/host/common/littlefs_mock.cpp index 73629787a2..0d99e82b1e 100644 --- a/tests/host/common/littlefs_mock.cpp +++ b/tests/host/common/littlefs_mock.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include "flash_hal_mock.h" #define LITTLEFS_FILE_NAME "littlefs.bin" diff --git a/tests/host/common/spiffs_mock.cpp b/tests/host/common/spiffs_mock.cpp index d32c56d9d0..c7f9f53aba 100644 --- a/tests/host/common/spiffs_mock.cpp +++ b/tests/host/common/spiffs_mock.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include "flash_hal_mock.h" From 685c25f5233c0fed3d2611843f8db280fa82e146 Mon Sep 17 00:00:00 2001 From: Maxim Prokhorov Date: Mon, 17 Aug 2020 23:06:27 +0300 Subject: [PATCH 11/16] amend 555c272, again --- cores/esp8266/umm_malloc/umm_malloc_cfg.h | 5 +++-- libraries/ESP8266WiFi/src/include/ClientContext.h | 2 -- libraries/ESP8266WiFi/src/include/UdpContext.h | 1 - tests/host/common/include/ClientContext.h | 1 - 4 files changed, 3 insertions(+), 6 deletions(-) diff --git a/cores/esp8266/umm_malloc/umm_malloc_cfg.h b/cores/esp8266/umm_malloc/umm_malloc_cfg.h index d6b7c5987b..2db2444753 100644 --- a/cores/esp8266/umm_malloc/umm_malloc_cfg.h +++ b/cores/esp8266/umm_malloc/umm_malloc_cfg.h @@ -17,9 +17,10 @@ #include #include #include -#include + #include -#include +#include "../debug.h" +#include "../esp8266_undocumented.h" #ifdef __cplusplus extern "C" { diff --git a/libraries/ESP8266WiFi/src/include/ClientContext.h b/libraries/ESP8266WiFi/src/include/ClientContext.h index b3ac5a1c78..8095e402a2 100644 --- a/libraries/ESP8266WiFi/src/include/ClientContext.h +++ b/libraries/ESP8266WiFi/src/include/ClientContext.h @@ -29,8 +29,6 @@ typedef void (*discard_cb_t)(void*, ClientContext*); extern "C" void esp_yield(); extern "C" void esp_schedule(); -#include - #include "DataSource.h" bool getDefaultPrivateGlobalSyncValue (); diff --git a/libraries/ESP8266WiFi/src/include/UdpContext.h b/libraries/ESP8266WiFi/src/include/UdpContext.h index 741099b9f0..8053748cd9 100644 --- a/libraries/ESP8266WiFi/src/include/UdpContext.h +++ b/libraries/ESP8266WiFi/src/include/UdpContext.h @@ -30,7 +30,6 @@ void esp_schedule(); } #include -#include #define PBUF_ALIGNER_ADJUST 4 #define PBUF_ALIGNER(x) ((void*)((((intptr_t)(x))+3)&~3)) diff --git a/tests/host/common/include/ClientContext.h b/tests/host/common/include/ClientContext.h index 0eeeec02a0..31366ac0dd 100644 --- a/tests/host/common/include/ClientContext.h +++ b/tests/host/common/include/ClientContext.h @@ -28,7 +28,6 @@ extern "C" void esp_yield(); extern "C" void esp_schedule(); #include -#include bool getDefaultPrivateGlobalSyncValue (); From 60de322b359a1582d72ae9065c59d858c173cb1f Mon Sep 17 00:00:00 2001 From: Maxim Prokhorov Date: Mon, 17 Aug 2020 23:23:20 +0300 Subject: [PATCH 12/16] fixup! Merge remote-tracking branch 'origin/master' into tests/sync-arduino-h --- tests/host/common/mock.h | 7 ------- 1 file changed, 7 deletions(-) diff --git a/tests/host/common/mock.h b/tests/host/common/mock.h index 191dc7b3dd..8ab2a057e1 100644 --- a/tests/host/common/mock.h +++ b/tests/host/common/mock.h @@ -38,7 +38,6 @@ #define ESP8266 1 #define A0 0 #define LED_BUILTIN 0 -#define F_CPU 80000000 #define LWIP_OPEN_SRC #define TCP_MSS 536 #define LWIP_FEATURES 1 @@ -55,12 +54,6 @@ #define D7 7 #define D8 8 -// include host's STL before any other include file -// because core definition like max() is in the way - -#ifdef __cplusplus -#include -#endif #include #ifdef __cplusplus From 1a2fd273fddccfd803bd2eeb9f53b5f20030455e Mon Sep 17 00:00:00 2001 From: Maxim Prokhorov Date: Mon, 17 Aug 2020 23:30:47 +0300 Subject: [PATCH 13/16] fixup! amend 555c272, again --- cores/esp8266/abi.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/cores/esp8266/abi.cpp b/cores/esp8266/abi.cpp index fe63354100..380768eef8 100644 --- a/cores/esp8266/abi.cpp +++ b/cores/esp8266/abi.cpp @@ -18,7 +18,6 @@ #include #include -#include #include #include From 8c89d900ec50888434b05d413158f54fbab38b70 Mon Sep 17 00:00:00 2001 From: Maxim Prokhorov Date: Mon, 17 Aug 2020 23:31:29 +0300 Subject: [PATCH 14/16] switch to the current -std=... opts --- tests/host/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/host/Makefile b/tests/host/Makefile index 3a8e0be7d8..b1fae685f0 100644 --- a/tests/host/Makefile +++ b/tests/host/Makefile @@ -161,8 +161,8 @@ FLAGS += -DNONOSDK221=1 FLAGS += -DF_CPU=80000000 FLAGS += $(MKFLAGS) FLAGS += -Wimplicit-fallthrough=2 # allow "// fall through" comments to stop spurious warnings -CXXFLAGS += -std=c++11 -fno-rtti $(FLAGS) -funsigned-char -CFLAGS += -std=c99 $(FLAGS) -funsigned-char +CXXFLAGS += -std=gnu++17 -fno-rtti $(FLAGS) -funsigned-char +CFLAGS += -std=c17 $(FLAGS) -funsigned-char LDFLAGS += -coverage $(OPTZ) -g $(M32) VALGRINDFLAGS += --leak-check=full --track-origins=yes --error-limit=no --show-leak-kinds=all --error-exitcode=999 CXXFLAGS += -Wno-error=format-security # cores/esp8266/Print.cpp:42:24: error: format not a string literal and no format arguments [-Werror=format-security] -- (os_printf_plus(not_the_best_way)) From f48cd4969517c2459f3aff32b02bbcf9e20a9746 Mon Sep 17 00:00:00 2001 From: Maxim Prokhorov Date: Mon, 17 Aug 2020 23:42:14 +0300 Subject: [PATCH 15/16] Revert "switch to the current -std=... opts" This reverts commit 8c89d900ec50888434b05d413158f54fbab38b70. --- tests/host/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/host/Makefile b/tests/host/Makefile index b1fae685f0..3a8e0be7d8 100644 --- a/tests/host/Makefile +++ b/tests/host/Makefile @@ -161,8 +161,8 @@ FLAGS += -DNONOSDK221=1 FLAGS += -DF_CPU=80000000 FLAGS += $(MKFLAGS) FLAGS += -Wimplicit-fallthrough=2 # allow "// fall through" comments to stop spurious warnings -CXXFLAGS += -std=gnu++17 -fno-rtti $(FLAGS) -funsigned-char -CFLAGS += -std=c17 $(FLAGS) -funsigned-char +CXXFLAGS += -std=c++11 -fno-rtti $(FLAGS) -funsigned-char +CFLAGS += -std=c99 $(FLAGS) -funsigned-char LDFLAGS += -coverage $(OPTZ) -g $(M32) VALGRINDFLAGS += --leak-check=full --track-origins=yes --error-limit=no --show-leak-kinds=all --error-exitcode=999 CXXFLAGS += -Wno-error=format-security # cores/esp8266/Print.cpp:42:24: error: format not a string literal and no format arguments [-Werror=format-security] -- (os_printf_plus(not_the_best_way)) From 481b351496f4d470d86450552a69e153269c92d3 Mon Sep 17 00:00:00 2001 From: Maxim Prokhorov Date: Tue, 18 Aug 2020 00:28:39 +0300 Subject: [PATCH 16/16] trying to fix CI, clean-up configTime decl + def --- tests/host/common/MockTools.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/host/common/MockTools.cpp b/tests/host/common/MockTools.cpp index a2d72081de..5eb7969de7 100644 --- a/tests/host/common/MockTools.cpp +++ b/tests/host/common/MockTools.cpp @@ -53,16 +53,6 @@ int ets_printf (const char* fmt, ...) return len; } -extern "C" void configTime(long timezone, int daylightOffset_sec, - const char* server1, const char* server2, const char* server3) -{ - (void)server1; - (void)server2; - (void)server3; - - mockverbose("configTime: TODO (tz=%ldH offset=%dS) (time will be host's)\n", timezone, daylightOffset_sec); -} - void stack_thunk_add_ref() { } void stack_thunk_del_ref() { } void stack_thunk_repaint() { } @@ -78,3 +68,13 @@ void stack_thunk_dump_stack() { } #define make_stack_thunk(fcnToThunk) }; + +void configTime(int timezone, int daylightOffset_sec, + const char* server1, const char* server2, const char* server3) +{ + (void)server1; + (void)server2; + (void)server3; + + mockverbose("configTime: TODO (tz=%dH offset=%dS) (time will be host's)\n", timezone, daylightOffset_sec); +}