msgbuf.h (217688) | msgbuf.h (222537) |
---|---|
1/*- 2 * Copyright (c) 1981, 1984, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 13 unchanged lines hidden (view full) --- 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * 29 * @(#)msgbuf.h 8.1 (Berkeley) 6/2/93 | 1/*- 2 * Copyright (c) 1981, 1984, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 13 unchanged lines hidden (view full) --- 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * 29 * @(#)msgbuf.h 8.1 (Berkeley) 6/2/93 |
30 * $FreeBSD: head/sys/sys/msgbuf.h 217688 2011-01-21 10:26:26Z pluknet $ | 30 * $FreeBSD: head/sys/sys/msgbuf.h 222537 2011-05-31 17:29:58Z ken $ |
31 */ 32 33#ifndef _SYS_MSGBUF_H_ 34#define _SYS_MSGBUF_H_ 35 | 31 */ 32 33#ifndef _SYS_MSGBUF_H_ 34#define _SYS_MSGBUF_H_ 35 |
36#include <sys/lock.h> 37#include <sys/mutex.h> 38 |
|
36struct msgbuf { | 39struct msgbuf { |
37 char *msg_ptr; /* pointer to buffer */ | 40 char *msg_ptr; /* pointer to buffer */ |
38#define MSG_MAGIC 0x063062 | 41#define MSG_MAGIC 0x063062 |
39 u_int msg_magic; 40 u_int msg_size; /* size of buffer area */ 41 u_int msg_wseq; /* write sequence number */ 42 u_int msg_rseq; /* read sequence number */ 43 u_int msg_cksum; /* checksum of contents */ 44 u_int msg_seqmod; /* range for sequence numbers */ | 42 u_int msg_magic; 43 u_int msg_size; /* size of buffer area */ 44 u_int msg_wseq; /* write sequence number */ 45 u_int msg_rseq; /* read sequence number */ 46 u_int msg_cksum; /* checksum of contents */ 47 u_int msg_seqmod; /* range for sequence numbers */ 48 int msg_lastpri; /* saved priority value */ 49 int msg_needsnl; /* set when newline needed */ 50 struct mtx msg_lock; /* mutex to protect the buffer */ |
45}; 46 47/* Normalise a sequence number or a difference between sequence numbers. */ 48#define MSGBUF_SEQNORM(mbp, seq) (((seq) + (mbp)->msg_seqmod) % \ 49 (mbp)->msg_seqmod) 50#define MSGBUF_SEQ_TO_POS(mbp, seq) ((seq) % (mbp)->msg_size) 51/* Subtract sequence numbers. Note that only positive values result. */ 52#define MSGBUF_SEQSUB(mbp, seq1, seq2) (MSGBUF_SEQNORM((mbp), (seq1) - (seq2))) 53 54#ifdef _KERNEL 55extern int msgbufsize; 56extern int msgbuftrigger; 57extern struct msgbuf *msgbufp; 58extern struct mtx msgbuf_lock; 59 60void msgbufinit(void *ptr, int size); 61void msgbuf_addchar(struct msgbuf *mbp, int c); | 51}; 52 53/* Normalise a sequence number or a difference between sequence numbers. */ 54#define MSGBUF_SEQNORM(mbp, seq) (((seq) + (mbp)->msg_seqmod) % \ 55 (mbp)->msg_seqmod) 56#define MSGBUF_SEQ_TO_POS(mbp, seq) ((seq) % (mbp)->msg_size) 57/* Subtract sequence numbers. Note that only positive values result. */ 58#define MSGBUF_SEQSUB(mbp, seq1, seq2) (MSGBUF_SEQNORM((mbp), (seq1) - (seq2))) 59 60#ifdef _KERNEL 61extern int msgbufsize; 62extern int msgbuftrigger; 63extern struct msgbuf *msgbufp; 64extern struct mtx msgbuf_lock; 65 66void msgbufinit(void *ptr, int size); 67void msgbuf_addchar(struct msgbuf *mbp, int c); |
68void msgbuf_addstr(struct msgbuf *mbp, int pri, char *str, int filter_cr); |
|
62void msgbuf_clear(struct msgbuf *mbp); 63void msgbuf_copy(struct msgbuf *src, struct msgbuf *dst); 64int msgbuf_getbytes(struct msgbuf *mbp, char *buf, int buflen); 65int msgbuf_getchar(struct msgbuf *mbp); 66int msgbuf_getcount(struct msgbuf *mbp); 67void msgbuf_init(struct msgbuf *mbp, void *ptr, int size); 68int msgbuf_peekbytes(struct msgbuf *mbp, char *buf, int buflen, 69 u_int *seqp); 70void msgbuf_reinit(struct msgbuf *mbp, void *ptr, int size); 71 72#ifndef MSGBUF_SIZE 73#define MSGBUF_SIZE (32768 * 2) 74#endif 75#endif /* KERNEL */ 76 77#endif /* !_SYS_MSGBUF_H_ */ | 69void msgbuf_clear(struct msgbuf *mbp); 70void msgbuf_copy(struct msgbuf *src, struct msgbuf *dst); 71int msgbuf_getbytes(struct msgbuf *mbp, char *buf, int buflen); 72int msgbuf_getchar(struct msgbuf *mbp); 73int msgbuf_getcount(struct msgbuf *mbp); 74void msgbuf_init(struct msgbuf *mbp, void *ptr, int size); 75int msgbuf_peekbytes(struct msgbuf *mbp, char *buf, int buflen, 76 u_int *seqp); 77void msgbuf_reinit(struct msgbuf *mbp, void *ptr, int size); 78 79#ifndef MSGBUF_SIZE 80#define MSGBUF_SIZE (32768 * 2) 81#endif 82#endif /* KERNEL */ 83 84#endif /* !_SYS_MSGBUF_H_ */ |