#define IPC_SHMAT (IPC_BASE+2)
#define IPC_SHMDT (IPC_BASE+3)
#define IPC_SHMCTL (IPC_BASE+4)
-# define SHMCTL_ID m2_i1
-# define SHMCTL_CMD m2_i2
-# define SHMCTL_BUF m2_l1
-# define SHMCTL_RET m2_i3
/* Semaphore */
#define IPC_SEMGET (IPC_BASE+5)
-# define SEMGET_KEY m2_l1
-# define SEMGET_NR m2_i1
-# define SEMGET_FLAG m2_i2
-# define SEMGET_RETID m2_i3
#define IPC_SEMCTL (IPC_BASE+6)
-# define SEMCTL_ID m2_i1
-# define SEMCTL_NUM m2_i2
-# define SEMCTL_CMD m2_i3
-# define SEMCTL_OPT m2_l1
#define IPC_SEMOP (IPC_BASE+7)
# define SEMOP_ID m2_i1
# define SEMOP_OPS m2_l1
} mess_lc_ipc_shmdt;
_ASSERT_MSG_SIZE(mess_lc_ipc_shmdt);
+typedef struct {
+ int id;
+ int cmd;
+ void *buf;
+ int ret;
+ uint8_t padding[40];
+} mess_lc_ipc_shmctl;
+_ASSERT_MSG_SIZE(mess_lc_ipc_shmctl);
+
+typedef struct {
+ key_t key;
+ int nr;
+ int flag;
+ int retid;
+ uint8_t padding[40];
+} mess_lc_ipc_semget;
+_ASSERT_MSG_SIZE(mess_lc_ipc_semget);
+
+typedef struct {
+ int id;
+ int num;
+ int cmd;
+ int opt;
+ int ret;
+ uint8_t padding[36];
+} mess_lc_ipc_semctl;
+_ASSERT_MSG_SIZE(mess_lc_ipc_semctl);
+
typedef struct {
endpoint_t m_source; /* who sent the message */
int m_type; /* what kind of message is it */
mess_lc_ipc_shmget m_lc_ipc_shmget;
mess_lc_ipc_shmat m_lc_ipc_shmat;
mess_lc_ipc_shmdt m_lc_ipc_shmdt;
+ mess_lc_ipc_shmctl m_lc_ipc_shmctl;
+ mess_lc_ipc_semget m_lc_ipc_semget;
+ mess_lc_ipc_semctl m_lc_ipc_semctl;
mess_vfs_lchardriver_cancel m_vfs_lchardriver_cancel;
mess_vfs_lchardriver_openclose m_vfs_lchardriver_openclose;
}
memset(&m, 0, sizeof(m));
- m.SEMGET_KEY = key;
- m.SEMGET_NR = nsems;
- m.SEMGET_FLAG = semflag;
+ m.m_lc_ipc_semget.key = key;
+ m.m_lc_ipc_semget.nr = nsems;
+ m.m_lc_ipc_semget.flag = semflag;
r = _syscall(ipc_pt, IPC_SEMGET, &m);
if (r != OK)
return r;
- return m.SEMGET_RETID;
+ return m.m_lc_ipc_semget.retid;
}
/* Semaphore control operation. */
}
memset(&m, 0, sizeof(m));
- m.SEMCTL_ID = semid;
- m.SEMCTL_NUM = semnum;
- m.SEMCTL_CMD = cmd;
+ m.m_lc_ipc_semctl.id = semid;
+ m.m_lc_ipc_semctl.num = semnum;
+ m.m_lc_ipc_semctl.cmd = cmd;
va_start(ap, cmd);
if (cmd == IPC_STAT || cmd == IPC_SET || cmd == IPC_INFO ||
cmd == SEM_INFO || cmd == SEM_STAT || cmd == GETALL ||
cmd == SETALL || cmd == SETVAL)
- m.SEMCTL_OPT = (long) va_arg(ap, long);
+ m.m_lc_ipc_semctl.opt = (long) va_arg(ap, long);
va_end(ap);
r = _syscall(ipc_pt, IPC_SEMCTL, &m);
if ((r != -1) && (cmd == GETNCNT || cmd == GETZCNT || cmd == GETPID ||
cmd == GETVAL || cmd == IPC_INFO || cmd == SEM_INFO ||
cmd == SEM_STAT))
- return m.SHMCTL_RET;
+ return m.m_lc_ipc_semctl.ret;
return r;
}
}
memset(&m, 0, sizeof(m));
- m.SHMCTL_ID = shmid;
- m.SHMCTL_CMD = cmd;
- m.SHMCTL_BUF = (long) buf;
+ m.m_lc_ipc_shmctl.id = shmid;
+ m.m_lc_ipc_shmctl.cmd = cmd;
+ m.m_lc_ipc_shmctl.buf = 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 m.m_lc_ipc_shmctl.ret;
return r;
}
int nsems, flag, id;
struct sem_struct *sem;
- key = m->SEMGET_KEY;
- nsems = m->SEMGET_NR;
- flag = m->SEMGET_FLAG;
+ key = m->m_lc_ipc_semget.key;
+ nsems = m->m_lc_ipc_semget.nr;
+ flag = m->m_lc_ipc_semget.flag;
if ((sem = sem_find_key(key))) {
if ((flag & IPC_CREAT) && (flag & IPC_EXCL))
sem_list_nr++;
}
- m->SEMGET_RETID = id;
+ m->m_lc_ipc_semget.retid = id;
return OK;
}
struct semid_ds *ds, tmp_ds;
struct sem_struct *sem;
- id = m->SEMCTL_ID;
- num = m->SEMCTL_NUM;
- cmd = m->SEMCTL_CMD;
+ id = m->m_lc_ipc_semctl.id;
+ num = m->m_lc_ipc_semctl.num;
+ cmd = m->m_lc_ipc_semctl.cmd;
if (cmd == IPC_STAT || cmd == IPC_SET || cmd == IPC_INFO ||
cmd == SEM_INFO || cmd == SEM_STAT || cmd == GETALL ||
cmd == SETALL || cmd == SETVAL)
- opt = m->SEMCTL_OPT;
+ opt = m->m_lc_ipc_semctl.opt;
if (!(sem = sem_find_id(id))) {
return EINVAL;
case GETNCNT:
if (num < 0 || num >= sem->semid_ds.sem_nsems)
return EINVAL;
- m->SHMCTL_RET = sem->sems[num].semncnt;
+ m->m_lc_ipc_semctl.ret = sem->sems[num].semncnt;
break;
case GETPID:
if (num < 0 || num >= sem->semid_ds.sem_nsems)
return EINVAL;
- m->SHMCTL_RET = sem->sems[num].sempid;
+ m->m_lc_ipc_semctl.ret = sem->sems[num].sempid;
break;
case GETVAL:
if (num < 0 || num >= sem->semid_ds.sem_nsems)
return EINVAL;
- m->SHMCTL_RET = sem->sems[num].semval;
+ m->m_lc_ipc_semctl.ret = sem->sems[num].semval;
break;
case GETZCNT:
if (num < 0 || num >= sem->semid_ds.sem_nsems)
return EINVAL;
- m->SHMCTL_RET = sem->sems[num].semzcnt;
+ m->m_lc_ipc_semctl.ret = sem->sems[num].semzcnt;
break;
case SETALL:
buf = malloc(sizeof(unsigned short) * sem->semid_ds.sem_nsems);
*===========================================================================*/
int do_shmctl(message *m)
{
- int id = m->SHMCTL_ID;
- int cmd = m->SHMCTL_CMD;
- struct shmid_ds *ds = (struct shmid_ds *)m->SHMCTL_BUF;
+ int id = m->m_lc_ipc_shmctl.id;
+ int cmd = m->m_lc_ipc_shmctl.cmd;
+ struct shmid_ds *ds = (struct shmid_ds *)m->m_lc_ipc_shmctl.buf;
struct shmid_ds tmp_ds;
struct shm_struct *shm = NULL;
struct shminfo sinfo;
who_e, (vir_bytes)ds, sizeof(struct shminfo));
if (r != OK)
return EFAULT;
- m->SHMCTL_RET = shm_list_nr - 1;
- if (m->SHMCTL_RET < 0)
- m->SHMCTL_RET = 0;
+ m->m_lc_ipc_shmctl.ret = (shm_list_nr - 1);
+ if (m->m_lc_ipc_shmctl.ret < 0)
+ m->m_lc_ipc_shmctl.ret = 0;
break;
case SHM_INFO:
if (!ds)
who_e, (vir_bytes)ds, sizeof(struct shm_info));
if (r != OK)
return EFAULT;
- m->SHMCTL_RET = shm_list_nr - 1;
- if (m->SHMCTL_RET < 0)
- m->SHMCTL_RET = 0;
+ m->m_lc_ipc_shmctl.ret = shm_list_nr - 1;
+ if (m->m_lc_ipc_shmctl.ret < 0)
+ m->m_lc_ipc_shmctl.ret = 0;
break;
case SHM_STAT:
if (id < 0 || id >= shm_list_nr)
who_e, (vir_bytes)ds, sizeof(struct shmid_ds));
if (r != OK)
return EFAULT;
- m->SHMCTL_RET = shm->id;
+ m->m_lc_ipc_shmctl.ret = shm->id;
break;
default:
return EINVAL;