2011-02-17 18:11:09 +01:00
|
|
|
#define _SYSTEM 1
|
2013-02-25 12:43:15 +01:00
|
|
|
|
2011-02-17 18:11:09 +01:00
|
|
|
#include <sys/cdefs.h>
|
|
|
|
#include <lib.h>
|
|
|
|
#include "namespace.h"
|
|
|
|
|
|
|
|
#include <minix/rs.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/ipc.h>
|
|
|
|
#include <sys/shm.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <errno.h>
|
2013-11-04 22:48:08 +01:00
|
|
|
#include <string.h>
|
2011-02-17 18:11:09 +01:00
|
|
|
|
|
|
|
static int get_ipc_endpt(endpoint_t *pt)
|
|
|
|
{
|
|
|
|
return minix_rs_lookup("ipc", pt);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get shared memory segment. */
|
|
|
|
int shmget(key_t key, size_t size, int shmflg)
|
|
|
|
{
|
|
|
|
message m;
|
|
|
|
endpoint_t ipc_pt;
|
|
|
|
int r;
|
|
|
|
|
|
|
|
if (get_ipc_endpt(&ipc_pt) != OK) {
|
|
|
|
errno = ENOSYS;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2013-11-04 22:48:08 +01:00
|
|
|
memset(&m, 0, sizeof(m));
|
2014-07-26 13:53:51 +02:00
|
|
|
m.m_lc_ipc_shmget.key = key;
|
|
|
|
m.m_lc_ipc_shmget.size = size;
|
|
|
|
m.m_lc_ipc_shmget.flag = shmflg;
|
2011-02-17 18:11:09 +01:00
|
|
|
|
|
|
|
r = _syscall(ipc_pt, IPC_SHMGET, &m);
|
|
|
|
if (r != OK)
|
|
|
|
return r;
|
2014-07-26 13:53:51 +02:00
|
|
|
return m.m_lc_ipc_shmget.retid;
|
2011-02-17 18:11:09 +01:00
|
|
|
}
|