sprofalyze fixes
[minix.git] / kernel / ipc.h
bloba62919eb94542f58c660803cf44dce0b4e8e7160
1 #ifndef IPC_H
2 #define IPC_H
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>
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 */
14 #define WILLRECEIVE(target, source_ep) \
15 ((RTS_ISSET(target, RTS_RECEIVING) && !RTS_ISSET(target, RTS_SENDING)) && \
16 (target->p_getfrom_e == ANY || target->p_getfrom_e == source_ep))
18 /* IPC status code macros. */
19 #define IPC_STATUS_GET(p) ((p)->p_reg.IPC_STATUS_REG)
20 #define IPC_STATUS_CLEAR(p) ((p)->p_reg.IPC_STATUS_REG = 0)
23 * XXX: the following check is used to set the status code only on RECEIVE.
24 * SENDREC is not currently atomic for user processes. A process can return
25 * from SENDREC in a different context than the original when a Posix signal
26 * handler gets executed. For this reason, it is not safe to manipulate
27 * the context (i.e. registers) when a process is blocked on a SENDREC.
28 * Unfortunately, avoiding setting the status code for SENDREC doesn't solve
29 * the problem entirely because in rare situations it is still necessary to
30 * override retreg dynamically (and possibly in a different context).
31 * A possible reliable solution is to improve our Posix signal handling
32 * implementation and guarantee SENDREC atomicity w.r.t. the process context.
34 #define IPC_STATUS_ADD(p, m) do { \
35 if(!((p)->p_misc_flags & MF_REPLY_PEND)) { \
36 (p)->p_reg.IPC_STATUS_REG |= (m); \
37 } \
38 } while(0)
39 #define IPC_STATUS_ADD_CALL(p, call) \
40 IPC_STATUS_ADD(p, IPC_STATUS_CALL_TO(call))
41 #define IPC_STATUS_ADD_FLAGS(p, flags) \
42 IPC_STATUS_ADD(p, IPC_STATUS_FLAGS(flags))
44 #endif /* IPC_H */