Skip to content

Commit 9ee8ee1

Browse files
committed
- adjustments regarding compiler warnings
1 parent d3be6d5 commit 9ee8ee1

File tree

2 files changed

+83
-15
lines changed

2 files changed

+83
-15
lines changed

cores/esp32/Arduino.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,9 @@
104104
#endif
105105

106106
#define bit(b) (1UL << (b))
107+
#ifndef _BV
107108
#define _BV(b) (1UL << (b))
109+
#endif
108110

109111
#define digitalPinToTimer(pin) (0)
110112
#define analogInPinToBit(P) (P)

tools/sdk/esp32/include/esp_common/include/esp_attr.h

Lines changed: 81 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,26 @@ extern "C" {
1515

1616
#define ROMFN_ATTR
1717

18+
#define __ESP_COUNTER__ 1
19+
#undef __TMP__
20+
1821
//Normally, the linker script will put all code and rodata in flash,
1922
//and all variables in shared RAM. These macros can be used to redirect
2023
//particular functions/variables to other memory regions.
2124

2225
// Forces code into IRAM instead of flash
23-
#define IRAM_ATTR _SECTION_ATTR_IMPL(".iram1", __COUNTER__)
26+
#define IRAM_ATTR _SECTION_ATTR_IMPL(".iram1", __ESP_COUNTER__)
27+
#define __TMP__ __ESP_COUNTER__ + 1
28+
#undef __ESP_COUNTER__
29+
#define __ESP_COUNTER__ __TMP__
30+
#undef __TMP__
2431

2532
// Forces data into DRAM instead of flash
26-
#define DRAM_ATTR _SECTION_ATTR_IMPL(".dram1", __COUNTER__)
33+
#define DRAM_ATTR _SECTION_ATTR_IMPL(".dram1", __ESP_COUNTER__)
34+
#define __TMP__ __ESP_COUNTER__ + 1
35+
#undef __ESP_COUNTER__
36+
#define __ESP_COUNTER__ __TMP__
37+
#undef __TMP__
2738

2839
// IRAM can only be accessed as an 8-bit memory on ESP32, when CONFIG_ESP32_IRAM_AS_8BIT_ACCESSIBLE_MEMORY is set
2940
#define IRAM_8BIT_ACCESSIBLE (CONFIG_IDF_TARGET_ESP32 && CONFIG_ESP32_IRAM_AS_8BIT_ACCESSIBLE_MEMORY)
@@ -35,7 +46,11 @@ extern "C" {
3546
#define IRAM_DATA_ATTR __attribute__((section(".iram.data")))
3647

3748
// Forces data into IRAM instead of DRAM and map it to coredump
38-
#define COREDUMP_IRAM_DATA_ATTR _SECTION_ATTR_IMPL(".iram2.coredump", __COUNTER__)
49+
#define COREDUMP_IRAM_DATA_ATTR _SECTION_ATTR_IMPL(".iram2.coredump", __ESP_COUNTER__)
50+
#define __TMP__ __ESP_COUNTER__ + 1
51+
#undef __ESP_COUNTER__
52+
#define __ESP_COUNTER__ __TMP__
53+
#undef __TMP__
3954

4055
// Forces bss into IRAM instead of DRAM
4156
#define IRAM_BSS_ATTR __attribute__((section(".iram.bss")))
@@ -62,35 +77,67 @@ extern "C" {
6277
#define DRAM_STR(str) (__extension__({static const DRAM_ATTR char __c[] = (str); (const char *)&__c;}))
6378

6479
// Forces code into RTC fast memory. See "docs/deep-sleep-stub.rst"
65-
#define RTC_IRAM_ATTR _SECTION_ATTR_IMPL(".rtc.text", __COUNTER__)
80+
#define RTC_IRAM_ATTR _SECTION_ATTR_IMPL(".rtc.text", __ESP_COUNTER__)
81+
#define __TMP__ __ESP_COUNTER__ + 1
82+
#undef __ESP_COUNTER__
83+
#define __ESP_COUNTER__ __TMP__
84+
#undef __TMP__
6685

6786
#if CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY
6887
// Forces bss variable into external memory. "
69-
#define EXT_RAM_ATTR _SECTION_ATTR_IMPL(".ext_ram.bss", __COUNTER__)
88+
#define EXT_RAM_ATTR _SECTION_ATTR_IMPL(".ext_ram.bss", __ESP_COUNTER__)
89+
#define __TMP__ __ESP_COUNTER__ + 1
90+
#undef __ESP_COUNTER__
91+
#define __ESP_COUNTER__ __TMP__
92+
#undef __TMP__
7093
#else
7194
#define EXT_RAM_ATTR
7295
#endif
7396

7497
// Forces data into RTC slow memory. See "docs/deep-sleep-stub.rst"
7598
// Any variable marked with this attribute will keep its value
7699
// during a deep sleep / wake cycle.
77-
#define RTC_DATA_ATTR _SECTION_ATTR_IMPL(".rtc.data", __COUNTER__)
100+
#define RTC_DATA_ATTR _SECTION_ATTR_IMPL(".rtc.data", __ESP_COUNTER__)
101+
#define __TMP__ __ESP_COUNTER__ + 1
102+
#undef __ESP_COUNTER__
103+
#define __ESP_COUNTER__ __TMP__
104+
#undef __TMP__
78105

79106
// Forces read-only data into RTC memory. See "docs/deep-sleep-stub.rst"
80-
#define RTC_RODATA_ATTR _SECTION_ATTR_IMPL(".rtc.rodata", __COUNTER__)
107+
#define RTC_RODATA_ATTR _SECTION_ATTR_IMPL(".rtc.rodata", __ESP_COUNTER__)
108+
#define __TMP__ __ESP_COUNTER__ + 1
109+
#undef __ESP_COUNTER__
110+
#define __ESP_COUNTER__ __TMP__
111+
#undef __TMP__
81112

82113
// Allows to place data into RTC_SLOW memory.
83-
#define RTC_SLOW_ATTR _SECTION_ATTR_IMPL(".rtc.force_slow", __COUNTER__)
114+
#define RTC_SLOW_ATTR _SECTION_ATTR_IMPL(".rtc.force_slow", __ESP_COUNTER__)
115+
#define __TMP__ __ESP_COUNTER__ + 1
116+
#undef __ESP_COUNTER__
117+
#define __ESP_COUNTER__ __TMP__
118+
#undef __TMP__
84119

85120
// Allows to place data into RTC_FAST memory.
86-
#define RTC_FAST_ATTR _SECTION_ATTR_IMPL(".rtc.force_fast", __COUNTER__)
121+
#define RTC_FAST_ATTR _SECTION_ATTR_IMPL(".rtc.force_fast", __ESP_COUNTER__)
122+
#define __TMP__ __ESP_COUNTER__ + 1
123+
#undef __ESP_COUNTER__
124+
#define __ESP_COUNTER__ __TMP__
125+
#undef __TMP__
87126

88127
// Forces data into noinit section to avoid initialization after restart.
89-
#define __NOINIT_ATTR _SECTION_ATTR_IMPL(".noinit", __COUNTER__)
128+
#define __NOINIT_ATTR _SECTION_ATTR_IMPL(".noinit", __ESP_COUNTER__)
129+
#define __TMP__ __ESP_COUNTER__ + 1
130+
#undef __ESP_COUNTER__
131+
#define __ESP_COUNTER__ __TMP__
132+
#undef __TMP__
90133

91134
#if CONFIG_SPIRAM_ALLOW_NOINIT_SEG_EXTERNAL_MEMORY
92135
// Forces data into external memory noinit section to avoid initialization after restart.
93-
#define EXT_RAM_NOINIT_ATTR _SECTION_ATTR_IMPL(".ext_ram_noinit", __COUNTER__)
136+
#define EXT_RAM_NOINIT_ATTR _SECTION_ATTR_IMPL(".ext_ram_noinit", __ESP_COUNTER__)
137+
#define __TMP__ __ESP_COUNTER__ + 1
138+
#undef __ESP_COUNTER__
139+
#define __ESP_COUNTER__ __TMP__
140+
#undef __TMP__
94141
#else
95142
// Place in internal noinit section
96143
#define EXT_RAM_NOINIT_ATTR __NOINIT_ATTR
@@ -99,18 +146,34 @@ extern "C" {
99146
// Forces data into RTC slow memory of .noinit section.
100147
// Any variable marked with this attribute will keep its value
101148
// after restart or during a deep sleep / wake cycle.
102-
#define RTC_NOINIT_ATTR _SECTION_ATTR_IMPL(".rtc_noinit", __COUNTER__)
149+
#define RTC_NOINIT_ATTR _SECTION_ATTR_IMPL(".rtc_noinit", __ESP_COUNTER__)
150+
#define __TMP__ __ESP_COUNTER__ + 1
151+
#undef __ESP_COUNTER__
152+
#define __ESP_COUNTER__ __TMP__
153+
#undef __TMP__
103154

104155
// Forces code into DRAM instead of flash and map it to coredump
105156
// Use dram2 instead of dram1 to make sure this section will not be included
106157
// by dram1 section in the linker script
107-
#define COREDUMP_DRAM_ATTR _SECTION_ATTR_IMPL(".dram2.coredump", __COUNTER__)
158+
#define COREDUMP_DRAM_ATTR _SECTION_ATTR_IMPL(".dram2.coredump", __ESP_COUNTER__)
159+
#define __TMP__ __ESP_COUNTER__ + 1
160+
#undef __ESP_COUNTER__
161+
#define __ESP_COUNTER__ __TMP__
162+
#undef __TMP__
108163

109164
// Forces data into RTC memory and map it to coredump
110-
#define COREDUMP_RTC_DATA_ATTR _SECTION_ATTR_IMPL(".rtc.coredump", __COUNTER__)
165+
#define COREDUMP_RTC_DATA_ATTR _SECTION_ATTR_IMPL(".rtc.coredump", __ESP_COUNTER__)
166+
#define __TMP__ __ESP_COUNTER__ + 1
167+
#undef __ESP_COUNTER__
168+
#define __ESP_COUNTER__ __TMP__
169+
#undef __TMP__
111170

112171
// Allows to place data into RTC_FAST memory and map it to coredump
113-
#define COREDUMP_RTC_FAST_ATTR _SECTION_ATTR_IMPL(".rtc.fast.coredump", __COUNTER__)
172+
#define COREDUMP_RTC_FAST_ATTR _SECTION_ATTR_IMPL(".rtc.fast.coredump", __ESP_COUNTER__)
173+
#define __TMP__ __ESP_COUNTER__ + 1
174+
#undef __ESP_COUNTER__
175+
#define __ESP_COUNTER__ __TMP__
176+
#undef __TMP__
114177

115178
// Forces to not inline function
116179
#define NOINLINE_ATTR __attribute__((noinline))
@@ -160,6 +223,9 @@ FORCE_INLINE_ATTR TYPE& operator<<=(TYPE& a, int b) { a <<= b; return a; }
160223
#define IDF_DEPRECATED(REASON)
161224
#endif
162225

226+
#undef __ESP_COUNTER__
227+
#undef __TMP__
228+
163229
#ifdef __cplusplus
164230
}
165231
#endif

0 commit comments

Comments
 (0)