HP85 GPIB Disk Emulator  1.0
HP85GPIBDiskEmulator
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
queue.h
Go to the documentation of this file.
1 
23 #ifndef _QUEUE_H_
24 #define _QUEUE_H_
25 
26 // Named address space
27 #ifndef MEMSPACE
28 #define MEMSPACE
29 #endif
30 
31 #define QUEUE_OVERRUN 1
32 #define QUEUE_EOL 2
33 
35 typedef struct
36 {
37  char *buf; /* Ring buffer */
38  uint8_t flags; /* flags */
39  size_t in; /* input offset */
40  size_t out; /* output offset */
41  size_t bytes; /* bytes used */
42  size_t size; /* Ring buffer size */
43 } queue_t;
44 
45 /* queue.c */
46 queue_t *queue_new ( size_t size );
47 void queue_del ( queue_t *q );
48 void queue_flush ( queue_t *q );
49 size_t queue_used ( queue_t *q );
50 size_t queue_empty ( queue_t *q );
51 size_t queue_space ( queue_t *q );
52 size_t queue_full ( queue_t *q );
53 size_t queue_push_buffer ( queue_t *q , uint8_t *src , size_t size );
54 size_t queue_pop_buffer ( queue_t *q , uint8_t *dst , size_t size );
55 int queue_pushc ( queue_t *q , uint8_t c );
56 int queue_popc ( queue_t *q );
57 #endif
queue_t::buf
char * buf
Definition: queue.h:37
queue_pop_buffer
size_t queue_pop_buffer(queue_t *q, uint8_t *dst, size_t size)
Get a data buffer from the ring buffer. Note: This function does not wait/block until there is enough...
Definition: queue.c:191
queue_del
void queue_del(queue_t *q)
Delete a ring buffer and free memory.
Definition: queue.c:61
dst
dst_t dst
DST start and stop in GMT epoch.
Definition: time.c:52
queue_push_buffer
size_t queue_push_buffer(queue_t *q, uint8_t *src, size_t size)
Add a data buffer to the ring buffer Note: This function does not wait/block util there is enough fre...
Definition: queue.c:161
queue_t::flags
uint8_t flags
Definition: queue.h:38
queue_popc
int queue_popc(queue_t *q)
Remove a byte from the ring buffer Note: This function does not wait/block util there is data to meet...
Definition: queue.c:250
queue_t::in
size_t in
Definition: queue.h:39
queue_full
size_t queue_full(queue_t *q)
Is the ring buffer full ?
Definition: queue.c:143
queue_t
queue structure
Definition: queue.h:35
queue_empty
size_t queue_empty(queue_t *q)
Is the ring buffer empty ?
Definition: queue.c:115
queue_t::out
size_t out
Definition: queue.h:40
queue_used
size_t queue_used(queue_t *q)
Find the number of bytes used by the ring buffer.
Definition: queue.c:102
queue_t::size
size_t size
Definition: queue.h:42
queue_space
size_t queue_space(queue_t *q)
Find the amount of free space remaining in the ring buffer.
Definition: queue.c:130
queue_flush
void queue_flush(queue_t *q)
Flush ring buffer.
Definition: queue.c:86
queue_t::bytes
size_t bytes
Definition: queue.h:41
queue_new
queue_t * queue_new(size_t size)
Create a ring buffer of a given size.
Definition: queue.c:36
queue_pushc
int queue_pushc(queue_t *q, uint8_t c)
Add a byte to the ring buffer Note: This function does not wait/block util there is enough free space...
Definition: queue.c:221