add __perfc_sync_barrier__();

This commit is contained in:
Gabriel Wang 2024-07-06 07:19:50 +01:00
parent e22be687f6
commit 4008b11d0c
4 changed files with 25 additions and 1 deletions

View File

@ -146,6 +146,7 @@ void update_perf_counter(void)
__IRQ_SAFE {
g_lLastTimeStamp = get_system_ticks();
__perfc_sync_barrier__();
g_nOffset = get_system_ticks() - g_lLastTimeStamp;
}
}

View File

@ -333,6 +333,17 @@ __super_loop_monitor__()
__asm(".global __ensure_systick_wrapper\n\t");
# endif
#ifndef __perfc_sync_barrier__
/* default implementation */
#if defined(__clang__) || __IS_COMPILER_GCC__
# define __perfc_sync_barrier__(...) __sync_synchronize()
#else
# define __perfc_sync_barrier__(...)
#endif
#endif
#endif
/*! @} */
@ -358,7 +369,9 @@ __asm(".global __ensure_systick_wrapper\n\t");
*/
#define __cycleof__(__STR, ...) \
using(int64_t _ = get_system_ticks(), __cycle_count__ = _, \
_=_, { \
{__perfc_sync_barrier__();}, \
{ \
__perfc_sync_barrier__(); \
_ = get_system_ticks() - _ - g_nOffset; \
__cycle_count__ = _; \
if (__PLOOC_VA_NUM_ARGS(__VA_ARGS__) == 0) { \

View File

@ -27,6 +27,11 @@
/*============================ MACROS ========================================*/
/*============================ MACROFIED FUNCTIONS ===========================*/
#ifndef __perfc_sync_barrier__
# define __perfc_sync_barrier__(...) do {__DSB();__ISB();} while(0)
#endif
/*============================ TYPES =========================================*/
typedef uint32_t perfc_global_interrupt_status_t;

View File

@ -23,6 +23,11 @@
/*============================ MACROS ========================================*/
/*============================ MACROFIED FUNCTIONS ===========================*/
#ifndef __perfc_sync_barrier__
# define __perfc_sync_barrier__(...) do {__DSB();__ISB();} while(0)
#endif
#define __cpu_perf__(__str, ...) \
using( \
struct { \