From e148f38dc937c34b222ba8df8612b3fa2b6bc349 Mon Sep 17 00:00:00 2001 From: Kimplul Date: Sun, 29 May 2022 11:23:29 +0300 Subject: modify formatting rules --- arch/riscv64/gen/asm-offsets.c | 2 +- arch/riscv64/init/init.c | 12 ++-- arch/riscv64/kernel/csr.h | 8 +-- arch/riscv64/kernel/regs.h | 2 +- common/debug.c | 4 +- common/nodes.c | 2 +- common/pmem.c | 26 ++++---- common/tcb.c | 42 ++++++------ include/apos/assert.h | 34 +++++----- include/apos/atomic.h | 40 ++++++------ include/apos/debug.h | 2 +- include/apos/elf.h | 6 +- include/apos/mem.h | 6 +- include/apos/uapi.h | 82 +++++++++++------------ include/apos/unaligned.h | 64 +++++++++--------- include/apos/utils.h | 144 ++++++++++++++++++++--------------------- include/apos/vmem.h | 6 +- include/libfdt.h | 2 +- uncrustify.conf | 4 +- 19 files changed, 244 insertions(+), 244 deletions(-) diff --git a/arch/riscv64/gen/asm-offsets.c b/arch/riscv64/gen/asm-offsets.c index 71a1c9a..dfebb5b 100644 --- a/arch/riscv64/gen/asm-offsets.c +++ b/arch/riscv64/gen/asm-offsets.c @@ -14,7 +14,7 @@ * @param sym Name of symbol. * @param val Value of symbol. */ -#define DEFINE(sym, val) \ +#define DEFINE(sym, val) \ __asm__ volatile ("\n#-> " #sym " %0 " #val "\n" : : "i" (val)) /** diff --git a/arch/riscv64/init/init.c b/arch/riscv64/init/init.c index db428dd..4b20614 100644 --- a/arch/riscv64/init/init.c +++ b/arch/riscv64/init/init.c @@ -69,12 +69,12 @@ static void move_kernel() * * @param reg Register to modify. */ -#define __va_reg(reg) \ - { \ - vm_t reg = 0; \ - __asm__ ("mv %0, " QUOTE(reg) : "=r" (reg)::); \ - reg = (vm_t)__va(reg); \ - __asm__ ("mv " QUOTE(reg) ", %0" ::"rK" (reg) :); \ +#define __va_reg(reg) \ + { \ + vm_t reg = 0; \ + __asm__ ("mv %0, " QUOTE(reg) : "=r" (reg)::); \ + reg = (vm_t)__va(reg); \ + __asm__ ("mv " QUOTE(reg) ", %0" ::"rK" (reg) :); \ } /** diff --git a/arch/riscv64/kernel/csr.h b/arch/riscv64/kernel/csr.h index ade397c..9cb5799 100644 --- a/arch/riscv64/kernel/csr.h +++ b/arch/riscv64/kernel/csr.h @@ -54,16 +54,16 @@ #define __ASM_STR(x) #x #endif -#define csr_read(csr, res) \ +#define csr_read(csr, res) \ __asm__ volatile ("csrr %0, " __ASM_STR(csr) : "=r" (res) : : "memory") -#define csr_write(csr, val) \ +#define csr_write(csr, val) \ __asm__ volatile ("csrw " __ASM_STR(csr) ", %0" : : "r" (val) : "memory") -#define csr_set(csr, val) \ +#define csr_set(csr, val) \ __asm__ volatile ("csrs " __ASM_STR(csr) ", %0" : : "r" (val) : "memory") -#define csr_clear(csr, val) \ +#define csr_clear(csr, val) \ __asm__ volatile ("csrc " __ASM_STR(csr) ", %0" : : "r" (val) : "memory") #endif /* APOS_CSR_H */ diff --git a/arch/riscv64/kernel/regs.h b/arch/riscv64/kernel/regs.h index 97bb17e..f2bf336 100644 --- a/arch/riscv64/kernel/regs.h +++ b/arch/riscv64/kernel/regs.h @@ -12,7 +12,7 @@ struct riscv_regs { long ra, sp, gp, tp, t0, t1, t2, s0, s1, a0, a1, a2, a3, a4, a5, a6, a7, - s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, t3, t4, t5, t6; + s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, t3, t4, t5, t6; }; #endif /* APOS_RISCV_REGS_H */ diff --git a/common/debug.c b/common/debug.c index ae56ab1..af35031 100644 --- a/common/debug.c +++ b/common/debug.c @@ -174,8 +174,8 @@ static size_t __integral_val(ssize_t value, size_t base, size_t flags, size_t ret = 0; signed char c = 0; -#define handle_type(x) \ - c = (x)value % (x)base; \ +#define handle_type(x) \ + c = (x)value % (x)base; \ value = (x)value / (x)base; if (!is_set(flags, UNSIGN_FLAG)) { diff --git a/common/nodes.c b/common/nodes.c index 30d3cfb..c54bbe8 100644 --- a/common/nodes.c +++ b/common/nodes.c @@ -38,7 +38,7 @@ * being free) */ -#define node_region(r) \ +#define node_region(r) \ ((struct node_region *)((uintptr_t)(r) & ~(BASE_PAGE_SIZE - 1))) static struct node_region *__create_region() diff --git a/common/pmem.c b/common/pmem.c index 197a0b8..cd3666d 100644 --- a/common/pmem.c +++ b/common/pmem.c @@ -30,28 +30,28 @@ #include /* NOTE: these are all for pnum_t, i.e. O0_SHIFT is from 0 */ -#define __foreach_page(var, start, end, attr, neg) \ - for (size_t i = num_indexes(start); i < num_elems(end); ++i) \ - if (var->attr[i] == (mm_info_t)(-1)) \ - continue; \ - else \ - for (pnum_t page = i * MM_OINFO_WIDTH, j = 0; \ - j < (pnum_t)MIN((end)-i * MM_OINFO_WIDTH, \ - MM_OINFO_WIDTH); \ - ++j, ++page) \ +#define __foreach_page(var, start, end, attr, neg) \ + for (size_t i = num_indexes(start); i < num_elems(end); ++i) \ + if (var->attr[i] == (mm_info_t)(-1)) \ + continue; \ + else \ + for (pnum_t page = i * MM_OINFO_WIDTH, j = 0; \ + j < (pnum_t)MIN((end)-i * MM_OINFO_WIDTH, \ + MM_OINFO_WIDTH); \ + ++j, ++page) \ if (neg(is_nset(var->attr[i], j))) #define NEG ! -#define foreach_full_page(var, start, order) \ +#define foreach_full_page(var, start, order) \ __foreach_page(var, start, var->entries, full, ) -#define foreach_not_full_page(var, start, order) \ +#define foreach_not_full_page(var, start, order) \ __foreach_page(var, start, var->entries, full, NEG) -#define foreach_used_page(var, start, order) \ +#define foreach_used_page(var, start, order) \ __foreach_page(var, start, var->entries, used, ) -#define foreach_not_used_page(var, start, order) \ +#define foreach_not_used_page(var, start, order) \ __foreach_page(var, start, var->entries, used, NEG) typedef uint32_t mm_info_t; diff --git a/common/tcb.c b/common/tcb.c index 1382f67..316cc3e 100644 --- a/common/tcb.c +++ b/common/tcb.c @@ -192,35 +192,35 @@ stat_t destroy_proc(struct tcb *p) return __destroy_thread_data(p); } -#define DEFINE_ATTACH(name, type) \ - stat_t name(struct tcb *r, struct tcb *t) \ - { \ - hard_assert(r != t, ERR_INVAL); \ - struct tcb *next = r->type.next; \ - t->type.next = next; \ -\ +#define DEFINE_ATTACH(name, type) \ + stat_t name(struct tcb *r, struct tcb *t) \ + { \ + hard_assert(r != t, ERR_INVAL); \ + struct tcb *next = r->type.next; \ + t->type.next = next; \ + \ if (next) { next->type.prev = t; } \ -\ - t->type.prev = r; \ - r->type.next = t; \ - return OK; \ + \ + t->type.prev = r; \ + r->type.next = t; \ + return OK; \ } DEFINE_ATTACH(attach_rpc, rpc); DEFINE_ATTACH(attach_proc, proc); -#define DEFINE_DETACH(name, type) \ - stat_t name(struct tcb *r, struct tcb *t) \ - { \ - MAYBE_UNUSED(r); \ - hard_assert(r != t, ERR_INVAL); \ - struct tcb *prev = t->type.prev; \ - struct tcb *next = t->type.next; \ -\ +#define DEFINE_DETACH(name, type) \ + stat_t name(struct tcb *r, struct tcb *t) \ + { \ + MAYBE_UNUSED(r); \ + hard_assert(r != t, ERR_INVAL); \ + struct tcb *prev = t->type.prev; \ + struct tcb *next = t->type.next; \ + \ if (prev) { prev->type.next = next; } \ if (next) { next->type.prev = prev; } \ -\ - return OK; \ + \ + return OK; \ } DEFINE_DETACH(detach_rpc, rpc); diff --git a/include/apos/assert.h b/include/apos/assert.h index 97523c7..81b267b 100644 --- a/include/apos/assert.h +++ b/include/apos/assert.h @@ -26,13 +26,13 @@ * * @param x Condition to check for. */ -#define catastrophic_assert(x) \ - do { \ - if (unlikely(!(x))) { \ +#define catastrophic_assert(x) \ + do { \ + if (unlikely(!(x))) { \ error("catastrophic assertion failed: " QUOTE(x) "\n"); \ - while (1) { \ - } \ - } \ + while (1) { \ + } \ + } \ } while (0); /** @@ -44,12 +44,12 @@ * @param x Condition to check for. * @param r Return value on failed check. */ -#define hard_assert(x, r) \ - { \ - if (unlikely(!(x))) { \ - warn("hard assertion failed: " QUOTE(x) "\n"); \ - return r; \ - } \ +#define hard_assert(x, r) \ + { \ + if (unlikely(!(x))) { \ + warn("hard assertion failed: " QUOTE(x) "\n"); \ + return r; \ + } \ } /** @@ -57,11 +57,11 @@ * * @param x Condition to check for. */ -#define soft_assert(x) \ - do { \ - if (unlikely(!(x))) { \ - info("soft assertion failed: " QUOTE(x) "\n"); \ - } \ +#define soft_assert(x) \ + do { \ + if (unlikely(!(x))) { \ + info("soft assertion failed: " QUOTE(x) "\n"); \ + } \ } while (0); #else #define catastrophic_assert(x) diff --git a/include/apos/atomic.h b/include/apos/atomic.h index d8d5368..006b4a6 100644 --- a/include/apos/atomic.h +++ b/include/apos/atomic.h @@ -315,7 +315,7 @@ typedef _Atomic __UINTMAX_TYPE__ atomic_uintmax_t; * @param mode Memory ordering. \see memory_order. * @return Value at \c obj. */ -#define atomic_exchange_explicit(obj, val, mode) \ +#define atomic_exchange_explicit(obj, val, mode) \ N_ATOMIC(exchange)(obj, val, mode) /** @@ -326,7 +326,7 @@ typedef _Atomic __UINTMAX_TYPE__ atomic_uintmax_t; * @param val Value to be inserted at \c obj. * @return Value at \c obj. */ -#define atomic_exchange(obj, val) \ +#define atomic_exchange(obj, val) \ atomic_exchange_explicit(obj, val, __ATOMIC_SEQ_CST) /** @@ -344,10 +344,10 @@ typedef _Atomic __UINTMAX_TYPE__ atomic_uintmax_t; * @return \ref true if \c obj and \c val equal, \ref false otherwise. */ #if defined(__GNUC__) -#define atomic_compare_exchange_strong_explicit(obj, val, des, suc, fail) \ +#define atomic_compare_exchange_strong_explicit(obj, val, des, suc, fail) \ N_ATOMIC(compare_exchange)(obj, val, des, 0, suc, fail) #elif defined(__clang__) -#define atomic_compare_exchange_strong_explicit(obj, val, des, suc, fail) \ +#define atomic_compare_exchange_strong_explicit(obj, val, des, suc, fail) \ N_ATOMIC(compare_exchange_strong)(obj, val, des, suc, fail) #endif @@ -361,8 +361,8 @@ typedef _Atomic __UINTMAX_TYPE__ atomic_uintmax_t; * @param des Value to be copied if \c obj and \c val equal. * @return \ref true if \c obj and \c val equal, \ref false otherwise. */ -#define atomic_compare_exchange_strong(obj, val, des) \ - atomic_compare_exchange_strong_explicit( \ +#define atomic_compare_exchange_strong(obj, val, des) \ + atomic_compare_exchange_strong_explicit( \ obj, val, des, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST) /** @@ -381,10 +381,10 @@ typedef _Atomic __UINTMAX_TYPE__ atomic_uintmax_t; * false otherwise. */ #if defined(__GNUC__) -#define atomic_compare_exchange_weak_explicit(obj, val, des, suc, fail) \ +#define atomic_compare_exchange_weak_explicit(obj, val, des, suc, fail) \ N_ATOMIC(compare_exchange)(obj, val, des, 1, suc, fail) #elif defined(__clang__) -#define atomic_compare_exchange_weak_explicit(obj, val, des, suc, fail) \ +#define atomic_compare_exchange_weak_explicit(obj, val, des, suc, fail) \ N_ATOMIC(compare_exchange_weak)(obj, val, des, suc, fail) #endif @@ -412,7 +412,7 @@ typedef _Atomic __UINTMAX_TYPE__ atomic_uintmax_t; * @param mode Memory ordering. \see memory_order. * @return Contents of \c obj before addition. */ -#define atomic_fetch_add_explicit(obj, val, mode) \ +#define atomic_fetch_add_explicit(obj, val, mode) \ C11_ATOMIC(fetch_add)(obj, val, mode) /** @@ -423,7 +423,7 @@ typedef _Atomic __UINTMAX_TYPE__ atomic_uintmax_t; * @param val Value to be added to object. * @return Contents of \c obj before addition. */ -#define atomic_fetch_add(obj, val) \ +#define atomic_fetch_add(obj, val) \ atomic_fetch_add_explicit(obj, val, __ATOMIC_SEQ_CST) /** @@ -435,7 +435,7 @@ typedef _Atomic __UINTMAX_TYPE__ atomic_uintmax_t; * @param mode Memory ordering. \see memory_order. * @return Contents of \c obj before subtraction. */ -#define atomic_fetch_sub_explicit(obj, val, mode) \ +#define atomic_fetch_sub_explicit(obj, val, mode) \ C11_ATOMIC(fetch_sub)(obj, val, mode) /** @@ -446,7 +446,7 @@ typedef _Atomic __UINTMAX_TYPE__ atomic_uintmax_t; * @param val Value to be subtracted from object. * @return Contents of \c obj before subtraction. */ -#define atomic_fetch_sub(obj, val) \ +#define atomic_fetch_sub(obj, val) \ atomic_fetch_sub_explicit(obj, val, __ATOMIC_SEQ_CST) /** @@ -458,7 +458,7 @@ typedef _Atomic __UINTMAX_TYPE__ atomic_uintmax_t; * @param mode Memory ordering. \see memory_order. * @return Contents of \c obj before bitwise \c AND. */ -#define atomic_fetch_and_explicit(obj, val, mode) \ +#define atomic_fetch_and_explicit(obj, val, mode) \ C11_ATOMIC(fetch_and)(obj, val, mode) /** @@ -469,7 +469,7 @@ typedef _Atomic __UINTMAX_TYPE__ atomic_uintmax_t; * @param val Value to bitwise \c AND with contents of object. * @return Contents of \c obj before bitwise \c AND. */ -#define atomic_fetch_and(obj, val) \ +#define atomic_fetch_and(obj, val) \ atomic_fetch_and_explicit(obj, val, __ATOMIC_SEQ_CST) /** @@ -481,7 +481,7 @@ typedef _Atomic __UINTMAX_TYPE__ atomic_uintmax_t; * @param mode Memory ordering. \see memory_order. * @return Contents of \c obj before bitwise \c XOR. */ -#define atomic_fetch_xor_explicit(obj, val, mode) \ +#define atomic_fetch_xor_explicit(obj, val, mode) \ C11_ATOMIC(fetch_xor)(obj, val, mode) /** @@ -492,7 +492,7 @@ typedef _Atomic __UINTMAX_TYPE__ atomic_uintmax_t; * @param val Value to bitwise \c XOR with contents of object. * @return Contents of \c obj before bitwise \c XOR. */ -#define atomic_fetch_xor(obj, val) \ +#define atomic_fetch_xor(obj, val) \ atomic_fetch_xor_explicit(obj, val, __ATOMIC_SEQ_CST) /** @@ -504,7 +504,7 @@ typedef _Atomic __UINTMAX_TYPE__ atomic_uintmax_t; * @param mode Memory ordering. \see memory_order. * @return Contents of \c obj before bitwise \c OR. */ -#define atomic_fetch_or_explicit(obj, val, mode) \ +#define atomic_fetch_or_explicit(obj, val, mode) \ C11_ATOMIC(fetch_or)(obj, val, mode) /** @@ -515,7 +515,7 @@ typedef _Atomic __UINTMAX_TYPE__ atomic_uintmax_t; * @param val Value to bitwise \c OR with contents of object. * @return Contents of \c obj before bitwise \c OR. */ -#define atomic_fetch_or(obj, val) \ +#define atomic_fetch_or(obj, val) \ atomic_fetch_or_explicit(obj, val, __ATOMIC_SEQ_CST) /** @@ -527,7 +527,7 @@ typedef _Atomic __UINTMAX_TYPE__ atomic_uintmax_t; * @param mode Memory ordering. \see memory_order. * @return Contents of \c obj before bitwise \c NAND. */ -#define atomic_fetch_nand_explicit(obj, val, mode) \ +#define atomic_fetch_nand_explicit(obj, val, mode) \ C11_ATOMIC(fetch_nand)(obj, val, mode) /** @@ -538,7 +538,7 @@ typedef _Atomic __UINTMAX_TYPE__ atomic_uintmax_t; * @param val Value to bitwise \c NAND with contents of object. * @return Contents of \c obj before bitwise \c NAND. */ -#define atomic_fetch_nand(obj, val) \ +#define atomic_fetch_nand(obj, val) \ atomic_fetch_nand_explicit(obj, val, __ATOMIC_SEQ_CST) /* skip atomic flags, probably not needed */ diff --git a/include/apos/debug.h b/include/apos/debug.h index cb46ba7..5935f60 100644 --- a/include/apos/debug.h +++ b/include/apos/debug.h @@ -390,7 +390,7 @@ void setup_io_dbg(struct vmem *vmem); * * @param fmt Message, integer subset of regular printf. */ -#define error(fmt, ...) \ +#define error(fmt, ...) \ dbg(COMMON_FORMAT fmt, COMMON_ARGS("ERROR"),##__VA_ARGS__) #else diff --git a/include/apos/elf.h b/include/apos/elf.h index 1e9a4aa..e6936a3 100644 --- a/include/apos/elf.h +++ b/include/apos/elf.h @@ -187,11 +187,11 @@ struct __packed section64_header { #define section64_header(s) ((struct section64_header *)s) #define section32_header(s) ((struct section32_header *)s) -#define elf_header_prop(c, e, p) \ +#define elf_header_prop(c, e, p) \ (c == ELFCLASS64 ? elf64_header(e)->p : elf32_header(e)->p) -#define program_header_prop(c, e, p) \ +#define program_header_prop(c, e, p) \ (c == ELFCLASS64 ? program64_header(e)->p : program32_header(e)->p) -#define section_header_prop(c, e, p) \ +#define section_header_prop(c, e, p) \ (c == ELFCLASS64 ? section64_header(e)->p : section32_header(e)->p) vm_t load_elf(struct tcb *t, vm_t binary, vm_t interp); diff --git a/include/apos/mem.h b/include/apos/mem.h index 1486400..af0ac89 100644 --- a/include/apos/mem.h +++ b/include/apos/mem.h @@ -11,7 +11,7 @@ #define MM_OINFO_WIDTH (sizeof(mm_info_t) * 8) -#define pnum_to_index(pnum, order) \ +#define pnum_to_index(pnum, order) \ (((pnum) >> __o_offset(order)) & (__o_width(order) - 1)) #define pm_to_index(paddr, \ order) (pnum_to_index(pm_to_pnum(paddr), (order))) @@ -43,8 +43,8 @@ RAM_BASE) #define __page(x) ((x) / BASE_PAGE_SIZE) #define __addr(x) ((x)*BASE_PAGE_SIZE) -#define __pages(x) \ - (is_aligned((x), BASE_PAGE_SIZE) ? __page((x)) : \ +#define __pages(x) \ + (is_aligned((x), BASE_PAGE_SIZE) ? __page((x)) : \ __page((x) + BASE_PAGE_SIZE)) #define __bytes(x) (__addr(x)) diff --git a/include/apos/uapi.h b/include/apos/uapi.h index 9304da7..f0cb9b7 100644 --- a/include/apos/uapi.h +++ b/include/apos/uapi.h @@ -20,55 +20,55 @@ struct sys_ret { sys_arg_t val; }; -#define SYSCALL_DECLARE(name) \ - struct sys_ret sys_##name(sys_arg_t a, sys_arg_t b, sys_arg_t c, \ +#define SYSCALL_DECLARE(name) \ + struct sys_ret sys_##name(sys_arg_t a, sys_arg_t b, sys_arg_t c, \ sys_arg_t d); -#define SYSCALL_DEFINE0(name) \ - static inline struct sys_ret __##name(); \ - struct sys_ret sys_##name(sys_arg_t a, sys_arg_t b, sys_arg_t c, \ - sys_arg_t d) \ - { \ - UNUSED(a); \ - UNUSED(b); \ - UNUSED(c); \ - UNUSED(d); \ - return __##name(); \ - } \ +#define SYSCALL_DEFINE0(name) \ + static inline struct sys_ret __##name(); \ + struct sys_ret sys_##name(sys_arg_t a, sys_arg_t b, sys_arg_t c, \ + sys_arg_t d) \ + { \ + UNUSED(a); \ + UNUSED(b); \ + UNUSED(c); \ + UNUSED(d); \ + return __##name(); \ + } \ static struct sys_ret __##name -#define SYSCALL_DEFINE1(name) \ - static inline struct sys_ret __##name(sys_arg_t); \ - struct sys_ret sys_##name(sys_arg_t a, sys_arg_t b, sys_arg_t c, \ - sys_arg_t d) \ - { \ - UNUSED(b); \ - UNUSED(c); \ - UNUSED(d); \ - return __##name(a); \ - } \ +#define SYSCALL_DEFINE1(name) \ + static inline struct sys_ret __##name(sys_arg_t); \ + struct sys_ret sys_##name(sys_arg_t a, sys_arg_t b, sys_arg_t c, \ + sys_arg_t d) \ + { \ + UNUSED(b); \ + UNUSED(c); \ + UNUSED(d); \ + return __##name(a); \ + } \ static inline struct sys_ret __##name -#define SYSCALL_DEFINE2(name) \ - static inline struct sys_ret __##name(sys_arg_t, sys_arg_t); \ - struct sys_ret sys_##name(sys_arg_t a, sys_arg_t b, sys_arg_t c, \ - sys_arg_t d) \ - { \ - UNUSED(c); \ - UNUSED(d); \ - return __##name(a, b); \ - } \ +#define SYSCALL_DEFINE2(name) \ + static inline struct sys_ret __##name(sys_arg_t, sys_arg_t); \ + struct sys_ret sys_##name(sys_arg_t a, sys_arg_t b, sys_arg_t c, \ + sys_arg_t d) \ + { \ + UNUSED(c); \ + UNUSED(d); \ + return __##name(a, b); \ + } \ static inline struct sys_ret __##name -#define SYSCALL_DEFINE3(name) \ - static inline struct sys_ret __##name(sys_arg_t, sys_arg_t, \ - sys_arg_t); \ - struct sys_ret sys_##name(sys_arg_t a, sys_arg_t b, sys_arg_t c, \ - sys_arg_t d) \ - { \ - UNUSED(d); \ - return __##name(a, b, c); \ - } \ +#define SYSCALL_DEFINE3(name) \ + static inline struct sys_ret __##name(sys_arg_t, sys_arg_t, \ + sys_arg_t); \ + struct sys_ret sys_##name(sys_arg_t a, sys_arg_t b, sys_arg_t c, \ + sys_arg_t d) \ + { \ + UNUSED(d); \ + return __##name(a, b, c); \ + } \ static inline struct sys_ret __##name #define SYSCALL_DEFINE4(name) \ diff --git a/include/apos/unaligned.h b/include/apos/unaligned.h index 94439ca..85d67b0 100644 --- a/include/apos/unaligned.h +++ b/include/apos/unaligned.h @@ -9,35 +9,35 @@ #include #include -#define get_unaligned(ptr) \ - _Generic(*(ptr), uint8_t \ - : __get_unaligned_uint8_t, uint16_t \ - : __get_unaligned_uint16_t, uint32_t \ - : __get_unaligned_uint32_t, uint64_t \ - : __get_unaligned_uint64_t, int8_t \ - : __get_unaligned_int8_t, int16_t \ - : __get_unaligned_int16_t, int32_t \ - : __get_unaligned_int32_t, int64_t \ +#define get_unaligned(ptr) \ + _Generic(*(ptr), uint8_t \ + : __get_unaligned_uint8_t, uint16_t \ + : __get_unaligned_uint16_t, uint32_t \ + : __get_unaligned_uint32_t, uint64_t \ + : __get_unaligned_uint64_t, int8_t \ + : __get_unaligned_int8_t, int16_t \ + : __get_unaligned_int16_t, int32_t \ + : __get_unaligned_int32_t, int64_t \ : __get_unaligned_int64_t)((void *)ptr) -#define put_unaligned(val, ptr) \ - _Generic(*(ptr), uint8_t \ - : __put_unaligned_uint8_t, uint16_t \ - : __put_unaligned_uint16_t, uint32_t \ - : __put_unaligned_uint32_t, uint64_t \ - : __put_unaligned_uint64_t, int8_t \ - : __put_unaligned_int8_t, int16_t \ - : __put_unaligned_int16_t, int32_t \ - : __put_unaligned_int32_t, int64_t \ +#define put_unaligned(val, ptr) \ + _Generic(*(ptr), uint8_t \ + : __put_unaligned_uint8_t, uint16_t \ + : __put_unaligned_uint16_t, uint32_t \ + : __put_unaligned_uint32_t, uint64_t \ + : __put_unaligned_uint64_t, int8_t \ + : __put_unaligned_int8_t, int16_t \ + : __put_unaligned_int16_t, int32_t \ + : __put_unaligned_int32_t, int64_t \ : __put_unaligned_int64_t)(val, (void *)ptr) -#define DEFINE_GET(type) \ - static inline type __get_unaligned_##type(void *ptr) \ - { \ - const struct __packed { \ - type x; \ - } *__pptr = ptr; \ - return __pptr->x; \ +#define DEFINE_GET(type) \ + static inline type __get_unaligned_##type(void *ptr) \ + { \ + const struct __packed { \ + type x; \ + } *__pptr = ptr; \ + return __pptr->x; \ } DEFINE_GET(uint8_t); @@ -51,13 +51,13 @@ DEFINE_GET(int64_t); #undef DEFINE_GET -#define DEFINE_PUT(type) \ - static inline void __put_unaligned_##type(type val, void *ptr) \ - { \ - struct __packed { \ - type x; \ - } *__pptr = ptr; \ - __pptr->x = val; \ +#define DEFINE_PUT(type) \ + static inline void __put_unaligned_##type(type val, void *ptr) \ + { \ + struct __packed { \ + type x; \ + } *__pptr = ptr; \ + __pptr->x = val; \ } DEFINE_PUT(uint8_t); diff --git a/include/apos/utils.h b/include/apos/utils.h index c4a83be..d2b81c0 100644 --- a/include/apos/utils.h +++ b/include/apos/utils.h @@ -10,13 +10,13 @@ #define MAX(a, b) ((a) >= (b) ? (a) : (b)) #define MAX3(a, b, c) (MAX(a, b) >= MAX(b, c) ? MAX(a, b) : MAX(b, c)) -#define MAX4(a, b, c, d) \ +#define MAX4(a, b, c, d) \ (MAX3(a, b, c) >= MAX3(b, c, d) ? MAX3(a, b, c) : MAX3(b, c, d)) /* etc... */ #define MIN(a, b) ((a) <= (b) ? (a) : (b)) #define MIN3(a, b, c) (MIN(a, b) <= MIN(b, c) ? MIN(a, b) : MIN(b, c)) -#define MIN4(a, b, c, d) \ +#define MIN4(a, b, c, d) \ (MIN3(a, b, c) <= MIN3(b, c, d) ? MIN3(a, b, c) : MIN3(b, c, d)) /* etc... */ @@ -45,7 +45,7 @@ #define unlikely(x) (x) #endif -#define container_of(ptr, type, member) \ +#define container_of(ptr, type, member) \ ((type *)((char *)(ptr)-offsetof(type, member))) #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) @@ -56,35 +56,35 @@ #include /* clang-format doesn't like _Generic, but I guess that's fine. */ -#define align_up(x, y) \ - _Generic((x), signed char \ - : align_up_c, signed short \ - : align_up_s, signed int \ - : align_up_i, signed long \ - : align_up_l, signed long long \ - : align_up_ll, \ - \ - unsigned char \ - : align_up_uc, unsigned short \ - : align_up_us, unsigned int \ - : align_up_ui, unsigned long \ - : align_up_ul, unsigned long long \ +#define align_up(x, y) \ + _Generic((x), signed char \ + : align_up_c, signed short \ + : align_up_s, signed int \ + : align_up_i, signed long \ + : align_up_l, signed long long \ + : align_up_ll, \ + \ + unsigned char \ + : align_up_uc, unsigned short \ + : align_up_us, unsigned int \ + : align_up_ui, unsigned long \ + : align_up_ul, unsigned long long \ : align_up_ull)((x), (y)) -#define DEFINE_ALIGN_UP(name, type) \ - static inline type align_up_##name(type val, type a) \ - { \ - if (!a) { \ - return val; \ - } \ - \ - type rem = val % a; \ - \ - if (rem == 0) { \ - return val; \ - } \ - \ - return val + a - rem; \ +#define DEFINE_ALIGN_UP(name, type) \ + static inline type align_up_##name(type val, type a) \ + { \ + if (!a) { \ + return val; \ + } \ + \ + type rem = val % a; \ + \ + if (rem == 0) { \ + return val; \ + } \ + \ + return val + a - rem; \ } DEFINE_ALIGN_UP(c, signed char); @@ -99,29 +99,29 @@ DEFINE_ALIGN_UP(ui, unsigned int); DEFINE_ALIGN_UP(ul, unsigned long); DEFINE_ALIGN_UP(ull, unsigned long long); -#define align_down(x, y) \ - _Generic((x), signed char \ - : align_down_c, signed short \ - : align_down_s, signed int \ - : align_down_i, signed long \ - : align_down_l, signed long long \ - : align_down_ll, \ - \ - unsigned char \ - : align_down_uc, unsigned short \ - : align_down_us, unsigned int \ - : align_down_ui, unsigned long \ - : align_down_ul, unsigned long long \ +#define align_down(x, y) \ + _Generic((x), signed char \ + : align_down_c, signed short \ + : align_down_s, signed int \ + : align_down_i, signed long \ + : align_down_l, signed long long \ + : align_down_ll, \ + \ + unsigned char \ + : align_down_uc, unsigned short \ + : align_down_us, unsigned int \ + : align_down_ui, unsigned long \ + : align_down_ul, unsigned long long \ : align_down_ull)((x), (y)) -#define DEFINE_ALIGN_DOWN(name, type) \ - static inline type align_down_##name(type val, type a) \ - { \ - if (!a) { \ - return val; \ - } \ - \ - return val - (val % a); \ +#define DEFINE_ALIGN_DOWN(name, type) \ + static inline type align_down_##name(type val, type a) \ + { \ + if (!a) { \ + return val; \ + } \ + \ + return val - (val % a); \ } DEFINE_ALIGN_DOWN(c, signed char); @@ -136,29 +136,29 @@ DEFINE_ALIGN_DOWN(ui, unsigned int); DEFINE_ALIGN_DOWN(ul, unsigned long); DEFINE_ALIGN_DOWN(ull, unsigned long long); -#define is_aligned(x, y) \ - _Generic((x), signed char \ - : is_aligned_c, signed short \ - : is_aligned_s, signed int \ - : is_aligned_i, signed long \ - : is_aligned_l, signed long long \ - : is_aligned_ll, \ - \ - unsigned char \ - : is_aligned_uc, unsigned short \ - : is_aligned_us, unsigned int \ - : is_aligned_ui, unsigned long \ - : is_aligned_ul, unsigned long long \ +#define is_aligned(x, y) \ + _Generic((x), signed char \ + : is_aligned_c, signed short \ + : is_aligned_s, signed int \ + : is_aligned_i, signed long \ + : is_aligned_l, signed long long \ + : is_aligned_ll, \ + \ + unsigned char \ + : is_aligned_uc, unsigned short \ + : is_aligned_us, unsigned int \ + : is_aligned_ui, unsigned long \ + : is_aligned_ul, unsigned long long \ : is_aligned_ll)((x), (y)) -#define DEFINE_ALIGNED(name, type) \ - static inline bool is_aligned_##name(type val, type a) \ - { \ - if (!a) { \ - return true; \ - } \ - \ - return val % a == 0; \ +#define DEFINE_ALIGNED(name, type) \ + static inline bool is_aligned_##name(type val, type a) \ + { \ + if (!a) { \ + return true; \ + } \ + \ + return val % a == 0; \ } DEFINE_ALIGNED(c, signed char); diff --git a/include/apos/vmem.h b/include/apos/vmem.h index 1451c82..96158be 100644 --- a/include/apos/vmem.h +++ b/include/apos/vmem.h @@ -31,16 +31,16 @@ stat_t clone_allocd_wrapper(struct vmem *b, pm_t *offset, vm_t vaddr, stat_t free_uvmem_wrapper(struct vmem *b, pm_t *offset, vm_t vaddr, vmflags_t flags, enum mm_order order, void *data); -#define map_allocd_region(b, start, bytes, flags, data) \ +#define map_allocd_region(b, start, bytes, flags, data) \ map_fill_region(b, &alloc_uvmem_wrapper, 0, start, bytes, flags, data) -#define map_shared_region(b, start, bytes, flags, data) \ +#define map_shared_region(b, start, bytes, flags, data) \ map_fill_region(b, &alloc_shared_wrapper, 0, start, bytes, flags, data) #define clone_allocd_region(b, start, bytes, flags, data) \ map_fill_region(b, &clone_allocd_wrapper, 0, start, bytes, flags, data) -#define unmap_freed_region(b, start, bytes, flags, data) \ +#define unmap_freed_region(b, start, bytes, flags, data) \ map_fill_region(b, &free_uvmem_wrapper, 0, start, bytes, flags, data) #define vm_flags(x) ((x) & ~0xff) diff --git a/include/libfdt.h b/include/libfdt.h index f6e159d..cc4de90 100644 --- a/include/libfdt.h +++ b/include/libfdt.h @@ -89,7 +89,7 @@ void __dbg_fdt(const void *fdt, int node_offset, int depth); * @param p Pointer to int{32,64} inside the global FDT. * @return Value of integer at location p. */ -#define fdt_load_int_ptr(c, p) \ +#define fdt_load_int_ptr(c, p) \ ((c) == 2 ? fdt_load_int64_ptr(p) : fdt_load_int32_ptr(p)) #endif diff --git a/uncrustify.conf b/uncrustify.conf index 7221de0..269ae79 100644 --- a/uncrustify.conf +++ b/uncrustify.conf @@ -1064,7 +1064,7 @@ indent_else_if = false # true/false indent_var_def_blk = 0 # number # Whether to indent continued variable declarations instead of aligning. -indent_var_def_cont = false # true/false +indent_var_def_cont = true # true/false # Whether to indent continued shift expressions ('<<' and '>>') instead of # aligning. Set align_left_shift=false when enabling this. @@ -2564,7 +2564,7 @@ align_oc_msg_spec_span = 0 # unsigned number # Whether to align macros wrapped with a backslash and a newline. This will # not work right if the macro contains a multi-line comment. -align_nl_cont = false # true/false +align_nl_cont = true # true/false # Whether to align macro functions and variables together. align_pp_define_together = false # true/false -- cgit v1.3