Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clang-format: do not enforce one-line functions #272

Merged
merged 1 commit into from
Jul 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ AllowAllConstructorInitializersOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortFunctionsOnASingleLine: false
AllowShortLambdasOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false
Expand Down
4 changes: 3 additions & 1 deletion arch/x86/apic.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ void apic_icr_write(const apic_icr_t *icr) {
apic_msr_write(X2APIC_REG(APIC_ICR0), icr->reg);
}

apic_mode_t apic_get_mode(void) { return apic_mode; }
apic_mode_t apic_get_mode(void) {
return apic_mode;
}

void init_apic(unsigned int cpu_id, apic_mode_t mode) {
apic_base_t apic_base;
Expand Down
4 changes: 3 additions & 1 deletion arch/x86/real_mode_func.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,6 @@ void long_to_real(void) {
spin_unlock(&lock);
}

void init_real_mode(void) { init_rmode_traps(); }
void init_real_mode(void) {
init_rmode_traps();
}
4 changes: 3 additions & 1 deletion common/console.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ void printk(const char *fmt, ...) {
}

#ifdef KTF_ACPICA
void AcpiOsVprintf(const char *Format, va_list args) { vprintk(Format, args); }
void AcpiOsVprintf(const char *Format, va_list args) {
vprintk(Format, args);
}

void AcpiOsPrintf(const char *Format, ...) {
va_list args;
Expand Down
8 changes: 6 additions & 2 deletions common/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,13 @@ cpu_t *get_cpu(unsigned int id) {
return NULL;
}

unsigned int get_nr_cpus(void) { return nr_cpus; }
unsigned int get_nr_cpus(void) {
return nr_cpus;
}

cpu_t *get_bsp_cpu(void) { return &bsp; }
cpu_t *get_bsp_cpu(void) {
return &bsp;
}

void for_each_cpu(void (*func)(cpu_t *cpu)) {
cpu_t *cpu;
Expand Down
4 changes: 3 additions & 1 deletion common/pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@

static list_head_t pci_list = LIST_INIT(pci_list);

static inline uint8_t pci_dev_hdr_type(pcidev_t *dev) { return dev->hdr & PCI_HDR_TYPE; }
static inline uint8_t pci_dev_hdr_type(pcidev_t *dev) {
return dev->hdr & PCI_HDR_TYPE;
}

static inline bool pci_dev_is_multifunc(pcidev_t *dev) {
return ((dev->hdr & PCI_HDR_MULTIFUNC) != 0);
Expand Down
4 changes: 3 additions & 1 deletion common/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,9 @@ static void display_cpu_info(void) {
printk("Frequency: %lu MHz\n", cpu_frequency / MHZ(1));
}

static void display_banner(void) { draw_logo(); }
static void display_banner(void) {
draw_logo();
}

static void __text_init init_vga_console(void) {
if (!boot_flags.vga)
Expand Down
16 changes: 12 additions & 4 deletions drivers/acpi/acpica/osl.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,13 @@ ACPI_STATUS AcpiOsPhysicalTableOverride(ACPI_TABLE_HEADER *ExistingTable,

/* Memory management functions */

void *AcpiOsAllocate(ACPI_SIZE Size) { return kmalloc(Size); }
void *AcpiOsAllocate(ACPI_SIZE Size) {
return kmalloc(Size);
}

void AcpiOsFree(void *Memory) { kfree(Memory); }
void AcpiOsFree(void *Memory) {
kfree(Memory);
}

BOOLEAN AcpiOsReadable(void *Memory, ACPI_SIZE Length) {
volatile bool success = false;
Expand Down Expand Up @@ -476,10 +480,14 @@ ACPI_STATUS AcpiOsSignalSemaphore(ACPI_SEMAPHORE Handle, UINT32 Units) {

/* Time management functions */

void AcpiOsSleep(UINT64 Miliseconds) { msleep(Miliseconds); }
void AcpiOsSleep(UINT64 Miliseconds) {
msleep(Miliseconds);
}

/* FIXME: Return in correct 100ns units */
UINT64 AcpiOsGetTimer(void) { return get_timer_ticks(); }
UINT64 AcpiOsGetTimer(void) {
return get_timer_ticks();
}

/* FIXME: Use actual microseconds granularity */
void AcpiOsStall(UINT32 Microseconds) {
Expand Down
4 changes: 3 additions & 1 deletion drivers/pit.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,6 @@ void init_pit(const cpu_t *cpu) {
configure_isa_irq(PIT_IRQ, PIT_IRQ0_OFFSET, IOAPIC_DEST_MODE_PHYSICAL, cpu->id);
}

void pit_disable(void) { pic_disable_irq(PIC1_DEVICE_SEL, PIT_IRQ); }
void pit_disable(void) {
pic_disable_irq(PIC1_DEVICE_SEL, PIT_IRQ);
}
4 changes: 3 additions & 1 deletion include/arch/x86/apic.h
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,9 @@ static inline void apic_icr_set_dest(apic_icr_t *icr, uint32_t dest) {
icr->x2apic_dest = dest;
}

static inline void apic_EOI(void) { apic_write(APIC_EOI, APIC_EOI_SIGNAL); }
static inline void apic_EOI(void) {
apic_write(APIC_EOI, APIC_EOI_SIGNAL);
}

#endif /* __ASSEMBLY__ */

Expand Down
8 changes: 6 additions & 2 deletions include/arch/x86/atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ static inline int64_t atomic64_add_return(atomic64_t *v, int64_t n) {
return val;
}

static inline int32_t atomic_inc_return(atomic_t *v) { return atomic_add_return(v, 1); }
static inline int32_t atomic_inc_return(atomic_t *v) {
return atomic_add_return(v, 1);
}

static inline int64_t atomic64_inc_return(atomic64_t *v) {
return atomic64_add_return(v, 1);
Expand Down Expand Up @@ -155,7 +157,9 @@ static inline int64_t atomic64_sub_return(atomic64_t *v, int64_t n) {
return atomic64_add_return(v, -n);
}

static inline int32_t atomic_dec_return(atomic_t *v) { return atomic_sub_return(v, 1); }
static inline int32_t atomic_dec_return(atomic_t *v) {
return atomic_sub_return(v, 1);
}

static inline int64_t atomic64_dec_return(atomic64_t *v) {
return atomic64_sub_return(v, 1);
Expand Down
12 changes: 9 additions & 3 deletions include/arch/x86/page.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,12 @@ extern pat_memory_type_t pat_get_type(pat_field_t field);

/* Static declarations */

static inline mfn_t paddr_to_mfn(paddr_t pa) { return (mfn_t)(pa >> PAGE_SHIFT); }
static inline paddr_t mfn_to_paddr(mfn_t mfn) { return (paddr_t)(mfn << PAGE_SHIFT); }
static inline mfn_t paddr_to_mfn(paddr_t pa) {
return (mfn_t)(pa >> PAGE_SHIFT);
}
static inline paddr_t mfn_to_paddr(mfn_t mfn) {
return (paddr_t)(mfn << PAGE_SHIFT);
}

static inline void *_paddr_to_virt(paddr_t pa, unsigned long addr_space) {
return _ptr(pa + addr_space);
Expand Down Expand Up @@ -213,7 +217,9 @@ static inline void *mfn_to_virt_user(mfn_t mfn) {
return paddr_to_virt_user(mfn << PAGE_SHIFT);
}

static inline void *mfn_to_virt(mfn_t mfn) { return paddr_to_virt(mfn << PAGE_SHIFT); }
static inline void *mfn_to_virt(mfn_t mfn) {
return paddr_to_virt(mfn << PAGE_SHIFT);
}

static inline paddr_t virt_to_paddr(const void *va) {
paddr_t pa = (paddr_t) va;
Expand Down
8 changes: 6 additions & 2 deletions include/arch/x86/pagetable.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,15 +215,19 @@ static inline pgentry_t pgentry_from_virt(const void *va, unsigned long flags) {
#define INVALID_PGENTRY(e) (!(e) || mfn_invalid((e)->mfn))

#if defined(__x86_64__)
static inline pml4_t *get_l4_table(void) { return paddr_to_virt_kern(read_cr3()); }
static inline pml4_t *get_l4_table(void) {
return paddr_to_virt_kern(read_cr3());
}

static inline pdpe_t *get_l3_table(const void *va) {
pml4_t *l3e = l4_table_entry(get_l4_table(), va);

return INVALID_PGENTRY(l3e) ? NULL : mfn_to_virt_kern(l3e->mfn);
}
#elif defined(__i386__)
static inline pdpe_t *get_l3_table(void) { return paddr_to_virt_kern(read_cr3()); }
static inline pdpe_t *get_l3_table(void) {
return paddr_to_virt_kern(read_cr3());
}
#endif

static inline pde_t *get_l2_table(const void *va) {
Expand Down
4 changes: 3 additions & 1 deletion include/cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ extern void wait_for_all_cpus(void);

/* Static declarations */

static inline void init_cpu_runstate(cpu_t *cpu) { atomic_set(&cpu->run_state, 0); }
static inline void init_cpu_runstate(cpu_t *cpu) {
atomic_set(&cpu->run_state, 0);
}

static inline bool is_cpu_finished(cpu_t *cpu) {
return atomic_test_bit(CPU_FINISHED, &cpu->run_state);
Expand Down
60 changes: 45 additions & 15 deletions include/lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,21 @@ static inline void wrmsr(uint32_t msr_idx, uint64_t value) {
"d"((uint32_t)(value >> 32)));
}

static inline void sti(void) { asm volatile("sti"); }
static inline void sti(void) {
asm volatile("sti");
}

static inline void cli(void) { asm volatile("cli"); }
static inline void cli(void) {
asm volatile("cli");
}

static inline void pause(void) { asm volatile("pause"); }
static inline void pause(void) {
asm volatile("pause");
}

static inline void hlt(void) { asm volatile("hlt"); }
static inline void hlt(void) {
asm volatile("hlt");
}

static inline unsigned long read_flags(void) {
unsigned long flags;
Expand Down Expand Up @@ -215,7 +223,9 @@ static inline unsigned long read_fs(void) {
return fs;
}

static inline void write_fs(unsigned long fs) { asm volatile("mov %0, %%fs" ::"r"(fs)); }
static inline void write_fs(unsigned long fs) {
asm volatile("mov %0, %%fs" ::"r"(fs));
}

static inline unsigned long read_gs(void) {
unsigned long gs;
Expand All @@ -225,7 +235,9 @@ static inline unsigned long read_gs(void) {
return gs;
}

static inline void write_gs(unsigned long gs) { asm volatile("mov %0, %%gs" ::"r"(gs)); }
static inline void write_gs(unsigned long gs) {
asm volatile("mov %0, %%gs" ::"r"(gs));
}

static inline unsigned long read_cr0(void) {
unsigned long cr0;
Expand Down Expand Up @@ -296,21 +308,33 @@ static inline void ltr(unsigned int selector) {
asm volatile("ltr %w0" ::"rm"(selector));
}

static inline void sgdt(gdt_ptr_t *gdt_ptr) { asm volatile("sgdt %0" : "=m"(*gdt_ptr)); }
static inline void sgdt(gdt_ptr_t *gdt_ptr) {
asm volatile("sgdt %0" : "=m"(*gdt_ptr));
}

static inline void sidt(idt_ptr_t *idt_ptr) { asm volatile("sidt %0" : "=m"(*idt_ptr)); }
static inline void sidt(idt_ptr_t *idt_ptr) {
asm volatile("sidt %0" : "=m"(*idt_ptr));
}

static inline void str(unsigned int *selector) {
asm volatile("str %0" : "=m"(*selector));
}

static inline void flush_tlb(void) { write_cr3(read_cr3()); }
static inline void flush_tlb(void) {
write_cr3(read_cr3());
}

static inline void ud2(void) { asm volatile("ud2"); }
static inline void ud2(void) {
asm volatile("ud2");
}

static inline void swapgs(void) { asm volatile("swapgs"); }
static inline void swapgs(void) {
asm volatile("swapgs");
}

static inline void syscall(void) { asm volatile("syscall"); }
static inline void syscall(void) {
asm volatile("syscall");
}

static inline void sysret(void) {
#if defined(__i386__)
Expand Down Expand Up @@ -374,15 +398,19 @@ static inline void outd(io_port_t port, uint32_t value) {
asm volatile("out %0, %1" ::"a"(value), "Nd"(port));
}

static inline void putc(io_port_t port, int c) { outb(port, c); }
static inline void putc(io_port_t port, int c) {
outb(port, c);
}

static inline void puts(io_port_t port, const char *buf, size_t len) {
asm volatile("rep; outsb" : "+S"(buf), "+c"(len) : "d"(port));
}

/* I/O port delay is believed to take ~1ms */
#define IO_DELAY_PORT 0x80
static inline void io_delay(void) { outb(IO_DELAY_PORT, 0xff); /* Random data write */ }
static inline void io_delay(void) {
outb(IO_DELAY_PORT, 0xff); /* Random data write */
}

static inline uint64_t rdtsc(void) {
unsigned int low, high;
Expand All @@ -400,7 +428,9 @@ static inline uint64_t rdtscp(void) {
return ((uint64_t) high << 32) | low;
}

static inline void rep_nop(void) { asm volatile("rep;nop" ::: "memory"); }
static inline void rep_nop(void) {
asm volatile("rep;nop" ::: "memory");
}
#define cpu_relax() rep_nop()

static inline void wait_cycles(unsigned int cycles) {
Expand Down
4 changes: 3 additions & 1 deletion include/list.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ static inline void list_unlink(list_head_t *entry) {
entry->prev = NULL;
}

static inline bool list_is_empty(list_head_t *list) { return list->next == list; }
static inline bool list_is_empty(list_head_t *list) {
return list->next == list;
}

#define list_entry(elem, type, member) container_of(elem, type, member)

Expand Down
8 changes: 6 additions & 2 deletions include/mm/pmm.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ static inline bool paddr_invalid(paddr_t pa) {
return pa == PADDR_INVALID || !has_memory_range(pa);
}

static inline bool mfn_invalid(mfn_t mfn) { return paddr_invalid(mfn_to_paddr(mfn)); }
static inline bool mfn_invalid(mfn_t mfn) {
return paddr_invalid(mfn_to_paddr(mfn));
}

static inline bool has_frames(list_head_t *frames, unsigned int order) {
return !(order > MAX_PAGE_ORDER || list_is_empty(&frames[order]));
Expand All @@ -97,7 +99,9 @@ static inline frame_t *get_first_frame(list_head_t *frames, unsigned int order)
return list_first_entry(&frames[order], frame_t, list);
}

static inline frame_t *get_free_frame(void) { return get_free_frames(PAGE_ORDER_4K); }
static inline frame_t *get_free_frame(void) {
return get_free_frames(PAGE_ORDER_4K);
}
static inline void put_free_frame(mfn_t mfn) {
return put_free_frames(mfn, PAGE_ORDER_4K);
}
Expand Down
4 changes: 3 additions & 1 deletion include/mm/vmm.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ static inline void *get_free_page_top(uint32_t flags) {
return get_free_page(flags) + PAGE_SIZE;
}

static inline void put_page(void *page) { put_pages(page, PAGE_ORDER_4K); }
static inline void put_page(void *page) {
put_pages(page, PAGE_ORDER_4K);
}

static inline void put_page_top(void *page) {
put_pages(page - PAGE_SIZE, PAGE_ORDER_4K);
Expand Down
4 changes: 3 additions & 1 deletion include/sched.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ extern void wait_for_task_group(const cpu_t *cpu, task_group_t group);

/* Static declarations */

static inline void set_task_group(task_t *task, task_group_t gid) { task->gid = gid; }
static inline void set_task_group(task_t *task, task_group_t gid) {
task->gid = gid;
}

static inline void wait_for_cpu_tasks(cpu_t *cpu) {
wait_for_task_group(cpu, TASK_GROUP_ALL);
Expand Down
Loading