41 #ifndef __SHM_ARENA_H__
42 #define __SHM_ARENA_H__
50 #include <sys/types.h>
64 #define SHM_DEFAULT_SPEW_LEVEL "WARN"
70 #define SHM_HOMEPAGE "http://shm-arena.sourceforge.net/"
77 #define SHM_PREFIX "/home/lanceman/installed/encap/shm_arena"
86 #define SHM_DEFAULT_ARENA_DIR "/tmp/shm_arena"
97 #define SHM_DEFAULT_ARENA_FILE "arena"
105 #define SHM_RW_MODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)
123 #define SHM_WITH_SHM_OPEN (01 << 24)
130 #define SHM_ARENA_HAVE_FLOCK (01 << 25)
138 #define SHM_USE_GIVEN_PATH (01 << 26)
144 #define SHM_ARENA_DEFAULT (01 << 27)
150 #define SHM_WITHOUT_RWLOCK (01 << 28)
158 #define SHM_TIMESTAMP (01 << 29)
165 #define SHM_UNKNOWN_SIZE ((size_t) -1)
206 void *
shm_get(shm_arena_t arena,
size_t size,
207 const char *name,
int flags);
210 ssize_t
shm_size(shm_arena_t arena,
const void *ptr);
216 int shm_remove(shm_arena_t arena,
const void *ptr);
222 char *
shm_name(shm_arena_t arena,
const void *ptr,
223 char *name,
size_t name_size);
229 int shm_wrlock(shm_arena_t arena,
const void *ptr);
232 int shm_rdlock(shm_arena_t arena,
const void *ptr);
235 int shm_unlock(shm_arena_t arena,
const void *ptr);
248 mode_t mode,
size_t min_size);
329 void *
sm_get(
size_t size,
const char *name)
331 return shm_get(NULL, size, name, O_CREAT);
356 return shm_get(NULL, size, name, O_CREAT|O_EXCL);
381 return shm_get(NULL, size, name, 0);
478 char *
sm_name(
const void *ptr,
char *name,
size_t name_size)
480 return shm_name(NULL, ptr, name, name_size);
613 smq_t
smq_get(shm_arena_t arena,
size_t element_size,
614 int q_length,
const char *name,
int flags);
static size_t sm_size(const void *ptr)
get the size of a shared memory segment from a pointer
int shm_rwlock_reset(shm_arena_t arena, const void *ptr)
reset a segment read-write lock
long double * smq_timestamp(smq_t q, const void *ptr)
read or write the time stamp
smq_t smq_get(shm_arena_t arena, size_t element_size, int q_length, const char *name, int flags)
get a Shared Multi-Queue object
ssize_t shm_size(shm_arena_t arena, const void *ptr)
get the size of a shared memory segment
void * smq_poll(smq_t q)
poll the last entry from the Shared Multi-Queue
int shm_arena_set_default(const shm_arena_t arena)
set the local default arena object
shm_arena_t shm_arena_create(const char *path, int flags, mode_t mode, size_t min_size)
create a shared memory arena object
int shm_arena_rdlock(shm_arena_t arena)
acquire an arena read lock
void * shm_get(shm_arena_t arena, size_t size, const char *name, int flags)
get a shared memory segment
int shm_remove(shm_arena_t arena, const void *ptr)
remove a shared memory segment
static int sm_arena_unlock(void)
release an arena read or write lock
int shm_unlock(shm_arena_t arena, const void *ptr)
release a shared memory segment read-write lock
int shm_arena_wrlock(shm_arena_t arena)
acquire an arena write lock
size_t smq_element_size(smq_t q)
get the element size of Shared Multi-Queue object
int smq_rdlock(smq_t q, int num)
acquire Shared Multi-Queue read-lock
static void * sm_connect(size_t size, const char *name)
connect to a shared memory segment
static char * sm_name(const void *ptr, char *name, size_t name_size)
get the name of a shared memory segment
static int sm_arena_rdlock(void)
acquire an arena read lock
static int sm_unlock(const void *ptr)
release a shared memory segment read-write lock
int smq_unblock_rdlock(smq_t q)
unblock a smq_rdlock() call if needed
int smq_remove(smq_t q)
remove a Shared Multi-Queue from the arena
void * smq_write(smq_t q)
write an entry into the Shared Multi-Queue
int shm_arena_print_list(shm_arena_t arena)
struct shm_arena * shm_arena_t
local process arena object
int shm_arena_rwlock_reset(shm_arena_t arena)
reset an arena read-write lock
static int sm_remove(const void *ptr)
remove a shared memory segment using a pointer
int shm_arena_destroy(const char *path, int flags)
destroy a shared memory arena file
int smq_delete(smq_t q)
delete the local Shared Multi-Queue object
int shm_remove_name(shm_arena_t arena, const char *name)
remove a shared memory segment by name
static size_t sm_size_name(const char *name)
get the size of a shared memory segment from the name
struct smq * smq_t
shared multi-queue object
char * shm_name(shm_arena_t arena, const void *ptr, char *name, size_t name_size)
get the name of a shared memory segment for a pointer
int shm_wrlock(shm_arena_t arena, const void *ptr)
acquire an segment write lock
static void * sm_get(size_t size, const char *name)
get a shared memory segment
static int sm_remove_name(const char *name)
remove a shared memory segment using the name
static int sm_wrlock(const void *ptr)
acquire a shared memory segment write lock
int shm_arena_unlock(shm_arena_t arena)
release an arena read or write lock
int smq_unlock(smq_t q)
release Shared Multi-Queue read or write lock
static int sm_rdlock(const void *ptr)
acquire a shared memory segment read lock
static void * sm_create(size_t size, const char *name)
create a shared memory segment
int smq_wrlock(smq_t q, int num)
acquire Shared Multi-Queue write-lock
void * smq_read(smq_t q)
read the next entry from the Shared Multi-Queue
static int sm_arena_wrlock(void)
acquire an arena write lock
ssize_t shm_size_name(shm_arena_t arena, const char *name)
get the size of a shared memory segment
int shm_arena_delete(shm_arena_t arena)
delete a local shared memory arena object
int shm_arena_print_dot(shm_arena_t arena)
print debug information about a shared memory arena object in this case a dot file that can be made i...
int shm_arena_print(shm_arena_t arena)
print the cotents of a shared memory arena file to stdout
int shm_rdlock(shm_arena_t arena, const void *ptr)
acquire an segment read lock