[rtems commit] score: Simplify <rtems/score/thread.h>

Sebastian Huber sebh at rtems.org
Fri Jun 26 09:23:24 UTC 2015


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

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Thu Jun 25 13:48:00 2015 +0200

score: Simplify <rtems/score/thread.h>

Avoid Thread_Control typedef in <rtems/score/percpu.h>.  This helps to
get rid of the <rtems/score/percpu.h> include in <rtems/score/thread.h>
which exposes a lot of implementation details.

---

 cpukit/posix/include/rtems/posix/psignalimpl.h |  1 +
 cpukit/rtems/include/rtems/rtems/signalimpl.h  |  1 +
 cpukit/score/include/rtems/score/percpu.h      | 37 +++++++++++++++++----
 cpukit/score/include/rtems/score/thread.h      | 45 ++++++--------------------
 cpukit/score/include/rtems/score/threadq.h     |  4 +--
 5 files changed, 44 insertions(+), 44 deletions(-)

diff --git a/cpukit/posix/include/rtems/posix/psignalimpl.h b/cpukit/posix/include/rtems/posix/psignalimpl.h
index 166705b..d7e1afa 100644
--- a/cpukit/posix/include/rtems/posix/psignalimpl.h
+++ b/cpukit/posix/include/rtems/posix/psignalimpl.h
@@ -33,6 +33,7 @@
 #include <rtems/posix/sigset.h>
 #include <rtems/score/apiext.h>
 #include <rtems/score/isrlock.h>
+#include <rtems/score/percpu.h>
 #include <rtems/score/threadqimpl.h>
 
 #define _States_Is_interruptible_signal( _states ) \
diff --git a/cpukit/rtems/include/rtems/rtems/signalimpl.h b/cpukit/rtems/include/rtems/rtems/signalimpl.h
index ddbe00b..e093394 100644
--- a/cpukit/rtems/include/rtems/rtems/signalimpl.h
+++ b/cpukit/rtems/include/rtems/rtems/signalimpl.h
@@ -18,6 +18,7 @@
 #define _RTEMS_RTEMS_SIGNALIMPL_H
 
 #include <rtems/rtems/signal.h>
+#include <rtems/score/percpu.h>
 #include <rtems/score/thread.h>
 
 #ifdef __cplusplus
