From dedb53fb102ba7c079b7ee84ffdbf30f73110cbc Mon Sep 17 00:00:00 2001 From: Tomas Hruby Date: Wed, 14 Nov 2012 22:00:29 +0000 Subject: [PATCH] ipc.h - IPC defined as functions again - CHOOSETRAP define makes impossible to use some common words like send, receive and notify in any other context, for instance as members or structures - any reasonable compiler inlines the static inline functions so no extra function call overhead is introduced by this change - this gets us back to the situation before the SYSCALL/SYSENTER change. It is not perfect, but it used to work and still does. --- include/minix/ipc.h | 50 ++++++++++++++++++++++++++++++++++++------- servers/procfs/root.c | 2 +- 2 files changed, 43 insertions(+), 9 deletions(-) diff --git a/include/minix/ipc.h b/include/minix/ipc.h index 48a92da52..c8c4efbf7 100644 --- a/include/minix/ipc.h +++ b/include/minix/ipc.h @@ -163,6 +163,15 @@ int _do_kernel_call_orig(message *m_ptr); int _minix_kernel_info_struct(struct minix_kerninfo **); +/* Hide names to avoid name space pollution. */ +#define notify _notify +#define sendrec _sendrec +#define receive _receive +#define receivenb _receivenb +#define send _send +#define sendnb _sendnb +#define senda _senda + struct minix_ipcvecs { int (*send_ptr)(endpoint_t dest, message *m_ptr); int (*receive_ptr)(endpoint_t src, message *m_ptr, int *st); @@ -176,14 +185,39 @@ struct minix_ipcvecs { /* kernel-set IPC vectors retrieved by a constructor in libc/sys-minix/init.c */ extern struct minix_ipcvecs _minix_ipcvecs; -#define CHOOSETRAP(name) (_minix_ipcvecs. name ## _ptr) +static inline int _send(endpoint_t dest, message *m_ptr) +{ + return _minix_ipcvecs.send_ptr(dest, m_ptr); +} -#define send CHOOSETRAP(send) -#define receive CHOOSETRAP(receive) -#define sendrec CHOOSETRAP(sendrec) -#define sendnb CHOOSETRAP(sendnb) -#define notify CHOOSETRAP(notify) -#define do_kernel_call CHOOSETRAP(do_kernel_call) -#define senda CHOOSETRAP(senda) +static inline int _receive(endpoint_t src, message *m_ptr, int *st) +{ + return _minix_ipcvecs.receive_ptr(src, m_ptr, st); +} + +static inline int _sendrec(endpoint_t src_dest, message *m_ptr) +{ + return _minix_ipcvecs.sendrec_ptr(src_dest, m_ptr); +} + +static inline int _sendnb(endpoint_t dest, message *m_ptr) +{ + return _minix_ipcvecs.send_ptr(dest, m_ptr); +} + +static inline int _notify(endpoint_t dest) +{ + return _minix_ipcvecs.notify_ptr(dest); +} + +static inline int do_kernel_call(message *m_ptr) +{ + return _minix_ipcvecs.do_kernel_call_ptr(m_ptr); +} + +static inline int _senda(asynmsg_t *table, size_t count) +{ + return _minix_ipcvecs.senda_ptr(table, count); +} #endif /* _IPC_H */ diff --git a/servers/procfs/root.c b/servers/procfs/root.c index f97a9dad4..44ee10539 100644 --- a/servers/procfs/root.c +++ b/servers/procfs/root.c @@ -185,7 +185,7 @@ static void root_ipcvecs(void) * to distinguish them from regular symbols. */ #define PRINT_ENTRYPOINT(name) \ - buf_printf("%08lx T %s(k)\n", _minix_ipcvecs.name ## _ptr, #name) + buf_printf("%08lx T %s(k)\n", _minix_ipcvecs.name, #name) PRINT_ENTRYPOINT(sendrec); PRINT_ENTRYPOINT(send);