28 lines
762 B
C
28 lines
762 B
C
#pragma once
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <stdint.h>
|
|
#include <string.h>
|
|
|
|
// 1500 = internet MTU
|
|
#define RING_BUFFER_SIZE 1500*10
|
|
|
|
struct ring_buffer {
|
|
char buffer[RING_BUFFER_SIZE];
|
|
int head;
|
|
int tail;
|
|
};
|
|
|
|
int ring_buffer_read(struct ring_buffer* rb, char* dest, int size);
|
|
void ring_buffer_ack_read(struct ring_buffer* rb, int size);
|
|
int ring_buffer_write(struct ring_buffer* rb, char* source, int size);
|
|
int ring_buffer_free_space(struct ring_buffer* rb);
|
|
int ring_buffer_used_space(struct ring_buffer* rb);
|
|
|
|
int ring_gt(uint16_t v1, uint16_t v2);
|
|
int ring_ge(uint16_t v1, uint16_t v2);
|
|
int ring_lt(uint16_t v1, uint16_t v2);
|
|
int ring_le(uint16_t v1, uint16_t v2);
|
|
|
|
uint64_t elapsed_micros(struct timespec* t1, struct timespec* t2);
|
|
|