Skip to content
Snippets Groups Projects
Commit fc52db23 authored by Dominik Loidolt's avatar Dominik Loidolt
Browse files

Replace inline with __inline for C89 compatibility

Remove bools
parent beb66c34
No related branches found
No related tags found
1 merge request!30Enhanced Error Handling in Chunk Compression Functions
......@@ -109,7 +109,7 @@
#endif /* USE_BUILTIN_BSWAP */
static inline __attribute__((const)) uint16_t __fswab16(uint16_t val)
static __inline __attribute__((const)) uint16_t __fswab16(uint16_t val)
{
#ifdef __HAVE_BUILTIN_BSWAP16__
return __builtin_bswap16(val);
......@@ -119,7 +119,7 @@ static inline __attribute__((const)) uint16_t __fswab16(uint16_t val)
}
static inline __attribute__((const)) uint32_t __fswab32(uint32_t val)
static __inline __attribute__((const)) uint32_t __fswab32(uint32_t val)
{
#ifdef __HAVE_BUILTIN_BSWAP32__
return __builtin_bswap32(val);
......@@ -129,7 +129,7 @@ static inline __attribute__((const)) uint32_t __fswab32(uint32_t val)
}
static inline __attribute__((const)) uint64_t __fswab64(uint64_t val)
static __inline __attribute__((const)) uint64_t __fswab64(uint64_t val)
{
#ifdef __HAVE_BUILTIN_BSWAP64__
return __builtin_bswap64(val);
......@@ -174,7 +174,7 @@ static inline __attribute__((const)) uint64_t __fswab64(uint64_t val)
* @brief return a byteswapped 16-bit value from a pointer
* @param p a pointer to a naturally-aligned 16-bit value
*/
static inline uint16_t __swab16p(const uint16_t *p)
static __inline uint16_t __swab16p(const uint16_t *p)
{
return __swab16(*p);
}
......@@ -184,7 +184,7 @@ static inline uint16_t __swab16p(const uint16_t *p)
* @brief return a byteswapped 32-bit value from a pointer
* @param p a pointer to a naturally-aligned 32-bit value
*/
static inline uint32_t __swab32p(const uint32_t *p)
static __inline uint32_t __swab32p(const uint32_t *p)
{
return __swab32(*p);
}
......@@ -194,7 +194,7 @@ static inline uint32_t __swab32p(const uint32_t *p)
* @brief return a byteswapped 64-bit value from a pointer
* @param p a pointer to a naturally-aligned 64-bit value
*/
static inline uint64_t __swab64p(const uint64_t *p)
static __inline uint64_t __swab64p(const uint64_t *p)
{
return __swab64(*p);
}
......@@ -205,7 +205,7 @@ static inline uint64_t __swab64p(const uint64_t *p)
* @param p a pointer to a naturally-aligned 16-bit value
*/
static inline void __swab16s(uint16_t *p)
static __inline void __swab16s(uint16_t *p)
{
*p = __swab16p(p);
}
......@@ -216,7 +216,7 @@ static inline void __swab16s(uint16_t *p)
* @param p a pointer to a naturally-aligned 32-bit value
*/
static inline void __swab32s(uint32_t *p)
static __inline void __swab32s(uint32_t *p)
{
*p = __swab32p(p);
}
......@@ -227,7 +227,7 @@ static inline void __swab32s(uint32_t *p)
* @param p a pointer to a naturally-aligned 64-bit value
*/
static inline void __swab64s(uint64_t *p)
static __inline void __swab64s(uint64_t *p)
{
*p = __swab64p(p);
}
......
......@@ -84,7 +84,7 @@
/* fast calculation for data size smaller that uint32_t */
static inline uint16_t cmp_up_model16(uint32_t data, uint32_t model,
static __inline uint16_t cmp_up_model16(uint32_t data, uint32_t model,
unsigned int model_value, unsigned int round)
{
/* round and round back input because for decompression the accurate
......@@ -100,7 +100,7 @@ static inline uint16_t cmp_up_model16(uint32_t data, uint32_t model,
/* slow calculation for uint32_t data size */
static inline uint32_t cmp_up_model32(uint32_t data, uint32_t model,
static __inline uint32_t cmp_up_model32(uint32_t data, uint32_t model,
unsigned int model_value, unsigned int round)
{
/* round and round back input because for decompression the accurate
......
......@@ -78,7 +78,7 @@ struct list_head {
#define LIST_HEAD(name) \
struct list_head name = LIST_HEAD_INIT(name)
static inline void __list_add(struct list_head *new, struct list_head *prev, struct list_head *next)
static __inline void __list_add(struct list_head *new, struct list_head *prev, struct list_head *next)
{
next->prev = new;
new->next = next;
......@@ -95,12 +95,12 @@ static inline void __list_add(struct list_head *new, struct list_head *prev, str
* This is good for implementing stacks.
*/
static inline void list_add(struct list_head *new, struct list_head *head)
static __inline void list_add(struct list_head *new, struct list_head *head)
{
__list_add(new, head, head->next);
}
static inline void INIT_LIST_HEAD(struct list_head *list)
static __inline void INIT_LIST_HEAD(struct list_head *list)
{
list->next = list;
list->prev = list;
......@@ -278,7 +278,7 @@ static inline void INIT_LIST_HEAD(struct list_head *list)
* This is only for internal list manipulation where we know
* the prev/next entries already!
*/
static inline void __list_del(struct list_head *prev, struct list_head *next)
static __inline void __list_del(struct list_head *prev, struct list_head *next)
{
next->prev = prev;
prev->next = next;
......@@ -292,7 +292,7 @@ static inline void __list_del(struct list_head *prev, struct list_head *next)
* the entry is in an undefined state.
*/
static inline void list_del(struct list_head *entry)
static __inline void list_del(struct list_head *entry)
{
__list_del(entry->prev, entry->next);
entry->next = (void *) 0;
......@@ -307,7 +307,7 @@ static inline void list_del(struct list_head *entry)
* in an undefined state.
*/
static inline void __list_del_entry(struct list_head *entry)
static __inline void __list_del_entry(struct list_head *entry)
{
__list_del(entry->prev, entry->next);
}
......@@ -316,7 +316,7 @@ static inline void __list_del_entry(struct list_head *entry)
* @brief deletes entry from list and reinitialize it.
* @param entry the element to delete from the list.
*/
static inline void list_del_init(struct list_head *entry)
static __inline void list_del_init(struct list_head *entry)
{
__list_del_entry(entry);
INIT_LIST_HEAD(entry);
......@@ -327,7 +327,7 @@ static inline void list_del_init(struct list_head *entry)
* @param list the entry to move
* @param head the head that will precede our entry
*/
static inline void list_move(struct list_head *list, struct list_head *head)
static __inline void list_move(struct list_head *list, struct list_head *head)
{
__list_del_entry(list);
list_add(list, head);
......@@ -343,7 +343,7 @@ static inline void list_move(struct list_head *list, struct list_head *head)
* This is useful for implementing queues.
*/
static inline void list_add_tail(struct list_head *new, struct list_head *head)
static __inline void list_add_tail(struct list_head *new, struct list_head *head)
{
__list_add(new, head->prev, head);
}
......@@ -357,7 +357,7 @@ static inline void list_add_tail(struct list_head *new, struct list_head *head)
* If the old parameter was empty, it will be overwritten.
*/
static inline void list_replace(struct list_head *old,
static __inline void list_replace(struct list_head *old,
struct list_head *new)
{
new->next = old->next;
......@@ -372,7 +372,7 @@ static inline void list_replace(struct list_head *old,
* @param entry1 the location to place entry2
* @param entry2 the location to place entry1
*/
static inline void list_swap(struct list_head *entry1,
static __inline void list_swap(struct list_head *entry1,
struct list_head *entry2)
{
struct list_head *pos = entry2->prev;
......@@ -389,7 +389,7 @@ static inline void list_swap(struct list_head *entry1,
* @param head the list to test.
*/
static inline int list_empty(struct list_head *head)
static __inline int list_empty(struct list_head *head)
{
return head->next == head;
}
......@@ -399,7 +399,7 @@ static inline int list_empty(struct list_head *head)
* @param head the list to test.
*/
static inline int list_filled(struct list_head *head)
static __inline int list_filled(struct list_head *head)
{
return head->next != head;
}
......@@ -411,7 +411,7 @@ static inline int list_filled(struct list_head *head)
* @param head the head that will follow our entry
*/
static inline void list_move_tail(struct list_head *list,
static __inline void list_move_tail(struct list_head *list,
struct list_head *head)
{
__list_del(list->prev, list->next);
......@@ -424,7 +424,7 @@ static inline void list_move_tail(struct list_head *list,
* @param head the head of the list
*/
static inline void list_rotate_left(struct list_head *head)
static __inline void list_rotate_left(struct list_head *head)
{
struct list_head *first;
......
......@@ -29,7 +29,6 @@
#if (DEBUGLEVEL > 0)
#include <stdbool.h>
#include <stdint.h>
#include <stddef.h>
#include <stdarg.h>
......@@ -150,7 +149,7 @@ typedef struct {
/* internal buffer output */
static inline void _out_buffer(char character, void* buffer, size_t idx, size_t maxlen)
static __inline void _out_buffer(char character, void* buffer, size_t idx, size_t maxlen)
{
if (idx < maxlen) {
((char*)buffer)[idx] = character;
......@@ -158,7 +157,7 @@ static inline void _out_buffer(char character, void* buffer, size_t idx, size_t
}
/* internal null output */
static inline void _out_null(char character, void* buffer, size_t idx, size_t maxlen)
static __inline void _out_null(char character, void* buffer, size_t idx, size_t maxlen)
{
(void)character; (void)buffer; (void)idx; (void)maxlen;
}
......@@ -168,7 +167,7 @@ static inline void _out_null(char character, void* buffer, size_t idx, size_t ma
* internal secure strlen
* @returns The length of the string (excluding the terminating 0) limited by 'maxsize'
*/
static inline unsigned int _strnlen_s(const char* str, size_t maxsize)
static __inline unsigned int _strnlen_s(const char* str, size_t maxsize)
{
const char* s;
for (s = str; *s && maxsize--; ++s);
......@@ -180,7 +179,7 @@ static inline unsigned int _strnlen_s(const char* str, size_t maxsize)
* internal test if char is a digit (0-9)
* @returns true if char is a digit
*/
static inline bool _is_digit(char ch)
static __inline int _is_digit(char ch)
{
return (ch >= '0') && (ch <= '9');
}
......@@ -227,7 +226,7 @@ static size_t _out_rev(out_fct_type out, char* buffer, size_t idx, size_t maxlen
/* internal itoa format */
static size_t _ntoa_format(out_fct_type out, char* buffer, size_t idx, size_t maxlen, char* buf, size_t len, bool negative, unsigned int base, unsigned int prec, unsigned int width, unsigned int flags)
static size_t _ntoa_format(out_fct_type out, char* buffer, size_t idx, size_t maxlen, char* buf, size_t len, int negative, unsigned int base, unsigned int prec, unsigned int width, unsigned int flags)
{
/* pad leading zeros */
if (!(flags & FLAGS_LEFT)) {
......@@ -281,7 +280,7 @@ static size_t _ntoa_format(out_fct_type out, char* buffer, size_t idx, size_t ma
/* internal itoa for 'long' type */
static size_t _ntoa_long(out_fct_type out, char* buffer, size_t idx, size_t maxlen, unsigned long value, bool negative, unsigned long base, unsigned int prec, unsigned int width, unsigned int flags)
static size_t _ntoa_long(out_fct_type out, char* buffer, size_t idx, size_t maxlen, unsigned long value, int negative, unsigned long base, unsigned int prec, unsigned int width, unsigned int flags)
{
char buf[PRINTF_NTOA_BUFFER_SIZE];
size_t len = 0U;
......@@ -306,7 +305,7 @@ static size_t _ntoa_long(out_fct_type out, char* buffer, size_t idx, size_t maxl
/* internal itoa for 'long long' type */
#if defined(PRINTF_SUPPORT_LONG_LONG)
static size_t _ntoa_long_long(out_fct_type out, char* buffer, size_t idx, size_t maxlen, unsigned long long value, bool negative, unsigned long long base, unsigned int prec, unsigned int width, unsigned int flags)
static size_t _ntoa_long_long(out_fct_type out, char* buffer, size_t idx, size_t maxlen, unsigned long long value, int negative, unsigned long long base, unsigned int prec, unsigned int width, unsigned int flags)
{
char buf[PRINTF_NTOA_BUFFER_SIZE];
size_t len = 0U;
......@@ -344,7 +343,7 @@ static size_t _ftoa(out_fct_type out, char* buffer, size_t idx, size_t maxlen, d
char buf[PRINTF_FTOA_BUFFER_SIZE];
size_t len = 0U;
double diff = 0.0;
bool negative = false;
int negative = 0;
int whole;
double tmp;
unsigned long frac;
......@@ -372,7 +371,7 @@ static size_t _ftoa(out_fct_type out, char* buffer, size_t idx, size_t maxlen, d
/* test for negative */
if (value < 0) {
negative = true;
negative = 1;
value = 0 - value;
}
......@@ -472,7 +471,7 @@ static size_t _ftoa(out_fct_type out, char* buffer, size_t idx, size_t maxlen, d
/* internal ftoa variant for exponential floating-point type, contributed by Martijn Jasperse <m.jasperse@gmail.com> */
static size_t _etoa(out_fct_type out, char* buffer, size_t idx, size_t maxlen, double value, unsigned int prec, unsigned int width, unsigned int flags)
{
const bool negative = value < 0;
const int negative = value < 0;
union {
uint64_t U;
double F;
......@@ -750,15 +749,15 @@ static int _vsnprintf(out_fct_type out, char* buffer, const size_t maxlen, const
/* unsigned */
if (flags & FLAGS_LONG_LONG) {
#if defined(PRINTF_SUPPORT_LONG_LONG)
idx = _ntoa_long_long(out, buffer, idx, maxlen, va_arg(va, unsigned long long), false, base, precision, width, flags);
idx = _ntoa_long_long(out, buffer, idx, maxlen, va_arg(va, unsigned long long), 0, base, precision, width, flags);
#endif
}
else if (flags & FLAGS_LONG) {
idx = _ntoa_long(out, buffer, idx, maxlen, va_arg(va, unsigned long), false, base, precision, width, flags);
idx = _ntoa_long(out, buffer, idx, maxlen, va_arg(va, unsigned long), 0, base, precision, width, flags);
}
else {
const unsigned int value = (flags & FLAGS_CHAR) ? (unsigned char)va_arg(va, unsigned int) : (flags & FLAGS_SHORT) ? (unsigned short int)va_arg(va, unsigned int) : va_arg(va, unsigned int);
idx = _ntoa_long(out, buffer, idx, maxlen, value, false, base, precision, width, flags);
idx = _ntoa_long(out, buffer, idx, maxlen, value, 0, base, precision, width, flags);
}
}
format++;
......@@ -834,11 +833,11 @@ static int _vsnprintf(out_fct_type out, char* buffer, const size_t maxlen, const
flags |= FLAGS_ZEROPAD | FLAGS_UPPERCASE;
#if defined(PRINTF_SUPPORT_LONG_LONG)
if (sizeof(uintptr_t) == sizeof(long long)) {
idx = _ntoa_long_long(out, buffer, idx, maxlen, (uintptr_t)va_arg(va, void*), false, 16U, precision, width, flags);
idx = _ntoa_long_long(out, buffer, idx, maxlen, (uintptr_t)va_arg(va, void*), 0, 16U, precision, width, flags);
}
else {
#endif
idx = _ntoa_long(out, buffer, idx, maxlen, (unsigned long)((uintptr_t)va_arg(va, void*)), false, 16U, precision, width, flags);
idx = _ntoa_long(out, buffer, idx, maxlen, (unsigned long)((uintptr_t)va_arg(va, void*)), 0, 16U, precision, width, flags);
#if defined(PRINTF_SUPPORT_LONG_LONG)
}
#endif
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment