From da179e0098edcc228875f377415cc723c1d175a8 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Mon, 2 Jul 2018 11:31:19 +0800 Subject: [PATCH] xtensa: make XTHAL_GET_INTERRUPT, XTHAL_GET_CCOUNT volatile INTERRUPT and CCOUNT registers will change outside of program control. Making the inline assembly used to read these registers volatile indicates this fact to the compiler. Fixes https://github.com/espressif/esp-idf/issues/2127 --- components/esp32/include/xtensa/core-macros.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/esp32/include/xtensa/core-macros.h b/components/esp32/include/xtensa/core-macros.h index c8f7e34762..37c48921a4 100644 --- a/components/esp32/include/xtensa/core-macros.h +++ b/components/esp32/include/xtensa/core-macros.h @@ -335,7 +335,7 @@ __asm__ __volatile__("wsr.intenable %0" :: "a"(__intenable):"memory"); \ } while(0) # define XTHAL_GET_INTERRUPT() ({ int __interrupt; \ - __asm__("rsr.interrupt %0" : "=a"(__interrupt)); \ + __asm__ __volatile__("rsr.interrupt %0" : "=a"(__interrupt)); \ __interrupt; }) # define XTHAL_SET_INTSET(v) do { int __interrupt = (int)(v); \ __asm__ __volatile__("wsr.intset %0" :: "a"(__interrupt):"memory"); \ @@ -344,7 +344,7 @@ __asm__ __volatile__("wsr.intclear %0" :: "a"(__interrupt):"memory"); \ } while(0) # define XTHAL_GET_CCOUNT() ({ int __ccount; \ - __asm__("rsr.ccount %0" : "=a"(__ccount)); \ + __asm__ __volatile__("rsr.ccount %0" : "=a"(__ccount)); \ __ccount; }) # define XTHAL_SET_CCOUNT(v) do { int __ccount = (int)(v); \ __asm__ __volatile__("wsr.ccount %0" :: "a"(__ccount):"memory"); \