[rtems commit] config: Add <rtems/confdefs/threads.h>

Sebastian Huber sebh at rtems.org
Tue Feb 25 11:32:19 UTC 2020


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

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Thu Feb 20 14:24:46 2020 +0100

config: Add <rtems/confdefs/threads.h>

Remove all comments and copyrightable content from the moved content.
Use BSD-2-Clause license for new file.

Update #3053.
Update #3875.

---

 cpukit/headers.am                       |   1 +
 cpukit/include/rtems/confdefs.h         | 192 +-------------------------
 cpukit/include/rtems/confdefs/threads.h | 234 ++++++++++++++++++++++++++++++++
 cpukit/posix/src/pthread.c              |   2 +
 4 files changed, 238 insertions(+), 191 deletions(-)

diff --git a/cpukit/headers.am b/cpukit/headers.am
index ba6222f..2a7e5a8 100644
--- a/cpukit/headers.am
+++ b/cpukit/headers.am
@@ -199,6 +199,7 @@ include_rtems_confdefs_HEADERS += include/rtems/confdefs/newlib.h
 include_rtems_confdefs_HEADERS += include/rtems/confdefs/obsolete.h
 include_rtems_confdefs_HEADERS += include/rtems/confdefs/percpu.h
 include_rtems_confdefs_HEADERS += include/rtems/confdefs/scheduler.h
+include_rtems_confdefs_HEADERS += include/rtems/confdefs/threads.h
 include_rtems_confdefs_HEADERS += include/rtems/confdefs/unlimited.h
 include_rtems_debugger_HEADERS += include/rtems/debugger/rtems-debugger-bsp.h
 include_rtems_debugger_HEADERS += include/rtems/debugger/rtems-debugger-remote.h
diff --git a/cpukit/include/rtems/confdefs.h b/cpukit/include/rtems/confdefs.h
index c48a2aa..82b6f11 100644
--- a/cpukit/include/rtems/confdefs.h
+++ b/cpukit/include/rtems/confdefs.h
@@ -37,7 +37,6 @@
 #include <rtems/rtems/ratemondata.h>
 #include <rtems/rtems/regiondata.h>
 #include <rtems/rtems/semdata.h>
-#include <rtems/rtems/tasksdata.h>
 #include <rtems/rtems/timerdata.h>
 #include <rtems/posix/key.h>
 #include <rtems/posix/mqueue.h>
@@ -61,7 +60,7 @@
 #include <rtems/confdefs/newlib.h>
 #include <rtems/confdefs/percpu.h>
 #include <rtems/confdefs/scheduler.h>
-#include <rtems/confdefs/unlimited.h>
+#include <rtems/confdefs/threads.h>
 
 #include <limits.h>
 
