This commit represents the progress I've made on migrating your codebase from
the temporary KASSERT_PLACEHOLDER macro to the new KASSERT macro
defined in <sys/kassert.h>.
**Work Completed:**
* **`minix/kernel/` (root directory files):**
* I processed all 30 `.c` and `.h` files in this directory.
* I found and replaced `KASSERT_PLACEHOLDER` with `KASSERT` (and included `<sys/kassert.h>`) in 6 files: `debug.c`, `interrupt.c`, `main.c`, `proc.c`, `smp.c`, and `system.c`.
* **`minix/kernel/system/` (system call handlers):**
* I processed all 38 `.c` files in this directory.
* I found and replaced `KASSERT_PLACEHOLDER` with `KASSERT` (and included `<sys/kassert.h>`) in 6 files: `do_copy.c`, `do_fork.c`, `do_mcontext.c`, `do_runctl.c`, `do_safecopy.c`, and `do_vumap.c`.
**Total Progress:**
* Files processed: 68
* Files with KASSERT migrations: 12
**Next Steps:**
My original plan was to continue this migration for the `arch/i386/` and `arch/earm/` directories.
**Reason for Current Status:**
This is the last turn allowed for our current session.
**Your Feedback Incorporated into Future Work Considerations:**
You have provided an exceptionally detailed "Technical Review: KASSERT Migration Progress Analysis." I've received this review and it will be invaluable for guiding the continuation of this work. Key points from your feedback include:
* **Validation:** Implementing post-migration validation steps to ensure completeness and correct include usage.
* **Arch-Specific Expectations:** Anticipating higher assertion density in specific files within `arch/i386` (e.g., `memory.c`, `protect.c`) and `arch/earm`.
* **Potential Issues:** Watching for conditional compilation conflicts (`DEBUG` vs. `DEBUG_KERNEL`) and ensuring C-only constructs from KASSERT don't affect assembly-visible headers.
* **Continuation Protocol:** You recommend proceeding with `arch/i386` using the established methodology, maintaining granular tracking, and flagging anomalies.
* **Optimization Opportunities:** Considering a migration log and preparing for potential macro expansion issues.
This update captures the state of the KASSERT migration before I address the `arch/` directories and before I fully incorporate the detailed verification and logging strategies from your latest feedback. I will resume based on this feedback in our next session.
30 lines
1015 B
C
30 lines
1015 B
C
#ifndef _SYS_KASSERT_H
|
|
#define _SYS_KASSERT_H
|
|
|
|
// Include kernel_types.h if kpanic might eventually need types from it,
|
|
// or if __FILE__, __LINE__, __func__ relate to types defined there (unlikely).
|
|
// For now, not strictly needed by the macros themselves.
|
|
// #include <minix/kernel_types.h>
|
|
|
|
/* Kernel panic function - defined in kpanic.c */
|
|
/* The format attribute helps the compiler check printf-style arguments. */
|
|
void kpanic(const char *fmt, ...) __attribute__((noreturn, format (printf, 1, 2) ));
|
|
|
|
// DEBUG_KERNEL flag will control if KASSERT is active.
|
|
// This should be defined in the build system for debug builds.
|
|
#ifdef DEBUG_KERNEL
|
|
#define KASSERT(cond) do { \
|
|
if (!(cond)) { \
|
|
kpanic("KASSERT failed: %s\n at %s:%d in %s()", \
|
|
#cond, __FILE__, __LINE__, __func__); \
|
|
} \
|
|
} while (0)
|
|
#else
|
|
#define KASSERT(cond) ((void)0)
|
|
#endif
|
|
|
|
/* Compile-time assertion (requires C11 or later) */
|
|
#define KSTATIC_ASSERT(cond) _Static_assert(cond, #cond)
|
|
|
|
#endif /* _SYS_KASSERT_H */
|