Skip to content

Commit

Permalink
core: uncrustify
Browse files Browse the repository at this point in the history
  • Loading branch information
kaspar030 committed Mar 30, 2020
1 parent f99bc89 commit 8efe596
Show file tree
Hide file tree
Showing 35 changed files with 352 additions and 241 deletions.
15 changes: 9 additions & 6 deletions core/atomic_c11.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ TEMPLATE_ATOMIC_OP_FETCH_N(nand, &, 8, ~) /* __atomic_nand_fetch_8 */
*/
void __atomic_load_c(size_t size, const void *src, void *dest, int memorder)
{
(void) memorder;
(void)memorder;
unsigned int mask = irq_disable();
memcpy(dest, src, size);
irq_restore(mask);
Expand All @@ -288,7 +288,7 @@ void __atomic_load_c(size_t size, const void *src, void *dest, int memorder)
*/
void __atomic_store_c(size_t size, void *dest, const void *src, int memorder)
{
(void) memorder;
(void)memorder;
unsigned int mask = irq_disable();
memcpy(dest, src, size);
irq_restore(mask);
Expand All @@ -303,9 +303,10 @@ void __atomic_store_c(size_t size, void *dest, const void *src, int memorder)
* @param[in] ret put the old value from @p ptr in @p ret
* @param[in] memorder memory ordering, ignored in this implementation
*/
void __atomic_exchange_c(size_t size, void *ptr, void *val, void *ret, int memorder)
void __atomic_exchange_c(size_t size, void *ptr, void *val, void *ret,
int memorder)
{
(void) memorder;
(void)memorder;
unsigned int mask = irq_disable();
memcpy(ret, ptr, size);
memcpy(ptr, val, size);
Expand Down Expand Up @@ -345,7 +346,8 @@ void __atomic_exchange_c(size_t size, void *ptr, void *val, void *ret, int memor
* @return false otherwise
*/
bool __atomic_compare_exchange_c(size_t len, void *ptr, void *expected,
void *desired, bool weak, int success_memorder, int failure_memorder)
void *desired, bool weak, int success_memorder,
int failure_memorder)
{
(void)weak;
(void)success_memorder;
Expand All @@ -366,7 +368,8 @@ bool __atomic_compare_exchange_c(size_t len, void *ptr, void *expected,
#if !defined(__llvm__) && !defined(__clang__)
/* Memory barrier helper function, for platforms without barrier instructions */
void __sync_synchronize(void) __attribute__((__weak__));
void __sync_synchronize(void) {
void __sync_synchronize(void)
{
/* ARMv4, ARMv5 do not have any hardware support for memory barriers,
* This is a software only barrier and a no-op, and will likely break on SMP
* systems, but we don't support any multi-CPU ARMv5 or ARMv4 boards in RIOT
Expand Down
1 change: 1 addition & 0 deletions core/bitarithm.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ unsigned bitarithm_bits_set(unsigned v)
uint8_t bitarithm_bits_set_u32(uint32_t v)
{
uint8_t c;

for (c = 0; v; c++) {
v &= v - 1; /* clear the least significant bit set */
}
Expand Down
3 changes: 2 additions & 1 deletion core/cond.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ static void _cond_signal(cond_t *cond, bool broadcast)
uint16_t min_prio = THREAD_PRIORITY_MIN + 1;

while ((next = list_remove_head(&cond->queue)) != NULL) {
thread_t *process = container_of((clist_node_t *)next, thread_t, rq_entry);
thread_t *process = container_of((clist_node_t *)next, thread_t,
rq_entry);
sched_set_status(process, STATUS_PENDING);
uint16_t process_priority = process->priority;
if (process_priority < min_prio) {
Expand Down
8 changes: 5 additions & 3 deletions core/include/assert.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ extern "C" {
extern const char assert_crash_message[];

#ifdef NDEBUG
#define assert(ignore)((void) 0)
#define assert(ignore)((void)0)
#elif defined(DEBUG_ASSERT_VERBOSE)
/**
* @brief Function to handle failed assertion
Expand Down Expand Up @@ -101,9 +101,11 @@ NORETURN void _assert_failure(const char *file, unsigned line);
*
* @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/assert.html
*/
#define assert(cond) ((cond) ? (void)0 : _assert_failure(RIOT_FILE_RELATIVE, __LINE__))
#define assert(cond) ((cond) ? (void)0 : _assert_failure(RIOT_FILE_RELATIVE, \
__LINE__))
#else
#define assert(cond) ((cond) ? (void)0 : core_panic(PANIC_ASSERT_FAIL, assert_crash_message))
#define assert(cond) ((cond) ? (void)0 : core_panic(PANIC_ASSERT_FAIL, \
assert_crash_message))
#endif

#if !defined __cplusplus
Expand Down
7 changes: 4 additions & 3 deletions core/include/bitarithm.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include "cpu_conf.h"

#ifdef __cplusplus
extern "C" {
extern "C" {
#endif

/**
Expand Down Expand Up @@ -147,7 +147,8 @@ static inline unsigned bitarithm_lsb(unsigned v)
{
/* Source: http://graphics.stanford.edu/~seander/bithacks.html#ZerosOnRightMultLookup */
extern const uint8_t MultiplyDeBruijnBitPosition[32];
return MultiplyDeBruijnBitPosition[((uint32_t)((v & -v) * 0x077CB531U)) >> 27];
return MultiplyDeBruijnBitPosition[((uint32_t)((v & -v) * 0x077CB531U)) >>
27];
}
#else
{
Expand All @@ -157,7 +158,7 @@ static inline unsigned bitarithm_lsb(unsigned v)
while ((v & 0x01) == 0) {
v >>= 1;
r++;
};
}

return r;
}
Expand Down
52 changes: 32 additions & 20 deletions core/include/byteorder.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ extern "C" {
* between different byte orders at compile time.
*/
typedef union __attribute__((packed)) {
uint16_t u16; /**< 16 bit representation */
uint8_t u8[2]; /**< 8 bit representation */
uint16_t u16; /**< 16 bit representation */
uint8_t u8[2]; /**< 8 bit representation */
} le_uint16_t;

/**
Expand All @@ -48,9 +48,9 @@ typedef union __attribute__((packed)) {
* between different byte orders at compile time.
*/
typedef union __attribute__((packed)) {
uint32_t u32; /**< 32 bit representation */
uint8_t u8[4]; /**< 8 bit representation */
uint16_t u16[2]; /**< 16 bit representation */
uint32_t u32; /**< 32 bit representation */
uint8_t u8[4]; /**< 8 bit representation */
uint16_t u16[2]; /**< 16 bit representation */
le_uint16_t l16[2]; /**< little endian 16 bit representation */
} le_uint32_t;

Expand All @@ -60,10 +60,10 @@ typedef union __attribute__((packed)) {
* between different byte orders at compile time.
*/
typedef union __attribute__((packed)) {
uint64_t u64; /**< 64 bit representation */
uint8_t u8[8]; /**< 8 bit representation */
uint16_t u16[4]; /**< 16 bit representation */
uint32_t u32[2]; /**< 32 bit representation */
uint64_t u64; /**< 64 bit representation */
uint8_t u8[8]; /**< 8 bit representation */
uint16_t u16[4]; /**< 16 bit representation */
uint32_t u32[2]; /**< 32 bit representation */
le_uint16_t l16[4]; /**< little endian 16 bit representation */
le_uint32_t l32[2]; /**< little endian 32 bit representation */
} le_uint64_t;
Expand All @@ -74,8 +74,8 @@ typedef union __attribute__((packed)) {
* between different byte orders at compile time.
*/
typedef union __attribute__((packed)) {
uint16_t u16; /**< 16 bit representation */
uint8_t u8[2]; /**< 8 bit representation */
uint16_t u16; /**< 16 bit representation */
uint8_t u8[2]; /**< 8 bit representation */
} be_uint16_t;

/**
Expand All @@ -84,9 +84,9 @@ typedef union __attribute__((packed)) {
* between different byte orders at compile time.
*/
typedef union __attribute__((packed)) {
uint32_t u32; /**< 32 bit representation */
uint8_t u8[4]; /**< 8 bit representation */
uint16_t u16[2]; /**< 16 bit representation */
uint32_t u32; /**< 32 bit representation */
uint8_t u8[4]; /**< 8 bit representation */
uint16_t u16[2]; /**< 16 bit representation */
be_uint16_t b16[2]; /**< big endian 16 bit representation */
} be_uint32_t;

Expand All @@ -96,10 +96,10 @@ typedef union __attribute__((packed)) {
* between different byte orders at compile time.
*/
typedef union __attribute__((packed)) {
uint64_t u64; /**< 64 bit representation */
uint8_t u8[8]; /**< 8 bit representation */
uint16_t u16[4]; /**< 16 bit representation */
uint32_t u32[2]; /**< 32 bit representation */
uint64_t u64; /**< 64 bit representation */
uint8_t u8[8]; /**< 8 bit representation */
uint16_t u16[4]; /**< 16 bit representation */
uint32_t u32[2]; /**< 32 bit representation */
be_uint16_t b16[4]; /**< big endian 16 bit representation */
be_uint32_t b32[2]; /**< big endian 32 bit representation */
} be_uint64_t;
Expand Down Expand Up @@ -303,7 +303,7 @@ static inline uint64_t ntohll(uint64_t v);
#ifdef HAVE_NO_BUILTIN_BSWAP16
static inline unsigned short __builtin_bswap16(unsigned short a)
{
return (a<<8)|(a>>8);
return (a << 8) | (a >> 8);
}
#endif

Expand Down Expand Up @@ -333,44 +333,50 @@ static inline uint64_t byteorder_swapll(uint64_t v)
static inline be_uint16_t byteorder_ltobs(le_uint16_t v)
{
be_uint16_t result = { byteorder_swaps(v.u16) };

return result;
}

static inline be_uint32_t byteorder_ltobl(le_uint32_t v)
{
be_uint32_t result = { byteorder_swapl(v.u32) };

return result;
}

static inline be_uint64_t byteorder_ltobll(le_uint64_t v)
{
be_uint64_t result = { byteorder_swapll(v.u64) };

return result;
}

static inline le_uint16_t byteorder_btols(be_uint16_t v)
{
le_uint16_t result = { byteorder_swaps(v.u16) };

return result;
}

static inline le_uint32_t byteorder_btoll(be_uint32_t v)
{
le_uint32_t result = { byteorder_swapl(v.u32) };

return result;
}

static inline le_uint64_t byteorder_btolll(be_uint64_t v)
{
le_uint64_t result = { byteorder_swapll(v.u64) };

return result;
}

/**
* @brief Swaps the byteorder according to the endianness
*/
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
# define _byteorder_swap(V, T) (byteorder_swap##T((V)))
# define _byteorder_swap(V, T) (byteorder_swap ## T((V)))
#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
# define _byteorder_swap(V, T) (V)
#else
Expand All @@ -380,18 +386,21 @@ static inline le_uint64_t byteorder_btolll(be_uint64_t v)
static inline network_uint16_t byteorder_htons(uint16_t v)
{
network_uint16_t result = { _byteorder_swap(v, s) };

return result;
}

static inline network_uint32_t byteorder_htonl(uint32_t v)
{
network_uint32_t result = { _byteorder_swap(v, l) };

return result;
}

static inline network_uint64_t byteorder_htonll(uint64_t v)
{
network_uint64_t result = { _byteorder_swap(v, ll) };

return result;
}

Expand Down Expand Up @@ -428,18 +437,21 @@ static inline uint64_t htonll(uint64_t v)
static inline uint16_t ntohs(uint16_t v)
{
network_uint16_t input = { v };

return byteorder_ntohs(input);
}

static inline uint32_t ntohl(uint32_t v)
{
network_uint32_t input = { v };

return byteorder_ntohl(input);
}

static inline uint64_t ntohll(uint64_t v)
{
network_uint64_t input = { v };

return byteorder_ntohll(input);
}

Expand Down
18 changes: 9 additions & 9 deletions core/include/cib.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* directory for more details.
*/

/**
/**
* @ingroup core_util
* @{
*
Expand Down Expand Up @@ -40,7 +40,7 @@ typedef struct {
/**
* @brief Initialize cib_t to a given size.
*/
#define CIB_INIT(SIZE) { 0, 0, (SIZE) - 1 }
#define CIB_INIT(SIZE) { 0, 0, (SIZE)-1 }

/**
* @brief Initialize @p cib to 0 and set buffer size to @p size.
Expand Down Expand Up @@ -80,7 +80,7 @@ static inline unsigned int cib_avail(const cib_t *cib)
*/
static inline unsigned int cib_full(const cib_t *cib)
{
return ((int) cib_avail(cib)) > ((int) cib->mask);
return ((int)cib_avail(cib)) > ((int)cib->mask);
}

/**
Expand All @@ -93,7 +93,7 @@ static inline unsigned int cib_full(const cib_t *cib)
static inline int cib_get(cib_t *__restrict cib)
{
if (cib_avail(cib)) {
return (int) (cib->read_count++ & cib->mask);
return (int)(cib->read_count++ & cib->mask);
}

return -1;
Expand All @@ -109,7 +109,7 @@ static inline int cib_get(cib_t *__restrict cib)
static inline int cib_peek(cib_t *__restrict cib)
{
if (cib_avail(cib)) {
return (int) (cib->read_count & cib->mask);
return (int)(cib->read_count & cib->mask);
}

return -1;
Expand All @@ -126,7 +126,7 @@ static inline int cib_peek(cib_t *__restrict cib)
*/
static inline int cib_get_unsafe(cib_t *cib)
{
return (int) (cib->read_count++ & cib->mask);
return (int)(cib->read_count++ & cib->mask);
}

/**
Expand All @@ -141,8 +141,8 @@ static inline int cib_put(cib_t *__restrict cib)
unsigned int avail = cib_avail(cib);

/* We use a signed compare, because the mask is -1u for an empty CIB. */
if ((int) avail <= (int) cib->mask) {
return (int) (cib->write_count++ & cib->mask);
if ((int)avail <= (int)cib->mask) {
return (int)(cib->write_count++ & cib->mask);
}

return -1;
Expand All @@ -159,7 +159,7 @@ static inline int cib_put(cib_t *__restrict cib)
*/
static inline int cib_put_unsafe(cib_t *cib)
{
return (int) (cib->write_count++ & cib->mask);
return (int)(cib->write_count++ & cib->mask);
}

#ifdef __cplusplus
Expand Down
Loading

0 comments on commit 8efe596

Please sign in to comment.