From 18d45d9d25beceedcc3e34eea3d28f87fa200e76 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Thu, 11 Apr 2019 12:10:53 +0200 Subject: score: Add _ISR_lock_Set_name() Add _ISR_lock_Set_name() to optimize the initialization of zero-initialized locks. --- cpukit/include/rtems/score/isrlock.h | 15 +++++++++++++++ cpukit/include/rtems/score/smplock.h | 21 ++++++++++++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) (limited to 'cpukit/include/rtems') diff --git a/cpukit/include/rtems/score/isrlock.h b/cpukit/include/rtems/score/isrlock.h index b1aea62bf0..de85286de7 100644 --- a/cpukit/include/rtems/score/isrlock.h +++ b/cpukit/include/rtems/score/isrlock.h @@ -199,6 +199,21 @@ RTEMS_INLINE_ROUTINE void _ISR_lock_Context_set_level( #define _ISR_lock_Destroy( _lock ) #endif +/** + * @brief Sets the name of an ISR lock. + * + * @param[out] _lock The ISR lock control. + * @param _name The name for the ISR lock. This name must be a string + * persistent throughout the life time of this lock. The name is only used + * if profiling is enabled. + */ +#if defined( RTEMS_SMP ) + #define _ISR_lock_Set_name( _lock, _name ) \ + _SMP_lock_Set_name( &( _lock )->Lock, _name ) +#else + #define _ISR_lock_Set_name( _lock, _name ) +#endif + /** * @brief Acquires an ISR lock. * diff --git a/cpukit/include/rtems/score/smplock.h b/cpukit/include/rtems/score/smplock.h index 1c37db465b..b1f5a6de28 100644 --- a/cpukit/include/rtems/score/smplock.h +++ b/cpukit/include/rtems/score/smplock.h @@ -149,7 +149,7 @@ static inline void _SMP_lock_Initialize_inline( #if defined(RTEMS_SMP_LOCK_DO_NOT_INLINE) void _SMP_lock_Initialize( SMP_lock_Control *lock, - const char * name + const char *name ); #else #define _SMP_lock_Initialize( lock, name ) \ @@ -176,6 +176,25 @@ void _SMP_lock_Destroy( SMP_lock_Control *lock ); _SMP_lock_Destroy_inline( lock ) #endif +/** + * @brief Sets the name of an SMP lock. + * + * @param[out] lock The SMP lock control. + * @param name The name for the SMP lock statistics. This name must be + * persistent throughout the life time of this statistics block. + */ +static inline void _SMP_lock_Set_name( + SMP_lock_Control *lock, + const char *name +) +{ +#if defined(RTEMS_PROFILING) + lock->Stats.name = name; +#else + (void) name; +#endif +} + #if defined(RTEMS_DEBUG) static inline uint32_t _SMP_lock_Who_am_I( void ) { -- cgit v1.2.3