[rtems commit] score: Optimize _Per_CPU_Get_index()

Sebastian Huber sebh at rtems.org
Tue Dec 10 07:30:07 UTC 2019


Module:    rtems
Branch:    master
Commit:    189da5f4428356e94182eb1313c6309cfcbddd04
Changeset: http://git.rtems.org/rtems/commit/?id=189da5f4428356e94182eb1313c6309cfcbddd04

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Tue Dec 10 08:26:33 2019 +0100

score: Optimize _Per_CPU_Get_index()

Optimize _Per_CPU_Get_index() in uniprocessor configurations.

---

 cpukit/include/rtems/score/percpu.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/cpukit/include/rtems/score/percpu.h b/cpukit/include/rtems/score/percpu.h
index c661310..7c95a96 100644
--- a/cpukit/include/rtems/score/percpu.h
+++ b/cpukit/include/rtems/score/percpu.h
@@ -654,10 +654,15 @@ static inline Per_CPU_Control *_Per_CPU_Get_by_index( uint32_t index )
 
 static inline uint32_t _Per_CPU_Get_index( const Per_CPU_Control *cpu )
 {
+#if defined(RTEMS_SMP)
   const Per_CPU_Control_envelope *per_cpu_envelope =
     ( const Per_CPU_Control_envelope * ) cpu;
 
   return ( uint32_t ) ( per_cpu_envelope - &_Per_CPU_Information[ 0 ] );
+#else
+  (void) cpu;
+  return 0;
+#endif
 }
 
 static inline struct _Thread_Control *_Per_CPU_Get_executing(



More information about the vc mailing list