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.
This commit is contained in:
Tomas Hruby 2012-11-14 22:00:29 +00:00 committed by Tomas Hruby
parent 54624a62f1
commit dedb53fb10
2 changed files with 43 additions and 9 deletions

View file

@ -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 */

View file

@ -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);