summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2018-10-25 10:07:46 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2018-10-29 10:33:37 +0100
commit701057e0b93fe0afd56f1cce206d6f6137cb57d4 (patch)
tree2284c8f151932f62d4917cc4daf24312d285a214
parentposix: Provide named semaphores by default (diff)
downloadrtems-701057e0b93fe0afd56f1cce206d6f6137cb57d4.tar.bz2
posix: Provide shared memory objects by default
Update #2514.
-rw-r--r--cpukit/Makefile.am15
-rw-r--r--cpukit/include/rtems/confdefs.h63
-rw-r--r--cpukit/posix/src/shmops.c40
-rw-r--r--cpukit/rtems/src/rtemsobjectgetapiclassname.c2
4 files changed, 72 insertions, 48 deletions
diff --git a/cpukit/Makefile.am b/cpukit/Makefile.am
index 3d9bead51a..6c2574b264 100644
--- a/cpukit/Makefile.am
+++ b/cpukit/Makefile.am
@@ -508,11 +508,13 @@ librtemscpu_a_SOURCES += posix/src/keysetspecific.c
librtemscpu_a_SOURCES += posix/src/lio_listio.c
librtemscpu_a_SOURCES += posix/src/mlockall.c
librtemscpu_a_SOURCES += posix/src/mlock.c
+librtemscpu_a_SOURCES += posix/src/mmap.c
librtemscpu_a_SOURCES += posix/src/mprotect.c
librtemscpu_a_SOURCES += posix/src/mqueueconfig.c
librtemscpu_a_SOURCES += posix/src/msync.c
librtemscpu_a_SOURCES += posix/src/munlockall.c
librtemscpu_a_SOURCES += posix/src/munlock.c
+librtemscpu_a_SOURCES += posix/src/munmap.c
librtemscpu_a_SOURCES += posix/src/mutexattrdestroy.c
librtemscpu_a_SOURCES += posix/src/mutexattrgetprioceiling.c
librtemscpu_a_SOURCES += posix/src/mutexattrgetprotocol.c
@@ -620,7 +622,13 @@ 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
+librtemscpu_a_SOURCES += posix/src/shm.c
librtemscpu_a_SOURCES += posix/src/shmconfig.c
+librtemscpu_a_SOURCES += posix/src/shmheap.c
+librtemscpu_a_SOURCES += posix/src/shmopen.c
+librtemscpu_a_SOURCES += posix/src/shmops.c
+librtemscpu_a_SOURCES += posix/src/shmunlink.c
+librtemscpu_a_SOURCES += posix/src/shmwkspace.c
librtemscpu_a_SOURCES += posix/src/sigaddset.c
librtemscpu_a_SOURCES += posix/src/sigdelset.c
librtemscpu_a_SOURCES += posix/src/sigemptyset.c
@@ -1039,7 +1047,6 @@ librtemscpu_a_SOURCES += posix/src/getitimer.c
librtemscpu_a_SOURCES += posix/src/kill.c
librtemscpu_a_SOURCES += posix/src/killinfo.c
librtemscpu_a_SOURCES += posix/src/kill_r.c
-librtemscpu_a_SOURCES += posix/src/mmap.c
librtemscpu_a_SOURCES += posix/src/mqueue.c
librtemscpu_a_SOURCES += posix/src/mqueueclose.c
librtemscpu_a_SOURCES += posix/src/mqueuedeletesupp.c
@@ -1054,7 +1061,6 @@ librtemscpu_a_SOURCES += posix/src/mqueuesetattr.c
librtemscpu_a_SOURCES += posix/src/mqueuetimedreceive.c
librtemscpu_a_SOURCES += posix/src/mqueuetimedsend.c
librtemscpu_a_SOURCES += posix/src/mqueueunlink.c
-librtemscpu_a_SOURCES += posix/src/munmap.c
librtemscpu_a_SOURCES += posix/src/pause.c
librtemscpu_a_SOURCES += posix/src/psignal.c
librtemscpu_a_SOURCES += posix/src/psignalclearprocesssignals.c
@@ -1074,11 +1080,6 @@ 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/setitimer.c
-librtemscpu_a_SOURCES += posix/src/shm.c
-librtemscpu_a_SOURCES += posix/src/shmheap.c
-librtemscpu_a_SOURCES += posix/src/shmopen.c
-librtemscpu_a_SOURCES += posix/src/shmunlink.c
-librtemscpu_a_SOURCES += posix/src/shmwkspace.c
librtemscpu_a_SOURCES += posix/src/sigaction.c
librtemscpu_a_SOURCES += posix/src/signal_2.c
librtemscpu_a_SOURCES += posix/src/sigpending.c
diff --git a/cpukit/include/rtems/confdefs.h b/cpukit/include/rtems/confdefs.h
index a38cdec8c0..78a73c8c4a 100644
--- a/cpukit/include/rtems/confdefs.h
+++ b/cpukit/include/rtems/confdefs.h
@@ -34,6 +34,7 @@
#include <rtems/score/wkspace.h>
#include <rtems/posix/key.h>
#include <rtems/posix/semaphore.h>
+#include <rtems/posix/shm.h>
#include <limits.h>
@@ -1940,6 +1941,10 @@ extern rtems_initialization_tasks_table Initialization_tasks[];
#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)
+ #endif
#ifdef RTEMS_POSIX_API
#if !defined(CONFIGURE_MAXIMUM_POSIX_THREADS)
@@ -1960,10 +1965,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_SHMS)
- #define CONFIGURE_MAXIMUM_POSIX_SHMS \
- rtems_resource_unlimited(CONFIGURE_UNLIMITED_ALLOCATION_SIZE)
- #endif
#endif /* RTEMS_POSIX_API */
#endif /* CONFIGURE_UNLIMITED_OBJECTS */
@@ -2323,6 +2324,20 @@ extern rtems_initialization_tasks_table Initialization_tasks[];
_Configure_POSIX_Named_Object_RAM( \
_semaphores, sizeof(POSIX_Semaphore_Control) )
+/**
+ * Configure the maximum number of POSIX shared memory objects.
+ */
+#ifndef CONFIGURE_MAXIMUM_POSIX_SHMS
+ #define CONFIGURE_MAXIMUM_POSIX_SHMS 0
+#endif
+
+/*
+ * This macro is calculated to specify the memory required for
+ * POSIX API shared memory.
+ */
+#define _CONFIGURE_MEMORY_FOR_POSIX_SHMS(_shms) \
+ _Configure_POSIX_Named_Object_RAM(_shms, sizeof(POSIX_Shm_Control) )
+
/*
* The rest of the POSIX threads API features are only available when
* POSIX is enabled.
@@ -2334,7 +2349,6 @@ extern rtems_initialization_tasks_table Initialization_tasks[];
#include <rtems/posix/mqueue.h>
#include <rtems/posix/psignal.h>
#include <rtems/posix/pthread.h>
- #include <rtems/posix/shm.h>
#include <rtems/posix/threadsup.h>
#include <rtems/posix/timer.h>
@@ -2393,32 +2407,6 @@ extern rtems_initialization_tasks_table Initialization_tasks[];
_Configure_POSIX_Named_Object_RAM( \
_message_queues, sizeof(POSIX_Message_queue_Control) )
- /**
- * Configure the maximum number of POSIX shared memory objects.
- */
- #if !defined(CONFIGURE_MAXIMUM_POSIX_SHMS)
- #define CONFIGURE_MAXIMUM_POSIX_SHMS 0
- #else
- #ifdef CONFIGURE_INIT
- #if !defined(CONFIGURE_HAS_OWN_POSIX_SHM_OBJECT_OPERATIONS)
- const POSIX_Shm_Object_operations _POSIX_Shm_Object_operations = {
- _POSIX_Shm_Object_create_from_workspace,
- _POSIX_Shm_Object_resize_from_workspace,
- _POSIX_Shm_Object_delete_from_workspace,
- _POSIX_Shm_Object_read_from_workspace,
- _POSIX_Shm_Object_mmap_from_workspace
- };
- #endif
- #endif
- #endif
-
- /*
- * This macro is calculated to specify the memory required for
- * POSIX API shared memory.
- */
- #define _CONFIGURE_MEMORY_FOR_POSIX_SHMS(_shms) \
- _Configure_POSIX_Named_Object_RAM(_shms, sizeof(POSIX_Shm_Control) )
-
#ifdef CONFIGURE_POSIX_INIT_THREAD_TABLE
#ifndef CONFIGURE_POSIX_HAS_OWN_INIT_THREAD_TABLE
#ifndef CONFIGURE_POSIX_INIT_THREAD_ENTRY_POINT
@@ -2559,8 +2547,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_SHMS( \
- CONFIGURE_MAXIMUM_POSIX_SHMS) + \
_CONFIGURE_MEMORY_FOR_POSIX_TIMERS(CONFIGURE_MAXIMUM_POSIX_TIMERS))
#else
/*
@@ -2721,6 +2707,8 @@ extern rtems_initialization_tasks_table Initialization_tasks[];
CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS ) + \
_CONFIGURE_MEMORY_FOR_POSIX_SEMAPHORES( \
CONFIGURE_MAXIMUM_POSIX_SEMAPHORES) + \
+ _CONFIGURE_MEMORY_FOR_POSIX_SHMS( \
+ CONFIGURE_MAXIMUM_POSIX_SHMS) + \
_CONFIGURE_MEMORY_FOR_POSIX + \
_CONFIGURE_MEMORY_FOR_STATIC_EXTENSIONS + \
_CONFIGURE_MEMORY_FOR_MP + \
@@ -3226,9 +3214,7 @@ extern rtems_initialization_tasks_table Initialization_tasks[];
uint32_t POSIX_MESSAGE_QUEUES;
#endif
uint32_t POSIX_SEMAPHORES;
-#ifdef RTEMS_POSIX_API
uint32_t POSIX_SHMS;
-#endif
/* Stack space sizes */
uint32_t IDLE_TASKS_STACK;
@@ -3268,18 +3254,16 @@ extern rtems_initialization_tasks_table Initialization_tasks[];
_CONFIGURE_MEMORY_FOR_POSIX_KEYS( _CONFIGURE_POSIX_KEYS, \
CONFIGURE_MAXIMUM_POSIX_KEY_VALUE_PAIRS ),
-#ifdef RTEMS_POSIX_API
/* POSIX API Pieces */
+#ifdef RTEMS_POSIX_API
+ _CONFIGURE_MEMORY_FOR_POSIX_TIMERS( CONFIGURE_MAXIMUM_POSIX_TIMERS ),
_CONFIGURE_MEMORY_FOR_POSIX_QUEUED_SIGNALS(
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
/* Stack space sizes */
_CONFIGURE_IDLE_TASKS_STACK,
@@ -3344,7 +3328,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_SHMS != 0) || \
defined(CONFIGURE_POSIX_INIT_THREAD_TABLE))
#error "CONFIGURATION ERROR: POSIX API support not configured!!"
#endif
diff --git a/cpukit/posix/src/shmops.c b/cpukit/posix/src/shmops.c
new file mode 100644
index 0000000000..0f28acac0d
--- /dev/null
+++ b/cpukit/posix/src/shmops.c
@@ -0,0 +1,40 @@
+/*
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2018, embedded brains GmbH <rtems@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
+ * HOLDER 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.
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <rtems/posix/shm.h>
+
+const POSIX_Shm_Object_operations _POSIX_Shm_Object_operations = {
+ _POSIX_Shm_Object_create_from_workspace,
+ _POSIX_Shm_Object_resize_from_workspace,
+ _POSIX_Shm_Object_delete_from_workspace,
+ _POSIX_Shm_Object_read_from_workspace,
+ _POSIX_Shm_Object_mmap_from_workspace
+};
diff --git a/cpukit/rtems/src/rtemsobjectgetapiclassname.c b/cpukit/rtems/src/rtemsobjectgetapiclassname.c
index 6b90897389..61ca90fe7e 100644
--- a/cpukit/rtems/src/rtemsobjectgetapiclassname.c
+++ b/cpukit/rtems/src/rtemsobjectgetapiclassname.c
@@ -52,8 +52,8 @@ static const rtems_assoc_t rtems_object_api_posix_assoc[] = {
{ "Semaphore", OBJECTS_POSIX_SEMAPHORES, 0},
#ifdef RTEMS_POSIX_API
{ "Timer", OBJECTS_POSIX_TIMERS, 0},
- { "Shared Memory", OBJECTS_POSIX_SHMS, 0},
#endif
+ { "Shared Memory", OBJECTS_POSIX_SHMS, 0},
{ NULL, 0, 0}
};