[rtems commit] Optional Classic Semaphore initialization

Sebastian Huber sebh at rtems.org
Wed Feb 3 09:31:12 UTC 2016


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

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Mon Dec 14 15:05:47 2015 +0100

Optional Classic Semaphore initialization

Update #2408.

---

 cpukit/rtems/Makefile.am                   |  1 -
 cpukit/rtems/include/rtems/rtems/semimpl.h | 24 +-----------------------
 cpukit/rtems/src/sem.c                     | 15 +++++++++------
 cpukit/rtems/src/semdata.c                 | 24 ------------------------
 cpukit/sapi/src/rtemsapi.c                 |  2 --
 cpukit/score/include/rtems/sysinit.h       |  1 +
 testsuites/sptests/spsysinit01/init.c      | 17 +++++++++++++++++
 7 files changed, 28 insertions(+), 56 deletions(-)

diff --git a/cpukit/rtems/Makefile.am b/cpukit/rtems/Makefile.am
index 2fd8ecb..d28e1bd 100644
--- a/cpukit/rtems/Makefile.am
+++ b/cpukit/rtems/Makefile.am
@@ -194,7 +194,6 @@ librtems_a_SOURCES += src/semobtain.c
 librtems_a_SOURCES += src/semrelease.c
 librtems_a_SOURCES += src/semflush.c
 librtems_a_SOURCES += src/semtranslatereturncode.c
-librtems_a_SOURCES += src/semdata.c
 librtems_a_SOURCES += src/semsetpriority.c
 
 ## EVENT_C_FILES
diff --git a/cpukit/rtems/include/rtems/rtems/semimpl.h b/cpukit/rtems/include/rtems/rtems/semimpl.h
index 8c93e93..68eac6f 100644
--- a/cpukit/rtems/include/rtems/rtems/semimpl.h
+++ b/cpukit/rtems/include/rtems/rtems/semimpl.h
@@ -27,25 +27,10 @@ extern "C" {
 #endif
 
 /**
- * @brief Instantiate Semaphore Data
- *
- * Semaphore Manager -- Data Instantiation
- *
- * This constant is defined to extern most of the time when using
- * this header file. However by defining it to nothing, the data
- * declared in this header file can be instantiated. This is done
- * in a single per manager file.
- *
- */
-#ifndef RTEMS_SEM_EXTERN
-#define RTEMS_SEM_EXTERN extern
-#endif
-
-/**
  *  The following defines the information control block used to manage
  *  this class of objects.
  */
-RTEMS_SEM_EXTERN Objects_Information  _Semaphore_Information;
+extern Objects_Information _Semaphore_Information;
 
 extern const rtems_status_code
   _Semaphore_Translate_core_mutex_return_code_[];
@@ -54,13 +39,6 @@ extern const rtems_status_code
   _Semaphore_Translate_core_semaphore_return_code_[];
 
 /**
- *  @brief Semaphore Manager Initialization
- *
- *  This routine performs the initialization necessary for this manager.
- */
-void _Semaphore_Manager_initialization(void);
-
-/**
  * @brief Semaphore Translate Core Mutex Return Code
  *
  * This function returns a RTEMS status code based on the mutex
diff --git a/cpukit/rtems/src/sem.c b/cpukit/rtems/src/sem.c
index 7612c82..13615eb 100644
--- a/cpukit/rtems/src/sem.c
+++ b/cpukit/rtems/src/sem.c
@@ -20,19 +20,16 @@
 
 #include <rtems/system.h>
 #include <rtems/config.h>
+#include <rtems/sysinit.h>
 #include <rtems/rtems/status.h>
 #include <rtems/rtems/support.h>
 #include <rtems/rtems/attrimpl.h>
-#include <rtems/score/isr.h>
 #include <rtems/rtems/options.h>
 #include <rtems/rtems/semimpl.h>
-#include <rtems/score/coremuteximpl.h>
-#include <rtems/score/coresemimpl.h>
-#include <rtems/score/thread.h>
 
-#include <rtems/score/interr.h>
+Objects_Information _Semaphore_Information;
 
-void _Semaphore_Manager_initialization(void)
+static void _Semaphore_Manager_initialization(void)
 {
   _Objects_Initialize_information(
     &_Semaphore_Information,     /* object information table */
@@ -62,3 +59,9 @@ void _Semaphore_Manager_initialization(void)
 #endif
 
 }
