[Jifty-commit] r5366 - Runops-Hook/trunk

Jifty commits jifty-commit at lists.jifty.org
Wed May 7 01:04:51 EDT 2008


Author: nothingmuch
Date: Wed May  7 01:04:45 2008
New Revision: 5366

Added:
   Runops-Hook/trunk/Hook.c
Modified:
   Runops-Hook/trunk/Hook.xs

Log:
not address of PL_op, but the pointer itself

Added: Runops-Hook/trunk/Hook.c
==============================================================================
--- (empty file)
+++ Runops-Hook/trunk/Hook.c	Wed May  7 01:04:45 2008
@@ -0,0 +1,264 @@
+/*
+ * This file was generated automatically by ExtUtils::ParseXS version 2.19 from the
+ * contents of Hook.xs. Do not edit this file, edit Hook.xs instead.
+ *
+ *	ANY CHANGES MADE HERE WILL BE LOST! 
+ *
+ */
+
+#line 1 "Hook.xs"
+#define PERL_NO_GET_CONTEXT
+#include "EXTERN.h"
+#include "perl.h"
+#include "XSUB.h"
+
+bool (*Runops_Hook_hook)(pTHX);
+
+static HV *Runops_Hook_op_counters;
+
+static bool Runops_Hook_enabled = 0;
+static UV Runops_Hook_threshold = 0;
+
+int runops_hooked(pTHX)
+{
+	if ( !Runops_Hook_op_counters )
+		Runops_Hook_op_counters = newHV();
+
+	for (;PL_op;) {
+		if (Runops_Hook_enabled) {
+			if (Runops_Hook_threshold == 0) {
+				if (Runops_Hook_hook(aTHX))
+					continue;
+			} else {
+				SV **count = hv_fetch(Runops_Hook_op_counters, (char *)PL_op, sizeof(PL_op), 1);
+				UV c       = SvTRUE(*count) ? SvUV(*count) + 1 : 1;
+				sv_setuv(*count, c);
+
+				if (c >= Runops_Hook_threshold)
+					if (Runops_Hook_hook(aTHX))
+						continue;
+			}
+		}
+
+		PL_op = CALL_FPTR(PL_op->op_ppaddr)(aTHX);
+
+		PERL_ASYNC_CHECK();
+	}
+
+	TAINT_NOT;
+
+	return 0;
+}
+
+bool
+Runops_Hook_noop (pTHX) {
+	/* resume normally */
+	return 0;
+}
+
+void
+Runops_Hook_clear_hook () {
+	Runops_Hook_hook = Runops_Hook_noop;
+}
+
+void
+Runops_Hook_set_hook (bool (*hook)(pTHX)) {
+	Runops_Hook_hook = hook;
+}
+
+void
+Runops_Hook_enable () {
+	Runops_Hook_enabled = 1;
+}
+
+void
+Runops_Hook_disable () {
+	Runops_Hook_enabled = 0;
+}
+
+#ifndef PERL_UNUSED_VAR
+#  define PERL_UNUSED_VAR(var) if (0) var = var
+#endif
+
+#line 84 "Hook.c"
+
+XS(XS_Runops__Hook_counters); /* prototype to pass -Wmissing-prototypes */
+XS(XS_Runops__Hook_counters)
+{
+#ifdef dVAR
+    dVAR; dXSARGS;
+#else
+    dXSARGS;
+#endif
+    if (items != 0)
+       Perl_croak(aTHX_ "Usage: %s(%s)", "Runops::Hook::counters", "");
+    PERL_UNUSED_VAR(cv); /* -W */
+    {
+	HV *	RETVAL;
+#line 79 "Hook.xs"
+{
+	RETVAL = Runops_Hook_op_counters;
+}
+#line 103 "Hook.c"
+	ST(0) = newRV((SV*)RETVAL);
+	sv_2mortal(ST(0));
+    }
+    XSRETURN(1);
+}
+
+
+XS(XS_Runops__Hook_enabled); /* prototype to pass -Wmissing-prototypes */
+XS(XS_Runops__Hook_enabled)
+{
+#ifdef dVAR
+    dVAR; dXSARGS;
+#else
+    dXSARGS;
+#endif
+    if (items != 0)
+       Perl_croak(aTHX_ "Usage: %s(%s)", "Runops::Hook::enabled", "");
+    PERL_UNUSED_VAR(cv); /* -W */
+    {
+	bool	RETVAL;
+#line 88 "Hook.xs"
+{
+	RETVAL = Runops_Hook_enabled;
+}
+#line 128 "Hook.c"
+	ST(0) = boolSV(RETVAL);
+	sv_2mortal(ST(0));
+    }
+    XSRETURN(1);
+}
+
+
+XS(XS_Runops__Hook_enable); /* prototype to pass -Wmissing-prototypes */
+XS(XS_Runops__Hook_enable)
+{
+#ifdef dVAR
+    dVAR; dXSARGS;
+#else
+    dXSARGS;
+#endif
+    if (items != 0)
+       Perl_croak(aTHX_ "Usage: %s(%s)", "Runops::Hook::enable", "");
+    PERL_UNUSED_VAR(cv); /* -W */
+    {
+#line 97 "Hook.xs"
+{
+	Runops_Hook_enable();
+}
+#line 152 "Hook.c"
+    }
+    XSRETURN_EMPTY;
+}
+
+
+XS(XS_Runops__Hook_disable); /* prototype to pass -Wmissing-prototypes */
+XS(XS_Runops__Hook_disable)
+{
+#ifdef dVAR
+    dVAR; dXSARGS;
+#else
+    dXSARGS;
+#endif
+    if (items != 0)
+       Perl_croak(aTHX_ "Usage: %s(%s)", "Runops::Hook::disable", "");
+    PERL_UNUSED_VAR(cv); /* -W */
+    {
+#line 104 "Hook.xs"
+{
+	Runops_Hook_disable();
+}
+#line 174 "Hook.c"
+    }
+    XSRETURN_EMPTY;
+}
+
+
+XS(XS_Runops__Hook_get_threshold); /* prototype to pass -Wmissing-prototypes */
+XS(XS_Runops__Hook_get_threshold)
+{
+#ifdef dVAR
+    dVAR; dXSARGS;
+#else
+    dXSARGS;
+#endif
+    if (items != 0)
+       Perl_croak(aTHX_ "Usage: %s(%s)", "Runops::Hook::get_threshold", "");
+    PERL_UNUSED_VAR(cv); /* -W */
+    {
+	UV	RETVAL;
+	dXSTARG;
+#line 111 "Hook.xs"
+{
+	RETVAL = Runops_Hook_threshold;
+}
+#line 198 "Hook.c"
+	XSprePUSH; PUSHu((UV)RETVAL);
+    }
+    XSRETURN(1);
+}
+
+
+XS(XS_Runops__Hook_set_threshold); /* prototype to pass -Wmissing-prototypes */
+XS(XS_Runops__Hook_set_threshold)
+{
+#ifdef dVAR
+    dVAR; dXSARGS;
+#else
+    dXSARGS;
+#endif
+    if (items != 1)
+       Perl_croak(aTHX_ "Usage: %s(%s)", "Runops::Hook::set_threshold", "a");
+    PERL_UNUSED_VAR(cv); /* -W */
+    {
+	SV *	a = ST(0);
+#line 120 "Hook.xs"
+{
+	   Runops_Hook_threshold = SvUV(a);
+}
+#line 222 "Hook.c"
+    }
+    XSRETURN_EMPTY;
+}
+
+#ifdef __cplusplus
+extern "C"
+#endif
+XS(boot_Runops__Hook); /* prototype to pass -Wmissing-prototypes */
+XS(boot_Runops__Hook)
+{
+#ifdef dVAR
+    dVAR; dXSARGS;
+#else
+    dXSARGS;
+#endif
+    char* file = __FILE__;
+
+    PERL_UNUSED_VAR(cv); /* -W */
+    PERL_UNUSED_VAR(items); /* -W */
+    XS_VERSION_BOOTCHECK ;
+
+        newXS("Runops::Hook::counters", XS_Runops__Hook_counters, file);
+        newXS("Runops::Hook::enabled", XS_Runops__Hook_enabled, file);
+        newXS("Runops::Hook::enable", XS_Runops__Hook_enable, file);
+        newXS("Runops::Hook::disable", XS_Runops__Hook_disable, file);
+        newXS("Runops::Hook::get_threshold", XS_Runops__Hook_get_threshold, file);
+        newXS("Runops::Hook::set_threshold", XS_Runops__Hook_set_threshold, file);
+
+    /* Initialisation Section */
+
+#line 73 "Hook.xs"
+	Runops_Hook_clear_hook();
+    PL_runops = runops_hooked;
+
+#line 257 "Hook.c"
+
+    /* End of Initialisation Section */
+
+    if (PL_unitcheckav)
+         call_list(PL_scopestack_ix, PL_unitcheckav);
+    XSRETURN_YES;
+}
+

Modified: Runops-Hook/trunk/Hook.xs
==============================================================================
--- Runops-Hook/trunk/Hook.xs	(original)
+++ Runops-Hook/trunk/Hook.xs	Wed May  7 01:04:45 2008
@@ -21,7 +21,7 @@
 				if (Runops_Hook_hook(aTHX))
 					continue;
 			} else {
-				SV **count = hv_fetch(Runops_Hook_op_counters, (char *)&PL_op, sizeof(PL_op), 1);
+				SV **count = hv_fetch(Runops_Hook_op_counters, (char *)PL_op, sizeof(PL_op), 1);
 				UV c       = SvTRUE(*count) ? SvUV(*count) + 1 : 1;
 				sv_setuv(*count, c);
 


More information about the Jifty-commit mailing list