summaryrefslogtreecommitdiff
path: root/ext/XS/APItest
diff options
context:
space:
mode:
Diffstat (limited to 'ext/XS/APItest')
-rw-r--r--ext/XS/APItest/APItest.xs28
-rw-r--r--ext/XS/APItest/MANIFEST1
-rw-r--r--ext/XS/APItest/Makefile.PL2
-rw-r--r--ext/XS/APItest/exception.c33
4 files changed, 38 insertions, 26 deletions
diff --git a/ext/XS/APItest/APItest.xs b/ext/XS/APItest/APItest.xs
index 9b7da1226d..fcdcc9a03c 100644
--- a/ext/XS/APItest/APItest.xs
+++ b/ext/XS/APItest/APItest.xs
@@ -2,32 +2,8 @@
#include "perl.h"
#include "XSUB.h"
-static void throws_exception(int throw_e)
-{
- if (throw_e)
- croak("boo\n");
-}
-
-static int exception(int throw_e)
-{
- dTHR;
- dXCPT;
- SV *caught = get_sv("XS::APItest::exception_caught", 0);
-
- XCPT_TRY_START {
- throws_exception(throw_e);
- } XCPT_TRY_END
-
- XCPT_CATCH
- {
- sv_setiv(caught, 1);
- XCPT_RETHROW;
- }
-
- sv_setiv(caught, 0);
-
- return 42;
-}
+/* from exception.c */
+int exception(int);
MODULE = XS::APItest:Hash PACKAGE = XS::APItest::Hash
diff --git a/ext/XS/APItest/MANIFEST b/ext/XS/APItest/MANIFEST
index 1feded88b8..a8cfd5f05d 100644
--- a/ext/XS/APItest/MANIFEST
+++ b/ext/XS/APItest/MANIFEST
@@ -3,6 +3,7 @@ MANIFEST
README
APItest.pm
APItest.xs
+exception.c
t/call.t
t/hash.t
t/printf.t
diff --git a/ext/XS/APItest/Makefile.PL b/ext/XS/APItest/Makefile.PL
index 4ff940394a..e49da36e08 100644
--- a/ext/XS/APItest/Makefile.PL
+++ b/ext/XS/APItest/Makefile.PL
@@ -9,6 +9,8 @@ WriteMakefile(
($] >= 5.005 ? ## Add these new keywords supported since 5.005
(ABSTRACT_FROM => 'APItest.pm', # retrieve abstract from module
AUTHOR => 'Tim Jenness <t.jenness@jach.hawaii.edu>, Christian Soeller <csoelle@mph.auckland.ac.nz>, Hugo van der Sanden <hv@crypt.compulink.co.uk>') : ()),
+ 'C' => ['exception.c'],
+ 'OBJECT' => '$(BASEEXT)$(OBJ_EXT) $(O_FILES)',
'LIBS' => [''], # e.g., '-lm'
'DEFINE' => '', # e.g., '-DHAVE_SOMETHING'
'INC' => '-I.', # e.g., '-I. -I/usr/include/other'
diff --git a/ext/XS/APItest/exception.c b/ext/XS/APItest/exception.c
new file mode 100644
index 0000000000..9477ea95f8
--- /dev/null
+++ b/ext/XS/APItest/exception.c
@@ -0,0 +1,33 @@
+#include "EXTERN.h"
+#include "perl.h"
+
+#define NO_XSLOCKS
+#include "XSUB.h"
+
+static void throws_exception(int throw_e)
+{
+ if (throw_e)
+ croak("boo\n");
+}
+
+int exception(int throw_e)
+{
+ dTHR;
+ dXCPT;
+ SV *caught = get_sv("XS::APItest::exception_caught", 0);
+
+ XCPT_TRY_START {
+ throws_exception(throw_e);
+ } XCPT_TRY_END
+
+ XCPT_CATCH
+ {
+ sv_setiv(caught, 1);
+ XCPT_RETHROW;
+ }
+
+ sv_setiv(caught, 0);
+
+ return 42;
+}
+