From be50854251ddd73d0830431ffac5407faa99d6a0 Mon Sep 17 00:00:00 2001 From: Imbus <> Date: Thu, 26 Jun 2025 10:29:40 +0200 Subject: [PATCH] proc.c: Simplify mycpu(), remove cpuid() for now as it is only a front for r_tp() --- lib/proc.c | 19 ++++--------------- lib/proc.h | 1 - 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/lib/proc.c b/lib/proc.c index aa28a41..73aec31 100644 --- a/lib/proc.c +++ b/lib/proc.c @@ -2,18 +2,7 @@ struct Cpu cpus[NCPU]; -// Must be called with interrupts disabled, -// to prevent race with process being moved -// to a different CPU. -int cpuid() { - int id = r_tp(); - return id; -} - -// Return this CPU's cpu struct. -// Interrupts must be disabled. -struct Cpu *mycpu(void) { - int id = cpuid(); - struct Cpu *c = &cpus[id]; - return c; -} +/** + * Return this CPU's cpu struct. Interrupts must be disabled. + */ +inline struct Cpu *mycpu(void) { return &cpus[r_tp()]; } diff --git a/lib/proc.h b/lib/proc.h index 67749a2..1208b2b 100644 --- a/lib/proc.h +++ b/lib/proc.h @@ -3,7 +3,6 @@ #include #include -int cpuid(void); struct Cpu *mycpu(void); /** Saved registers for kernel context switches. */