From 17bfb0ef0a48330b1d54e61fe3c30d83528d2d90 Mon Sep 17 00:00:00 2001 From: dzwdz Date: Wed, 25 Jan 2023 20:16:22 +0100 Subject: style: typedef structs, shorter namespaces I've wanted to do this for a while, and since I've just had a relatively large refactor commit (pcpy), this is as good of a time as any. Typedefing structs was mostly inspired by Plan 9's coding style. It makes some lines of code much shorter at basically no expense. Everything related to userland kept old-style struct definitions, so as not to force that style onto other people. I also considered changing SCREAMING_ENUM_FIELDS to NicerLookingCamelcase, but I didn't, just in case that'd be confusing. --- src/kernel/arch/amd64/time.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/kernel/arch/amd64/time.c') diff --git a/src/kernel/arch/amd64/time.c b/src/kernel/arch/amd64/time.c index d6e53dd..0e40521 100644 --- a/src/kernel/arch/amd64/time.c +++ b/src/kernel/arch/amd64/time.c @@ -3,7 +3,7 @@ #include static uint64_t uptime = 0, goal = ~0; -static struct process *scheduled = NULL; +static Proc *scheduled = NULL; uint64_t uptime_ms(void) { return uptime; } @@ -16,18 +16,18 @@ void pit_irq(void) { uptime++; if (uptime < goal) return; - struct process *p = scheduled; + Proc *p = scheduled; assert(p); scheduled = p->waits4timer.next; - process_transition(p, PS_RUNNING); + proc_setstate(p, PS_RUNNING); update_goal(); } -void timer_schedule(struct process *p, uint64_t time) { - process_transition(p, PS_WAITS4TIMER); +void timer_schedule(Proc *p, uint64_t time) { + proc_setstate(p, PS_WAITS4TIMER); p->waits4timer.goal = time; - struct process **slot = &scheduled; + Proc **slot = &scheduled; while (*slot && (*slot)->waits4timer.goal <= time) { assert((*slot)->state == PS_WAITS4TIMER); slot = &(*slot)->waits4timer.next; @@ -37,10 +37,10 @@ void timer_schedule(struct process *p, uint64_t time) { update_goal(); } -void timer_deschedule(struct process *p) { +void timer_deschedule(Proc *p) { assert(p->state == PS_WAITS4TIMER); - struct process **slot = &scheduled; + Proc **slot = &scheduled; while (*slot && *slot != p) slot = &(*slot)->waits4timer.next; assert(*slot); -- cgit v1.2.3