From 48602fcfae193445d936ad519523bd294416318e Mon Sep 17 00:00:00 2001 From: Tomas Hruby Date: Tue, 22 Sep 2009 21:46:47 +0000 Subject: [PATCH] NOT_REACHABLE macro - marks code path that should be unreachable (never executed) - if hit, panics and reports the problem - the end of main() marked as such. The SMP changes need some magic with stack switching before the AP can be started as they need to run on the boot stack before figuring out what is their own stack. As main() uses the boot stack to, we need to switch to to the stack of BSP before executing the last part of main() which needs to be in a separate function so we can jump to it. Therefore restart() won't be the last call in main() which may be confusing. The macro can/should be used in other such places too. --- kernel/debug.h | 6 ++++++ kernel/main.c | 1 + 2 files changed, 7 insertions(+) diff --git a/kernel/debug.h b/kernel/debug.h index e25605e0c..e9de2a5ca 100644 --- a/kernel/debug.h +++ b/kernel/debug.h @@ -67,4 +67,10 @@ #define vmassert(t) { } #endif +#define NOT_REACHABLE(__x) do { \ + kprintf("NOT_REACHABLE at %s:%d\n", __FILE__, __LINE__); \ + minix_panic("execution at an unexpected location\n", NO_NUM); \ + for(;;); \ +} while(0) + #endif /* DEBUG_H */ diff --git a/kernel/main.c b/kernel/main.c index b847b2bef..1f63e08ac 100755 --- a/kernel/main.c +++ b/kernel/main.c @@ -206,6 +206,7 @@ PUBLIC void main() FIXME("PROC check enabled"); #endif restart(); + NOT_REACHABLE(); } /*===========================================================================*