From b33175f36c3bd47e4a5969db532b5c099e8bb7b2 Mon Sep 17 00:00:00 2001 From: Josarn Date: Mon, 28 May 2018 15:47:02 +0200 Subject: [PATCH] xtimer_core: uncrustified --- sys/xtimer/xtimer_core.c | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/sys/xtimer/xtimer_core.c b/sys/xtimer/xtimer_core.c index 4247f498de37..9985a55508da 100644 --- a/sys/xtimer/xtimer_core.c +++ b/sys/xtimer/xtimer_core.c @@ -1,6 +1,7 @@ /** * Copyright (C) 2015 Kaspar Schleiser - * Copyright (C) 2016 Eistec AB + * 2016 Eistec AB + * 2018 Josua Arndt * * This file is subject to the terms and conditions of the GNU Lesser * General Public License v2.1. See the file LICENSE in the top level @@ -12,6 +13,7 @@ * @brief xtimer core functionality * @author Kaspar Schleiser * @author Joakim NohlgÄrd + * @author Josua Arndt * @} */ @@ -58,12 +60,13 @@ static inline int _is_set(xtimer_t *timer) return (timer->target || timer->long_target); } -static inline void xtimer_spin_until(uint32_t target) { +static inline void xtimer_spin_until(uint32_t target) +{ #if XTIMER_MASK target = _xtimer_lltimer_mask(target); #endif - while (_xtimer_lltimer_now() > target); - while (_xtimer_lltimer_now() < target); + while (_xtimer_lltimer_now() > target) {} + while (_xtimer_lltimer_now() < target) {} } void xtimer_init(void) @@ -85,7 +88,7 @@ static void _xtimer_now_internal(uint32_t *short_term, uint32_t *long_term) long_value = _long_cnt; after = _xtimer_now(); - } while(before > after); + } while (before > after); *short_term = after; *long_term = long_value; @@ -94,9 +97,10 @@ static void _xtimer_now_internal(uint32_t *short_term, uint32_t *long_term) uint64_t _xtimer_now64(void) { uint32_t short_term, long_term; + _xtimer_now_internal(&short_term, &long_term); - return ((uint64_t)long_term<<32) + short_term; + return ((uint64_t)long_term << 32) + short_term; } void _xtimer_set64(xtimer_t *timer, uint32_t offset, uint32_t long_offset) @@ -104,7 +108,7 @@ void _xtimer_set64(xtimer_t *timer, uint32_t offset, uint32_t long_offset) DEBUG(" _xtimer_set64() offset=%" PRIu32 " long_offset=%" PRIu32 "\n", offset, long_offset); if (!long_offset) { /* timer fits into the short timer */ - _xtimer_set(timer, (uint32_t) offset); + _xtimer_set(timer, (uint32_t)offset); } else { int state = irq_disable(); @@ -122,7 +126,7 @@ void _xtimer_set64(xtimer_t *timer, uint32_t offset, uint32_t long_offset) _add_timer_to_long_list(&long_list_head, timer); irq_restore(state); DEBUG("xtimer_set64(): added longterm timer (long_target=%" PRIu32 " target=%" PRIu32 ")\n", - timer->long_target, timer->target); + timer->long_target, timer->target); } } @@ -199,7 +203,7 @@ int _xtimer_set_absolute(xtimer_t *timer, uint32_t target) timer->long_target++; } - if ( (timer->long_target > _long_cnt) || !_this_high_period(target) ) { + if ((timer->long_target > _long_cnt) || !_this_high_period(target)) { DEBUG("xtimer_set_absolute(): the timer doesn't fit into the low-level timer's mask.\n"); _add_timer_to_long_list(&long_list_head, timer); } @@ -236,9 +240,9 @@ static void _add_timer_to_list(xtimer_t **list_head, xtimer_t *timer) static void _add_timer_to_long_list(xtimer_t **list_head, xtimer_t *timer) { - while (*list_head - && (((*list_head)->long_target < timer->long_target) - || (((*list_head)->long_target == timer->long_target) && ((*list_head)->target <= timer->target)))) { + while (*list_head && (((*list_head)->long_target < timer->long_target) + || (((*list_head)->long_target == timer->long_target) + && ((*list_head)->target <= timer->target)))) { list_head = &((*list_head)->next); } @@ -285,6 +289,7 @@ static void _remove(xtimer_t *timer) void xtimer_remove(xtimer_t *timer) { int state = irq_disable(); + if (_is_set(timer)) { _remove(timer); } @@ -307,7 +312,8 @@ static uint32_t _time_left(uint32_t target, uint32_t reference) } } -static inline int _this_high_period(uint32_t target) { +static inline int _this_high_period(uint32_t target) +{ #if XTIMER_MASK return (target & XTIMER_MASK) == _xtimer_high_cnt; #else @@ -340,7 +346,7 @@ static xtimer_t *_merge_lists(xtimer_t *head_a, xtimer_t *head_b) xtimer_t *result_head = _compare(head_a, head_b); xtimer_t *pos = result_head; - while(1) { + while (1) { head_a = head_a->next; head_b = head_b->next; if (!head_a) { @@ -504,7 +510,7 @@ static void _timer_callback(void) next_target = timer_list_head->target - XTIMER_OVERHEAD; /* make sure we're not setting a time in the past */ - if (next_target < ( _xtimer_now() + XTIMER_ISR_BACKOFF)) { + if (next_target < (_xtimer_now() + XTIMER_ISR_BACKOFF)) { goto overflow; } }