Exception.c 714 B

123456789101112131415161718192021222324252627282930313233
  1. /* -*- mode:c; c-file-style:"k&r"; c-basic-offset: 4; tab-width:4; indent-tabs-mode:nil; mode:auto-fill; fill-column:78; -*- */
  2. /* vim: set ts=4 sw=4 et tw=78 fo=cqt wm=0: */
  3. /* This Hello World simply print out "Hello World" */
  4. #include "pal.h"
  5. #include "pal_debug.h"
  6. int count = 0;
  7. int i = 0;
  8. void handler (PAL_PTR event, PAL_NUM arg, PAL_CONTEXT * context)
  9. {
  10. pal_printf("failure in the handler: 0x%08lx\n", arg);
  11. count++;
  12. if (count == 30)
  13. DkProcessExit(0);
  14. DkExceptionReturn(event);
  15. }
  16. int main (void)
  17. {
  18. pal_printf("Enter Main Thread\n");
  19. DkSetExceptionHandler(handler, PAL_EVENT_ARITHMETIC_ERROR);
  20. i = 1 / i;
  21. pal_printf("Leave Main Thread\n");
  22. return 0;
  23. }