ext/XS/APItest/Makefile.PL XS::APItest extension
ext/XS/APItest/MANIFEST XS::APItest extension
ext/XS/APItest/README XS::APItest extension
+ext/XS/APItest/exception.c XS::APItest extension
ext/XS/APItest/t/call.t XS::APItest extension
ext/XS/APItest/t/exception.t XS::APItest extension
ext/XS/APItest/t/hash.t XS::APItest extension
# define XS_VERSION_BOOTCHECK
#endif
-#define dXCPT dJMPENV; int rEtV = 0
-#define XCPT_TRY_START JMPENV_PUSH(rEtV); if (rEtV == 0)
-#define XCPT_TRY_END JMPENV_POP;
-#define XCPT_CATCH if (rEtV != 0)
-#define XCPT_RETHROW JMPENV_JUMP(rEtV)
+#ifdef NO_XSLOCKS
+# define dXCPT dJMPENV; int rEtV = 0
+# define XCPT_TRY_START JMPENV_PUSH(rEtV); if (rEtV == 0)
+# define XCPT_TRY_END JMPENV_POP;
+# define XCPT_CATCH if (rEtV != 0)
+# define XCPT_RETHROW JMPENV_JUMP(rEtV)
+#endif
/*
The DBM_setFilter & DBM_ckFilter macros are only used by
#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
README
APItest.pm
APItest.xs
+exception.c
t/call.t
t/hash.t
t/printf.t
($] >= 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'
--- /dev/null
+#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;
+}
+
=head2 Exception Handling
-There are a couple of macros to do very basic exception handling in
-XS modules. You can use these macros if you call code that may croak,
-but you need to do some cleanup before giving control back to Perl.
-For example:
+There are a couple of macros to do very basic exception handling in XS
+modules. You have to define C<NO_XSLOCKS> before including F<XSUB.h> to
+be able to use these macros:
+
+ #define NO_XSLOCKS
+ #include "XSUB.h"
+
+You can use these macros if you call code that may croak, but you need
+to do some cleanup before giving control back to Perl. For example:
dXCPT; /* set up neccessary variables */