Skip to content

Commit 542b593

Browse files
committed
treewide: apply clang-format
Signed-off-by: Nick Schonning <nschonni@gmail.com>
1 parent 0f88eeb commit 542b593

43 files changed

Lines changed: 617 additions & 1080 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

kernel/arch/arm/arch.c

Lines changed: 42 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -95,18 +95,18 @@ struct pbl_kernel_debug_layout {
9595
};
9696

9797
const struct pbl_kernel_debug_layout pbl_kernel_debug_layout __attribute__((used)) = {
98-
.version = 1,
99-
.thread_sp = offsetof(struct pbl_thread, backend.sp),
100-
.thread_all_next = offsetof(struct pbl_thread, backend.all_next),
101-
.thread_state = offsetof(struct pbl_thread, backend.state),
102-
.thread_id = offsetof(struct pbl_thread, id),
103-
.thread_name = offsetof(struct pbl_thread, name),
104-
.thread_name_len = PBL_THREAD_NAME_LEN,
105-
.ctx_control = offsetof(struct saved_context, control),
106-
.ctx_r4 = offsetof(struct saved_context, r4_r11),
107-
.ctx_exc_return = offsetof(struct saved_context, exc_return),
108-
.ctx_hw = offsetof(struct saved_context, r0),
109-
.ctx_fp_extra = NUM_EXTRA_FP_REGS * sizeof(uint32_t),
98+
.version = 1,
99+
.thread_sp = offsetof(struct pbl_thread, backend.sp),
100+
.thread_all_next = offsetof(struct pbl_thread, backend.all_next),
101+
.thread_state = offsetof(struct pbl_thread, backend.state),
102+
.thread_id = offsetof(struct pbl_thread, id),
103+
.thread_name = offsetof(struct pbl_thread, name),
104+
.thread_name_len = PBL_THREAD_NAME_LEN,
105+
.ctx_control = offsetof(struct saved_context, control),
106+
.ctx_r4 = offsetof(struct saved_context, r4_r11),
107+
.ctx_exc_return = offsetof(struct saved_context, exc_return),
108+
.ctx_hw = offsetof(struct saved_context, r0),
109+
.ctx_fp_extra = NUM_EXTRA_FP_REGS * sizeof(uint32_t),
110110
};
111111

