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.
This commit is contained in:
Tomas Hruby 2009-09-22 21:46:47 +00:00
parent c0a1fd1292
commit 48602fcfae
2 changed files with 7 additions and 0 deletions

View file

@ -67,4 +67,10 @@
#define vmassert(t) { } #define vmassert(t) { }
#endif #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 */ #endif /* DEBUG_H */

View file

@ -206,6 +206,7 @@ PUBLIC void main()
FIXME("PROC check enabled"); FIXME("PROC check enabled");
#endif #endif
restart(); restart();
NOT_REACHABLE();
} }
/*===========================================================================* /*===========================================================================*