![]() |
|
|||
File indexing completed on 2025-05-11 08:24:12
0001 /* SPDX-License-Identifier: BSD-2-Clause */ 0002 0003 /** 0004 * @file 0005 * 0006 * @brief Internal Support for POSIX Shared Memory 0007 */ 0008 0009 /* 0010 * Copyright (c) 2016 Gedare Bloom. 0011 * 0012 * Redistribution and use in source and binary forms, with or without 0013 * modification, are permitted provided that the following conditions 0014 * are met: 0015 * 1. Redistributions of source code must retain the above copyright 0016 * notice, this list of conditions and the following disclaimer. 0017 * 2. Redistributions in binary form must reproduce the above copyright 0018 * notice, this list of conditions and the following disclaimer in the 0019 * documentation and/or other materials provided with the distribution. 0020 * 0021 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 0022 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 0023 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 0024 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 0025 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 0026 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 0027 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 0028 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 0029 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 0030 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 0031 * POSSIBILITY OF SUCH DAMAGE. 0032 */ 0033 0034 #ifndef _RTEMS_POSIX_SHM_H 0035 #define _RTEMS_POSIX_SHM_H 0036 0037 #include <rtems/score/objectdata.h> 0038 #include <rtems/score/threadq.h> 0039 0040 #include <sys/types.h> 0041 0042 #ifdef __cplusplus 0043 extern "C" { 0044 #endif 0045 0046 /** 0047 * @defgroup POSIXShmPrivate POSIX Shared Memory Private Support 0048 * 0049 * @ingroup POSIXAPI 0050 * 0051 * Internal implementation support for POSIX shared memory. 0052 * @{ 0053 */ 0054 typedef struct POSIX_Shm_Object_operations POSIX_Shm_Object_operations; 0055 extern const POSIX_Shm_Object_operations _POSIX_Shm_Object_operations; 0056 0057 /** 0058 * @brief Encapsulation for the storage and manipulation of shm objects. 0059 */ 0060 typedef struct { 0061 /** 0062 * @brief The handle is private for finding object storage. 0063 */ 0064 void *handle; 0065 0066 /** 0067 * @brief The number of bytes allocated to the object. A size of 0 with 0068 * a handle of NULL means no object is allocated. 0069 */ 0070 size_t size; 0071 0072 /** 0073 * @brief Implementation-specific operations on shm objects. 0074 */ 0075 const POSIX_Shm_Object_operations *ops; 0076 } POSIX_Shm_Object; 0077 0078 /** 0079 * @brief Operations on POSIX Shared Memory Objects. 0080 */ 0081 struct POSIX_Shm_Object_operations { 0082 /** 0083 * @brief Allocates a new @a shm_obj with initial @a size. 0084 * 0085 * New shared memory is initialized to zeroes. 0086 * 0087 * Returns 0 for success. 0088 */ 0089 int ( *object_create ) ( POSIX_Shm_Object *shm_obj, size_t size ); 0090 0091 /** 0092 * @brief Changes the @a shm_obj size to @a size. 0093 * 0094 * Zeroes out the portion of the shared memory object that shrinks or grows. 0095 * 0096 * Returns 0 for success. 0097 */ 0098 int ( *object_resize ) ( POSIX_Shm_Object *shm_obj, size_t size ); 0099 0100 /** 0101 * @brief Deletes the @a shm_obj. 0102 * 0103 * Zeroes out the memory. 0104 * 0105 * Returns 0 for success. 0106 */ 0107 int ( *object_delete ) ( POSIX_Shm_Object *shm_obj ); 0108 0109 /** 0110 * @brief Copies up to @count bytes of the @a shm_obj data into @a buf. 0111 * 0112 * Returns the number of bytes read (copied) into @a buf. 0113 */ 0114 int ( *object_read ) ( POSIX_Shm_Object *shm_obj, void *buf, size_t count ); 0115 0116 /** 0117 * @brief Maps a shared memory object. 0118 * 0119 * Establishes a memory mapping between the shared memory object and the 0120 * caller. 0121 * 0122 * Returns the mapped address of the object. 0123 */ 0124 void * ( *object_mmap ) ( POSIX_Shm_Object *shm_obj, size_t len, int prot, off_t off); 0125 }; 0126 0127 /** 0128 * @brief Control for a POSIX Shared Memory Object 0129 */ 0130 typedef struct { 0131 Objects_Control Object; 0132 Thread_queue_Control Wait_queue; 0133 0134 int reference_count; 0135 0136 POSIX_Shm_Object shm_object; 0137 0138 uid_t uid; 0139 gid_t gid; 0140 mode_t mode; 0141 int oflag; 0142 0143 time_t atime; 0144 time_t mtime; 0145 time_t ctime; 0146 } POSIX_Shm_Control; 0147 0148 /** 0149 * @brief The POSIX Shared Memory objects information. 0150 */ 0151 extern Objects_Information _POSIX_Shm_Information; 0152 0153 /** 0154 * @brief Macro to define the objects information for the POSIX Shared Memory 0155 * objects. 0156 * 0157 * This macro should only be used by <rtems/confdefs.h>. 0158 * 0159 * @param max The configured object maximum (the OBJECTS_UNLIMITED_OBJECTS flag 0160 * may be set). 0161 */ 0162 #define POSIX_SHM_INFORMATION_DEFINE( max ) \ 0163 OBJECTS_INFORMATION_DEFINE( \ 0164 _POSIX_Shm, \ 0165 OBJECTS_POSIX_API, \ 0166 OBJECTS_POSIX_SHMS, \ 0167 POSIX_Shm_Control, \ 0168 max, \ 0169 _POSIX_PATH_MAX, \ 0170 NULL \ 0171 ) 0172 0173 /** 0174 * @brief object_create operation for shm objects stored in RTEMS Workspace. 0175 */ 0176 extern int _POSIX_Shm_Object_create_from_workspace( 0177 POSIX_Shm_Object *shm_obj, 0178 size_t size 0179 ); 0180 0181 /** 0182 * @brief object_delete operation for shm objects stored in RTEMS Workspace. 0183 */ 0184 extern int _POSIX_Shm_Object_delete_from_workspace( POSIX_Shm_Object *shm_obj ); 0185 0186 /** 0187 * @brief object_resize operation for shm objects stored in RTEMS Workspace. 0188 */ 0189 extern int _POSIX_Shm_Object_resize_from_workspace( 0190 POSIX_Shm_Object *shm_obj, 0191 size_t size 0192 ); 0193 0194 /** 0195 * @brief object_read operation for shm objects stored in RTEMS Workspace. 0196 */ 0197 extern int _POSIX_Shm_Object_read_from_workspace( 0198 POSIX_Shm_Object *shm_obj, 0199 void *buf, 0200 size_t count 0201 ); 0202 0203 /** 0204 * @brief object_mmap operation for shm objects stored in RTEMS Workspace. 0205 */ 0206 extern void * _POSIX_Shm_Object_mmap_from_workspace( 0207 POSIX_Shm_Object *shm_obj, 0208 size_t len, 0209 int prot, 0210 off_t off 0211 ); 0212 0213 /** 0214 * @brief object_create operation for shm objects stored in C program heap. 0215 */ 0216 extern int _POSIX_Shm_Object_create_from_heap( 0217 POSIX_Shm_Object *shm_obj, 0218 size_t size 0219 ); 0220 0221 /** 0222 * @brief object_delete operation for shm objects stored in C program heap. 0223 */ 0224 extern int _POSIX_Shm_Object_delete_from_heap( POSIX_Shm_Object *shm_obj ); 0225 0226 /** 0227 * @brief object_resize operation for shm objects stored in C program heap. 0228 */ 0229 extern int _POSIX_Shm_Object_resize_from_heap( 0230 POSIX_Shm_Object *shm_obj, 0231 size_t size 0232 ); 0233 0234 /** 0235 * @brief object_read operation for shm objects stored in C program heap. 0236 */ 0237 extern int _POSIX_Shm_Object_read_from_heap( 0238 POSIX_Shm_Object *shm_obj, 0239 void *buf, 0240 size_t count 0241 ); 0242 0243 /** 0244 * @brief object_mmap operation for shm objects stored in C program heap. 0245 */ 0246 extern void * _POSIX_Shm_Object_mmap_from_heap( 0247 POSIX_Shm_Object *shm_obj, 0248 size_t len, 0249 int prot, 0250 off_t off 0251 ); 0252 0253 /** @} */ 0254 0255 #ifdef __cplusplus 0256 } 0257 #endif 0258 0259 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |