summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2015-12-14 16:34:50 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2016-02-03 10:00:55 +0100
commit2189b3e963f7e43e9fc577ab4f24c952cef5b08e (patch)
treec8766c8417fcb06105f4e9736b6eeeb0974d315f
parentOptional POSIX Message Queue initialization (diff)
downloadrtems-2189b3e963f7e43e9fc577ab4f24c952cef5b08e.tar.bz2
Optional POSIX Semaphore initialization
Update #2408.
-rw-r--r--cpukit/posix/include/rtems/posix/semaphoreimpl.h9
-rw-r--r--cpukit/posix/src/semaphore.c11
-rw-r--r--cpukit/sapi/src/posixapi.c2
-rw-r--r--cpukit/score/include/rtems/sysinit.h1
-rw-r--r--testsuites/sptests/spsysinit01/init.c17
5 files changed, 29 insertions, 11 deletions
diff --git a/cpukit/posix/include/rtems/posix/semaphoreimpl.h b/cpukit/posix/include/rtems/posix/semaphoreimpl.h
index eeea51c488..fe5ee44034 100644
--- a/cpukit/posix/include/rtems/posix/semaphoreimpl.h
+++ b/cpukit/posix/include/rtems/posix/semaphoreimpl.h
@@ -33,7 +33,7 @@ extern "C" {
* This defines the information control block used to manage
* this class of objects.
*/
-POSIX_EXTERN Objects_Information _POSIX_Semaphore_Information;
+extern Objects_Information _POSIX_Semaphore_Information;
/**
* This defines the mapping from Score status codes to POSIX return codes.
@@ -41,13 +41,6 @@ POSIX_EXTERN Objects_Information _POSIX_Semaphore_Information;
extern const int
_POSIX_Semaphore_Return_codes[CORE_SEMAPHORE_STATUS_LAST + 1];
-/**
- * @brief POSIX Semaphore Manager Initialization
- *
- * This routine performs the initialization necessary for this manager.
- */
-void _POSIX_Semaphore_Manager_initialization(void);
-
RTEMS_INLINE_ROUTINE POSIX_Semaphore_Control *
_POSIX_Semaphore_Allocate_unprotected( void )
{
diff --git a/cpukit/posix/src/semaphore.c b/cpukit/posix/src/semaphore.c
index 5830373d3a..db3ae0c2b5 100644
--- a/cpukit/posix/src/semaphore.c
+++ b/cpukit/posix/src/semaphore.c
@@ -28,9 +28,12 @@
#include <rtems/system.h>
#include <rtems/config.h>
+#include <rtems/sysinit.h>
#include <rtems/posix/semaphoreimpl.h>
#include <rtems/seterr.h>
+Objects_Information _POSIX_Semaphore_Information;
+
/*
* _POSIX_Semaphore_Manager_initialization
*
@@ -41,7 +44,7 @@
* Output parameters: NONE
*/
-void _POSIX_Semaphore_Manager_initialization(void)
+static void _POSIX_Semaphore_Manager_initialization(void)
{
_Objects_Initialize_information(
&_POSIX_Semaphore_Information, /* object information table */
@@ -60,3 +63,9 @@ void _POSIX_Semaphore_Manager_initialization(void)
#endif
);
}
+
+RTEMS_SYSINIT_ITEM(
+ _POSIX_Semaphore_Manager_initialization,
+ RTEMS_SYSINIT_POSIX_SEMAPHORE,
+ RTEMS_SYSINIT_ORDER_MIDDLE
+);
diff --git a/cpukit/sapi/src/posixapi.c b/cpukit/sapi/src/posixapi.c
index 8d99678196..f1997bfd08 100644
--- a/cpukit/sapi/src/posixapi.c
+++ b/cpukit/sapi/src/posixapi.c
@@ -37,7 +37,6 @@
#include <rtems/posix/psignalimpl.h>
#include <rtems/posix/rwlockimpl.h>
#include <rtems/posix/timerimpl.h>
-#include <rtems/posix/semaphoreimpl.h>
#include <rtems/posix/spinlockimpl.h>
#endif
@@ -60,7 +59,6 @@ void _POSIX_API_Initialize(void)
_POSIX_Key_Manager_initialization();
#ifdef RTEMS_POSIX_API
- _POSIX_Semaphore_Manager_initialization();
_POSIX_Timer_Manager_initialization();
_POSIX_Barrier_Manager_initialization();
_POSIX_RWLock_Manager_initialization();
diff --git a/cpukit/score/include/rtems/sysinit.h b/cpukit/score/include/rtems/sysinit.h
index bce999e60b..b32723c81a 100644
--- a/cpukit/score/include/rtems/sysinit.h
+++ b/cpukit/score/include/rtems/sysinit.h
@@ -47,6 +47,7 @@ extern "C" {
#define RTEMS_SYSINIT_POSIX_CONDITION_VARIABLE 000362
#define RTEMS_SYSINIT_POSIX_MUTEX 000363
#define RTEMS_SYSINIT_POSIX_MESSAGE_QUEUE 000364
+#define RTEMS_SYSINIT_POSIX_SEMAPHORE 000365
#define RTEMS_SYSINIT_POSIX_CLEANUP 00036a
#define RTEMS_SYSINIT_IDLE_THREADS 000380
#define RTEMS_SYSINIT_BSP_LIBC 000400
diff --git a/testsuites/sptests/spsysinit01/init.c b/testsuites/sptests/spsysinit01/init.c
index 9e97fdb1fb..6854d7025a 100644
--- a/testsuites/sptests/spsysinit01/init.c
+++ b/testsuites/sptests/spsysinit01/init.c
@@ -33,6 +33,7 @@
#include <rtems/posix/muteximpl.h>
#include <rtems/posix/psignalimpl.h>
#include <rtems/posix/pthreadimpl.h>
+#include <rtems/posix/semaphoreimpl.h>
#endif /* RTEMS_POSIX_API */
#include <rtems/rtems/barrierimpl.h>
#include <rtems/rtems/dpmemimpl.h>
@@ -95,6 +96,8 @@ typedef enum {
POSIX_MUTEX_POST,
POSIX_MESSAGE_QUEUE_PRE,
POSIX_MESSAGE_QUEUE_POST,
+ POSIX_SEMAPHORE_PRE,
+ POSIX_SEMAPHORE_POST,
POSIX_CLEANUP_PRE,
POSIX_CLEANUP_POST,
#endif /* RTEMS_POSIX_API */
@@ -407,6 +410,18 @@ LAST(RTEMS_SYSINIT_POSIX_MESSAGE_QUEUE)
next_step(POSIX_MESSAGE_QUEUE_POST);
}
+FIRST(RTEMS_SYSINIT_POSIX_SEMAPHORE)
+{
+ assert(_POSIX_Semaphore_Information.maximum == 0);
+ next_step(POSIX_SEMAPHORE_PRE);
+}
+
+LAST(RTEMS_SYSINIT_POSIX_SEMAPHORE)
+{
+ assert(_POSIX_Semaphore_Information.maximum != 0);
+ next_step(POSIX_SEMAPHORE_POST);
+}
+
static size_t user_extensions_pre_posix_cleanup;
FIRST(RTEMS_SYSINIT_POSIX_CLEANUP)
@@ -542,6 +557,8 @@ static void Init(rtems_task_argument arg)
#define CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES 1
+#define CONFIGURE_MAXIMUM_POSIX_SEMAPHORES 1
+
#define CONFIGURE_MAXIMUM_POSIX_THREADS 1
#endif /* RTEMS_POSIX_API */