bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 1/2] Replace kernel header includes in include/mach/mach_types.h


From: Flavio Cruz
Subject: [PATCH 1/2] Replace kernel header includes in include/mach/mach_types.h with forward declarations.
Date: Mon, 12 Feb 2024 01:26:33 -0500

I was trying to reuse TASK_NAME_SIZE in kern/thread.h but it was
impossible because files included from kern/task.h end up requiring
kern/thread.h (through percpu.h), creating a recursive dependency.

With this change, mach_types.h only defines forward declarations and
modules have to explicitly include the appropriate header file if they
want to be able touch those structures. Most of the other includes are
required because we no longer grab many different includes through
mach_types.h.
---
 ddb/db_examine.c          |  1 +
 device/io_req.h           |  1 +
 i386/i386/machine_task.c  |  1 +
 i386/i386/percpu.h        |  2 +-
 i386/i386/trap.h          |  1 +
 i386/i386at/int_init.c    |  1 +
 include/mach/mach_types.h | 13 ++++++-------
 include/mach/std_types.h  |  4 ----
 ipc/ipc_space.h           |  1 +
 kern/eventcount.h         |  2 ++
 kern/ipc_mig.h            |  1 +
 kern/thread.c             |  4 ++++
 12 files changed, 20 insertions(+), 12 deletions(-)

diff --git a/ddb/db_examine.c b/ddb/db_examine.c
index 88d7a57..1941fc3 100644
--- a/ddb/db_examine.c
+++ b/ddb/db_examine.c
@@ -47,6 +47,7 @@
 #include <kern/task.h>
 #include <kern/smp.h>
 #include <mach/vm_param.h>
+#include <vm/vm_map.h>
 
 #define db_thread_to_task(thread)      ((thread)? thread->task: TASK_NULL)
 
diff --git a/device/io_req.h b/device/io_req.h
index e66e080..fb63696 100644
--- a/device/io_req.h
+++ b/device/io_req.h
@@ -38,6 +38,7 @@
 #include <kern/slab.h>
 #include <kern/kalloc.h>
 #include <kern/lock.h>
+#include <vm/vm_map.h>
 #include <vm/vm_page.h>
 #include <device/device_types.h>
 #include <device/dev_hdr.h>
diff --git a/i386/i386/machine_task.c b/i386/i386/machine_task.c
index d592838..8bebf36 100644
--- a/i386/i386/machine_task.c
+++ b/i386/i386/machine_task.c
@@ -23,6 +23,7 @@
 #include <kern/lock.h>
 #include <mach/mach_types.h>
 #include <kern/slab.h>
+#include <kern/task.h>
 #include <machine/task.h>
 
 #include <machine/io_perm.h>
diff --git a/i386/i386/percpu.h b/i386/i386/percpu.h
index 86b0a31..637d2ca 100644
--- a/i386/i386/percpu.h
+++ b/i386/i386/percpu.h
@@ -66,7 +66,7 @@ MACRO_END
 #endif
 
 #include <kern/processor.h>
