Skip to content

Commit

Permalink
Decapitalize function-like macros
Browse files Browse the repository at this point in the history
  • Loading branch information
alanjian85 committed Jun 12, 2024
1 parent bdf5315 commit 5dd3408
Show file tree
Hide file tree
Showing 16 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion include/dev.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ typedef struct {
u32 num;
} dev_t;

#define MAKE_DEV(driver, num) ((dev_t){&(driver), num})
#define make_dev(driver, num) ((dev_t){&(driver), num})

isize dev_read(dev_t dev, u8 *buf, usize size);
isize dev_write(dev_t dev, const u8 *buf, usize size);
Expand Down
2 changes: 1 addition & 1 deletion include/dev_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ typedef struct {
i32 (*init)(const dev_node_t *node);
} dev_init_t;

#define DEV_INIT(compat, func) \
#define dev_init(compat, func) \
__section(.init.dev) __used static dev_init_t _dev_init = {compat, func}
6 changes: 3 additions & 3 deletions include/init.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
#include <compiler.h>
#include <types.h>

#define MODULE_PRE_INIT(func) \
#define module_pre_init(func) \
__section(.init.pre_init) __used static i32 (*_pre_init)(void) = func
#define MODULE_INIT(func) \
#define module_init(func) \
__section(.init.init) __used static i32 (*_init)(void) = func
#define MODULE_POST_INIT(func) \
#define module_post_init(func) \
__section(.init.post_init) __used static i32 (*_post_init)(void) = func

i32 init_modules(void);
2 changes: 1 addition & 1 deletion include/list.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ typedef struct list_node {
struct list_node *prev, *next;
} list_node_t;

#define LIST_HEAD_INIT(name) \
#define list_head_init(name) \
{ &name, &name }

static inline void list_init_head(list_node_t *head) {
Expand Down
2 changes: 1 addition & 1 deletion src/dev_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ static i32 init(void) {
return 0;
}

MODULE_POST_INIT(init);
module_post_init(init);
6 changes: 3 additions & 3 deletions src/drivers/fb.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ static driver_t driver = {

static i32 init(void) { return 0; }

MODULE_INIT(init);
module_init(init);

i32 fb_register_dev(dev_t dev) {
if (nr_devs == DRIVER_DEV_CAPACITY)
return -EAGAIN;
u32 num = nr_devs++;
ctrl_blks[num].dev = dev;
for (u32 i = 0; i < nr_dev_probes; i++) {
probes[i](MAKE_DEV(driver, num));
probes[i](make_dev(driver, num));
}
return 0;
}
Expand All @@ -45,7 +45,7 @@ i32 fb_register_dev_probe(void (*probe)(dev_t dev)) {
return -EAGAIN;
probes[nr_dev_probes++] = probe;
for (u32 num = 0; num < nr_devs; num++) {
probe(MAKE_DEV(driver, num));
probe(make_dev(driver, num));
}
return 0;
}
4 changes: 2 additions & 2 deletions src/drivers/fbcon.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,12 @@ static void init_dev(dev_t dev) {
ctrl_blk->fg = DEFAULT_FG;
ctrl_blk->bg = DEFAULT_BG;

tty_register_sink(dev.num, MAKE_DEV(driver, dev.num));
tty_register_sink(dev.num, make_dev(driver, dev.num));
}

static i32 init(void) {
fb_register_dev_probe(init_dev);
return 0;
}

MODULE_POST_INIT(init);
module_post_init(init);
2 changes: 1 addition & 1 deletion src/drivers/plic.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ static i32 init_dev(const dev_node_t *node) {
return 0;
}

DEV_INIT("plic", init_dev);
dev_init("plic", init_dev);
2 changes: 1 addition & 1 deletion src/drivers/tty.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ driver_t tty_driver = {

static i32 init(void) { return 0; }

MODULE_INIT(init);
module_init(init);

static void lazy_init_ctrl_blks(u32 num) {
if (num < nr_devs)
Expand Down
2 changes: 1 addition & 1 deletion src/drivers/uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,4 @@ static i32 init_dev(const dev_node_t *node) {
return 0;
}

DEV_INIT("uart", init_dev);
dev_init("uart", init_dev);
2 changes: 1 addition & 1 deletion src/drivers/virtio-gpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -383,4 +383,4 @@ static i32 init(void) {
return 0;
}

MODULE_POST_INIT(init);
module_post_init(init);
2 changes: 1 addition & 1 deletion src/mm/kalloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ typedef struct {
usize size;
} block_header_t;

static list_node_t block_list = LIST_HEAD_INIT(block_list);
static list_node_t block_list = list_head_init(block_list);

void *kmalloc(usize size) {
size += sizeof(block_header_t);
Expand Down
4 changes: 2 additions & 2 deletions src/mm/page_alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

extern u8 _heap_start[KHEAP_SIZE];

static list_node_t free_list = LIST_HEAD_INIT(free_list);
static list_node_t free_list = list_head_init(free_list);

static i32 init(void) {
list_node_t *node = (list_node_t *) _heap_start;
Expand All @@ -17,7 +17,7 @@ static i32 init(void) {
return 0;
}

MODULE_PRE_INIT(init);
module_pre_init(init);

void *page_alloc(void) {
if (list_empty(&free_list))
Expand Down
4 changes: 2 additions & 2 deletions src/sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <config.h>
#include <init.h>

static list_node_t ready_queue = LIST_HEAD_INIT(ready_queue);
static list_node_t ready_queue = list_head_init(ready_queue);
static proc_t idle_proc;
static timer_t timer;

Expand All @@ -26,7 +26,7 @@ static i32 init(void) {
return 0;
}

MODULE_POST_INIT(init);
module_post_init(init);

void sched_update_state(proc_t *proc, proc_state_t state) {
if (proc->state == state)
Expand Down
4 changes: 2 additions & 2 deletions src/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@

extern const u32 TIMER_FREQ;

static list_node_t wait_queue = LIST_HEAD_INIT(wait_queue);
static list_node_t wait_queue = list_head_init(wait_queue);

static i32 init(void) {
csr_set_bits(sie, CSR_SIE_STIE);
return sbi_set_timer(TIME_MAX);
}

MODULE_INIT(init);
module_init(init);

void timer_init(timer_t *timer) { list_init_head(&timer->node); }

Expand Down
2 changes: 1 addition & 1 deletion src/trap.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ static i32 init(void) {
return 0;
}

MODULE_PRE_INIT(init);
module_pre_init(init);

void trap_handler(trapframe_t *frame) {
if (frame->scause & CSR_SCAUSE_INTR) {
Expand Down

0 comments on commit 5dd3408

Please sign in to comment.