From e57d31d3312907ef3b9604f6aaaf1d6d83b096ca Mon Sep 17 00:00:00 2001 From: Ben Gras Date: Sat, 26 Jul 2014 13:53:52 +0200 Subject: [PATCH] custom messages for SHMAT, SHMDT --- include/minix/com.h | 5 ----- include/minix/ipc.h | 17 +++++++++++++++++ lib/libc/sys-minix/shmat.c | 10 +++++----- servers/ipc/shm.c | 10 +++++----- 4 files changed, 27 insertions(+), 15 deletions(-) diff --git a/include/minix/com.h b/include/minix/com.h index 942b131e2..67bc7a1f1 100644 --- a/include/minix/com.h +++ b/include/minix/com.h @@ -828,12 +828,7 @@ /* Shared Memory */ #define IPC_SHMGET (IPC_BASE+1) #define IPC_SHMAT (IPC_BASE+2) -# define SHMAT_ID m2_i1 -# define SHMAT_ADDR m2_l1 -# define SHMAT_FLAG m2_i2 -# define SHMAT_RETADDR m2_l2 #define IPC_SHMDT (IPC_BASE+3) -# define SHMDT_ADDR m2_l1 #define IPC_SHMCTL (IPC_BASE+4) # define SHMCTL_ID m2_i1 # define SHMCTL_CMD m2_i2 diff --git a/include/minix/ipc.h b/include/minix/ipc.h index 19aeb8bec..374da5358 100644 --- a/include/minix/ipc.h +++ b/include/minix/ipc.h @@ -1774,6 +1774,21 @@ typedef struct { } mess_lc_ipc_shmget; _ASSERT_MSG_SIZE(mess_lc_ipc_shmget); +typedef struct { + int id; + const void *addr; + int flag; + void *retaddr; + uint8_t padding[40]; +} mess_lc_ipc_shmat; +_ASSERT_MSG_SIZE(mess_lc_ipc_shmat); + +typedef struct { + const void *addr; + uint8_t padding[52]; +} mess_lc_ipc_shmdt; +_ASSERT_MSG_SIZE(mess_lc_ipc_shmdt); + typedef struct { endpoint_t m_source; /* who sent the message */ int m_type; /* what kind of message is it */ @@ -2001,6 +2016,8 @@ typedef struct { mess_lsys_vm_update m_lsys_vm_update; mess_lsys_vm_watch_exit m_lsys_vm_watch_exit; 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_vfs_lchardriver_cancel m_vfs_lchardriver_cancel; mess_vfs_lchardriver_openclose m_vfs_lchardriver_openclose; diff --git a/lib/libc/sys-minix/shmat.c b/lib/libc/sys-minix/shmat.c index aa99007b4..66466d952 100644 --- a/lib/libc/sys-minix/shmat.c +++ b/lib/libc/sys-minix/shmat.c @@ -33,14 +33,14 @@ void *shmat(int shmid, const void *shmaddr, int shmflg) } memset(&m, 0, sizeof(m)); - m.SHMAT_ID = shmid; - m.SHMAT_ADDR = (long) shmaddr; - m.SHMAT_FLAG = shmflg; + m.m_lc_ipc_shmat.id = shmid; + m.m_lc_ipc_shmat.addr = shmaddr; + m.m_lc_ipc_shmat.flag = shmflg; r = _syscall(ipc_pt, IPC_SHMAT, &m); if (r != OK) return (void *) -1; - return (void *) m.SHMAT_RETADDR; + return m.m_lc_ipc_shmat.retaddr; } /* Deattach shared memory segment. */ @@ -55,7 +55,7 @@ int shmdt(const void *shmaddr) } memset(&m, 0, sizeof(m)); - m.SHMDT_ADDR = (long) shmaddr; + m.m_lc_ipc_shmdt.addr = shmaddr; return _syscall(ipc_pt, IPC_SHMDT, &m); } diff --git a/servers/ipc/shm.c b/servers/ipc/shm.c index d213301a1..da90a9cbd 100644 --- a/servers/ipc/shm.c +++ b/servers/ipc/shm.c @@ -111,9 +111,9 @@ int do_shmat(message *m) void *ret; struct shm_struct *shm; - id = m->SHMAT_ID; - addr = (vir_bytes) m->SHMAT_ADDR; - flag = m->SHMAT_FLAG; + id = m->m_lc_ipc_shmat.id; + addr = (vir_bytes) m->m_lc_ipc_shmat.addr; + flag = m->m_lc_ipc_shmat.flag; if (addr && (addr % PAGE_SIZE)) { if (flag & SHM_RND) @@ -141,7 +141,7 @@ int do_shmat(message *m) shm->shmid_ds.shm_lpid = getnpid(who_e); /* nattach is updated lazily */ - m->SHMAT_RETADDR = (long) ret; + m->m_lc_ipc_shmat.retaddr = ret; return OK; } @@ -186,7 +186,7 @@ int do_shmdt(message *m) phys_bytes vm_id; int i; - addr = m->SHMDT_ADDR; + addr = (vir_bytes) m->m_lc_ipc_shmdt.addr; if ((vm_id = vm_getphys(who_e, (void *) addr)) == 0) return EINVAL;