Skip to content

Commit 00673e0

Browse files
authored
Merge branch 'master' into feature/issue-2246-multi-wifi-hidden
2 parents 0d94b5f + 9003b02 commit 00673e0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+1075
-887
lines changed

cores/esp8266/Arduino.h

+28-16
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ extern "C" {
3737
#include "binary.h"
3838
#include "esp8266_peri.h"
3939
#include "twi.h"
40+
4041
#include "core_esp8266_features.h"
4142
#include "core_esp8266_version.h"
4243

@@ -125,15 +126,11 @@ void timer0_isr_init(void);
125126
void timer0_attachInterrupt(timercallback userFunc);
126127
void timer0_detachInterrupt(void);
127128

128-
// Use stdlib abs() and round() to avoid issues with the C++ libraries
129129
#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt)))
130130
#define radians(deg) ((deg)*DEG_TO_RAD)
131131
#define degrees(rad) ((rad)*RAD_TO_DEG)
132132
#define sq(x) ((x)*(x))
133133

134-
void ets_intr_lock();
135-
void ets_intr_unlock();
136-
137134
#define interrupts() xt_rsil(0)
138135
#define noInterrupts() xt_rsil(15)
139136

@@ -162,11 +159,12 @@ typedef uint16_t word;
162159
typedef bool boolean;
163160
typedef uint8_t byte;
164161

162+
void ets_intr_lock();
163+
void ets_intr_unlock();
164+
165165
void init(void);
166166
void initVariant(void);
167167

168-
int atexit(void (*func)()) __attribute__((weak));
169-
170168
void pinMode(uint8_t pin, uint8_t mode);
171169
void digitalWrite(uint8_t pin, uint8_t val);
172170
int digitalRead(uint8_t pin);
@@ -212,28 +210,31 @@ void optimistic_yield(uint32_t interval_us);
212210
} // extern "C"
213211
#endif
214212

213+
// undefine stdlib's definitions when encountered, provide abs that supports floating point for C code
214+
#ifndef __cplusplus
215+
#undef abs
216+
#define abs(x) ({ __typeof__(x) _x = (x); _x > 0 ? _x : -_x; })
217+
#undef round
218+
#define round(x) ({ __typeof__(x) _x = (x); _x >= 0 ? (long)(_x + 0.5) : (long)(_x - 0.5); })
219+
#endif // ifndef __cplusplus
215220

216-
221+
// from this point onward, we need to configure the c++ environment
217222
#ifdef __cplusplus
218223

219224
#include <algorithm>
225+
#include <cstdlib>
220226
#include <cmath>
221-
#include <pgmspace.h>
222-
223-
#include "WCharacter.h"
224-
#include "WString.h"
225-
226-
#include "HardwareSerial.h"
227-
#include "Esp.h"
228-
#include "Updater.h"
229-
#include "debug.h"
230227

231228
using std::min;
232229
using std::max;
233230
using std::round;
234231
using std::isinf;
235232
using std::isnan;
236233

234+
// Use float-compatible stl abs() and round(), we don't use Arduino macros to avoid issues with the C++ libraries
235+
using std::abs;
236+
using std::round;
237+
237238
#define _min(a,b) ({ decltype(a) _a = (a); decltype(b) _b = (b); _a < _b? _a : _b; })
238239
#define _max(a,b) ({ decltype(a) _a = (a); decltype(b) _b = (b); _a > _b? _a : _b; })
239240

@@ -273,8 +274,19 @@ inline void configTzTime(const char* tz, const char* server1,
273274
configTime(tz, server1, server2, server3);
274275
}
275276

277+
// Everything we expect to be implicitly loaded for the sketch
278+
#include <pgmspace.h>
279+
280+
#include "WCharacter.h"
281+
#include "WString.h"
282+
283+
#include "HardwareSerial.h"
284+
#include "Esp.h"
285+
#include "Updater.h"
286+
276287
#endif // __cplusplus
277288

289+
#include "debug.h"
278290
#include "pins_arduino.h"
279291

280292
#endif

0 commit comments

Comments
 (0)