29 return SSVM_API_ERROR_NO_SIZE;
31 ssvm_filename =
format (0,
"/dev/shm/%s%c", ssvm->
name, 0);
33 unlink ((
char *) ssvm_filename);
37 ssvm_fd = shm_open((
char *) ssvm->
name, O_RDWR | O_CREAT | O_EXCL, 0777);
42 return SSVM_API_ERROR_CREATE_FAILURE;
45 lseek(ssvm_fd, ssvm->
ssvm_size, SEEK_SET);
46 if (write(ssvm_fd, &junk, 1) != 1)
50 return SSVM_API_ERROR_SET_SIZE;
63 PROT_READ | PROT_WRITE,
flags, ssvm_fd, 0);
65 if (ssvm->
sh == MAP_FAILED)
69 return SSVM_API_ERROR_MMAP;
102 while (timeout_in_seconds-- > 0)
105 ssvm_fd = shm_open((
char *)ssvm->
name, O_RDWR, 0777);
111 if (fstat(ssvm_fd, &stat) < 0)
117 if (stat.st_size > 0)
121 return SSVM_API_ERROR_SLAVE_TIMEOUT;
124 sh = (
void *) mmap (0,
MMAP_PAGESIZE, PROT_READ | PROT_WRITE, MAP_SHARED,
126 if (sh == MAP_FAILED)
130 return SSVM_API_ERROR_MMAP;
133 while (timeout_in_seconds-- > 0)
141 return SSVM_API_ERROR_SLAVE_TIMEOUT;
149 PROT_READ | PROT_WRITE,
150 MAP_SHARED | MAP_FIXED,
153 if (sh == MAP_FAILED)
157 return SSVM_API_ERROR_MMAP;
int ssvm_master_init(ssvm_private_t *ssvm, u32 master_index)
ssvm_shared_header_t * sh
#define MHEAP_FLAG_THREAD_SAFE
#define MHEAP_FLAG_DISABLE_VM
static void * ssvm_push_heap(ssvm_shared_header_t *sh)
#define clib_warning(format, args...)
static void ssvm_pop_heap(void *oldheap)
static uword pointer_to_uword(const void *p)
int ssvm_slave_init(ssvm_private_t *ssvm, int timeout_in_seconds)
#define vec_free(V)
Free vector's memory (no header).
#define clib_unix_warning(format, args...)
void * mheap_alloc_with_flags(void *memory, uword memory_size, uword flags)
always_inline u64 clib_cpu_time_now(void)