Author: tim.bunce
Date: Fri Jan 30 04:41:34 2009
New Revision: 678
Modified:
trunk/NYTProf.xs
trunk/t/50.errno.t
Log:
Save/restore errno in incr_sub_inclusive_time() and more finely in
pp_entersub_profiler().
Use NYTP_SCi_* constats in more places.
Refine 50.errno.t slightly.
Modified: trunk/NYTProf.xs
==============================================================================
--- trunk/NYTProf.xs (original)
+++ trunk/NYTProf.xs Fri Jan 30 04:41:34 2009
@@ -1947,10 +1947,11 @@
static void
incr_sub_inclusive_time(pTHX_ sub_call_start_t *sub_call_start)
{
+ int saved_errno = errno;
AV *av = sub_call_start->sub_av;
SV *subname_sv = sub_call_start->subname_sv;
- SV *incl_time_sv = *av_fetch(av, 1, 1);
- SV *excl_time_sv = *av_fetch(av, 2, 1);
+ SV *incl_time_sv = *av_fetch(av, NYTP_SCi_INCL_RTIME, 1);
+ SV *excl_time_sv = *av_fetch(av, NYTP_SCi_EXCL_RTIME, 1);
/* statement overheads we've accumulated since we entered the sub */
NV overhead_ticks = (int)(cumulative_overhead_ticks -
sub_call_start->current_overhead_ticks);
/* seconds spent in subroutines called by this subroutine */
@@ -2004,6 +2005,7 @@
sv_free(sub_call_start->subname_sv);
cumulative_subr_secs += excl_subr_sec;
+ SETERRNO(saved_errno, 0);
}
@@ -2093,11 +2095,13 @@
int profile_sub_call = (profile_subs && is_profiling);
if (profile_sub_call) {
+ int saved_errno = errno;
if (!profile_stmts)
reinit_if_forked(aTHX);
get_time_of_day(sub_call_start.sub_call_time);
sub_call_start.current_overhead_ticks = cumulative_overhead_ticks;
sub_call_start.current_subr_secs = cumulative_subr_secs;
+ SETERRNO(saved_errno, 0);
}
/*
@@ -2700,7 +2704,7 @@
AV *av = (AV *)SvRV(sv);
unsigned int fid = 0, line = 0;
- sscanf(fid_line_string, "%u:%u", &fid, &line);
+ (void)sscanf(fid_line_string, "%u:%u", &fid, &line);
output_tag_int(NYTP_TAG_SUB_CALLERS, fid);
output_int(line);
Modified: trunk/t/50.errno.t
==============================================================================
--- trunk/t/50.errno.t (original)
+++ trunk/t/50.errno.t Fri Jan 30 04:41:34 2009
@@ -1,4 +1,4 @@
-use Test::More tests => 4;
+use Test::More tests => 5;
my $nytprof_out;
BEGIN {
@@ -19,9 +19,12 @@
ok $size1, "$nytprof_out should be non-empty";
$! = 9999;
-example_xsub();
example_sub();
-is 0+$!, 9999, '$! should not be altered by assigning fids to previously
unprofiled modules';
+is 0+$!, 9999, "\$! should not be altered by assigning fids to previously
unprofiled modules ($!)";
+
+$! = 9999;
+example_xsub();
+is 0+$!, 9999, "\$! should not be altered by assigning fids to previously
unprofiled modules ($!)";
$! = 9999;
while (-s $nytprof_out == $size1) {
--~--~---------~--~----~------------~-------~--~----~
You've received this message because you are subscribed to
the Devel::NYTProf Development User group.
Group hosted at: http://groups.google.com/group/develnytprof-dev
Project hosted at: http://perl-devel-nytprof.googlecode.com
CPAN distribution: http://search.cpan.org/dist/Devel-NYTProf
To post, email: [email protected]
To unsubscribe, email: [email protected]
-~----------~----~----~----~------~----~------~--~---