1 #ifndef IPC_H 2 #define IPC_H 3 4 /* This header file defines constants for MINIX inter-process communication. 5 * These definitions are used in the file proc.c. 6 */ 7 #include <minix/com.h> 8 #include <minix/ipcconst.h> 9 10 /* Masks and flags for system calls. */ 11 #define NON_BLOCKING 0x0080 /* do not block if target not ready */ 12 #define FROM_KERNEL 0x0100 /* message from kernel on behalf of a process */ 13 14 #define WILLRECEIVE(src_e,dst_ptr,m_src_v,m_src_p) \ 15 ((RTS_ISSET(dst_ptr, RTS_RECEIVING) && \ 16 !RTS_ISSET(dst_ptr, RTS_SENDING)) && \ 17 CANRECEIVE(dst_ptr->p_getfrom_e,src_e,dst_ptr,m_src_v,m_src_p)) 18 19 #define CANRECEIVE(receive_e,src_e,dst_ptr,m_src_v,m_src_p) \ 20 (((receive_e) == ANY || (receive_e) == (src_e)) && \ 21 (priv(dst_ptr)->s_ipcf == NULL || \ 22 allow_ipc_filtered_msg(dst_ptr,src_e,m_src_v,m_src_p))) 23 24 /* IPC status code macros. */ 25 #define IPC_STATUS_GET(p) ((p)->p_reg.IPC_STATUS_REG) 26 #define IPC_STATUS_CLEAR(p) ((p)->p_reg.IPC_STATUS_REG = 0) 27 28 /* 29 * XXX: the following check is used to set the status code only on RECEIVE. 30 * SENDREC is not currently atomic for user processes. A process can return 31 * from SENDREC in a different context than the original when a Posix signal 32 * handler gets executed. For this reason, it is not safe to manipulate 33 * the context (i.e. registers) when a process is blocked on a SENDREC. 34 * Unfortunately, avoiding setting the status code for SENDREC doesn't solve 35 * the problem entirely because in rare situations it is still necessary to 36 * override retreg dynamically (and possibly in a different context). 37 * A possible reliable solution is to improve our Posix signal handling 38 * implementation and guarantee SENDREC atomicity w.r.t. the process context. 39 */ 40 #define IPC_STATUS_ADD(p, m) do { \ 41 if(!((p)->p_misc_flags & MF_REPLY_PEND)) { \ 42 (p)->p_reg.IPC_STATUS_REG |= (m); \ 43 } \ 44 } while(0) 45 #define IPC_STATUS_ADD_CALL(p, call) \ 46 IPC_STATUS_ADD(p, IPC_STATUS_CALL_TO(call)) 47 #define IPC_STATUS_ADD_FLAGS(p, flags) \ 48 IPC_STATUS_ADD(p, IPC_STATUS_FLAGS(flags)) 49 50 #endif /* IPC_H */ 51