1 /* exit.h 2 * Copyright (C) 2001-2010, Parrot Foundation. 3 * Overview: 4 * 5 * Data Structure and Algorithms: 6 * History: 7 * Notes: 8 * References: 9 * exit.c 10 */ 11 12 #ifndef PARROT_EXIT_H_GUARD 13 #define PARROT_EXIT_H_GUARD 14 15 #include "parrot/compiler.h" /* compiler capabilities */ 16 17 typedef void (*exit_handler_f)(PARROT_INTERP, int , void *); 18 19 typedef struct _handler_node_t { 20 exit_handler_f function; 21 void *arg; 22 struct _handler_node_t *next; 23 } handler_node_t; 24 25 /* This macro is used to exit Parrot, when all else fails. This is a last 26 resort. This may be platform specific if certain systems cannot just call 27 the libc exit() function 28 */ 29 #define PARROT_FORCE_EXIT(x) exit(x) 30 31 /* The DUMPCORE macro is defined for most platforms, but defined here if not 32 * found elsewhere, so we're sure it's safe to call. */ 33 #ifndef DUMPCORE 34 # define DUMPCORE() do { \ 35 fprintf(stderr, "Sorry, coredump is not yet implemented " \ 36 "for this platform.\n\n"); \ 37 PARROT_FORCE_EXIT(EXIT_FAILURE); \ 38 } while (0) 39 #endif 40 41 #define PANIC(interp, message) Parrot_x_panic_and_exit((interp), (message), __FILE__, __LINE__) 42 43 /* HEADERIZER BEGIN: src/exit.c */ 44 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */ 45 46 PARROT_EXPORT 47 PARROT_DOES_NOT_RETURN 48 PARROT_COLD 49 void Parrot_x_exit(PARROT_INTERP, int status) 50 __attribute__nonnull__(1); 51 52 PARROT_EXPORT 53 PARROT_DOES_NOT_RETURN 54 PARROT_COLD 55 void Parrot_x_jump_out(NULLOK_INTERP, int status); 56 57 PARROT_EXPORT 58 void Parrot_x_on_exit(PARROT_INTERP, 59 ARGIN(exit_handler_f function), 60 ARGIN_NULLOK(void *arg)) 61 __attribute__nonnull__(1) 62 __attribute__nonnull__(2); 63 64 PARROT_EXPORT 65 PARROT_DOES_NOT_RETURN 66 PARROT_COLD 67 void Parrot_x_panic_and_exit( 68 NULLOK_INTERP, 69 ARGIN_NULLOK(const char *message), 70 ARGIN_NULLOK(const char *file), 71 unsigned int line); 72 73 PARROT_COLD 74 PARROT_NO_ADDRESS_SAFETY_ANALYSIS 75 void Parrot_x_execute_on_exit_handlers(PARROT_INTERP, int status) 76 __attribute__nonnull__(1); 77 78 PARROT_DOES_NOT_RETURN 79 PARROT_COLD 80 void Parrot_x_force_error_exit( 81 NULLOK_INTERP, 82 int exitcode, 83 ARGIN_FORMAT(const char * format), 84 ...) 85 __attribute__format__(3, 4) 86 __attribute__nonnull__(3); 87 88 #define ASSERT_ARGS_Parrot_x_exit __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 89 PARROT_ASSERT_ARG(interp)) 90 #define ASSERT_ARGS_Parrot_x_jump_out __attribute__unused__ int _ASSERT_ARGS_CHECK = (0) 91 #define ASSERT_ARGS_Parrot_x_on_exit __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 92 PARROT_ASSERT_ARG(interp) \ 93 , PARROT_ASSERT_ARG(function)) 94 #define ASSERT_ARGS_Parrot_x_panic_and_exit __attribute__unused__ int _ASSERT_ARGS_CHECK = (0) 95 #define ASSERT_ARGS_Parrot_x_execute_on_exit_handlers \ 96 __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 97 PARROT_ASSERT_ARG(interp)) 98 #define ASSERT_ARGS_Parrot_x_force_error_exit __attribute__unused__ int _ASSERT_ARGS_CHECK = (\ 99 PARROT_ASSERT_ARG(format)) 100 /* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */ 101 /* HEADERIZER END: src/exit.c */ 102 103 #endif /* PARROT_EXIT_H_GUARD */ 104 105 /* 106 * Local variables: 107 * c-file-style: "parrot" 108 * End: 109 * vim: expandtab shiftwidth=4 cinoptions='\:2=2' : 110 */ 111