X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=Cleanup.xs;h=e88916c2c52be88447a381a336270125ec0e5668;hb=5df33e24c91c6ebd942de8ed5eb45dd4c1b24269;hp=f41b2c865dc029904c2bf5d7c4f9badb1302f1f9;hpb=22959c257e28ede6726925b5098404585a8bac40;p=perl%2Fmodules%2FThread-Cleanup.git diff --git a/Cleanup.xs b/Cleanup.xs index f41b2c8..e88916c 100644 --- a/Cleanup.xs +++ b/Cleanup.xs @@ -1,9 +1,9 @@ /* 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" @@ -11,49 +11,23 @@ #define TC_HAS_PERL(R, V, S) (PERL_REVISION > (R) || (PERL_REVISION == (R) && (PERL_VERSION > (V) || (PERL_VERSION == (V) && (PERL_SUBVERSION >= (S)))))) -#undef ENTERn -#if defined(ENTER_with_name) && !TC_HAS_PERL(5, 11, 4) -# define ENTERn(N) ENTER_with_name(N) -#else -# define ENTERn(N) ENTER -#endif - -#undef LEAVEn -#if defined(LEAVE_with_name) && !TC_HAS_PERL(5, 11, 4) -# define LEAVEn(N) LEAVE_with_name(N) -#else -# define LEAVEn(N) LEAVE -#endif - -STATIC void tc_callback(pTHX_ void *); +#include "reap.h" STATIC void tc_callback(pTHX_ void *ud) { - int *level = ud; - SV *id; - - if (*level) { - *level = 0; - LEAVE; - SAVEDESTRUCTOR_X(tc_callback, level); - ENTER; - } else { - dSP; - - PerlMemShared_free(level); + dSP; - ENTER; - SAVETMPS; + ENTER; + SAVETMPS; - PUSHMARK(SP); - PUTBACK; + PUSHMARK(SP); + PUTBACK; - call_pv(__PACKAGE__ "::_CLEANUP", G_VOID | G_EVAL); + call_pv(__PACKAGE__ "::_CLEANUP", G_VOID | G_EVAL); - PUTBACK; + PUTBACK; - FREETMPS; - LEAVE; - } + FREETMPS; + LEAVE; } MODULE = Thread::Cleanup PACKAGE = Thread::Cleanup @@ -63,12 +37,6 @@ PROTOTYPES: DISABLE void CLONE(...) PREINIT: - int *level; -CODE: - { - level = PerlMemShared_malloc(sizeof *level); - *level = 1; - LEAVEn("sub"); - SAVEDESTRUCTOR_X(tc_callback, level); - ENTERn("sub"); - } +PPCODE: + reap(3, tc_callback, NULL); + XSRETURN(0);