xref: /openbsd-src/gnu/usr.bin/perl/ext/XS-APItest/exception.c (revision 898184e3e61f9129feb5978fad5a8c6865f00b92)
143003dfeSmillert #include "EXTERN.h"
243003dfeSmillert #include "perl.h"
343003dfeSmillert 
443003dfeSmillert #define NO_XSLOCKS
543003dfeSmillert #include "XSUB.h"
643003dfeSmillert 
throws_exception(int throw_e)743003dfeSmillert static void throws_exception(int throw_e)
843003dfeSmillert {
943003dfeSmillert   if (throw_e)
1043003dfeSmillert     croak("boo\n");
1143003dfeSmillert }
1243003dfeSmillert 
13*898184e3Ssthen /* Don't give this the same name as execution() in ext/Devel/PPPort/module3.c
14*898184e3Ssthen    as otherwise building entirely statically will cause a test to fail, as
1543003dfeSmillert    PPPort's execption() gets used in place of this one.  */
1643003dfeSmillert 
apitest_exception(int throw_e)1743003dfeSmillert int apitest_exception(int throw_e)
1843003dfeSmillert {
1943003dfeSmillert   dTHR;
2043003dfeSmillert   dXCPT;
2143003dfeSmillert   SV *caught = get_sv("XS::APItest::exception_caught", 0);
2243003dfeSmillert 
2343003dfeSmillert   XCPT_TRY_START {
2443003dfeSmillert     throws_exception(throw_e);
2543003dfeSmillert   } XCPT_TRY_END
2643003dfeSmillert 
2743003dfeSmillert   XCPT_CATCH
2843003dfeSmillert   {
2943003dfeSmillert     sv_setiv(caught, 1);
3043003dfeSmillert     XCPT_RETHROW;
3143003dfeSmillert   }
3243003dfeSmillert 
3343003dfeSmillert   sv_setiv(caught, 0);
3443003dfeSmillert 
3543003dfeSmillert   return 42;
3643003dfeSmillert }
3743003dfeSmillert 
38