From: Gregory Minshall Date: Sun, 11 Oct 1987 04:39:07 +0000 (-0800) Subject: date and time created 87/10/10 12:39:07 by minshall X-Git-Tag: BSD-4_3_Net_1-Snapshot-Development~3508 X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/commitdiff_plain/097761fdc3e801c2297941d40fc5fb83029667b2 date and time created 87/10/10 12:39:07 by minshall SCCS-vsn: usr.bin/telnet/ring.h 1.1 --- diff --git a/usr/src/usr.bin/telnet/ring.h b/usr/src/usr.bin/telnet/ring.h new file mode 100644 index 0000000000..fc8c9a0ef6 --- /dev/null +++ b/usr/src/usr.bin/telnet/ring.h @@ -0,0 +1,52 @@ +/* + * This defines a structure for a receive or send ring buffer. + * + * The circular buffer actually has three parts: + *((( + * full, sent, not acked: [ack, send) + * full, not sent: [send, add) + * empty: [add, ack) + *]]] + * + * Any given byte will go through "empty" -> "send" -> "ack" -> "empty" + * as data is moved through it. The transition from "ack" to "empty" + * may occur instantaneously (as in the case of sending data up to another + * process). + */ +typedef struct { + char *ack, /* where you can't add at */ + *send, /* where data comes out of */ + *add, /* where data comes in to */ + *bottom, /* lowest address in buffer */ + *top; /* highest address+1 in buffer */ + int size; /* size in bytes of buffer */ + u_long acktime, /* the relations between these clocks */ + sendtime, /* help us keep straight full, empty, etc. */ + addtime; +} Ring; + +/* Here are some functions and macros to deal with the ring buffer */ + + +#if defined(LINT_ARGS) + +/* Data movement routines */ +extern void + ring_add_data(Ring *ring, char *buffer, int count), + ring_send_data(Ring *ring, char *buffer, int count); + +/* Buffer state transition routines */ +extern void + ring_added(Ring *ring, int count), + ring_sent(Ring *ring, int count), + ring_acked(Ring *ring, int count); + +/* Buffer state query routines */ +extern int + ring_empty_count(Ring *ring), + ring_empty_consecutive(Ring *ring), + ring_unsent_count(Ring *ring), + ring_unsent_consecutive(Ring *ring), + ring_unacked_count(Ring *ring); + +#endif /* defined(LINT_ARGS) */