Merge pull request #4 from froloffw7/master

Небольшая оптимизация функции wakeupProcess1()
This commit is contained in:
Victor 2024-01-09 19:33:53 +03:00 committed by GitHub
commit dc53ec8d28
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 0 deletions

View file

@ -5639,6 +5639,11 @@ void config_RTC1(uint32 time)
@return None.
*/
uint32 sleep_total;
#ifdef __GNUC__
// Indicate that the specified function does not need prologue/epilogue sequences
// generated by the compiler. And function doesn't return.
void wakeupProcess1(void) __attribute__ ((naked));
#endif
void wakeupProcess1(void)
{
uint32 current_RTC_tick;

View file

@ -459,7 +459,19 @@ __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_MSP(void)
*/
__attribute__( ( always_inline ) ) __STATIC_INLINE void __set_MSP(uint32_t topOfMainStack)
{
// https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html#Clobbers-and-Scratch-Registers
// The clobber list should not contain the stack pointer register.
// This is because the compiler requires the value of the stack pointer
// to be the same after an asm statement as it was on entry to the statement.
// However, previous versions of GCC did not enforce this rule and allowed the
// stack pointer to appear in the list, with unclear semantics.
// This behavior is deprecated and listing the stack pointer may become an error
// in future versions of GCC.
#if __GNUC__ >= 9
__ASM volatile ("MSR msp, %0\n" : : "r" (topOfMainStack));
#else
__ASM volatile ("MSR msp, %0\n" : : "r" (topOfMainStack) : "sp");
#endif
}