xref: /original-bsd/usr.bin/telnet/ring.h (revision 9acaf688)
1 /*
2  * Copyright (c) 1988 Regents of the University of California.
3  * All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  *
7  *	@(#)ring.h	1.9 (Berkeley) 06/01/90
8  */
9 
10 /*
11  * This defines a structure for a ring buffer.
12  *
13  * The circular buffer has two parts:
14  *(((
15  *	full:	[consume, supply)
16  *	empty:	[supply, consume)
17  *]]]
18  *
19  */
20 typedef struct {
21     char	*consume,	/* where data comes out of */
22     		*supply,	/* where data comes in to */
23 		*bottom,	/* lowest address in buffer */
24 		*top,		/* highest address+1 in buffer */
25 		*mark;		/* marker (user defined) */
26     int		size;		/* size in bytes of buffer */
27     u_long	consumetime,	/* help us keep straight full, empty, etc. */
28 		supplytime;
29 } Ring;
30 
31 /* Here are some functions and macros to deal with the ring buffer */
32 
33 
34 #if	defined(LINT_ARGS)
35 
36 /* Initialization routine */
37 extern int
38 	ring_init(Ring *ring, char *buffer, int count);
39 
40 /* Data movement routines */
41 extern void
42 	ring_supply_data(Ring *ring, char *buffer, int count),
43 	ring_consume_data(Ring *ring, char *buffer, int count);
44 
45 /* Buffer state transition routines */
46 extern void
47 	ring_supplied(Ring *ring, int count),
48 	ring_consumed(Ring *ring, int count);
49 
50 /* Buffer state query routines */
51 extern int
52 	ring_empty_count(Ring *ring),
53 	ring_empty_consecutive(Ring *ring),
54 	ring_full_count(Ring *ring),
55 	ring_full_consecutive(Ring *ring);
56 
57 #else /* LINT_ARGS */
58 extern int
59 	ring_init();
60 
61 extern void
62     ring_supply_data(),
63     ring_consume_data();
64 
65 extern void
66     ring_supplied(),
67     ring_consumed();
68 
69 extern void
70     ring_clear_mark(),
71     ring_mark();
72 
73 extern int
74     ring_empty_count(),
75     ring_empty_consecutive(),
76     ring_full_count(),
77     ring_full_consecutive();
78 #endif	/* defined(LINT_ARGS) */
79