etc/services - sync with NetBSD-8
[minix.git] / minix / lib / libc / sys / shmget.c
blob5cb373daf131b1de018151ae0625f4fa4277ba40
1 #define _SYSTEM 1
3 #include <sys/cdefs.h>
4 #include <lib.h>
5 #include "namespace.h"
7 #include <minix/rs.h>
8 #include <sys/types.h>
9 #include <sys/ipc.h>
10 #include <sys/shm.h>
11 #include <stdlib.h>
12 #include <errno.h>
13 #include <string.h>
15 static int get_ipc_endpt(endpoint_t *pt)
17 return minix_rs_lookup("ipc", pt);
20 /* Get shared memory segment. */
21 int shmget(key_t key, size_t size, int shmflg)
23 message m;
24 endpoint_t ipc_pt;
25 int r;
27 if (get_ipc_endpt(&ipc_pt) != OK) {
28 errno = ENOSYS;
29 return -1;
32 memset(&m, 0, sizeof(m));
33 m.m_lc_ipc_shmget.key = key;
34 m.m_lc_ipc_shmget.size = size;
35 m.m_lc_ipc_shmget.flag = shmflg;
37 r = _syscall(ipc_pt, IPC_SHMGET, &m);
38 if (r != OK)
39 return r;
40 return m.m_lc_ipc_shmget.retid;