/* Create new SHM segment and attach to it with specified starting address * hnd : A "init"ed shared mem handle * seg_sz: Size of shared mem segment * shm_addr_ptr (inout): Pointer to specified starting address, the address cannot be NULL. * The actual attached memory address is updated at return. * offset : Offset to attach the shared memory address to */ int MPL_shm_fixed_seg_create_and_attach(MPL_shm_hnd_t hnd, intptr_t seg_sz, void **shm_addr_ptr, int offset) { return MPL_shm_seg_create_attach_templ(hnd, seg_sz, shm_addr_ptr, offset, MPLI_SHM_FLAG_SHM_CREATE | MPLI_SHM_FLAG_SHM_ATTACH | MPLI_SHM_FLAG_FIXED_ADDR); }
/* Create new SHM segment * hnd : A "init"ed shared memory handle * seg_sz : Size of shared memory segment to be created */ int MPL_shm_seg_create(MPL_shm_hnd_t hnd, intptr_t seg_sz) { int rc = -1; rc = MPL_shm_seg_create_attach_templ(hnd, seg_sz, NULL, 0, MPLI_SHM_FLAG_SHM_CREATE); return rc; }
/* Create new SHM segment and attach to it * hnd : A "init"ed shared mem handle * seg_sz: Size of shared mem segment * shm_addr_ptr : Pointer to shared memory address to attach * the shared mem segment * offset : Offset to attach the shared memory address to */ int MPL_shm_seg_create_and_attach(MPL_shm_hnd_t hnd, intptr_t seg_sz, char **shm_addr_ptr, int offset) { int rc = 0; rc = MPL_shm_seg_create_attach_templ(hnd, seg_sz, shm_addr_ptr, offset, MPLI_SHM_FLAG_SHM_CREATE | MPLI_SHM_FLAG_SHM_ATTACH); return rc; }
/* Open an existing SHM segment * hnd : A shm handle with a valid global handle * seg_sz : Size of shared memory segment to open * Currently only using internally within wrapper funcs */ int MPL_shm_seg_open(MPL_shm_hnd_t hnd, intptr_t seg_sz) { return MPL_shm_seg_create_attach_templ(hnd, seg_sz, NULL, 0, MPLI_SHM_FLAG_CLR); }
/* Attach to an existing SHM segment * hnd : A "init"ed shared mem handle * seg_sz: Size of shared mem segment * shm_addr_ptr : Pointer to shared memory address to attach * the shared mem segment * offset : Offset to attach the shared memory address to */ int MPL_shm_seg_attach(MPL_shm_hnd_t hnd, intptr_t seg_sz, void **shm_addr_ptr, int offset) { return MPL_shm_seg_create_attach_templ(hnd, seg_sz, shm_addr_ptr, offset, MPLI_SHM_FLAG_SHM_ATTACH); }