<div dir="auto">Does this have a gcc issue?</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Jun 23, 2022, 3:28 AM Sebastian Huber <<a href="mailto:sebastian.huber@embedded-brains.de">sebastian.huber@embedded-brains.de</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Conditional expressions with inline functions are not optimized away if<br>
optimization is disabled.  Avoid such expressions to prevent dead<br>
branches.  It helps also during code review to immediately see if a loop<br>
is used or not.<br>
---<br>
 cpukit/include/rtems/score/priorityimpl.h | 33 ++++-------------------<br>
 cpukit/score/src/kern_tc.c                |  4 +++<br>
 cpukit/score/src/threadchangepriority.c   | 10 ++++++-<br>
 cpukit/score/src/threadqops.c             | 16 +++++++++--<br>
 cpukit/score/src/watchdogtick.c           |  4 +++<br>
 5 files changed, 36 insertions(+), 31 deletions(-)<br>
<br>
diff --git a/cpukit/include/rtems/score/priorityimpl.h b/cpukit/include/rtems/score/priorityimpl.h<br>
index 1463bf6c2a..55cddf53be 100644<br>
--- a/cpukit/include/rtems/score/priorityimpl.h<br>
+++ b/cpukit/include/rtems/score/priorityimpl.h<br>
@@ -124,26 +124,6 @@ RTEMS_INLINE_ROUTINE bool _Priority_Actions_is_empty(<br>
   return actions->actions == NULL;<br>
 }<br>
<br>
-/**<br>
- * @brief Checks if the priority actions is valid.<br>
- *<br>
- * @param aggregation The aggregation of the priority action.<br>
- *<br>
- * @retval true The @a aggregation is valid.<br>
- * @retval false The @a aggregation is not valid.<br>
- */<br>
-RTEMS_INLINE_ROUTINE bool _Priority_Actions_is_valid(<br>
-  const Priority_Aggregation *aggregation<br>
-)<br>
-{<br>
-#if defined(RTEMS_SMP)<br>
-  return aggregation != NULL;<br>
-#else<br>
-  (void) aggregation;<br>
-  return false;<br>
-#endif<br>
-}<br>
-<br>
 /**<br>
  * @brief Moves the priority actions' actions.<br>
  *<br>
@@ -389,25 +369,22 @@ RTEMS_INLINE_ROUTINE void _Priority_Set_action(<br>
   aggregation->Action.type = type;<br>
 }<br>
<br>
+#if defined(RTEMS_SMP)<br>
 /**<br>
  * @brief Gets the next action of the priority aggregation.<br>
  *<br>
- * @param aggregation The priority aggregation to get the next action of.<br>
+ * @param aggregation is the priority aggregation to get the next action of.<br>
  *<br>
- * @retval next_action The next action of @a aggregation if RTEMS_SMP is defined.<br>
- * @retval NULL RTEMS_SMP is not defined.<br>
+ * @return Returns the next action of the priority aggregation or NULL if there<br>
+ *   is no next action.<br>
  */<br>
 RTEMS_INLINE_ROUTINE Priority_Aggregation *_Priority_Get_next_action(<br>
   const Priority_Aggregation *aggregation<br>
 )<br>
 {<br>
-#if defined(RTEMS_SMP)<br>
   return aggregation->Action.next;<br>
-#else<br>
-  (void) aggregation;<br>
-  return NULL;<br>
-#endif<br>
 }<br>