-#include <kern/thread.h>
+#include <mach/mach_types.h>
 
 struct percpu {
     struct percpu      *self;
diff --git a/i386/i386/trap.h b/i386/i386/trap.h
index e82164d..db22273 100644
--- a/i386/i386/trap.h
+++ b/i386/i386/trap.h
@@ -30,6 +30,7 @@
 #include <mach/machine/trap.h>
 
 #ifndef __ASSEMBLER__
+#include <i386/thread.h>
 #include <mach/mach_types.h>
 
 char *trap_name(unsigned int trapnum);
diff --git a/i386/i386at/int_init.c b/i386/i386at/int_init.c
index 262bef1..5c8fce6 100644
--- a/i386/i386at/int_init.c
+++ b/i386/i386at/int_init.c
@@ -23,6 +23,7 @@
 
 #include <i386at/idt.h>
 #include <i386at/int_init.h>
+#include <i386/gdt.h>
 #include <i386/mp_desc.h>
 #include <kern/printf.h>
 #ifdef APIC
diff --git a/include/mach/mach_types.h b/include/mach/mach_types.h
index 57f8f22..5ecd686 100644
--- a/include/mach/mach_types.h
+++ b/include/mach/mach_types.h
@@ -57,13 +57,12 @@
 #include <mach/vm_sync.h>
 
 #ifdef MACH_KERNEL
-#include <kern/task.h>         /* for task_array_t */
-#include <kern/thread.h>       /* for thread_array_t */
-#include <kern/processor.h>    /* for processor_array_t,
-                                      processor_set_array_t,
-                                      processor_set_name_array_t */
-#include <kern/syscall_emulation.h>
-                               /* for emulation_vector_t */
+
+typedef struct task            *task_t;
+typedef struct thread          *thread_t;
+typedef struct processor       *processor_t;
+typedef struct processor_set   *processor_set_t;
+
 #else  /* MACH_KERNEL */
 typedef        mach_port_t     task_t;
 typedef task_t         *task_array_t;
diff --git a/include/mach/std_types.h b/include/mach/std_types.h
index f78e236..0d5db0a 100644
--- a/include/mach/std_types.h
+++ b/include/mach/std_types.h
@@ -41,8 +41,4 @@
 typedef        vm_offset_t     pointer_t;
 typedef        vm_offset_t     vm_address_t;
 
-#ifdef MACH_KERNEL
-#include <ipc/ipc_port.h>
-#endif /* MACH_KERNEL */
-
 #endif /* _MACH_STD_TYPES_H_ */
diff --git a/ipc/ipc_space.h b/ipc/ipc_space.h
index 3f0eaa0..96d5894 100644
--- a/ipc/ipc_space.h
+++ b/ipc/ipc_space.h
@@ -49,6 +49,7 @@
 #include <kern/slab.h>
 #include <kern/printf.h>
 #include <ipc/ipc_entry.h>
+#include <ipc/ipc_port.h>
 #include <ipc/ipc_types.h>
 
 /*
diff --git a/kern/eventcount.h b/kern/eventcount.h
index 7cc8220..598d7e0 100644
--- a/kern/eventcount.h
+++ b/kern/eventcount.h
@@ -35,6 +35,8 @@
 #ifndef        _KERN_EVENTCOUNT_H_
 #define        _KERN_EVENTCOUNT_H_     1
 
+#include <kern/lock.h>
+
 /* kernel visible only */
 
 typedef struct evc {
diff --git a/kern/ipc_mig.h b/kern/ipc_mig.h
index a8ee786..422e8d8 100644
--- a/kern/ipc_mig.h
+++ b/kern/ipc_mig.h
@@ -28,6 +28,7 @@
 
 #include <mach/std_types.h>
 #include <device/device_types.h>
+#include <ipc/ipc_thread.h>
 
 /*
  *  Routine:    mach_msg_send_from_kernel
diff --git a/kern/thread.c b/kern/thread.c
index de9d198..23ee8b0 100644
--- a/kern/thread.c
+++ b/kern/thread.c
@@ -32,12 +32,15 @@
  */
 
 #include <kern/printf.h>
+#include <mach/message.h>
 #include <mach/std_types.h>
 #include <mach/policy.h>
 #include <mach/thread_info.h>
 #include <mach/thread_special_ports.h>
 #include <mach/thread_status.h>
 #include <mach/time_value.h>
+#include <mach/vm_prot.h>
+#include <mach/vm_inherit.h>
 #include <machine/vm_param.h>
 #include <kern/ast.h>
 #include <kern/counters.h>
@@ -59,6 +62,7 @@
 #include <kern/slab.h>
 #include <kern/smp.h>
 #include <kern/mach_clock.h>
+#include <string.h>
 #include <vm/vm_kern.h>
 #include <vm/vm_user.h>
 #include <ipc/ipc_kmsg.h>
-- 
2.39.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]