25#define LELY_CAN_BUF_INLINE extern inline
33#ifndef LELY_CAN_BUF_SIZE
35#define LELY_CAN_BUF_SIZE 16
45 while (buf->
size - 1 < size)
79 struct can_buf *buf = malloc(
sizeof(*buf));
100can_buf_destroy(
struct can_buf *buf)
115#ifdef LELY_NO_ATOMICS
129 while (
size - 1 < buf->
size - capacity + n)
135 realloc(buf->
ptr, (size + 1) *
sizeof(
struct can_msg));
147 begin += size - buf->
size;
149 memmove(dst, src, (end - src) *
sizeof(
struct can_msg));
153#ifdef LELY_NO_ATOMICS
161 return (begin - end - 1) & buf->
size;
struct can_buf * can_buf_create(size_t size)
Allocates and initializes a CAN frame buffer.
#define LELY_CAN_BUF_SIZE
The minimum size (in number of frames) of a CAN frame buffer.
size_t can_buf_reserve(struct can_buf *buf, size_t n)
Resizes a CAN frame buffer, if necessary, to make room for at least n additional frames.
int can_buf_init(struct can_buf *buf, size_t size)
Initializes a CAN frame buffer.
void can_buf_fini(struct can_buf *buf)
Finalizes a CAN frame buffer.
This header file is part of the CAN library; it contains the CAN frame buffer declarations.
This header file is part of the utilities library; it contains the native and platform-independent er...
int get_errc(void)
Returns the last (thread-specific) native error code set by a system call or library function.
void set_errc(int errc)
Sets the current (thread-specific) native error code to errc.
int errno2c(int errnum)
Transforms a standard C error number to a native error code.
This is the internal header file of the CAN library.
#define atomic_store(object, desired)
Equivalent to atomic_store_explicit(object, desired, memory_order_seq_cst).
#define atomic_load(object)
Equivalent to #atomic_load_explicit(object, memory_order_seq_cst).
#define atomic_init(obj, value)
Initializes the atomic object at obj with the value value.
This header file is part of the C11 and POSIX compatibility library; it includes <stdlib....
This header file is part of the C11 and POSIX compatibility library; it includes <string....
struct can_msg * ptr
A pointer to the allocated memory for the buffer.
size_t end
The offset (with respect to ptr) of one past the last value available for reading (and the first avai...
size_t begin
The offset (with respect to ptr) of the first value available for reading (and two past the last avai...
size_t size
The total size (in number of frames) of the buffer, excluding the unused frame used to distinguish be...
A CAN or CAN FD format frame.