112112
_Static_assert(offsetof(struct pbl_thread, backend.sp) == 0, "saved SP must be first");
@@ -119,7 +119,9 @@ static inline bool prv_fp_active(uint32_t exc_return) {
119119

120120
// ---- threads ----------------------------------------------------------------
121121

122-
static void prv_thread_return(void) { pbl_thread_abort(NULL); }
122+
static void prv_thread_return(void) {
123+
pbl_thread_abort(NULL);
124+
}
123125

124126
void arch_thread_init(struct pbl_thread *t, void (*entry)(void *), void *arg) {
125127
uintptr_t top = ((uintptr_t)t->stack + t->stack_size) & ~7u;
@@ -164,7 +166,9 @@ void arch_thread_regions_set(struct pbl_thread *t, const MpuRegion *const *regio
164166
#endif
165167
}
166168

167-
void arch_thread_aborted(struct pbl_thread *t) { (void)t; }
169+
void arch_thread_aborted(struct pbl_thread *t) {
170+
(void)t;
171+
}
168172

169173
void arch_thread_exit(void) {
170174
// The switch requested by the abort takes over as soon as we get here.
@@ -175,15 +179,19 @@ void arch_thread_exit(void) {
175179

176180
// ---- interrupts -------------------------------------------------------------
177181

178-
bool arch_in_isr(void) { return mcu_state_is_isr(); }
182+
bool arch_in_isr(void) {
183+
return mcu_state_is_isr();
184+
}
179185

180186
void arch_irq_disable(void) {
181187
__set_BASEPRI(PBL_IRQ_PRIO_MAX_SYSCALL);
182188
__DSB();
183189
__ISB();
184190
}
185191

186-
void arch_irq_enable(void) { __set_BASEPRI(0); }
192+
void arch_irq_enable(void) {
193+
__set_BASEPRI(0);
194+
}
187195

188196
void arch_switch_request(void) {
189197
SCB->ICSR = SCB_ICSR_PENDSVSET_Msk;
@@ -213,7 +221,7 @@ void arch_switch_request(void) {
213221
#endif
214222

215223
// r1 -> thread's MPU words; clobbers r2, r4-r11.
216-
#define RESTORE_MPU \
224+
#define RESTORE_MPU \
217225
" ldr r2, =0xe000ed98 \n" /* MPU_RNR */ \
218226
" mov r4, #" STR(FIRST_MPU_REGION) " \n" \
219227
" str r4, [r2] \n" \
@@ -226,45 +234,38 @@ __attribute__((naked)) void PendSV_Handler(void) {
226234
" mrs r0, psp \n"
227235
" isb \n"
228236
" ldr r3, =pbl_cur \n"
229-
" ldr r2, [r3] \n"
230-
SAVE_FP
231-
SAVE_REGS
232-
" str r0, [r2] \n" /* pbl_cur->backend.sp */
237+
" ldr r2, [r3] \n" SAVE_FP SAVE_REGS
238+
" str r0, [r2] \n" /* pbl_cur->backend.sp */
233239
" stmdb sp!, {r3, r14} \n"
234240
" mov r0, %0 \n"
235241
" msr basepri, r0 \n"
236242
" dsb \n"
237243
" isb \n"
238-
" bl sched_switch_in \n" /* returns the next thread */
244+
" bl sched_switch_in \n" /* returns the next thread */
239245
" mov r4, r0 \n"
240246
" mov r0, #0 \n"
241247
" msr basepri, r0 \n"
242248
" ldmia sp!, {r3, r14} \n"
243-
" ldr r0, [r4] \n" /* next->backend.sp */
244-
" add r1, r4, #4 \n" /* next->backend.arch.mpu */
245-
RESTORE_MPU
246-
RESTORE_REGS
247-
RESTORE_FP
249+
" ldr r0, [r4] \n" /* next->backend.sp */
250+
" add r1, r4, #4 \n" /* next->backend.arch.mpu */
251+
RESTORE_MPU RESTORE_REGS RESTORE_FP
248252
" msr psp, r0 \n"
249253
" isb \n"
250254
" bx r14 \n"
251-
" .ltorg \n"
252-
::"i"(PBL_IRQ_PRIO_MAX_SYSCALL));
255+
" .ltorg \n" ::"i"(PBL_IRQ_PRIO_MAX_SYSCALL));
253256
}
254257

255258
// Loads the first thread's context. MSP is reset to the top of the ISR stack.
256259
__attribute__((naked)) static void prv_restore_first_thread(void) {
257260
__asm volatile(
258-
" ldr r0, =0xE000ED08 \n" /* VTOR: initial MSP is the first vector */
261+
" ldr r0, =0xE000ED08 \n" /* VTOR: initial MSP is the first vector */
259262
" ldr r0, [r0] \n"
260263
" ldr r0, [r0] \n"
261264
" msr msp, r0 \n"
262265
" ldr r3, =pbl_cur \n"
263266
" ldr r4, [r3] \n"
264267
" ldr r0, [r4] \n"
265-
" add r1, r4, #4 \n"
266-
RESTORE_MPU
267-
RESTORE_REGS
268+
" add r1, r4, #4 \n" RESTORE_MPU RESTORE_REGS
268269
" msr psp, r0 \n"
269270
" mov r0, #0 \n"
270271
" msr basepri, r0 \n"
@@ -367,7 +368,8 @@ __attribute__((naked)) void SVC_Handler(void) {
367368

368369
// ---- start and tick ---------------------------------------------------------
369370

370-
void arch_init(void) {}
371+
void arch_init(void) {
372+
}
371373

372374
void arch_start(void) {
373375
// PendSV and SysTick at the lowest priority; SVC follows once started.
@@ -392,7 +394,9 @@ void arch_start(void) {
392394
}
393395

394396
#ifndef CONFIG_SOC_SF32LB52
395-
void SysTick_Handler(void) { pbl_kernel_tick_isr(); }
397+
void SysTick_Handler(void) {
398+
pbl_kernel_tick_isr();
399+
}
396400
#endif
397401

398402
void arch_idle(pbl_tick_t max_ticks) {
@@ -408,16 +412,16 @@ void arch_thread_saved_regs(const struct pbl_thread *t, struct pbl_thread_saved_
408412
if (t == pbl_cur && arch_in_isr()) {
409413
// The running thread's registers are live on its stack, not saved.
410414
const uint32_t *frame = (const uint32_t *)__get_PSP();
411-
*regs = (struct pbl_thread_saved_regs){
412-
.pc = frame[6], .lr = frame[5], .control = __get_CONTROL() };
415+
*regs =
416+
(struct pbl_thread_saved_regs){.pc = frame[6], .lr = frame[5], .control = __get_CONTROL()};
413417
return;
414418
}
415419
const struct saved_context *ctx = t->backend.sp;
416420
const uint32_t *hw = &ctx->r0;
417421
if (prv_fp_active(ctx->exc_return)) {
418422
hw += NUM_EXTRA_FP_REGS;
419423
}
420-
*regs = (struct pbl_thread_saved_regs){ .pc = hw[6], .lr = hw[5], .control = ctx->control };
424+
*regs = (struct pbl_thread_saved_regs){.pc = hw[6], .lr = hw[5], .control = ctx->control};
421425
}
422426

423427
void arch_thread_info_regs(const struct pbl_thread *t, uint32_t regs[PBL_THREAD_REG_COUNT]) {

kernel/arch/posix/arch.c

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ static void *prv_thread_main(void *arg) {
5353
return NULL;
5454
}
5555

56-
void arch_init(void) {}
56+
void arch_init(void) {
57+
}
5758

5859
void arch_thread_init(struct pbl_thread *t, void (*entry)(void *), void *arg) {
5960
pthread_cond_init(&t->backend.arch.wake, NULL);
@@ -97,7 +98,9 @@ static void prv_switch(void) {
9798
}
9899
}
99100

100-
void arch_switch_request(void) { s_switch_pending = true; }
101+
void arch_switch_request(void) {
102+
s_switch_pending = true;
103+
}
101104

102105
void arch_thread_exit(void) {
103106
// pbl_thread_abort() already switched away and ended this pthread.
@@ -111,9 +114,12 @@ void arch_thread_aborted(struct pbl_thread *t) {
111114
}
112115
}
113116

114-
bool arch_in_isr(void) { return s_in_isr; }
117+
bool arch_in_isr(void) {
118+
return s_in_isr;
119+
}
115120

116-
void arch_irq_disable(void) {}
121+
void arch_irq_disable(void) {
122+
}
117123

118124
void arch_irq_enable(void) {
119125
if (!s_in_isr && s_switch_pending && pbl_kernel_is_started()) {
@@ -123,7 +129,7 @@ void arch_irq_enable(void) {
123129

124130
void arch_thread_saved_regs(const struct pbl_thread *t, struct pbl_thread_saved_regs *regs) {
125131
(void)t;
126-
*regs = (struct pbl_thread_saved_regs){ 0 };
132+
*regs = (struct pbl_thread_saved_regs){0};
127133
}
128134

129135
void arch_thread_info_regs(const struct pbl_thread *t, uint32_t regs[PBL_THREAD_REG_COUNT]) {
@@ -207,7 +213,9 @@ void pbl_test_kernel_stop(void) {
207213
}
208214
}
209215

210-
void pbl_test_isr_enter(void) { s_in_isr = true; }
216+
void pbl_test_isr_enter(void) {
217+
s_in_isr = true;
218+
}
211219

212220
void pbl_test_isr_exit(void) {
213221
s_in_isr = false;

kernel/debug.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
void pbl_thread_foreach(pbl_thread_info_fn fn, void *ctx) {
1111
for (struct pbl_thread *t = pbl_all_threads; t != NULL; t = t->backend.all_next) {
1212
struct pbl_thread_info info = {
13-
.thread = t,
14-
.name = t->name,
15-
.id = (uintptr_t)t,
16-
.current = (t == pbl_cur),
13+
.thread = t,
14+
.name = t->name,
15+
.id = (uintptr_t)t,
16+
.current = (t == pbl_cur),
1717
};
1818
if (!info.current) {
1919
arch_thread_info_regs(t, info.regs);
@@ -33,9 +33,9 @@ void pbl_thread_stack_info(const struct pbl_thread *t, struct pbl_thread_stack_i
3333
untouched++;
3434
}
3535
*info = (struct pbl_thread_stack_info){
36-
.start = (uintptr_t)t->stack,
37-
.size = t->stack_size,
38-
.high_water = untouched * sizeof(uint32_t),
36+
.start = (uintptr_t)t->stack,
37+
.size = t->stack_size,
38+
.high_water = untouched * sizeof(uint32_t),
3939
};
4040
}
4141

@@ -50,12 +50,12 @@ size_t pbl_thread_stats_snapshot(struct pbl_thread_stats *out, size_t max,
5050
struct pbl_thread_stack_info stack;
5151
pbl_thread_stack_info(t, &stack);
5252
out[n++] = (struct pbl_thread_stats){
53-
.thread = t,
54-
.name = t->name,
55-
.number = t->backend.number,
56-
.run_time = t->backend.run_time,
57-
.stack_high_water = stack.high_water,
58-
.state = (enum pbl_thread_state)t->backend.state,
53+
.thread = t,
54+
.name = t->name,
55+
.number = t->backend.number,
56+
.run_time = t->backend.run_time,
57+
.stack_high_water = stack.high_water,
58+
.state = (enum pbl_thread_state)t->backend.state,
5959
};
6060
}
6161
pbl_irq_unlock();

kernel/irq.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,14 @@ void pbl_irq_unlock(void) {
1717
}
1818
}
1919

20-
void irq_reset(void) { s_nesting = 0; }
20+
void irq_reset(void) {
21+
s_nesting = 0;
22+
}
2123

22-
bool pbl_in_isr(void) { return arch_in_isr(); }
24+
bool pbl_in_isr(void) {
25+
return arch_in_isr();
26+
}
2327

24-
bool pbl_irq_is_locked(void) { return s_nesting > 0; }
28+
bool pbl_irq_is_locked(void) {
29+
return s_nesting > 0;
30+
}

kernel/msgq.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ void pbl_msgq_init(struct pbl_msgq *q, void *buf, size_t msg_size, uint32_t max_
1313
*q = (struct pbl_msgq)PBL_MSGQ_INITIALIZER(buf, msg_size, max_msgs);
1414
}
1515

16-
void pbl_msgq_deinit(struct pbl_msgq *q) { KERNEL_ASSERT(q->group == NULL); }
16+
void pbl_msgq_deinit(struct pbl_msgq *q) {
17+
KERNEL_ASSERT(q->group == NULL);
18+
}
1719

1820
static uint8_t *prv_slot(struct pbl_msgq *q, uint32_t index) {
1921
return (uint8_t *)q->buf + index * q->msg_size;
@@ -114,6 +116,10 @@ void pbl_msgq_purge(struct pbl_msgq *q) {
114116
pbl_irq_unlock();
115117
}
116118

117-
uint32_t pbl_msgq_num_used(const struct pbl_msgq *q) { return q->backend.count; }
119+
uint32_t pbl_msgq_num_used(const struct pbl_msgq *q) {
120+
return q->backend.count;
121+
}
118122

119-
uint32_t pbl_msgq_num_free(const struct pbl_msgq *q) { return q->max_msgs - q->backend.count; }
123+
uint32_t pbl_msgq_num_free(const struct pbl_msgq *q) {
124+
return q->max_msgs - q->backend.count;
125+
}

kernel/mutex.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,13 @@
55

66
#include "kernel.h"
77

8-
void pbl_mutex_init(struct pbl_mutex *m) { *m = (struct pbl_mutex)PBL_MUTEX_INITIALIZER; }
8+
void pbl_mutex_init(struct pbl_mutex *m) {
9+
*m = (struct pbl_mutex)PBL_MUTEX_INITIALIZER;
10+
}
911

10-
void pbl_mutex_deinit(struct pbl_mutex *m) { KERNEL_ASSERT(m->count == 0); }
12+
void pbl_mutex_deinit(struct pbl_mutex *m) {
13+
KERNEL_ASSERT(m->count == 0);
14+
}
1115

1216
int pbl_mutex_lock_lr(struct pbl_mutex *m, pbl_timeout_t timeout, uintptr_t lr) {
1317
KERNEL_ASSERT(!arch_in_isr());

kernel/poll.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ void pbl_poll_group_add(struct pbl_poll_group *g, struct pbl_msgq *q) {
2727
// queue cannot starve the others.
2828
static struct pbl_msgq *prv_ready_member(struct pbl_poll_group *g) {
2929
struct pbl_msgq *cursor = g->backend.cursor;
30-
for (struct pbl_msgq *m = cursor ? cursor->group_next : g->members; m != NULL; m = m->group_next) {
30+
for (struct pbl_msgq *m = cursor ? cursor->group_next : g->members; m != NULL;
31+
m = m->group_next) {
3132
if (m->backend.count > 0) {
3233
g->backend.cursor = m;
3334
return m;

0 commit comments

Comments
 (0)