]> git.vpit.fr Git - perl/modules/Thread-Cleanup.git/blob - Cleanup.xs
Test that the thread destructors are executed before global destruction
[perl/modules/Thread-Cleanup.git] / Cleanup.xs
1 /* This file is part of the Thread::Cleanup Perl module.
2  * See http://search.cpan.org/dist/Thread-Cleanup/ */
3
4 #define PERL_NO_GET_CONTEXT
5 #include "EXTERN.h"
6 #include "perl.h"
7 #include "XSUB.h"
8
9 #define __PACKAGE__     "Thread::Cleanup"
10 #define __PACKAGE_LEN__ (sizeof(__PACKAGE__)-1)
11
12 #define TC_HAS_PERL(R, V, S) (PERL_REVISION > (R) || (PERL_REVISION == (R) && (PERL_VERSION > (V) || (PERL_VERSION == (V) && (PERL_SUBVERSION >= (S))))))
13
14 #include "reap.h"
15
16 STATIC void tc_callback(pTHX_ void *ud) {
17  dSP;
18
19  ENTER;
20  SAVETMPS;
21
22  PUSHMARK(SP);
23  PUTBACK;
24
25  call_pv(__PACKAGE__ "::_CLEANUP", G_VOID | G_EVAL);
26
27  PUTBACK;
28
29  FREETMPS;
30  LEAVE;
31 }
32
33 MODULE = Thread::Cleanup            PACKAGE = Thread::Cleanup
34
35 PROTOTYPES: DISABLE
36
37 void
38 CLONE(...)
39 PREINIT:
40 PPCODE:
41  reap(3, tc_callback, NULL);
42  XSRETURN(0);