Subversion Repositories shark

Rev

Rev 422 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
422 giacomo 1
#ifndef _LINUX_MSG_H
2
#define _LINUX_MSG_H
3
 
4
#include <linux/ipc.h>
5
 
6
/* ipcs ctl commands */
7
#define MSG_STAT 11
8
#define MSG_INFO 12
9
 
10
/* msgrcv options */
11
#define MSG_NOERROR     010000  /* no error if message is too big */
12
#define MSG_EXCEPT      020000  /* recv any msg except of specified type.*/
13
 
14
/* Obsolete, used only for backwards compatibility and libc5 compiles */
15
struct msqid_ds {
16
        struct ipc_perm msg_perm;
17
        struct msg *msg_first;          /* first message on queue,unused  */
18
        struct msg *msg_last;           /* last message in queue,unused */
19
        __kernel_time_t msg_stime;      /* last msgsnd time */
20
        __kernel_time_t msg_rtime;      /* last msgrcv time */
21
        __kernel_time_t msg_ctime;      /* last change time */
22
        unsigned long  msg_lcbytes;     /* Reuse junk fields for 32 bit */
23
        unsigned long  msg_lqbytes;     /* ditto */
24
        unsigned short msg_cbytes;      /* current number of bytes on queue */
25
        unsigned short msg_qnum;        /* number of messages in queue */
26
        unsigned short msg_qbytes;      /* max number of bytes on queue */
27
        __kernel_ipc_pid_t msg_lspid;   /* pid of last msgsnd */
28
        __kernel_ipc_pid_t msg_lrpid;   /* last receive pid */
29
};
30
 
31
/* Include the definition of msqid64_ds */
32
#include <asm/msgbuf.h>
33
 
34
/* message buffer for msgsnd and msgrcv calls */
35
struct msgbuf {
36
        long mtype;         /* type of message */
37
        char mtext[1];      /* message text */
38
};
39
 
40
/* buffer for msgctl calls IPC_INFO, MSG_INFO */
41
struct msginfo {
42
        int msgpool;
43
        int msgmap;
44
        int msgmax;
45
        int msgmnb;
46
        int msgmni;
47
        int msgssz;
48
        int msgtql;
49
        unsigned short  msgseg;
50
};
51
 
52
#define MSGMNI    16   /* <= IPCMNI */     /* max # of msg queue identifiers */
53
#define MSGMAX  8192   /* <= INT_MAX */   /* max size of message (bytes) */
54
#define MSGMNB 16384   /* <= INT_MAX */   /* default max size of a message queue */
55
 
56
/* unused */
57
#define MSGPOOL (MSGMNI*MSGMNB/1024)  /* size in kilobytes of message pool */
58
#define MSGTQL  MSGMNB            /* number of system message headers */
59
#define MSGMAP  MSGMNB            /* number of entries in message map */
60
#define MSGSSZ  16                /* message segment size */
61
#define __MSGSEG ((MSGPOOL*1024)/ MSGSSZ) /* max no. of segments */
62
#define MSGSEG (__MSGSEG <= 0xffff ? __MSGSEG : 0xffff)
63
 
64
#ifdef __KERNEL__
65
 
66
/* one msg_msg structure for each message */
67
struct msg_msg {
68
        struct list_head m_list;
69
        long  m_type;          
70
        int m_ts;           /* message text size */
71
        struct msg_msgseg* next;
72
        void *security;
73
        /* the actual message follows immediately */
74
};
75
 
76
#define DATALEN_MSG     (PAGE_SIZE-sizeof(struct msg_msg))
77
#define DATALEN_SEG     (PAGE_SIZE-sizeof(struct msg_msgseg))
78
 
79
/* one msq_queue structure for each present queue on the system */
80
struct msg_queue {
81
        struct kern_ipc_perm q_perm;
82
        time_t q_stime;                 /* last msgsnd time */
83
        time_t q_rtime;                 /* last msgrcv time */
84
        time_t q_ctime;                 /* last change time */
85
        unsigned long q_cbytes;         /* current number of bytes on queue */
86
        unsigned long q_qnum;           /* number of messages in queue */
87
        unsigned long q_qbytes;         /* max number of bytes on queue */
88
        pid_t q_lspid;                  /* pid of last msgsnd */
89
        pid_t q_lrpid;                  /* last receive pid */
90
 
91
        struct list_head q_messages;
92
        struct list_head q_receivers;
93
        struct list_head q_senders;
94
};
95
 
96
asmlinkage long sys_msgget (key_t key, int msgflg);
97
asmlinkage long sys_msgsnd (int msqid, struct msgbuf __user *msgp, size_t msgsz, int msgflg);
98
asmlinkage long sys_msgrcv (int msqid, struct msgbuf __user *msgp, size_t msgsz, long msgtyp, int msgflg);
99
asmlinkage long sys_msgctl (int msqid, int cmd, struct msqid_ds __user *buf);
100
 
101
#endif /* __KERNEL__ */
102
 
103
#endif /* _LINUX_MSG_H */