42 #define HAVE_CREATE_ARENA_MUTEX (01 << 31)
46 extern struct shm_arena *_shm_default_arena;
47 extern pthread_mutex_t _shm_create_arena_mutex;
51 pthread_rwlock_t *arena_rwlock(
const struct shm_arena *a)
63 IF_SPEW(
const char *func,)
size_t min_size)
71 pthread_mutex_lock(&_shm_create_arena_mutex);
72 if(!_shm_default_arena)
78 HAVE_CREATE_ARENA_MUTEX;
84 if(!_shm_default_arena)
88 pthread_mutex_unlock(&_shm_create_arena_mutex);
89 return SPEW_SYS_RET(NULL, _WARN,
96 pthread_mutex_unlock(&_shm_create_arena_mutex);
97 return SPEW_SYS_RET(NULL, _WARN,
98 "%s() failed: the arena object "
99 "has not been created yet", func);
102 a = _shm_default_arena;
103 pthread_mutex_unlock(&_shm_create_arena_mutex);
114 IF_SPEW(,
const char *func))
116 return get_arena_min_size(a, rwlock_type, err IF_SPEW(, func), 0);
120 *get_arena_min_size_and_autolock(
struct shm_arena *a,
124 IF_SPEW(
const char *func,)
135 ASSERT(rwlock_type == 0 || rwlock_type == 1 || rwlock_type == 2);
137 a = get_arena_min_size(a, rwlock_type, err IF_SPEW(, func), min_size);
140 rwlock = get_rwlock_attr(a);
143 return SPEW_RET(NULL, _WARN,
"%s() failed: %s() failed",
152 SPEW_SYS_RET(NULL, _WARN,
153 "%s() failed: you have an arena read-lock"
154 " but need an arena write-lock", func);
164 *err = pthread_rwlock_unlock(arena_rwlock(a));
170 *err = pthread_rwlock_unlock(arena_rwlock(a));
175 "%s() failed: pthread_rwlock_unlock() failed",
193 *err = pthread_rwlock_rdlock(arena_rwlock(a));
200 "%s() failed: pthread_rwlock_rdlock() failed",
207 *err = pthread_rwlock_wrlock(arena_rwlock(a));
214 "%s() failed: pthread_rwlock_wrlock() failed",
220 *get_arena_and_autolock(
struct shm_arena *a,
224 IF_SPEW(,
const char *func))
226 return get_arena_min_size_and_autolock(a, rwlock_type,
233 IF_SPEW(,
const char *func))
244 rwlock = get_rwlock_attr(a);
247 return SPEW_RET(errno, _WARN,
"%s() failed: %s() failed",
257 err = pthread_rwlock_unlock(arena_rwlock(a));
263 err = pthread_rwlock_unlock(arena_rwlock(a));
269 "%s() failed: pthread_rwlock_unlock() failed",
struct arena_header * header
#define SHM_RW_MODE
a mode with all the read and write bits enabled
shm_arena_t shm_arena_create(const char *path, int flags, mode_t mode, size_t min_size)
create a shared memory arena object
#define SHM_ARENA_DEFAULT
shm_arena_create() flag for insuring this is the default arena