+
+RTEMS_SYSINIT_ITEM(
+  _Semaphore_Manager_initialization,
+  RTEMS_SYSINIT_CLASSIC_SEMAPHORE,
+  RTEMS_SYSINIT_ORDER_MIDDLE
+);
diff --git a/cpukit/rtems/src/semdata.c b/cpukit/rtems/src/semdata.c
deleted file mode 100644
index bac5c81..0000000
--- a/cpukit/rtems/src/semdata.c
+++ /dev/null
@@ -1,24 +0,0 @@
-/**
- * @file
- *
- * @brief Instantiate Semaphore Data
- * @ingroup ClassicSem Semaphores
- */
-
-/*
- *  COPYRIGHT (c) 1989-2007.
- *  On-Line Applications Research Corporation (OAR).
- *
- *  The license and distribution terms for this file may be
- *  found in the file LICENSE in this distribution or at
- *  http://www.rtems.org/license/LICENSE.
- */
-
-#if HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-/* instantiate semaphore data */
-#define RTEMS_SEM_EXTERN
-
-#include <rtems/rtems/semimpl.h>
diff --git a/cpukit/sapi/src/rtemsapi.c b/cpukit/sapi/src/rtemsapi.c
index e66643c..1d1c932 100644
--- a/cpukit/sapi/src/rtemsapi.c
+++ b/cpukit/sapi/src/rtemsapi.c
@@ -32,11 +32,9 @@
 #include <rtems/rtems/partimpl.h>
 #include <rtems/rtems/ratemonimpl.h>
 #include <rtems/rtems/regionimpl.h>
-#include <rtems/rtems/semimpl.h>
 
 void _RTEMS_API_Initialize(void)
 {
-  _Semaphore_Manager_initialization();
   _Partition_Manager_initialization();
   _Region_Manager_initialization();
   _Dual_ported_memory_Manager_initialization();
diff --git a/cpukit/score/include/rtems/sysinit.h b/cpukit/score/include/rtems/sysinit.h
index 56b6c3b..aaafec5 100644
--- a/cpukit/score/include/rtems/sysinit.h
+++ b/cpukit/score/include/rtems/sysinit.h
@@ -36,6 +36,7 @@ extern "C" {
 #define RTEMS_SYSINIT_CLASSIC_SIGNAL             000342
 #define RTEMS_SYSINIT_CLASSIC_EVENT              000343
 #define RTEMS_SYSINIT_CLASSIC_MESSAGE_QUEUE      000344
+#define RTEMS_SYSINIT_CLASSIC_SEMAPHORE          000345
 #define RTEMS_SYSINIT_IDLE_THREADS               000380
 #define RTEMS_SYSINIT_BSP_LIBC                   000400
 #define RTEMS_SYSINIT_BEFORE_DRIVERS             000500
diff --git a/testsuites/sptests/spsysinit01/init.c b/testsuites/sptests/spsysinit01/init.c
index 753218e..f9d2701 100644
--- a/testsuites/sptests/spsysinit01/init.c
+++ b/testsuites/sptests/spsysinit01/init.c
@@ -26,6 +26,7 @@
 
 #include <rtems/extensionimpl.h>
 #include <rtems/rtems/messageimpl.h>
+#include <rtems/rtems/semimpl.h>
 #include <rtems/rtems/tasksimpl.h>
 #include <rtems/rtems/timerimpl.h>
 #include <rtems/score/apimutex.h>
@@ -56,6 +57,8 @@ typedef enum {
   CLASSIC_EVENT_POST,
   CLASSIC_MESSAGE_QUEUE_PRE,
   CLASSIC_MESSAGE_QUEUE_POST,
+  CLASSIC_SEMAPHORE_PRE,
+  CLASSIC_SEMAPHORE_POST,
   IDLE_THREADS_PRE,
   IDLE_THREADS_POST,
   BSP_LIBC_PRE,
@@ -219,6 +222,18 @@ LAST(RTEMS_SYSINIT_CLASSIC_MESSAGE_QUEUE)
   next_step(CLASSIC_MESSAGE_QUEUE_POST);
 }
 
+FIRST(RTEMS_SYSINIT_CLASSIC_SEMAPHORE)
+{
+  assert(_Semaphore_Information.maximum == 0);
+  next_step(CLASSIC_SEMAPHORE_PRE);
+}
+
+LAST(RTEMS_SYSINIT_CLASSIC_SEMAPHORE)
+{
+  assert(_Semaphore_Information.maximum != 0);
+  next_step(CLASSIC_SEMAPHORE_POST);
+}
+
 FIRST(RTEMS_SYSINIT_IDLE_THREADS)
 {
   assert(_System_state_Is_before_initialization(_System_state_Get()));
@@ -306,6 +321,8 @@ static void Init(rtems_task_argument arg)
 
 #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 1
 
+#define CONFIGURE_MAXIMUM_SEMAPHORES 1
+
 #define CONFIGURE_MAXIMUM_TASKS 1
 
 #define CONFIGURE_MAXIMUM_TIMERS 1



More information about the vc mailing list