X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=Cleanup.xs;h=0a19890d9b41753f65e903b66a18957c77c3b566;hb=a518962799a5d83550da2be0f469ff665edbbb81;hp=948c38f767fa36330cb694dcb32f8c98386eb615;hpb=94379b075db18e2c93b1432b581792ed418c78f2;p=perl%2Fmodules%2FThread-Cleanup.git diff --git a/Cleanup.xs b/Cleanup.xs index 948c38f..0a19890 100644 --- a/Cleanup.xs +++ b/Cleanup.xs @@ -9,43 +9,25 @@ #define __PACKAGE__ "Thread::Cleanup" #define __PACKAGE_LEN__ (sizeof(__PACKAGE__)-1) -#ifndef ENTER_with_name -# define ENTER_with_name(N) ENTER -#endif +#define TC_HAS_PERL(R, V, S) (PERL_REVISION > (R) || (PERL_REVISION == (R) && (PERL_VERSION > (V) || (PERL_VERSION == (V) && (PERL_SUBVERSION >= (S)))))) -#ifndef LEAVE_with_name -# define LEAVE_with_name(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; + dSP; - PerlMemShared_free(level); + 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,7 @@ 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"); + reap(3, tc_callback, NULL); }