source: rtems/cpukit/posix/include/rtems/posix/shm.h @ ea4488ae

5
Last change on this file since ea4488ae was ea4488ae, checked in by Joel Sherrill <joel@…>, on 08/02/17 at 23:26:51

posix shm: Add oflag to Shm_Control

  • Property mode set to 100644
File size: 4.8 KB
Line 
1/**
2 * @file
3 *
4 * @brief Internal Support for POSIX Shared Memory
5 */
6
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/object.h>
19#include <rtems/score/threadq.h>
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
25/**
26 * @defgroup POSIXShmPrivate POSIX Shared Memory Private Support
27 *
28 * @ingroup POSIXAPI
29 *
30 * Internal implementation support for POSIX shared memory.
31 * @{
32 */
33typedef struct POSIX_Shm_Object_operations POSIX_Shm_Object_operations;
34extern const POSIX_Shm_Object_operations _POSIX_Shm_Object_operations;
35
36/**
37 * @brief Encapsulation for the storage and manipulation of shm objects.
38 */
39typedef struct {
40  /**
41   * @brief The handle is private for finding object storage.
42   */
43  void                               *handle;
44
45  /**
46   * @brief The number of bytes allocated to the object. A size of 0 with
47   * a handle of NULL means no object is allocated.
48   */
49  size_t                              size;
50
51  /**
52   * @brief Implementation-specific operations on shm objects.
53   */
54  const POSIX_Shm_Object_operations  *ops;
55} POSIX_Shm_Object;
56
57/**
58 * @brief Operations on POSIX Shared Memory Objects.
59 */
60struct POSIX_Shm_Object_operations {
61  /**
62   * @brief Allocates a new @a shm_obj with initial @a size.
63   *
64   * New shared memory is initialized to zeroes.
65   *
66   * Returns 0 for success.
67   */
68  int ( *object_create ) ( POSIX_Shm_Object *shm_obj, size_t size );
69
70  /**
71   * @brief Changes the @a shm_obj size to @a size.
72   *
73   * Zeroes out the portion of the shared memory object that shrinks or grows.
74   *
75   * Returns 0 for success.
76   */
77  int ( *object_resize ) ( POSIX_Shm_Object *shm_obj, size_t size );
78
79  /**
80   * @brief Deletes the @a shm_obj.
81   *
82   * Zeroes out the memory.
83   *
84   * Returns 0 for success.
85   */
86  int ( *object_delete ) ( POSIX_Shm_Object *shm_obj );
87
88  /**
89   * @brief Copies up to @count bytes of the @a shm_obj data into @a buf.
90   *
91   * Returns the number of bytes read (copied) into @a buf.
92   */
93  int ( *object_read ) ( POSIX_Shm_Object *shm_obj, void *buf, size_t count );
94
95  /**
96   * @brief Maps a shared memory object.
97   *
98   * Establishes a memory mapping between the shared memory object and the
99   * caller.
100   *
101   * Returns the mapped address of the object.
102   */
103  void * ( *object_mmap ) ( POSIX_Shm_Object *shm_obj, size_t len, int prot, off_t off);
104};
105
106/**
107 * @brief Control for a POSIX Shared Memory Object
108 */
109typedef struct {
110   Objects_Control      Object;
111   Thread_queue_Control Wait_queue;
112
113   int                  reference_count;
114
115   POSIX_Shm_Object     shm_object;
116
117   uid_t                uid;
118   gid_t                gid;
119   mode_t               mode;
120   int                  oflag;
121
122   time_t               atime;
123   time_t               mtime;
124   time_t               ctime;
125} POSIX_Shm_Control;
126
127/**
128 * @brief object_create operation for shm objects stored in RTEMS Workspace.
129 */
130extern int _POSIX_Shm_Object_create_from_workspace(
131  POSIX_Shm_Object *shm_obj,
132  size_t size
133);
134
135/**
136 * @brief object_delete operation for shm objects stored in RTEMS Workspace.
137 */
138extern int _POSIX_Shm_Object_delete_from_workspace( POSIX_Shm_Object *shm_obj );
139
140/**
141 * @brief object_resize operation for shm objects stored in RTEMS Workspace.
142 */
143extern int _POSIX_Shm_Object_resize_from_workspace(
144  POSIX_Shm_Object *shm_obj,
145  size_t size
146);
147
148/**
149 * @brief object_read operation for shm objects stored in RTEMS Workspace.
150 */
151extern int _POSIX_Shm_Object_read_from_workspace(
152  POSIX_Shm_Object *shm_obj,
153  void *buf,
154  size_t count
155);
156
157/**
158 * @brief object_mmap operation for shm objects stored in RTEMS Workspace.
159 */
160extern void * _POSIX_Shm_Object_mmap_from_workspace(
161  POSIX_Shm_Object *shm_obj,
162  size_t len,
163  int prot,
164  off_t off
165);
166
167/**
168 * @brief object_create operation for shm objects stored in C program heap.
169 */
170extern int _POSIX_Shm_Object_create_from_heap(
171  POSIX_Shm_Object *shm_obj,
172  size_t size
173);
174
175/**
176 * @brief object_delete operation for shm objects stored in C program heap.
177 */
178extern int _POSIX_Shm_Object_delete_from_heap( POSIX_Shm_Object *shm_obj );
179
180/**
181 * @brief object_resize operation for shm objects stored in C program heap.
182 */
183extern int _POSIX_Shm_Object_resize_from_heap(
184  POSIX_Shm_Object *shm_obj,
185  size_t size
186);
187
188/**
189 * @brief object_read operation for shm objects stored in C program heap.
190 */
191extern int _POSIX_Shm_Object_read_from_heap(
192  POSIX_Shm_Object *shm_obj,
193  void *buf,
194  size_t count
195);
196
197/**
198 * @brief object_mmap operation for shm objects stored in C program heap.
199 */
200extern void * _POSIX_Shm_Object_mmap_from_heap(
201  POSIX_Shm_Object *shm_obj,
202  size_t len,
203  int prot,
204  off_t off
205);
206
207/** @} */
208
209#ifdef __cplusplus
210}
211#endif
212
213#endif
Note: See TracBrowser for help on using the repository browser.