Skip to content

Commit 38d8b6e

Browse files
mhightower83devyte
authored andcommitted
Added memory fence to xt_rsil() (#6301)
Without this the compiler may use memory references loaded to registers before the fence, in computation within the fence. These values could have changed before xt_rsil() (critical section start) was called. Note: this is needed to stop the compiler from reordering instructions at the critical section boundary.
1 parent 147fada commit 38d8b6e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

cores/esp8266/Arduino.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ void ets_intr_unlock();
159159
// level 15 will disable ALL interrupts,
160160
// level 0 will enable ALL interrupts,
161161
//
162-
#define xt_rsil(level) (__extension__({uint32_t state; __asm__ __volatile__("rsil %0," __STRINGIFY(level) : "=a" (state)); state;}))
162+
#define xt_rsil(level) (__extension__({uint32_t state; __asm__ __volatile__("rsil %0," __STRINGIFY(level) : "=a" (state) :: "memory"); state;}))
163163
#define xt_wsr_ps(state) __asm__ __volatile__("wsr %0,ps; isync" :: "a" (state) : "memory")
164164

165165
#define interrupts() xt_rsil(0)

0 commit comments

Comments
 (0)