[PATCH 06/14] posix: Provide named semaphores by default
Sebastian Huber
sebastian.huber at embedded-brains.de
Mon Oct 29 09:03:15 UTC 2018
Update #2514.
---
cpukit/Makefile.am | 12 ++---
cpukit/include/rtems/confdefs.h | 77 ++++++++++++++-------------
cpukit/rtems/src/rtemsobjectgetapiclassname.c | 8 +--
3 files changed, 50 insertions(+), 47 deletions(-)
diff --git a/cpukit/Makefile.am b/cpukit/Makefile.am
index 71afecfdc2..3d9bead51a 100644
--- a/cpukit/Makefile.am
+++ b/cpukit/Makefile.am
@@ -551,7 +551,9 @@ librtemscpu_a_SOURCES += posix/src/pspindestroy.c
librtemscpu_a_SOURCES += posix/src/pspininit.c
librtemscpu_a_SOURCES += posix/src/pspinlock.c
librtemscpu_a_SOURCES += posix/src/pspinunlock.c
+librtemscpu_a_SOURCES += posix/src/psxnametoid.c
librtemscpu_a_SOURCES += posix/src/psxpriorityisvalid.c
+librtemscpu_a_SOURCES += posix/src/psxsemaphore.c
librtemscpu_a_SOURCES += posix/src/psxsemaphoreconfig.c
librtemscpu_a_SOURCES += posix/src/psxtimerconfig.c
librtemscpu_a_SOURCES += posix/src/psxtransschedparam.c
@@ -605,12 +607,16 @@ librtemscpu_a_SOURCES += posix/src/sched_rr_get_interval.c
librtemscpu_a_SOURCES += posix/src/sched_setparam.c
librtemscpu_a_SOURCES += posix/src/sched_setscheduler.c
librtemscpu_a_SOURCES += posix/src/sched_yield.c
+librtemscpu_a_SOURCES += posix/src/semaphoredeletesupp.c
+librtemscpu_a_SOURCES += posix/src/semclose.c
librtemscpu_a_SOURCES += posix/src/semdestroy.c
librtemscpu_a_SOURCES += posix/src/semgetvalue.c
librtemscpu_a_SOURCES += posix/src/seminit.c
+librtemscpu_a_SOURCES += posix/src/semopen.c
librtemscpu_a_SOURCES += posix/src/sempost.c
librtemscpu_a_SOURCES += posix/src/semtimedwait.c
librtemscpu_a_SOURCES += posix/src/semtrywait.c
+librtemscpu_a_SOURCES += posix/src/semunlink.c
librtemscpu_a_SOURCES += posix/src/semwait.c
librtemscpu_a_SOURCES += posix/src/setcancelstate.c
librtemscpu_a_SOURCES += posix/src/setcanceltype.c
@@ -1055,9 +1061,7 @@ librtemscpu_a_SOURCES += posix/src/psignalclearprocesssignals.c
librtemscpu_a_SOURCES += posix/src/psignalclearsignals.c
librtemscpu_a_SOURCES += posix/src/psignalsetprocesssignals.c
librtemscpu_a_SOURCES += posix/src/psignalunblockthread.c
-librtemscpu_a_SOURCES += posix/src/psxnametoid.c
librtemscpu_a_SOURCES += posix/src/psxpriorityisvalid.c
-librtemscpu_a_SOURCES += posix/src/psxsemaphore.c
librtemscpu_a_SOURCES += posix/src/psxtimercreate.c
librtemscpu_a_SOURCES += posix/src/psxtimerdelete.c
librtemscpu_a_SOURCES += posix/src/pthread.c
@@ -1069,10 +1073,6 @@ librtemscpu_a_SOURCES += posix/src/pthreadsetschedparam.c
librtemscpu_a_SOURCES += posix/src/pthreadsetschedprio.c
librtemscpu_a_SOURCES += posix/src/pthreadsigmask.c
librtemscpu_a_SOURCES += posix/src/ptimer.c
-librtemscpu_a_SOURCES += posix/src/semaphoredeletesupp.c
-librtemscpu_a_SOURCES += posix/src/semclose.c
-librtemscpu_a_SOURCES += posix/src/semopen.c
-librtemscpu_a_SOURCES += posix/src/semunlink.c
librtemscpu_a_SOURCES += posix/src/setitimer.c
librtemscpu_a_SOURCES += posix/src/shm.c
librtemscpu_a_SOURCES += posix/src/shmheap.c
diff --git a/cpukit/include/rtems/confdefs.h b/cpukit/include/rtems/confdefs.h
index aa3d23e80c..a38cdec8c0 100644
--- a/cpukit/include/rtems/confdefs.h
+++ b/cpukit/include/rtems/confdefs.h
@@ -32,6 +32,10 @@
#include <rtems/score/percpu.h>
#include <rtems/score/userextimpl.h>
#include <rtems/score/wkspace.h>
+#include <rtems/posix/key.h>
+#include <rtems/posix/semaphore.h>
+
+#include <limits.h>
#ifdef CONFIGURE_DISABLE_BSP_SETTINGS
#undef BSP_DEFAULT_UNIFIED_WORK_AREAS
@@ -1932,6 +1936,10 @@ extern rtems_initialization_tasks_table Initialization_tasks[];
#define CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS \
rtems_resource_unlimited(CONFIGURE_UNLIMITED_ALLOCATION_SIZE)
#endif
+ #if !defined(CONFIGURE_MAXIMUM_POSIX_SEMAPHORES)
+ #define CONFIGURE_MAXIMUM_POSIX_SEMAPHORES \
+ rtems_resource_unlimited(CONFIGURE_UNLIMITED_ALLOCATION_SIZE)
+ #endif
#ifdef RTEMS_POSIX_API
#if !defined(CONFIGURE_MAXIMUM_POSIX_THREADS)
@@ -1952,10 +1960,6 @@ extern rtems_initialization_tasks_table Initialization_tasks[];
#define CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES \
rtems_resource_unlimited(CONFIGURE_UNLIMITED_ALLOCATION_SIZE)
#endif
- #if !defined(CONFIGURE_MAXIMUM_POSIX_SEMAPHORES)
- #define CONFIGURE_MAXIMUM_POSIX_SEMAPHORES \
- rtems_resource_unlimited(CONFIGURE_UNLIMITED_ALLOCATION_SIZE)
- #endif
#if !defined(CONFIGURE_MAXIMUM_POSIX_SHMS)
#define CONFIGURE_MAXIMUM_POSIX_SHMS \
rtems_resource_unlimited(CONFIGURE_UNLIMITED_ALLOCATION_SIZE)
@@ -2256,8 +2260,6 @@ extern rtems_initialization_tasks_table Initialization_tasks[];
*/
/**@{*/
-#include <rtems/posix/key.h>
-
/**
* This configuration parameter specifies the maximum number of
* POSIX API keys.
@@ -2296,6 +2298,31 @@ extern rtems_initialization_tasks_table Initialization_tasks[];
_Configure_Max_Objects(_key_value_pairs) \
* sizeof(POSIX_Keys_Key_value_pair)))
+/*
+ * Account for the object control structures plus the name
+ * of the object to be duplicated.
+ */
+#define _Configure_POSIX_Named_Object_RAM(_number, _size) \
+ (_Configure_Object_RAM(_number, _size) \
+ + _Configure_Max_Objects(_number) \
+ * _Configure_From_workspace(_POSIX_PATH_MAX + 1))
+
+/**
+ * This configuration parameter specifies the maximum number of
+ * POSIX API semaphores.
+ */
+#ifndef CONFIGURE_MAXIMUM_POSIX_SEMAPHORES
+ #define CONFIGURE_MAXIMUM_POSIX_SEMAPHORES 0
+#endif
+
+/*
+ * This macro is calculated to specify the memory required for
+ * POSIX API semaphores.
+ */
+#define _CONFIGURE_MEMORY_FOR_POSIX_SEMAPHORES(_semaphores) \
+ _Configure_POSIX_Named_Object_RAM( \
+ _semaphores, sizeof(POSIX_Semaphore_Control) )
+
/*
* The rest of the POSIX threads API features are only available when
* POSIX is enabled.
@@ -2303,25 +2330,14 @@ extern rtems_initialization_tasks_table Initialization_tasks[];
#ifdef RTEMS_POSIX_API
#include <sys/types.h>
#include <signal.h>
- #include <limits.h>
#include <mqueue.h>
#include <rtems/posix/mqueue.h>
#include <rtems/posix/psignal.h>
#include <rtems/posix/pthread.h>
- #include <rtems/posix/semaphore.h>
#include <rtems/posix/shm.h>
#include <rtems/posix/threadsup.h>
#include <rtems/posix/timer.h>
- /*
- * Account for the object control structures plus the name
- * of the object to be duplicated.
- */
- #define _Configure_POSIX_Named_Object_RAM(_number, _size) \
- (_Configure_Object_RAM(_number, _size) \
- + _Configure_Max_Objects(_number) \
- * _Configure_From_workspace(_POSIX_PATH_MAX + 1))
-
/**
* This configuration parameter specifies the maximum number of
* POSIX API threads.
@@ -2377,22 +2393,6 @@ extern rtems_initialization_tasks_table Initialization_tasks[];
_Configure_POSIX_Named_Object_RAM( \
_message_queues, sizeof(POSIX_Message_queue_Control) )
- /**
- * This configuration parameter specifies the maximum number of
- * POSIX API semaphores.
- */
- #ifndef CONFIGURE_MAXIMUM_POSIX_SEMAPHORES
- #define CONFIGURE_MAXIMUM_POSIX_SEMAPHORES 0
- #endif
-
- /*
- * This macro is calculated to specify the memory required for
- * POSIX API semaphores.
- */
- #define _CONFIGURE_MEMORY_FOR_POSIX_SEMAPHORES(_semaphores) \
- _Configure_POSIX_Named_Object_RAM( \
- _semaphores, sizeof(POSIX_Semaphore_Control) )
-
/**
* Configure the maximum number of POSIX shared memory objects.
*/
@@ -2559,8 +2559,6 @@ extern rtems_initialization_tasks_table Initialization_tasks[];
CONFIGURE_MAXIMUM_POSIX_QUEUED_SIGNALS) + \
_CONFIGURE_MEMORY_FOR_POSIX_MESSAGE_QUEUES( \
CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES) + \
- _CONFIGURE_MEMORY_FOR_POSIX_SEMAPHORES( \
- CONFIGURE_MAXIMUM_POSIX_SEMAPHORES) + \
_CONFIGURE_MEMORY_FOR_POSIX_SHMS( \
CONFIGURE_MAXIMUM_POSIX_SHMS) + \
_CONFIGURE_MEMORY_FOR_POSIX_TIMERS(CONFIGURE_MAXIMUM_POSIX_TIMERS))
@@ -2721,6 +2719,8 @@ extern rtems_initialization_tasks_table Initialization_tasks[];
_CONFIGURE_MEMORY_FOR_POSIX_KEYS( \
_CONFIGURE_POSIX_KEYS, \
CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS ) + \
+ _CONFIGURE_MEMORY_FOR_POSIX_SEMAPHORES( \
+ CONFIGURE_MAXIMUM_POSIX_SEMAPHORES) + \
_CONFIGURE_MEMORY_FOR_POSIX + \
_CONFIGURE_MEMORY_FOR_STATIC_EXTENSIONS + \
_CONFIGURE_MEMORY_FOR_MP + \
@@ -3219,12 +3219,14 @@ extern rtems_initialization_tasks_table Initialization_tasks[];
/* POSIX API managers that are always enabled */
uint32_t POSIX_KEYS;
-#ifdef RTEMS_POSIX_API
/* POSIX API Pieces */
+#ifdef RTEMS_POSIX_API
uint32_t POSIX_TIMERS;
uint32_t POSIX_QUEUED_SIGNALS;
uint32_t POSIX_MESSAGE_QUEUES;
+#endif
uint32_t POSIX_SEMAPHORES;
+#ifdef RTEMS_POSIX_API
uint32_t POSIX_SHMS;
#endif
@@ -3272,7 +3274,9 @@ extern rtems_initialization_tasks_table Initialization_tasks[];
CONFIGURE_MAXIMUM_POSIX_QUEUED_SIGNALS ),
_CONFIGURE_MEMORY_FOR_POSIX_MESSAGE_QUEUES(
CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES ),
+#endif
_CONFIGURE_MEMORY_FOR_POSIX_SEMAPHORES( CONFIGURE_MAXIMUM_POSIX_SEMAPHORES ),
+#ifdef RTEMS_POSIX_API
_CONFIGURE_MEMORY_FOR_POSIX_SHMS( CONFIGURE_MAXIMUM_POSIX_SHMS ),
_CONFIGURE_MEMORY_FOR_POSIX_TIMERS( CONFIGURE_MAXIMUM_POSIX_TIMERS ),
#endif
@@ -3340,7 +3344,6 @@ extern rtems_initialization_tasks_table Initialization_tasks[];
(CONFIGURE_MAXIMUM_POSIX_TIMERS != 0) || \
(CONFIGURE_MAXIMUM_POSIX_QUEUED_SIGNALS != 0) || \
(CONFIGURE_MAXIMUM_POSIX_MESSAGE_QUEUES != 0) || \
- (CONFIGURE_MAXIMUM_POSIX_SEMAPHORES != 0) || \
(CONFIGURE_MAXIMUM_POSIX_SHMS != 0) || \
defined(CONFIGURE_POSIX_INIT_THREAD_TABLE))
#error "CONFIGURATION ERROR: POSIX API support not configured!!"
diff --git a/cpukit/rtems/src/rtemsobjectgetapiclassname.c b/cpukit/rtems/src/rtemsobjectgetapiclassname.c
index b1cc161c9e..6b90897389 100644
--- a/cpukit/rtems/src/rtemsobjectgetapiclassname.c
+++ b/cpukit/rtems/src/rtemsobjectgetapiclassname.c
@@ -42,18 +42,20 @@ static const rtems_assoc_t rtems_object_api_classic_assoc[] = {
{ NULL, 0, 0}
};
-#ifdef RTEMS_POSIX_API
static const rtems_assoc_t rtems_object_api_posix_assoc[] = {
+#ifdef RTEMS_POSIX_API
{ "Thread", OBJECTS_POSIX_THREADS, 0},
{ "Key", OBJECTS_POSIX_KEYS, 0},
{ "Interrupt", OBJECTS_POSIX_INTERRUPTS, 0},
{ "Message Queue", OBJECTS_POSIX_MESSAGE_QUEUES, 0},
+#endif
{ "Semaphore", OBJECTS_POSIX_SEMAPHORES, 0},
+#ifdef RTEMS_POSIX_API
{ "Timer", OBJECTS_POSIX_TIMERS, 0},
{ "Shared Memory", OBJECTS_POSIX_SHMS, 0},
+#endif
{ NULL, 0, 0}
};
-#endif
const char *rtems_object_get_api_class_name(
int the_api,
@@ -67,10 +69,8 @@ const char *rtems_object_get_api_class_name(
api_assoc = rtems_object_api_internal_assoc;
else if ( the_api == OBJECTS_CLASSIC_API )
api_assoc = rtems_object_api_classic_assoc;
-#ifdef RTEMS_POSIX_API
else if ( the_api == OBJECTS_POSIX_API )
api_assoc = rtems_object_api_posix_assoc;
-#endif
else
return "BAD API";
class_assoc = rtems_assoc_ptr_by_local( api_assoc, the_class );
--
2.16.4
More information about the devel
mailing list