diff --git a/cpukit/score/include/rtems/score/percpu.h b/cpukit/score/include/rtems/score/percpu.h
index 600f46e..a6f7a25 100644
--- a/cpukit/score/include/rtems/score/percpu.h
+++ b/cpukit/score/include/rtems/score/percpu.h
@@ -51,10 +51,7 @@ extern "C" {
 
 #if !defined( ASM )
 
-#ifndef __THREAD_CONTROL_DEFINED__
-#define __THREAD_CONTROL_DEFINED__
-typedef struct Thread_Control_struct Thread_Control;
-#endif
+struct Thread_Control;
 
 struct Scheduler_Context;
 
@@ -276,7 +273,7 @@ typedef struct Per_CPU_Control {
    * configurations use _Thread_Is_executing_on_a_processor() to figure out if
    * a thread context is executing on a processor.
    */
-  Thread_Control *executing;
+  struct Thread_Control *executing;
 
   /**
    * @brief This is the heir thread for this processor.
@@ -290,7 +287,7 @@ typedef struct Per_CPU_Control {
    *
    * @see _Thread_Get_heir_and_make_it_executing().
    */
-  Thread_Control *heir;
+  struct Thread_Control *heir;
 
   /**
    * @brief This is set to true when this processor needs to run the
@@ -595,6 +592,34 @@ bool _Per_CPU_State_wait_for_non_initial_state(
 #define _Thread_Time_of_last_context_switch \
   _Per_CPU_Get()->time_of_last_context_switch
 
+/**
+ * @brief Returns the thread control block of the executing thread.
+ *
+ * This function can be called in any context.  On SMP configurations
+ * interrupts are disabled to ensure that the processor index is used
+ * consistently.
+ *
+ * @return The thread control block of the executing thread.
+ */
+RTEMS_INLINE_ROUTINE struct Thread_Control *_Thread_Get_executing( void )
+{
+  struct Thread_Control *executing;
+
+  #if defined( RTEMS_SMP )
+    ISR_Level level;
+
+    _ISR_Disable_without_giant( level );
+  #endif
+
+  executing = _Thread_Executing;
+
+  #if defined( RTEMS_SMP )
+    _ISR_Enable_without_giant( level );
+  #endif
+
+  return executing;
+}
+
 /**@}*/
 
 #endif /* !defined( ASM ) */
diff --git a/cpukit/score/include/rtems/score/thread.h b/cpukit/score/include/rtems/score/thread.h
index 05c1ff7..9d8382c 100644
--- a/cpukit/score/include/rtems/score/thread.h
+++ b/cpukit/score/include/rtems/score/thread.h
@@ -28,7 +28,6 @@
 #endif
 #include <rtems/score/isrlock.h>
 #include <rtems/score/object.h>
-#include <rtems/score/percpu.h>
 #include <rtems/score/priority.h>
 #include <rtems/score/resource.h>
 #include <rtems/score/stack.h>
@@ -40,6 +39,8 @@
   #include <rtems/score/cpuset.h>
 #endif
 
+struct Per_CPU_Control;
+
 struct Scheduler_Control;
 
 struct Scheduler_Node;
@@ -453,10 +454,10 @@ typedef struct Thread_Action Thread_Action;
  * @param[in] level The ISR level for _Thread_Action_release_and_ISR_enable().
  */
 typedef void ( *Thread_Action_handler )(
-  Thread_Control  *thread,
-  Thread_Action   *action,
-  Per_CPU_Control *cpu,
-  ISR_Level        level
+  Thread_Control         *thread,
+  Thread_Action          *action,
+  struct Per_CPU_Control *cpu,
+  ISR_Level               level
 );
 
 /**
@@ -611,14 +612,14 @@ typedef struct {
   /**
    * @brief The processor assigned by the current scheduler.
    */
-  Per_CPU_Control *cpu;
+  struct Per_CPU_Control *cpu;
 
 #if defined(RTEMS_DEBUG)
   /**
    * @brief The processor on which this thread executed the last time or is
    * executing.
    */
-  Per_CPU_Control *debug_real_cpu;
+  struct Per_CPU_Control *debug_real_cpu;
 #endif
 #endif
 } Thread_Scheduler_control;
@@ -667,7 +668,7 @@ typedef struct {
 /**
  *  This structure defines the Thread Control Block (TCB).
  */
-struct Thread_Control_struct {
+struct Thread_Control {
   /** This field is the object management structure for each thread. */
   Objects_Control          Object;
   /** This field is the current execution state of this thread. */
@@ -851,34 +852,6 @@ void rtems_iterate_over_all_threads(
 );
 
 /**
- * @brief Returns the thread control block of the executing thread.
- *
- * This function can be called in any context.  On SMP configurations
- * interrupts are disabled to ensure that the processor index is used
- * consistently.
- *
- * @return The thread control block of the executing thread.
- */
-RTEMS_INLINE_ROUTINE Thread_Control *_Thread_Get_executing( void )
-{
-  Thread_Control *executing;
-
-  #if defined( RTEMS_SMP )
-    ISR_Level level;
-
-    _ISR_Disable_without_giant( level );
-  #endif
-
-  executing = _Thread_Executing;
-
-  #if defined( RTEMS_SMP )
-    _ISR_Enable_without_giant( level );
-  #endif
-
-  return executing;
-}
-
-/**
  * @brief Thread control add-on.
  */
 typedef struct {
diff --git a/cpukit/score/include/rtems/score/threadq.h b/cpukit/score/include/rtems/score/threadq.h
index 4a8db7c..06ea36a 100644
--- a/cpukit/score/include/rtems/score/threadq.h
+++ b/cpukit/score/include/rtems/score/threadq.h
@@ -21,10 +21,8 @@
 
 #include <rtems/score/chain.h>
 #include <rtems/score/isrlock.h>
-#include <rtems/score/percpu.h>
 #include <rtems/score/priority.h>
 #include <rtems/score/rbtree.h>
-#include <rtems/score/states.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -41,6 +39,8 @@ extern "C" {
  */
 /**@{*/
 
+typedef struct Thread_Control Thread_Control;
+
 typedef struct Thread_queue_Control Thread_queue_Control;
 
 /**



More information about the vc mailing list