]> git.vpit.fr Git - perl/modules/Thread-Cleanup.git/blobdiff - Cleanup.xs
Fix the thread destructor trick for 5.13.1
[perl/modules/Thread-Cleanup.git] / Cleanup.xs
index 948c38f767fa36330cb694dcb32f8c98386eb615..0a19890d9b41753f65e903b66a18957c77c3b566 100644 (file)
@@ -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);
  }