aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Zammit <damien@zamaudio.com>2023-09-24 10:34:49 +0000
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2023-09-24 14:37:50 +0200
commit31d45d0d8ee1d8eee96fc2a283a388b6b6aca669 (patch)
treea95db566461b2cb4d5fac435b32bbc8349664fc3
parent74a1d4600a53541f5c89d55c6d4efd3210fe992d (diff)
downloadgnumach-31d45d0d8ee1d8eee96fc2a283a388b6b6aca669.tar.gz
gnumach-31d45d0d8ee1d8eee96fc2a283a388b6b6aca669.tar.bz2
gnumach-31d45d0d8ee1d8eee96fc2a283a388b6b6aca669.zip
cpu_number: Inline widely used simple function
TESTED: on uniprocessor and smp, both behaved as normal. Message-Id: <20230924103428.455966-2-damien@zamaudio.com>
-rw-r--r--i386/Makefrag_x86.am1
-rw-r--r--i386/i386/cpu_number.c30
-rw-r--r--i386/i386/cpu_number.h10
-rw-r--r--kern/ast.h1
-rw-r--r--kern/processor.h3
-rw-r--r--kern/thread.h3
6 files changed, 12 insertions, 36 deletions
diff --git a/i386/Makefrag_x86.am b/i386/Makefrag_x86.am
index 46c1d38b..272de023 100644
--- a/i386/Makefrag_x86.am
+++ b/i386/Makefrag_x86.am
@@ -18,7 +18,6 @@ libkernel_a_SOURCES += \
i386/i386/ast_check.c \
i386/i386/ast_types.h \
i386/i386/cpu.h \
- i386/i386/cpu_number.c \
i386/i386/cpu_number.h \
i386/i386/db_disasm.c \
i386/i386/db_interface.c \
diff --git a/i386/i386/cpu_number.c b/i386/i386/cpu_number.c
deleted file mode 100644
index ef19e11f..00000000
--- a/i386/i386/cpu_number.c
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (c) 2022 Free Software Foundation, Inc.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <i386/cpu_number.h>
-#include <i386/apic.h>
-#include <i386/smp.h>
-#include <i386/cpu.h>
-#include <i386/mp_desc.h>
-#include <kern/printf.h>
-
-#if NCPUS > 1
-int cpu_number(void)
-{
- return cpu_id_lut[apic_get_current_cpu()];
-}
-#endif
diff --git a/i386/i386/cpu_number.h b/i386/i386/cpu_number.h
index 479a847a..8357be84 100644
--- a/i386/i386/cpu_number.h
+++ b/i386/i386/cpu_number.h
@@ -64,8 +64,14 @@
popl %esi ;\
#ifndef __ASSEMBLER__
-#include "kern/cpu_number.h"
-int cpu_number(void);
+#include <kern/cpu_number.h>
+#include <i386/apic.h>
+
+static inline int cpu_number(void)
+{
+ return cpu_id_lut[apic_get_current_cpu()];
+}
+
#endif
#else /* NCPUS == 1 */
diff --git a/kern/ast.h b/kern/ast.h
index c8cbd04f..aded1677 100644
--- a/kern/ast.h
+++ b/kern/ast.h
@@ -40,7 +40,6 @@
* a set of reasons for an AST, and passing this set to ast_taken.
*/
-#include "cpu_number.h"
#include <kern/kern_types.h>
#include <kern/macros.h>
#include <machine/ast.h>
diff --git a/kern/processor.h b/kern/processor.h
index 17b784a3..79386627 100644
--- a/kern/processor.h
+++ b/kern/processor.h
@@ -41,7 +41,6 @@
#include <mach/kern_return.h>
#include <mach/port.h>
#include <mach/processor_info.h>
-#include <kern/cpu_number.h>
#include <kern/lock.h>
#include <kern/queue.h>
#include <kern/sched.h>
@@ -112,6 +111,8 @@ struct processor {
typedef struct processor Processor;
extern struct processor processor_array[NCPUS];
+#include <kern/cpu_number.h>
+
/*
* Chain of all processor sets.
*/
diff --git a/kern/thread.h b/kern/thread.h
index 8547464d..bf07828a 100644
--- a/kern/thread.h
+++ b/kern/thread.h
@@ -42,7 +42,6 @@
#include <mach/port.h>
#include <mach/vm_prot.h>
#include <kern/ast.h>
-#include <kern/cpu_number.h>
#include <kern/mach_clock.h>
#include <kern/queue.h>
#include <kern/pc_sample.h>
@@ -235,6 +234,8 @@ struct thread {
#endif
};
+#include <kern/cpu_number.h>
+
/* typedef of thread_t is in kern/kern_types.h */
typedef struct thread_shuttle *thread_shuttle_t;
#define THREAD_NULL ((thread_t) 0)