12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- #ifndef __SHM_MEM_H__
- #define __SHM_MEM_H__
- #pragma once
- #include "config.h"
- #ifdef __cplusplus
- extern "C" {
- #endif
- #include <stdarg.h>
- #define SHM_MEM_SIZE 16 /* MB */
- #ifndef INVALID_MAP
- #define INVALID_MAP ((void *)-1)
- #endif // !INVALID_MAP
- /* allocates the memory (mmap or sysv shmap) */
- TOOLKIT_API void* osips_shm_getmem(int, void*, unsigned long);
- /* deallocates the memory allocated by shm_getmem() */
- TOOLKIT_API void osips_shm_relmem(void*, unsigned long);
- TOOLKIT_API void osips_shm_mem_destroy();
- TOOLKIT_API int shm_getmem_addr(void** hint);
- TOOLKIT_API int shm_getmem(int key, void** hint, int);
- TOOLKIT_API void* shm_mem_init(void* hint, int newcreate);
- TOOLKIT_API int shm_mem_init2(int key, void *hint, int newcreate);
- TOOLKIT_API void shm_mem_destroy();
- TOOLKIT_API void shm_mem_destroy2(int newcreate);
- TOOLKIT_API char *shm_strdup(const char *str);
- TOOLKIT_API char *shm_strdup_printf(const char *format, ...);
- TOOLKIT_API char *shm_strdup_vprintf(const char *format, va_list args);
- TOOLKIT_API void shm_lock();
- TOOLKIT_API void shm_unlock();
- //
- TOOLKIT_API void shm_set_user_data(int idx, void *user_data);
- TOOLKIT_API void *shm_get_user_data(int idx);
- TOOLKIT_API void *shm_malloc_unsafe(unsigned int size);
- TOOLKIT_API void* shm_malloc(unsigned int size);
- TOOLKIT_API void shm_free_unsafe(void *_p);
- #define shm_free(_p) \
- do { \
- shm_lock(); \
- shm_free_unsafe( _p ); \
- shm_unlock(); \
- }while(0)
- #ifdef __cplusplus
- } // extern "C" {
- #endif
- #endif //__SHM_MEM_H__
|