2011-02-17 18:11:09 +01:00
|
|
|
#define _SYSTEM 1
|
2014-03-05 12:21:55 +01:00
|
|
|
#define _MINIX_SYSTEM 1
|
2011-02-17 18:11:09 +01:00
|
|
|
|
|
|
|
#include <sys/cdefs.h>
|
|
|
|
#include <lib.h>
|
|
|
|
#include "namespace.h"
|
|
|
|
|
|
|
|
#include <minix/rs.h>
|
|
|
|
#include <lib.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);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Shared memory control operation. */
|
|
|
|
int shmctl(int shmid, int cmd, struct shmid_ds *buf)
|
|
|
|
{
|
|
|
|
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));
|
2011-02-17 18:11:09 +01:00
|
|
|
m.SHMCTL_ID = shmid;
|
|
|
|
m.SHMCTL_CMD = cmd;
|
|
|
|
m.SHMCTL_BUF = (long) buf;
|
|
|
|
|
|
|
|
r = _syscall(ipc_pt, IPC_SHMCTL, &m);
|
|
|
|
if ((cmd == IPC_INFO || cmd == SHM_INFO || cmd == SHM_STAT)
|
|
|
|
&& (r == OK))
|
|
|
|
return m.SHMCTL_RET;
|
|
|
|
return r;
|
|
|
|
}
|
2013-01-07 20:10:08 +01:00
|
|
|
|
2013-01-18 00:06:11 +01:00
|
|
|
#if defined(__minix) && defined(__weak_alias)
|
2013-01-07 20:10:08 +01:00
|
|
|
__weak_alias(shmctl, __shmctl50)
|
|
|
|
#endif
|