|
|
1.1 root 1: /*
2: * Copyright (c) 1988 Regents of the University of California.
3: * All rights reserved.
4: *
5: * Redistribution and use in source and binary forms are permitted provided
6: * that: (1) source distributions retain this entire copyright notice and
7: * comment, and (2) distributions including binaries display the following
8: * acknowledgement: ``This product includes software developed by the
9: * University of California, Berkeley and its contributors'' in the
10: * documentation or other materials provided with the distribution and in
11: * all advertising materials mentioning features or use of this software.
12: * Neither the name of the University nor the names of its contributors may
13: * be used to endorse or promote products derived from this software without
14: * specific prior written permission.
15: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
16: * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
17: * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
18: *
19: * @(#)ring.h 1.10 (Berkeley) 6/28/90
20: */
21:
22: /*
23: * This defines a structure for a ring buffer.
24: *
25: * The circular buffer has two parts:
26: *(((
27: * full: [consume, supply)
28: * empty: [supply, consume)
29: *]]]
30: *
31: */
32: typedef struct {
33: char *consume, /* where data comes out of */
34: *supply, /* where data comes in to */
35: *bottom, /* lowest address in buffer */
36: *top, /* highest address+1 in buffer */
37: *mark; /* marker (user defined) */
38: int size; /* size in bytes of buffer */
39: u_long consumetime, /* help us keep straight full, empty, etc. */
40: supplytime;
41: } Ring;
42:
43: /* Here are some functions and macros to deal with the ring buffer */
44:
45:
46: #if defined(LINT_ARGS)
47:
48: /* Initialization routine */
49: extern int
50: ring_init(Ring *ring, char *buffer, int count);
51:
52: /* Data movement routines */
53: extern void
54: ring_supply_data(Ring *ring, char *buffer, int count);
55: #ifdef notdef
56: extern void
57: ring_consume_data(Ring *ring, char *buffer, int count);
58: #endif
59:
60: /* Buffer state transition routines */
61: extern void
62: ring_supplied(Ring *ring, int count),
63: ring_consumed(Ring *ring, int count);
64:
65: /* Buffer state query routines */
66: extern int
67: ring_empty_count(Ring *ring),
68: ring_empty_consecutive(Ring *ring),
69: ring_full_count(Ring *ring),
70: ring_full_consecutive(Ring *ring);
71:
72: #else /* LINT_ARGS */
73: extern int
74: ring_init();
75:
76: extern void
77: ring_supply_data();
78: #ifdef notdef
79: extern void
80: ring_consume_data();
81: #endif
82:
83: extern void
84: ring_supplied(),
85: ring_consumed();
86:
87: extern void
88: ring_clear_mark(),
89: ring_mark();
90:
91: extern int
92: ring_empty_count(),
93: ring_empty_consecutive(),
94: ring_full_count(),
95: ring_full_consecutive();
96: #endif /* defined(LINT_ARGS) */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.