@@ -157,18 +156,6 @@ extern "C" {
  */
 /**@{*/
 
-/** This configures the maximum number of Classic API tasks. */
-#ifndef CONFIGURE_MAXIMUM_TASKS
-  #define CONFIGURE_MAXIMUM_TASKS               0
-#endif
-
-/*
- * This is calculated to account for the maximum number of Classic API
- * tasks used by the application and configured RTEMS capabilities.
- */
-#define _CONFIGURE_TASKS \
-  (CONFIGURE_MAXIMUM_TASKS + _CONFIGURE_LIBBLOCK_TASKS)
-
 #ifndef CONFIGURE_MAXIMUM_TIMERS
   /** This specifies the maximum number of Classic API timers. */
   #define CONFIGURE_MAXIMUM_TIMERS             0
@@ -257,14 +244,6 @@ extern "C" {
      (CONFIGURE_MAXIMUM_POSIX_THREADS + CONFIGURE_MAXIMUM_TASKS))
 #endif
 
-/**
- * This configuration parameter specifies the maximum number of
- * POSIX API threads.
- */
-#ifndef CONFIGURE_MAXIMUM_POSIX_THREADS
-  #define CONFIGURE_MAXIMUM_POSIX_THREADS 0
-#endif
-
 /*
  * Account for the object control structures plus the name
  * of the object to be duplicated.
@@ -478,129 +457,7 @@ extern "C" {
     _CONFIGURE_HEAP_HANDLER_OVERHEAD \
   )
 
-#ifndef CONFIGURE_MAXIMUM_THREAD_NAME_SIZE
-  #define CONFIGURE_MAXIMUM_THREAD_NAME_SIZE THREAD_DEFAULT_MAXIMUM_NAME_SIZE
-#endif
-
 #ifdef CONFIGURE_INIT
-  typedef union {
-    Scheduler_Node Base;
-    #ifdef CONFIGURE_SCHEDULER_CBS
-      Scheduler_CBS_Node CBS;
-    #endif
-    #ifdef CONFIGURE_SCHEDULER_EDF
-      Scheduler_EDF_Node EDF;
-    #endif
-    #ifdef CONFIGURE_SCHEDULER_EDF_SMP
-      Scheduler_EDF_SMP_Node EDF_SMP;
-    #endif
-    #ifdef CONFIGURE_SCHEDULER_PRIORITY
-      Scheduler_priority_Node Priority;
-    #endif
-    #ifdef CONFIGURE_SCHEDULER_SIMPLE_SMP
-      Scheduler_SMP_Node Simple_SMP;
-    #endif
-    #ifdef CONFIGURE_SCHEDULER_PRIORITY_SMP
-      Scheduler_priority_SMP_Node Priority_SMP;
-    #endif
-    #ifdef CONFIGURE_SCHEDULER_PRIORITY_AFFINITY_SMP
-      Scheduler_priority_affinity_SMP_Node Priority_affinity_SMP;
-    #endif
-    #ifdef CONFIGURE_SCHEDULER_STRONG_APA
-      Scheduler_strong_APA_Node Strong_APA;
-    #endif
-    #ifdef CONFIGURE_SCHEDULER_USER_PER_THREAD
-      CONFIGURE_SCHEDULER_USER_PER_THREAD User;
-    #endif
-  } Configuration_Scheduler_node;
-
-  #ifdef RTEMS_SMP
-    const size_t _Scheduler_Node_size = sizeof( Configuration_Scheduler_node );
-  #endif
-
-  const size_t _Thread_Maximum_name_size = CONFIGURE_MAXIMUM_THREAD_NAME_SIZE;
-
-  struct Thread_Configured_control {
-    Thread_Control Control;
-    #if CONFIGURE_MAXIMUM_USER_EXTENSIONS > 0
-      void *extensions[ CONFIGURE_MAXIMUM_USER_EXTENSIONS + 1 ];
-    #endif
-    Configuration_Scheduler_node Scheduler_nodes[ _CONFIGURE_SCHEDULER_COUNT ];
-    RTEMS_API_Control API_RTEMS;
-    #ifdef RTEMS_POSIX_API
-      POSIX_API_Control API_POSIX;
-    #endif
-    #if CONFIGURE_MAXIMUM_THREAD_NAME_SIZE > 1
-      char name[ CONFIGURE_MAXIMUM_THREAD_NAME_SIZE ];
-    #endif
-    #ifdef _CONFIGURE_ENABLE_NEWLIB_REENTRANCY
-      struct _reent Newlib;
-    #else
-      struct { /* Empty */ } Newlib;
-    #endif
-  };
-
-  const Thread_Control_add_on _Thread_Control_add_ons[] = {
-    {
-      offsetof( Thread_Configured_control, Control.Scheduler.nodes ),
-      offsetof( Thread_Configured_control, Scheduler_nodes )
-    }, {
-      offsetof(
-        Thread_Configured_control,
-        Control.API_Extensions[ THREAD_API_RTEMS ]
-      ),
-      offsetof( Thread_Configured_control, API_RTEMS )
-    }, {
-      offsetof(
-        Thread_Configured_control,
-        Control.libc_reent
-      ),
-      offsetof( Thread_Configured_control, Newlib )
-    }
-    #if CONFIGURE_MAXIMUM_THREAD_NAME_SIZE > 1
-      , {
-        offsetof(
-          Thread_Configured_control,
-          Control.Join_queue.Queue.name
-        ),
-        offsetof( Thread_Configured_control, name )
-      }
-    #endif
-    #ifdef RTEMS_POSIX_API
-      , {
-        offsetof(
-          Thread_Configured_control,
-          Control.API_Extensions[ THREAD_API_POSIX ]
-        ),
-        offsetof( Thread_Configured_control, API_POSIX )
-      }
-    #endif
-  };
-
-  const size_t _Thread_Control_add_on_count =
-    RTEMS_ARRAY_SIZE( _Thread_Control_add_ons );
-
-  #if defined(RTEMS_SMP)
-    struct Thread_queue_Configured_heads {
-      Thread_queue_Heads Heads;
-        Thread_queue_Priority_queue Priority[ _CONFIGURE_SCHEDULER_COUNT ];
-    };
-
-    const size_t _Thread_queue_Heads_size =
-      sizeof( Thread_queue_Configured_heads );
-  #endif
-
-  const size_t _Thread_Initial_thread_count =
-    rtems_resource_maximum_per_allocation( _CONFIGURE_TASKS ) +
-    rtems_resource_maximum_per_allocation( CONFIGURE_MAXIMUM_POSIX_THREADS );
-
-  THREAD_INFORMATION_DEFINE(
-    _Thread,
-    OBJECTS_INTERNAL_API,
-    OBJECTS_INTERNAL_THREADS,
-    _CONFIGURE_MAXIMUM_PROCESSORS + _CONFIGURE_MPCI_RECEIVE_SERVER_COUNT
-  );
-
   #if CONFIGURE_MAXIMUM_BARRIERS > 0
     BARRIER_INFORMATION_DEFINE( CONFIGURE_MAXIMUM_BARRIERS );
   #endif
