X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=Cleanup.xs;h=e88916c2c52be88447a381a336270125ec0e5668;hb=80bbdd645dcd29e89423be24aa15d85a28be59f2;hp=948c38f767fa36330cb694dcb32f8c98386eb615;hpb=94379b075db18e2c93b1432b581792ed418c78f2;p=perl%2Fmodules%2FThread-Cleanup.git diff --git a/Cleanup.xs b/Cleanup.xs index 948c38f..e88916c 100644 --- a/Cleanup.xs +++ b/Cleanup.xs @@ -1,51 +1,33 @@ /* 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) -#ifndef ENTER_with_name -# define ENTER_with_name(N) ENTER -#endif - -#ifndef LEAVE_with_name -# define LEAVE_with_name(N) LEAVE -#endif +#define TC_HAS_PERL(R, V, S) (PERL_REVISION > (R) || (PERL_REVISION == (R) && (PERL_VERSION > (V) || (PERL_VERSION == (V) && (PERL_SUBVERSION >= (S)))))) -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 @@ -55,12 +37,6 @@ PROTOTYPES: DISABLE void CLONE(...) PREINIT: - int *level; -CODE: - { - level = PerlMemShared_malloc(sizeof *level); - *level = 1; - LEAVE_with_name("sub"); - SAVEDESTRUCTOR_X(tc_callback, level); - ENTER_with_name("sub"); - } +PPCODE: + reap(3, tc_callback, NULL); + XSRETURN(0);