29 #include <sys/types.h>
43 #include "debug_lock.h"
44 #include "shm_arena.h"
46 #include "arena_lock.h"
69 SPEW(_INFO,
"%s(arena=%p, ptr=%p)", __func__, arena, ptr);
73 return SPEW_SYS_ERR_RET(ret, _WARN, EINVAL,
74 "%s(arena=%p, ptr=%p) failed: ptr=%p",
75 __func__, arena, ptr, ptr);
77 arena = get_arena_and_autolock(arena, 1, &err IF_SPEW(, __func__));
91 if(_shm_arena_sync_mappings(IF_SPEW(__func__,) arena))
119 err = arena_autounlock(arena IF_SPEW(, __func__));
151 SPEW(_INFO,
"%s(arena=%p, name=\"%s\")",
152 __func__, arena, name);
154 if(!name || !name[0])
156 return SPEW_SYS_ERR_RET(ret, _WARN, EINVAL,
157 "%s() failed: name is invalid", __func__);
159 arena = get_arena_and_autolock(arena, 1, &err IF_SPEW(, __func__));
173 if(_shm_arena_sync_mappings(IF_SPEW(__func__,) arena))
184 if(find_segment_name(arena, name, &size))
185 ret = (ssize_t) size;
191 err = arena_autounlock(arena IF_SPEW(, __func__));
228 char *name,
size_t name_size)
234 SPEW(_INFO,
"%s(arena=%p, ptr=%p, name=%p, name_size=%zu)",
235 __func__, arena, ptr, name, name_size);
239 return SPEW_SYS_ERR_RET(ret, _WARN, EINVAL,
240 "%s() failed: ptr=%p",
243 arena = get_arena_and_autolock(arena, 1, &err IF_SPEW(, __func__));
257 if(_shm_arena_sync_mappings(IF_SPEW(__func__,) arena))
279 ret = get_seg_name(seg);
283 CHUNKS(strlen(ret)) +
284 ((get_seg_footer(seg)->flags & WITH_RWLOCK)?CHUNKS(
sizeof(pthread_rwlock_t)):0)
287 if(name_size > 0 && name)
299 SPEW(_WARN,
"%s() failed: name_size=%zu is smaller than the"
300 " segment name size=%zu with null terminator",
301 __func__, name_size, len+1);
309 SPEW(_WARN,
"%s() failed: malloc() failed", __func__);
318 err = arena_autounlock(arena IF_SPEW(, __func__));
struct arena_header * header
pthread_mutex_t mapping_mutex
ssize_t shm_size(shm_arena_t arena, const void *ptr)
get the size of a shared memory segment
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
ssize_t shm_size_name(shm_arena_t arena, const char *name)
get the size of a shared memory segment