@@ -636,15 +493,6 @@ extern "C" {
     TIMER_INFORMATION_DEFINE( CONFIGURE_MAXIMUM_TIMERS );
   #endif
 
-  #if _CONFIGURE_TASKS > 0
-    THREAD_INFORMATION_DEFINE(
-      _RTEMS_tasks,
-      OBJECTS_CLASSIC_API,
-      OBJECTS_RTEMS_TASKS,
-      _CONFIGURE_TASKS
-    );
-  #endif
-
   #if CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS > 0
     POSIX_Keys_Key_value_pair _POSIX_Keys_Key_value_pairs[
       rtems_resource_maximum_per_allocation(
@@ -674,15 +522,6 @@ extern "C" {
     POSIX_SHM_INFORMATION_DEFINE( CONFIGURE_MAXIMUM_POSIX_SHMS );
   #endif
 
-  #if CONFIGURE_MAXIMUM_POSIX_THREADS > 0
-    THREAD_INFORMATION_DEFINE(
-      _POSIX_Threads,
-      OBJECTS_POSIX_API,
-      OBJECTS_POSIX_THREADS,
-      CONFIGURE_MAXIMUM_POSIX_THREADS
-    );
-  #endif
-
   #ifdef RTEMS_POSIX_API
     #if CONFIGURE_MAXIMUM_POSIX_QUEUED_SIGNALS > 0
       const uint32_t _POSIX_signals_Maximum_queued_signals =
@@ -698,9 +537,6 @@ extern "C" {
     #endif
   #endif
 
-  const size_t _POSIX_Threads_Minimum_stack_size =
-    CONFIGURE_MINIMUM_POSIX_THREAD_STACK_SIZE;
-
   /**
    * This variable specifies the minimum stack size for tasks in an RTEMS
    * application.
@@ -780,32 +616,6 @@ extern "C" {
 #ifdef CONFIGURE_INIT
 
 /*
- *  Make sure a task/thread of some sort is configured.
- *
- *  When analyzing RTEMS to find the smallest possible of memory
- *  that must be allocated, you probably do want to configure 0
- *  tasks/threads so there is a smaller set of calls to _Workspace_Allocate
- *  to analyze.
- */
-#if !defined(CONFIGURE_IDLE_TASK_INITIALIZES_APPLICATION) \
-  && CONFIGURE_MAXIMUM_TASKS == 0 \
-  && CONFIGURE_MAXIMUM_POSIX_THREADS == 0
-  #error "CONFIGURATION ERROR: No tasks or threads configured!!"
-#endif
-
-#ifndef RTEMS_SCHEDSIM
-/*
- *  Make sure at least one of the initialization task/thread
- *  tables was defined.
- */
-#if !defined(CONFIGURE_RTEMS_INIT_TASKS_TABLE) && \
-    !defined(CONFIGURE_POSIX_INIT_THREAD_TABLE) && \
-    !defined(CONFIGURE_IDLE_TASK_INITIALIZES_APPLICATION)
-#error "CONFIGURATION ERROR: No initialization tasks or threads configured!!"
-#endif
-#endif
-
-/*
  * POSIX Key pair shouldn't be less than POSIX Key, which is highly
  * likely to be error.
  */
diff --git a/cpukit/include/rtems/confdefs/threads.h b/cpukit/include/rtems/confdefs/threads.h
new file mode 100644
index 0000000..7288243
--- /dev/null
+++ b/cpukit/include/rtems/confdefs/threads.h
@@ -0,0 +1,234 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
+/**
+ * @file
+ *
+ * @ingroup RTEMSApplicationConfiguration
+ *
+ * @brief Evaluate Thread Configuration Options
+ */
+
+/*
+ * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _RTEMS_CONFDEFS_THREADS_H
+#define _RTEMS_CONFDEFS_THREADS_H
+
+#ifndef __CONFIGURATION_TEMPLATE_h
+#error "Do not include this file directly, use <rtems/confdefs.h> instead"
+#endif
+
+#ifdef CONFIGURE_INIT
+
+#include <rtems/confdefs/bdbuf.h>
+#include <rtems/confdefs/extensions.h>
+#include <rtems/confdefs/mpci.h>
+#include <rtems/confdefs/percpu.h>
+#include <rtems/confdefs/scheduler.h>
+#include <rtems/confdefs/unlimited.h>
+#include <rtems/score/thread.h>
+#include <rtems/posix/threadsup.h>
+#include <rtems/rtems/tasksdata.h>
+
+#ifndef CONFIGURE_MAXIMUM_TASKS
+  #define CONFIGURE_MAXIMUM_TASKS 0
+#endif
+
+#define _CONFIGURE_TASKS ( CONFIGURE_MAXIMUM_TASKS + _CONFIGURE_LIBBLOCK_TASKS )
+
+#ifndef CONFIGURE_MAXIMUM_POSIX_THREADS
+  #define CONFIGURE_MAXIMUM_POSIX_THREADS 0
+#endif
+
+#if CONFIGURE_MAXIMUM_POSIX_THREADS > 0
+  #include <rtems/posix/pthread.h>
+#endif
+
+#if !defined(CONFIGURE_IDLE_TASK_INITIALIZES_APPLICATION) \
+  && CONFIGURE_MAXIMUM_TASKS == 0 \
+  && CONFIGURE_MAXIMUM_POSIX_THREADS == 0
+  #error "You must define one of CONFIGURE_IDLE_TASK_INITIALIZES_APPLICATION, CONFIGURE_MAXIMUM_TASKS, and CONFIGURE_MAXIMUM_POSIX_THREADS"
+#endif
+
+#if !defined(CONFIGURE_RTEMS_INIT_TASKS_TABLE) \
+  && !defined(CONFIGURE_POSIX_INIT_THREAD_TABLE) \
+  && !defined(CONFIGURE_IDLE_TASK_INITIALIZES_APPLICATION)
+  #error "You must define one of CONFIGURE_IDLE_TASK_INITIALIZES_APPLICATION, CONFIGURE_RTEMS_INIT_TASKS_TABLE, and CONFIGURE_POSIX_INIT_THREAD_TABLE"
+#endif
+
+#ifndef CONFIGURE_MAXIMUM_THREAD_NAME_SIZE
+  #define CONFIGURE_MAXIMUM_THREAD_NAME_SIZE THREAD_DEFAULT_MAXIMUM_NAME_SIZE
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef union {
+  Scheduler_Node Base;
+  #ifdef CONFIGURE_SCHEDULER_CBS
+    Scheduler_CBS_Node CBS;
+  #endif
+  #ifdef CONFIGURE_SCHEDULER_EDF
+    Scheduler_EDF_Node EDF;
+  #endif
+  #ifdef CONFIGURE_SCHEDULER_EDF_SMP
+    Scheduler_EDF_SMP_Node EDF_SMP;
+  #endif
+  #ifdef CONFIGURE_SCHEDULER_PRIORITY
+    Scheduler_priority_Node Priority;
+  #endif
+  #ifdef CONFIGURE_SCHEDULER_SIMPLE_SMP
+    Scheduler_SMP_Node Simple_SMP;
+  #endif
+  #ifdef CONFIGURE_SCHEDULER_PRIORITY_SMP
+    Scheduler_priority_SMP_Node Priority_SMP;
+  #endif
+  #ifdef CONFIGURE_SCHEDULER_PRIORITY_AFFINITY_SMP
+    Scheduler_priority_affinity_SMP_Node Priority_affinity_SMP;
+  #endif
+  #ifdef CONFIGURE_SCHEDULER_STRONG_APA
+    Scheduler_strong_APA_Node Strong_APA;
+  #endif
+  #ifdef CONFIGURE_SCHEDULER_USER_PER_THREAD
+    CONFIGURE_SCHEDULER_USER_PER_THREAD User;
+  #endif
+} Configuration_Scheduler_node;
+
+#ifdef RTEMS_SMP
+  const size_t _Scheduler_Node_size = sizeof( Configuration_Scheduler_node );
+#endif
+
+const size_t _Thread_Maximum_name_size = CONFIGURE_MAXIMUM_THREAD_NAME_SIZE;
+
+struct Thread_Configured_control {
+  Thread_Control Control;
+  #if CONFIGURE_MAXIMUM_USER_EXTENSIONS > 0
+    void *extensions[ CONFIGURE_MAXIMUM_USER_EXTENSIONS + 1 ];
+  #endif
+  Configuration_Scheduler_node Scheduler_nodes[ _CONFIGURE_SCHEDULER_COUNT ];
+  RTEMS_API_Control API_RTEMS;
+  #ifdef RTEMS_POSIX_API
+    POSIX_API_Control API_POSIX;
+  #endif
+  #if CONFIGURE_MAXIMUM_THREAD_NAME_SIZE > 1
+    char name[ CONFIGURE_MAXIMUM_THREAD_NAME_SIZE ];
+  #endif
+  #ifdef _CONFIGURE_ENABLE_NEWLIB_REENTRANCY
+    struct _reent Newlib;
+  #else
+    struct { /* Empty */ } Newlib;
+  #endif
+};
+
+const Thread_Control_add_on _Thread_Control_add_ons[] = {
+  {
+    offsetof( Thread_Configured_control, Control.Scheduler.nodes ),
+    offsetof( Thread_Configured_control, Scheduler_nodes )
+  }, {
+    offsetof(
+      Thread_Configured_control,
+      Control.API_Extensions[ THREAD_API_RTEMS ]
+    ),
+    offsetof( Thread_Configured_control, API_RTEMS )
+  }, {
+    offsetof(
+      Thread_Configured_control,
+      Control.libc_reent
+    ),
+    offsetof( Thread_Configured_control, Newlib )
+  }
+  #if CONFIGURE_MAXIMUM_THREAD_NAME_SIZE > 1
+    , {
+      offsetof(
+        Thread_Configured_control,
+        Control.Join_queue.Queue.name
+      ),
+      offsetof( Thread_Configured_control, name )
+    }
+  #endif
+  #ifdef RTEMS_POSIX_API
+    , {
+      offsetof(
+        Thread_Configured_control,
+        Control.API_Extensions[ THREAD_API_POSIX ]
+      ),
+      offsetof( Thread_Configured_control, API_POSIX )
+    }
+  #endif
+};
+
+const size_t _Thread_Control_add_on_count =
+  RTEMS_ARRAY_SIZE( _Thread_Control_add_ons );
+
+#ifdef RTEMS_SMP
+  struct Thread_queue_Configured_heads {
+    Thread_queue_Heads Heads;
+      Thread_queue_Priority_queue Priority[ _CONFIGURE_SCHEDULER_COUNT ];
+  };
+
+  const size_t _Thread_queue_Heads_size =
+    sizeof( Thread_queue_Configured_heads );
+#endif
+
+const size_t _Thread_Initial_thread_count =
+  rtems_resource_maximum_per_allocation( _CONFIGURE_TASKS ) +
+  rtems_resource_maximum_per_allocation( CONFIGURE_MAXIMUM_POSIX_THREADS );
+
+THREAD_INFORMATION_DEFINE(
+  _Thread,
+  OBJECTS_INTERNAL_API,
+  OBJECTS_INTERNAL_THREADS,
+  _CONFIGURE_MAXIMUM_PROCESSORS + _CONFIGURE_MPCI_RECEIVE_SERVER_COUNT
+);
+
+#if _CONFIGURE_TASKS > 0
+  THREAD_INFORMATION_DEFINE(
+    _RTEMS_tasks,
+    OBJECTS_CLASSIC_API,
+    OBJECTS_RTEMS_TASKS,
+    _CONFIGURE_TASKS
+  );
+#endif
+
+#if CONFIGURE_MAXIMUM_POSIX_THREADS > 0
+  const size_t _POSIX_Threads_Minimum_stack_size =
+    CONFIGURE_MINIMUM_POSIX_THREAD_STACK_SIZE;
+
+  THREAD_INFORMATION_DEFINE(
+    _POSIX_Threads,
+    OBJECTS_POSIX_API,
+    OBJECTS_POSIX_THREADS,
+    CONFIGURE_MAXIMUM_POSIX_THREADS
+  );
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CONFIGURE_INIT */
+
+#endif /* _RTEMS_CONFDEFS_THREADS_H */
diff --git a/cpukit/posix/src/pthread.c b/cpukit/posix/src/pthread.c
index 18c8635..ff76c86 100644
--- a/cpukit/posix/src/pthread.c
+++ b/cpukit/posix/src/pthread.c
@@ -20,6 +20,8 @@
 
 #include <rtems/posix/pthread.h>
 
+const size_t _POSIX_Threads_Minimum_stack_size;
+
 THREAD_INFORMATION_DEFINE_ZERO(
   _POSIX_Threads,
   OBJECTS_POSIX_API,



More information about the vc mailing list