28 #include <shm_arena.h>
35 const char *SEG_NAME =
"my count";
36 size_t seg_size =
sizeof(int);
45 printf(
"Failed to get arena lock\n");
57 ptr = (
int *)
sm_create(seg_size, SEG_NAME);
71 printf(
"failed to create segment \"%s\"\n", SEG_NAME);
81 printf(
"Created shared memory segment \"%s\" of size %zu\n",
84 printf(
"Shared memory segment \"%s\" of size %zu already exists\n",
static size_t sm_size(const void *ptr)
get the size of a shared memory segment from a pointer
#define SHM_UNKNOWN_SIZE
shm_get() flag for when you don't know the segment size
static int sm_arena_unlock(void)
release an arena read or write lock
static void * sm_connect(size_t size, const char *name)
connect to a shared memory segment
static void * sm_create(size_t size, const char *name)
create a shared memory segment
static int sm_arena_wrlock(void)
acquire an arena write lock