+#endif<br>
<br>
 /**<br>
  * @brief Compares two priorities.<br>
diff --git a/cpukit/score/src/kern_tc.c b/cpukit/score/src/kern_tc.c<br>
index 2b7aeaad31..643026a1c8 100644<br>
--- a/cpukit/score/src/kern_tc.c<br>
+++ b/cpukit/score/src/kern_tc.c<br>
@@ -2329,9 +2329,13 @@ _Timecounter_Tick(void)<br>
 {<br>
        Per_CPU_Control *cpu_self = _Per_CPU_Get();<br>
<br>
+#if defined(RTEMS_SMP)<br>
        if (_Per_CPU_Is_boot_processor(cpu_self)) {<br>
+#endif<br>
                 tc_windup(NULL);<br>
+#if defined(RTEMS_SMP)<br>
        }<br>
+#endif<br>
<br>
        _Watchdog_Tick(cpu_self);<br>
 }<br>
diff --git a/cpukit/score/src/threadchangepriority.c b/cpukit/score/src/threadchangepriority.c<br>
index 321bb15cab..80f030fdc6 100644<br>
--- a/cpukit/score/src/threadchangepriority.c<br>
+++ b/cpukit/score/src/threadchangepriority.c<br>
@@ -135,11 +135,15 @@ static void _Thread_Priority_do_perform_actions(<br>
   priority_aggregation = _Priority_Actions_move( &queue_context->Priority.Actions );<br>
<br>
   do {<br>
+#if defined(RTEMS_SMP)<br>
     Priority_Aggregation *next_aggregation;<br>
+#endif<br>
     Priority_Node        *priority_action_node;<br>
     Priority_Action_type  priority_action_type;<br>
<br>
+#if defined(RTEMS_SMP)<br>
     next_aggregation = _Priority_Get_next_action( priority_aggregation );<br>
+#endif<br>
<br>
     priority_action_node = priority_aggregation->Action.node;<br>
     priority_action_type = priority_aggregation->Action.type;<br>
@@ -198,8 +202,12 @@ static void _Thread_Priority_do_perform_actions(<br>
         break;<br>
     }<br>
<br>
+#if defined(RTEMS_SMP)<br>
     priority_aggregation = next_aggregation;<br>
-  } while ( _Priority_Actions_is_valid( priority_aggregation ) );<br>
+  } while ( priority_aggregation != NULL );<br>
+#else<br>
+  } while ( false );<br>
+#endif<br>
<br>
   if ( !_Priority_Actions_is_empty( &queue_context->Priority.Actions ) ) {<br>
     _Thread_queue_Context_add_priority_update( queue_context, the_thread );<br>
diff --git a/cpukit/score/src/threadqops.c b/cpukit/score/src/threadqops.c<br>
index 33fc5a44cb..fbea9f6de6 100644<br>
--- a/cpukit/score/src/threadqops.c<br>
+++ b/cpukit/score/src/threadqops.c<br>
@@ -404,8 +404,12 @@ static void _Thread_queue_Priority_priority_actions(<br>
         break;<br>
     }<br>
<br>
+#if defined(RTEMS_SMP)<br>
     priority_aggregation = _Priority_Get_next_action( priority_aggregation );<br>
-  } while ( _Priority_Actions_is_valid( priority_aggregation ) );<br>
+  } while ( priority_aggregation != NULL );<br>
+#else<br>
+  } while ( false );<br>
+#endif<br>
 }<br>
<br>
 static void _Thread_queue_Priority_do_initialize(<br>
@@ -734,14 +738,18 @@ static void _Thread_queue_Priority_inherit_priority_actions(<br>
   priority_aggregation = _Priority_Actions_move( priority_actions );<br>
<br>
   do {<br>
+#if defined(RTEMS_SMP)<br>
     Priority_Aggregation        *next_aggregation;<br>
+#endif<br>
     Scheduler_Node              *scheduler_node;<br>
     size_t                       scheduler_index;<br>
     Thread_queue_Priority_queue *priority_queue;<br>
     Scheduler_Node              *scheduler_node_of_owner;<br>
     Priority_Action_type         priority_action_type;<br>
<br>
+#if defined(RTEMS_SMP)<br>
     next_aggregation = _Priority_Get_next_action( priority_aggregation );<br>
+#endif<br>
<br>
     scheduler_node = SCHEDULER_NODE_OF_WAIT_PRIORITY( priority_aggregation );<br>
     scheduler_index = _Thread_queue_Scheduler_index( scheduler_node );<br>
@@ -797,8 +805,12 @@ static void _Thread_queue_Priority_inherit_priority_actions(<br>
         break;<br>
     }<br>
<br>
+#if defined(RTEMS_SMP)<br>
     priority_aggregation = next_aggregation;<br>
-  } while ( _Priority_Actions_is_valid( priority_aggregation ) );<br>
+  } while ( priority_aggregation != NULL );<br>
+#else<br>
+  } while ( false );<br>
+#endif<br>
 }<br>
<br>
 static void _Thread_queue_Priority_inherit_do_initialize(<br>
diff --git a/cpukit/score/src/watchdogtick.c b/cpukit/score/src/watchdogtick.c<br>
index 6edb3f071a..71311b598e 100644<br>
--- a/cpukit/score/src/watchdogtick.c<br>
+++ b/cpukit/score/src/watchdogtick.c<br>
@@ -83,9 +83,13 @@ void _Watchdog_Tick( Per_CPU_Control *cpu )<br>
   Thread_Control                     *executing;<br>
   const Thread_CPU_budget_operations *cpu_budget_operations;<br>
<br>
+#ifdef RTEMS_SMP<br>
   if ( _Per_CPU_Is_boot_processor( cpu ) ) {<br>
+#endif<br>
     ++_Watchdog_Ticks_since_boot;<br>
+#ifdef RTEMS_SMP<br>
   }<br>
+#endif<br>
<br>
   _ISR_lock_ISR_disable_and_acquire( &cpu->Watchdog.Lock, &lock_context );<br>
<br>
-- <br>
2.35.3<br>
<br>
_______________________________________________<br>
devel mailing list<br>
<a href="mailto:devel@rtems.org" target="_blank" rel="noreferrer">devel@rtems.org</a><br>
<a href="http://lists.rtems.org/mailman/listinfo/devel" rel="noreferrer noreferrer" target="_blank">http://lists.rtems.org/mailman/listinfo/devel</a><br>
</blockquote></div>