RTEMS: cpukit/include/rtems/posix/shm.h Source File

| RTEMS 5.4-rc2

Loading...
Searching...
No Matches
shm.h
Go to the documentation of this file.
1
7/*
8 * Copyright (c) 2016 Gedare Bloom.
9 *
10 * The license and distribution terms for this file may be
11 * found in the file LICENSE in this distribution or at
12 * http://www.rtems.org/license/LICENSE.
13 */
14
15#ifndef _RTEMS_POSIX_SHM_H
16#define _RTEMS_POSIX_SHM_H
17
18#include <rtems/score/objectdata.h>
19#include <rtems/score/threadq.h>
20
21#include <sys/types.h>
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
35typedef struct POSIX_Shm_Object_operations POSIX_Shm_Object_operations;
36extern const POSIX_Shm_Object_operations _POSIX_Shm_Object_operations;
37
41 typedef struct {
45 void *handle;
46
51 size_t size;
52
56 const POSIX_Shm_Object_operations *ops;
57} POSIX_Shm_Object;
58
62 struct POSIX_Shm_Object_operations {
70 int ( *object_create ) ( POSIX_Shm_Object *shm_obj, size_t size );
71
79 int ( *object_resize ) ( POSIX_Shm_Object *shm_obj, size_t size );
80
88 int ( *object_delete ) ( POSIX_Shm_Object *shm_obj );
89
95 int ( *object_read ) ( POSIX_Shm_Object *shm_obj, void *buf, size_t count );
96
105 void * ( *object_mmap ) ( POSIX_Shm_Object *shm_obj, size_t len, int prot, off_t off);
106};
107
111 typedef struct {
112 Objects_Control Object;
113 Thread_queue_Control Wait_queue;
114
115 int reference_count;
116
117 POSIX_Shm_Object shm_object;
118
119 uid_t uid;
120 gid_t gid;
121 mode_t mode;
122 int oflag;
123
124 time_t atime;
125 time_t mtime;
126 time_t ctime;
127} POSIX_Shm_Control;
128
132extern Objects_Information _POSIX_Shm_Information;
133
143#define POSIX_SHM_INFORMATION_DEFINE( max ) \
144 OBJECTS_INFORMATION_DEFINE( \
145 _POSIX_Shm, \
146 OBJECTS_POSIX_API, \
147 OBJECTS_POSIX_SHMS, \
148 POSIX_Shm_Control, \
149 max, \
150 _POSIX_PATH_MAX, \
151 NULL \
152 )
153
157extern int _POSIX_Shm_Object_create_from_workspace(
158 POSIX_Shm_Object *shm_obj,
159 size_t size
160);
161
165extern int _POSIX_Shm_Object_delete_from_workspace( POSIX_Shm_Object *shm_obj );
166
170extern int _POSIX_Shm_Object_resize_from_workspace(
171 POSIX_Shm_Object *shm_obj,
172 size_t size
173);
174
178extern int _POSIX_Shm_Object_read_from_workspace(
179 POSIX_Shm_Object *shm_obj,
180 void *buf,
181 size_t count
182);
183
187extern void * _POSIX_Shm_Object_mmap_from_workspace(
188 POSIX_Shm_Object *shm_obj,
189 size_t len,
190 int prot,
191 off_t off
192);
193
197extern int _POSIX_Shm_Object_create_from_heap(
198 POSIX_Shm_Object *shm_obj,
199 size_t size
200);
201
205extern int _POSIX_Shm_Object_delete_from_heap( POSIX_Shm_Object *shm_obj );
206
210extern int _POSIX_Shm_Object_resize_from_heap(
211 POSIX_Shm_Object *shm_obj,
212 size_t size
213);
214
218extern int _POSIX_Shm_Object_read_from_heap(
219 POSIX_Shm_Object *shm_obj,
220 void *buf,
221 size_t count
222);
223
227extern void * _POSIX_Shm_Object_mmap_from_heap(
228 POSIX_Shm_Object *shm_obj,
229 size_t len,
230 int prot,
231 off_t off
232);
233
236#ifdef __cplusplus
237}
238#endif
239
240#endif
_POSIX_Shm_Object_create_from_workspace
int _POSIX_Shm_Object_create_from_workspace(POSIX_Shm_Object *shm_obj, size_t size)
object_create operation for shm objects stored in RTEMS Workspace.
Definition: shmwkspace.c:22
_POSIX_Shm_Object_read_from_workspace
int _POSIX_Shm_Object_read_from_workspace(POSIX_Shm_Object *shm_obj, void *buf, size_t count)
object_read operation for shm objects stored in RTEMS Workspace.
Definition: shmwkspace.c:65
_POSIX_Shm_Object_resize_from_heap
int _POSIX_Shm_Object_resize_from_heap(POSIX_Shm_Object *shm_obj, size_t size)
object_resize operation for shm objects stored in C program heap.
Definition: shmheap.c:47
_POSIX_Shm_Object_mmap_from_heap
void * _POSIX_Shm_Object_mmap_from_heap(POSIX_Shm_Object *shm_obj, size_t len, int prot, off_t off)
object_mmap operation for shm objects stored in C program heap.
Definition: shmheap.c:94
_POSIX_Shm_Object_read_from_heap
int _POSIX_Shm_Object_read_from_heap(POSIX_Shm_Object *shm_obj, void *buf, size_t count)
object_read operation for shm objects stored in C program heap.
Definition: shmheap.c:75
_POSIX_Shm_Object_delete_from_workspace
int _POSIX_Shm_Object_delete_from_workspace(POSIX_Shm_Object *shm_obj)
object_delete operation for shm objects stored in RTEMS Workspace.
Definition: shmwkspace.c:37
_POSIX_Shm_Object_create_from_heap
int _POSIX_Shm_Object_create_from_heap(POSIX_Shm_Object *shm_obj, size_t size)
object_create operation for shm objects stored in C program heap.
Definition: shmheap.c:22
_POSIX_Shm_Object_resize_from_workspace
int _POSIX_Shm_Object_resize_from_workspace(POSIX_Shm_Object *shm_obj, size_t size)
object_resize operation for shm objects stored in RTEMS Workspace.
Definition: shmwkspace.c:47
_POSIX_Shm_Object_delete_from_heap
int _POSIX_Shm_Object_delete_from_heap(POSIX_Shm_Object *shm_obj)
object_delete operation for shm objects stored in C program heap.
Definition: shmheap.c:37
_POSIX_Shm_Information
Objects_Information _POSIX_Shm_Information
The POSIX Shared Memory objects information.
_POSIX_Shm_Object_mmap_from_workspace
void * _POSIX_Shm_Object_mmap_from_workspace(POSIX_Shm_Object *shm_obj, size_t len, int prot, off_t off)
object_mmap operation for shm objects stored in RTEMS Workspace.
Definition: shmwkspace.c:83
objectdata.h
Object Handler Data Structures.
Objects_Control
Definition: objectdata.h:39
Objects_Information
The information structure used to manage each API class of objects.
Definition: objectdata.h:176
POSIX_Shm_Control
Control for a POSIX Shared Memory Object.
Definition: shm.h:111
POSIX_Shm_Object_operations
Operations on POSIX Shared Memory Objects.
Definition: shm.h:62
POSIX_Shm_Object_operations::object_resize
int(* object_resize)(POSIX_Shm_Object *shm_obj, size_t size)
Changes the shm_obj size to size.
Definition: shm.h:79
POSIX_Shm_Object_operations::object_create
int(* object_create)(POSIX_Shm_Object *shm_obj, size_t size)
Allocates a new shm_obj with initial size.
Definition: shm.h:70
POSIX_Shm_Object_operations::object_read
int(* object_read)(POSIX_Shm_Object *shm_obj, void *buf, size_t count)
Copies up to @count bytes of the shm_obj data into buf.
Definition: shm.h:95
POSIX_Shm_Object_operations::object_delete
int(* object_delete)(POSIX_Shm_Object *shm_obj)
Deletes the shm_obj.
Definition: shm.h:88
POSIX_Shm_Object
Encapsulation for the storage and manipulation of shm objects.
Definition: shm.h:41
POSIX_Shm_Object::size
size_t size
The number of bytes allocated to the object. A size of 0 with a handle of NULL means no object is all...
Definition: shm.h:51
POSIX_Shm_Object::handle
void * handle
The handle is private for finding object storage.
Definition: shm.h:45
POSIX_Shm_Object::ops
const POSIX_Shm_Object_operations * ops
Implementation-specific operations on shm objects.
Definition: shm.h:56
Thread_queue_Control
Definition: threadq.h:553
threadq.h
Constants and Structures Needed to Declare a Thread Queue.