Compare commits
3 commits
41f817fd5b
...
68af34c428
Author | SHA1 | Date | |
---|---|---|---|
|
68af34c428 | ||
|
8e77f810ec | ||
|
8cbca38726 |
3 changed files with 20 additions and 3 deletions
1
Makefile
1
Makefile
|
@ -10,6 +10,7 @@ ifneq ($(DEBUG), 1)
|
|||
CFLAGS += -fno-exceptions -fno-asynchronous-unwind-tables -fno-ident
|
||||
CFLAGS += -fno-unwind-tables -fno-stack-protector -fno-plt -fno-pic
|
||||
CFLAGS += -O3 -std=c99 -march=native -mtune=native -fomit-frame-pointer
|
||||
CFLAGS += -fshort-enums
|
||||
else
|
||||
CFLAGS += -g -O0 -std=c99 -march=native -mtune=native
|
||||
CFLAGS += -DDEBUG
|
||||
|
|
|
@ -107,7 +107,7 @@ rb_push_many(struct RingBuf *rb, const void *items, MEMCPY_T memcpy_fn,
|
|||
|
||||
// Advance the write head
|
||||
rb->write_head = (char *)rb->write_head + rb->struct_size * n;
|
||||
rb->count+=n;
|
||||
rb->count += n;
|
||||
|
||||
return WriteOk;
|
||||
}
|
||||
|
|
20
ringbuf.h
20
ringbuf.h
|
@ -25,8 +25,24 @@ struct RingBuf {
|
|||
void *buffer_end; /** The end of the buffer */
|
||||
} __attribute__((packed));
|
||||
|
||||
enum WriteResult { Full, WriteOk }; /** Result of a write */
|
||||
enum ReadResult { Empty, ReadOk }; /** Result of a read */
|
||||
/*
|
||||
* Considerations: One hot encoding for the enum values
|
||||
* (8 bit each with -fshort-enums)
|
||||
*/
|
||||
|
||||
/** Result of a write */
|
||||
enum WriteResult {
|
||||
WriteOk, /** The write was successful */
|
||||
Full, /** The buffer is full */
|
||||
InsufficientSpace /** There is not enough space to write */
|
||||
};
|
||||
|
||||
/** Result of a read */
|
||||
enum ReadResult {
|
||||
Empty, /** The buffer is empty */
|
||||
ReadOk, /** The read was successful */
|
||||
InsufficientData /** There is not enough data to read */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Initialize the ring buffer
|
||||
|
|
Loading…
Reference in a new issue