plibsys
pshm.h
Go to the documentation of this file.
1 /*
2  * The MIT License
3  *
4  * Copyright (C) 2010-2017 Alexander Saprykin <saprykin.spb@gmail.com>
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining
7  * a copy of this software and associated documentation files (the
8  * 'Software'), to deal in the Software without restriction, including
9  * without limitation the rights to use, copy, modify, merge, publish,
10  * distribute, sublicense, and/or sell copies of the Software, and to
11  * permit persons to whom the Software is furnished to do so, subject to
12  * the following conditions:
13  *
14  * The above copyright notice and this permission notice shall be
15  * included in all copies or substantial portions of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
18  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24  */
25 
86 #if !defined (PLIBSYS_H_INSIDE) && !defined (PLIBSYS_COMPILATION)
87 # error "Header files shouldn't be included directly, consider using <plibsys.h> instead."
88 #endif
89 
90 #ifndef PLIBSYS_HEADER_PSHM_H
91 #define PLIBSYS_HEADER_PSHM_H
92 
93 #include <pmacros.h>
94 #include <ptypes.h>
95 #include <perror.h>
96 
98 
100 typedef enum PShmAccessPerms_ {
104 
106 typedef struct PShm_ PShm;
107 
118 P_LIB_API PShm * p_shm_new (const pchar *name,
119  psize size,
120  PShmAccessPerms perms,
121  PError **error);
122 
140 
149 P_LIB_API void p_shm_free (PShm *shm);
150 
162  PError **error);
163 
172  PError **error);
173 
181 
191 P_LIB_API psize p_shm_get_size (const PShm *shm);
192 
194 
195 #endif /* PLIBSYS_HEADER_PSHM_H */
#define P_END_DECLS
Closes .h file declarations to be exported as C functions, should be always used after P_BEGIN_DECLS...
Definition: pmacros.h:299
P_LIB_API pboolean p_shm_lock(PShm *shm, PError **error)
Locks PShm object for usage.
P_LIB_API ppointer p_shm_get_address(const PShm *shm)
Gets a starting address of a PShm memory segment.
struct PShm_ PShm
Shared memory opaque data structure.
Definition: pshm.h:106
char pchar
Type for a char.
Definition: ptypes.h:116
typedefP_BEGIN_DECLS struct PError_ PError
Opaque data structure for an error object.
Definition: perror.h:68
unsigned int psize
Type for a platform independent size_t.
Definition: ptypes.h:224
Miscellaneous macros.
Read/write access.
Definition: pshm.h:102
PShmAccessPerms_
Enum with shared memory access permissions.
Definition: pshm.h:100
P_LIB_API void p_shm_take_ownership(PShm *shm)
Takes ownership of a shared memory segment.
void * ppointer
Type for a pointer.
Definition: ptypes.h:109
P_LIB_API pboolean p_shm_unlock(PShm *shm, PError **error)
Unlocks PShm object.
signed int pboolean
Type for a bool.
Definition: ptypes.h:114
Read-only access.
Definition: pshm.h:101
P_BEGIN_DECLS enum PShmAccessPerms_ PShmAccessPerms
Enum with shared memory access permissions.
Error report system.
P_LIB_API PShm * p_shm_new(const pchar *name, psize size, PShmAccessPerms perms, PError **error)
Creates a new PShm object.
#define P_LIB_API
Exports a symbol from a shared library.
Definition: pmacros.h:138
Types definitions.
P_LIB_API void p_shm_free(PShm *shm)
Frees PShm object.
P_LIB_API psize p_shm_get_size(const PShm *shm)
Gets the size of a PShm memory segment.
#define P_BEGIN_DECLS
Starts .h file declarations to be exported as C functions.
Definition: pmacros.h:298