Arduino-GPIO
General Purpose Input/Output (GPIO) library for Arduino
iovec.h
Go to the documentation of this file.
1 
19 #ifndef IOVEC_H
20 #define IOVEC_H
21 
25 struct iovec_t {
26  void* buf;
27  size_t size;
28 };
29 
35 inline size_t iovec_size(const iovec_t* vec) __attribute__((always_inline));
36 inline size_t iovec_size(const iovec_t* vec)
37 {
38  size_t len = 0;
39  for (const iovec_t* vp = vec; vp->buf != NULL; vp++)
40  len += vp->size;
41  return (len);
42 }
43 
57 inline void iovec_arg(iovec_t* &vp, const void* buf, size_t size)
58  __attribute__((always_inline));
59 inline void iovec_arg(iovec_t* &vp, const void* buf, size_t size)
60 {
61  vp->buf = (void*) buf;
62  vp->size = size;
63  vp++;
64 }
65 
77 inline void iovec_end(iovec_t* &vp) __attribute__((always_inline));
78 inline void iovec_end(iovec_t* &vp)
79 {
80  vp->buf = 0;
81  vp->size = 0;
82 }
83 #endif
void iovec_arg(iovec_t *&vp, const void *buf, size_t size)
Definition: iovec.h:59
Definition: iovec.h:25
void iovec_end(iovec_t *&vp)
Definition: iovec.h:78
size_t size
Size of buffer in bytes.
Definition: iovec.h:27
void * buf
Buffer pointer.
Definition: iovec.h:26
size_t iovec_size(const iovec_t *vec)
Definition: iovec.h:36