X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=Cleanup.xs;h=e88916c2c52be88447a381a336270125ec0e5668;hb=3b18f02197b39a66ea8779d68d1c90d790cf8031;hp=34296e1d22116b68b21ade2426941dc496510255;hpb=15b9171b2fc61b12e0dcc123369fc2b66fe87012;p=perl%2Fmodules%2FThread-Cleanup.git diff --git a/Cleanup.xs b/Cleanup.xs index 34296e1..e88916c 100644 --- a/Cleanup.xs +++ b/Cleanup.xs @@ -1,43 +1,33 @@ -/* This file is part of the Scope::Upper Perl module. - * See http://search.cpan.org/dist/Scope-Upper/ */ - +/* This file is part of the Thread::Cleanup Perl module. + * See http://search.cpan.org/dist/Thread-Cleanup/ */ + #define PERL_NO_GET_CONTEXT #include "EXTERN.h" -#include "perl.h" +#include "perl.h" #include "XSUB.h" #define __PACKAGE__ "Thread::Cleanup" #define __PACKAGE_LEN__ (sizeof(__PACKAGE__)-1) -STATIC void tc_callback(pTHX_ void *); - -STATIC void tc_callback(pTHX_ void *ud) { - int *level = ud; - SV *id; +#define TC_HAS_PERL(R, V, S) (PERL_REVISION > (R) || (PERL_REVISION == (R) && (PERL_VERSION > (V) || (PERL_VERSION == (V) && (PERL_SUBVERSION >= (S)))))) - if (*level) { - *level = 0; - LEAVE; - SAVEDESTRUCTOR_X(tc_callback, level); - ENTER; - } else { - dSP; +#include "reap.h" - PerlMemShared_free(level); +STATIC void tc_callback(pTHX_ void *ud) { + dSP; - ENTER; - SAVETMPS; + ENTER; + SAVETMPS; - PUSHMARK(SP); - PUTBACK; + PUSHMARK(SP); + PUTBACK; - call_pv(__PACKAGE__ "::_CLEANUP", G_VOID); + call_pv(__PACKAGE__ "::_CLEANUP", G_VOID | G_EVAL); - SPAGAIN; + PUTBACK; - FREETMPS; - LEAVE; - } + FREETMPS; + LEAVE; } MODULE = Thread::Cleanup PACKAGE = Thread::Cleanup @@ -47,12 +37,6 @@ PROTOTYPES: DISABLE void CLONE(...) PREINIT: - int *level; -CODE: - { - level = PerlMemShared_malloc(sizeof *level); - *level = 1; - LEAVE; - SAVEDESTRUCTOR_X(tc_callback, level); - ENTER; - } +PPCODE: + reap(3, tc_callback, NULL); + XSRETURN(0);