From 4b5c7745936bdfa844bdca069e7f86cc5df70bd9 Mon Sep 17 00:00:00 2001 From: angt Date: Sat, 24 Oct 2015 15:59:52 +0200 Subject: [PATCH] Use common-static.h --- common-static.h | 9 ---- common.h | 113 ------------------------------------------------ glorytun.c | 2 +- 3 files changed, 1 insertion(+), 123 deletions(-) diff --git a/common-static.h b/common-static.h index 854ea37..712181d 100644 --- a/common-static.h +++ b/common-static.h @@ -68,15 +68,6 @@ static inline size_t str_len (const char *restrict str) return i; } -typedef struct buffer buffer_t; - -struct buffer { - uint8_t *data; - uint8_t *read; - uint8_t *write; - uint8_t *end; -}; - static inline void buffer_setup (buffer_t *buffer, void *data, size_t size) { if (!data) diff --git a/common.h b/common.h index c5be591..51f87b1 100644 --- a/common.h +++ b/common.h @@ -6,8 +6,6 @@ #include #include -#include -#include #define COUNT(x) (sizeof(x)/sizeof(x[0])) @@ -20,69 +18,6 @@ #define PALIGN(x) ((void *)ALIGN((size_t)(x))) #define PALIGN_DOWN(x) ((void *)ALIGN_DOWN((size_t)(x))) -static inline void byte_set (void *dst, const char value, size_t size) -{ - if (!dst) - return; - - char *restrict d = dst; - - while (size--) - *d++ = value; -} - -static inline void byte_cpy (void *dst, const void *src, size_t size) -{ - if (!dst || !src) - return; - - char *restrict d = dst; - const char *restrict s = src; - - while (size--) - *d++ = *s++; -} - -static inline size_t str_cpy (char *restrict dst, const char *restrict src, size_t len) -{ - if (!dst || !src) - return 0; - - size_t i; - - for (i=0; idata = data; - buffer->read = data; - buffer->write = data; - buffer->end = data; - buffer->end += size; -} - -static inline void buffer_format (buffer_t *buffer) -{ - buffer->write = buffer->data; - buffer->read = buffer->data; -} - -static inline size_t buffer_size (buffer_t *buffer) -{ - return buffer->end-buffer->data; -} - -static inline size_t buffer_write_size (buffer_t *buffer) -{ - return buffer->end-buffer->write; -} - -static inline size_t buffer_read_size (buffer_t *buffer) -{ - return buffer->write-buffer->read; -} - -static inline void buffer_shift (buffer_t *buffer) -{ - if (buffer->read==buffer->write) { - buffer_format(buffer); - } else { - const uint8_t *src = PALIGN_DOWN(buffer->read); - const size_t size = ALIGN(buffer->write-src); - if (buffer->data+sizedata, src, size); - buffer->read -= src-buffer->data; - buffer->write -= src-buffer->data; - } - } -} diff --git a/glorytun.c b/glorytun.c index ae30ddd..86a7cb4 100644 --- a/glorytun.c +++ b/glorytun.c @@ -1,4 +1,4 @@ -#include "common.h" +#include "common-static.h" #include #include