Skip to content

Commit

Permalink
add __perfc_sync_barrier__();
Browse files Browse the repository at this point in the history
  • Loading branch information
GorgonMeducer committed Jul 6, 2024
1 parent e22be68 commit 4008b11
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
1 change: 1 addition & 0 deletions perf_counter.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
15 changes: 14 additions & 1 deletion perf_counter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
/*! @} */

Expand All @@ -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) { \
Expand Down
5 changes: 5 additions & 0 deletions perfc_port_default.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
5 changes: 5 additions & 0 deletions perfc_port_pmu.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 { \
Expand Down

0 comments on commit 4008b11

Please sign in to comment.