<html><body>pujde dat ?<br><p><span style="color: rgb(0, 51, 153); line-height: 16.8px;">inline void volatile EnterCritical() __attribute__( ( always_inline ) );</span><br></p><p><span style="color: rgb(0, 51, 153); line-height: 16.8px;"><br></span></p><p><span style="color: rgb(0, 51, 153); line-height: 16.8px;">Zdenek Aster</span></p><p>---------- Původní zpráva ----------<br>Od: Jaroslav Buchta <jaroslav.buchta@hascomp.cz><br>Komu: HW-news <hw-list@list.hw.cz><br>Datum: 13. 8. 2016 7:47:28<br>Předmět: GCC inline a optimalizace</p><br><blockquote>Zdravim,<br><br>nevim jak donutit compiler, aby mi neprehazel posloupnost operaci v <br>nasledujici funkci<br><br>inline void EnterCritical() __attribute__( ( always_inline ) );<br>inline void ExitCritical() __attribute__( ( always_inline ) );<br><br><br>inline void EnterCritical()<br>{<br> __asm volatile<br> (<br> " mov r0, %0 \n"<br> " msr basepri, r0 \n"<br> ::"i"(CRITICAL_INT_PRIORITY):"r0"<br> );<br> criticalNesting++;<br>}<br><br>inline void ExitCritical()<br>{<br> criticalNesting--;<br> if( criticalNesting == 0 )<br> {<br> __asm volatile<br> (<br> " mov r0, #0 \n"<br> " msr basepri, r0 \n"<br> :::"r0"<br> );<br> }<br><br>}<br><br><br>volatile uint64_t sysTicksCounter;<br><br>void SysTick_Handler(void)<br>{<br> EnterCritical();<br> sysTicksCounter++;<br> ExitCritical();<br>}<br><br>Ma nekdo tip jak na to? Takhle z toho vypadne toto v asm:<br><br><br>08000458 mov.w r0, #95 ; 0x5f<br>0800045C msr BASEPRI, r0<br>(56) (<br>(57) " mov r0, %0 \n"<br>(58) " msr basepri, r0 \n"<br>(59) ::"i"(CRITICAL_INT_PRIORITY):"r0"<br>(60) );<br>(61) criticalNesting++;<br>08000460 ldr r3, [pc, #60] ; (0x80004a0 <SysTick_Handler+76>)<br>08000462 ldr r3, [r3, #0]<br>08000464 adds r2, r3, #1<br>08000466 ldr r3, [pc, #56] ; (0x80004a0 <SysTick_Handler+76>)<br>08000468 str r2, [r3, #0]<br>(62) }<br>(63)<br>(64) inline void ExitCritical()<br>(65) {<br>(66) criticalNesting--;<br>0800047C ldr r3, [pc, #32] ; (0x80004a0 <SysTick_Handler+76>)<br>0800047E ldr r3, [r3, #0]<br>08000480 subs r2, r3, #1<br>08000482 ldr r3, [pc, #28] ; (0x80004a0 <SysTick_Handler+76>)<br>08000484 str r2, [r3, #0]<br>(67) if( criticalNesting == 0 )<br>08000486 ldr r3, [pc, #24] ; (0x80004a0 <SysTick_Handler+76>)<br>08000488 ldr r3, [r3, #0]<br>0800048A cmp r3, #0<br>0800048C bne.n 0x8000496 <SysTick_Handler+66><br>(68) {<br>(69) __asm volatile<br>0800048E mov.w r0, #0<br>08000492 msr BASEPRI, r0<br>(70) (<br>(71) " mov r0, #0 \n"<br>(72) " msr basepri, r0 \n"<br>(73) :::"r0"<br>(74) );<br>(75) }<br>(76)<br>(77) }<br>(78)<br>(79) volatile uint64_t sysTicksCounter;<br>(80)<br>(81) void SysTick_Handler(void)<br>(82) {<br>08000454 push {r7}<br>08000456 add r7, sp, #0<br>(83) EnterCritical();<br>(84) sysTicksCounter++;<br>0800046A ldr r3, [pc, #56] ; (0x80004a4 <SysTick_Handler+80>)<br>0800046C ldrd r2, r3, [r3]<br>08000470 adds r2, #1<br>08000472 adc.w r3, r3, #0<br>08000476 ldr r1, [pc, #44] ; (0x80004a4 <SysTick_Handler+80>)<br>08000478 strd r2, r3, [r1]<br>(85) ExitCritical();<br>(86) }<br>08000496 mov sp, r7<br>08000498 ldr.w r7, [sp], #4<br>0800049C bx lr<br>0800049E nop<br>080004A0 lsls r4, r1, #17<br>080004A2 movs r0, #0<br>080004A4 lsls r0, r2, #17<br>080004A6 movs r0, #0<br><br><br>-> cili to provede omezeni preruseni, zrusi omezeni a teprve potom <br>provede increment ktery ma byt samozrejme mezi tim...<br><br>_______________________________________________<br>HW-list mailing list - sponsored by www.HW.cz<br>Hw-list@list.hw.cz<br>http://list.hw.cz/mailman/listinfo/hw-list</blockquote></body></html>