Exception.c 538 B

123456789101112131415161718192021222324252627282930
  1. /* This Hello World simply print out "Hello World" */
  2. #include "pal.h"
  3. #include "pal_debug.h"
  4. int count = 0;
  5. int i = 0;
  6. void handler (PAL_PTR event, PAL_NUM arg, PAL_CONTEXT * context)
  7. {
  8. pal_printf("failure in the handler: 0x%08lx\n", arg);
  9. count++;
  10. if (count == 30)
  11. DkProcessExit(0);
  12. DkExceptionReturn(event);
  13. }
  14. int main (void)
  15. {
  16. pal_printf("Enter Main Thread\n");
  17. DkSetExceptionHandler(handler, PAL_EVENT_ARITHMETIC_ERROR);
  18. i = 1 / i;
  19. pal_printf("Leave Main Thread\n");
  20. return 0;
  21. }