This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Attempt to fix problems with new exception handling macros.
[perl5.git] / ext / XS / APItest / exception.c
1 #include "EXTERN.h"
2 #include "perl.h"
3
4 #define NO_XSLOCKS
5 #include "XSUB.h"
6
7 static void throws_exception(int throw_e)
8 {
9   if (throw_e)
10     croak("boo\n");
11 }
12
13 int exception(int throw_e)
14 {
15   dTHR;
16   dXCPT;
17   SV *caught = get_sv("XS::APItest::exception_caught", 0);
18
19   XCPT_TRY_START {
20     throws_exception(throw_e);
21   } XCPT_TRY_END
22
23   XCPT_CATCH
24   {
25     sv_setiv(caught, 1);
26     XCPT_RETHROW;
27   }
28
29   sv_setiv(caught, 0);
30
31   return 42;
32 }
33