posix: Provide shared memory objects by default

Update #2514.
This commit is contained in:
Sebastian Huber
2018-10-29 10:33:37 +01:00
parent 9318cfb050
commit 701057e0b9
4 changed files with 72 additions and 48 deletions
+8 -7
View File
@@ -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
+23 -40
View File
@@ -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
+40
View File
@@ -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
};
@@ -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}
};