Failure.c 741 B

123456789101112131415161718192021222324252627282930313233
  1. /* This Hello World simply print out "Hello World" */
  2. #include "pal.h"
  3. #include "pal_error.h"
  4. #include "pal_debug.h"
  5. int handled = 0;
  6. void FailureHandler (PAL_PTR event, PAL_NUM arg, PAL_CONTEXT * context)
  7. {
  8. pal_printf("Failure notified: %s\n",
  9. pal_errstring[(unsigned long) arg]);
  10. handled = 1;
  11. DkExceptionReturn(event);
  12. }
  13. int main (int argc, char ** argv, char ** envp)
  14. {
  15. pal_printf("Enter Main Thread\n");
  16. DkSetExceptionHandler(FailureHandler, PAL_EVENT_FAILURE);
  17. PAL_HANDLE out = DkStreamOpen("foo:unknown", PAL_ACCESS_WRONLY, 0, 0, 0);
  18. if (!out && !handled) {
  19. pal_printf("DkStreamOpen failed\n");
  20. return -1;
  21. }
  22. pal_printf("Leave Main Thread\n");
  23. return 0;
  24. }