*Massive cleanup (\n\n -> \n, *\n -> \n, cleanup for(...) to for (...), and some other cleanups by hand)

*Fix a possible crash in Spell::DoAllEffectOnTarget

--HG--
branch : trunk
This commit is contained in:
maximius
2009-10-17 15:35:07 -07:00
parent f21f47005d
commit 26b5e033ff
2257 changed files with 750 additions and 103852 deletions
-77
View File
@@ -1,30 +1,20 @@
// $Id: Profile_Timer.cpp 82208 2008-06-26 20:44:51Z jtc $
#include "ace/Profile_Timer.h"
#if !defined (__ACE_INLINE__)
# include "ace/Profile_Timer.inl"
#endif /* __ACE_INLINE__ */
#include "ace/Log_Msg.h"
#include "ace/OS_NS_string.h"
#if defined (ACE_HAS_PRUSAGE_T)
#include "ace/OS_NS_fcntl.h"
#include "ace/OS_NS_unistd.h"
#endif
ACE_RCSID(ace, Profile_Timer, "$Id: Profile_Timer.cpp 82208 2008-06-26 20:44:51Z jtc $")
#if (defined (ACE_HAS_PRUSAGE_T) || defined (ACE_HAS_GETRUSAGE)) && !defined (ACE_WIN32)
#include "ace/OS_NS_stdio.h"
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_ALLOC_HOOK_DEFINE(ACE_Profile_Timer)
void
ACE_Profile_Timer::dump (void) const
{
@@ -32,21 +22,17 @@ ACE_Profile_Timer::dump (void) const
ACE_TRACE ("ACE_Profile_Timer::dump");
#endif /* ACE_HAS_DUMP */
}
// Initialize interval timer.
ACE_Profile_Timer::ACE_Profile_Timer (void)
{
ACE_TRACE ("ACE_Profile_Timer::ACE_Profile_Timer");
ACE_OS::memset (&this->end_usage_, 0, sizeof this->end_usage_);
ACE_OS::memset (&this->begin_usage_, 0, sizeof this->begin_usage_);
ACE_OS::memset (&this->last_usage_, 0, sizeof this->last_usage_);
# if defined (ACE_HAS_PRUSAGE_T)
ACE_OS::memset (&this->last_usage_, 0, sizeof this->last_usage_);
char buf[20];
ACE_OS::sprintf (buf, "/proc/%d", static_cast<int> (ACE_OS::getpid ()));
this->proc_handle_ = ACE_OS::open (buf, O_RDONLY, 0);
if (this->proc_handle_ == -1)
ACE_ERROR ((LM_ERROR,
@@ -58,7 +44,6 @@ ACE_Profile_Timer::ACE_Profile_Timer (void)
ACE_OS::memset (&this->last_time_, 0, sizeof this->last_time_);
# endif /* ACE_HAS_PRUSAGE_T */
}
// Terminate the interval timer.
ACE_Profile_Timer::~ACE_Profile_Timer (void)
{
@@ -69,20 +54,15 @@ ACE_Profile_Timer::~ACE_Profile_Timer (void)
ACE_TEXT ("ACE_Profile_Timer::~ACE_Profile_Timer")));
# endif /* ACE_HAS_PRUSAGE_T */
}
// Return the resource utilization.
void
ACE_Profile_Timer::get_rusage (ACE_Profile_Timer::Rusage &usage)
{
ACE_TRACE ("ACE_Profile_Timer::get_rusage");
usage = this->end_usage_;
}
# if defined (ACE_HAS_PRUSAGE_T)
// Compute the amount of resource utilization since the start time.
void
ACE_Profile_Timer::elapsed_rusage (ACE_Profile_Timer::Rusage &rusage)
{
@@ -123,18 +103,14 @@ ACE_Profile_Timer::elapsed_rusage (ACE_Profile_Timer::Rusage &rusage)
rusage.pr_ioch =
this->end_usage_.pr_ioch - this->last_usage_.pr_ioch;
}
// Compute the elapsed time.
void
ACE_Profile_Timer::compute_times (ACE_Elapsed_Time &et)
{
ACE_TRACE ("ACE_Profile_Timer::compute_times");
timespec_t td;
ACE_Profile_Timer::Rusage &end = this->end_usage_;
ACE_Profile_Timer::Rusage &begin = this->begin_usage_;
this->subtract (td, end.pr_tstamp, begin.pr_tstamp);
// Convert nanoseconds into seconds.
et.real_time = td.tv_sec + ((double) td.tv_nsec) / ACE_ONE_SECOND_IN_NSECS;
@@ -145,28 +121,22 @@ ACE_Profile_Timer::compute_times (ACE_Elapsed_Time &et)
// Convert nanoseconds into seconds.
et.system_time = td.tv_sec + ((double) td.tv_nsec) / ACE_ONE_SECOND_IN_NSECS;
}
// Determine the difference between T1 and T2.
void
ACE_Profile_Timer::subtract (timespec_t &tdiff, timespec_t &t1, timespec_t &t0)
{
ACE_TRACE ("ACE_Profile_Timer::subtract");
tdiff.tv_sec = t1.tv_sec - t0.tv_sec;
tdiff.tv_nsec = t1.tv_nsec - t0.tv_nsec;
// Normalize the time.
while (tdiff.tv_nsec < 0)
{
tdiff.tv_sec--;
tdiff.tv_nsec += ACE_ONE_SECOND_IN_NSECS;
}
}
# elif defined (ACE_HAS_GETRUSAGE)
// Compute the amount of resource utilization since the start time.
void
ACE_Profile_Timer::elapsed_rusage (ACE_Profile_Timer::Rusage &usage)
{
@@ -221,46 +191,34 @@ ACE_Profile_Timer::elapsed_rusage (ACE_Profile_Timer::Rusage &usage)
ACE_UNUSED_ARG(usage);
# endif /* ACE_HAS_LIMITED_RUSAGE_T */
}
void
ACE_Profile_Timer::compute_times (ACE_Elapsed_Time &et)
{
ACE_TRACE ("ACE_Profile_Timer::compute_times");
timeval td;
this->subtract (td, this->end_time_, this->begin_time_);
et.real_time = td.tv_sec + ((double) td.tv_usec) / ACE_ONE_SECOND_IN_USECS;
this->subtract (td, this->end_usage_.ru_utime, this->begin_usage_.ru_utime);
et.user_time = td.tv_sec + ((double) td.tv_usec) / ACE_ONE_SECOND_IN_USECS;
this->subtract (td, this->end_usage_.ru_stime, this->begin_usage_.ru_stime);
et.system_time = td.tv_sec + ((double) td.tv_usec) / ACE_ONE_SECOND_IN_USECS;
}
// Determine the difference between T1 and T2.
void
ACE_Profile_Timer::subtract (timeval &tdiff, timeval &t1, timeval &t0)
{
ACE_TRACE ("ACE_Profile_Timer::subtract");
tdiff.tv_sec = t1.tv_sec - t0.tv_sec;
tdiff.tv_usec = t1.tv_usec - t0.tv_usec;
// Normalize the time.
while (tdiff.tv_usec < 0)
{
tdiff.tv_sec--;
tdiff.tv_usec += ACE_ONE_SECOND_IN_USECS;
}
}
# endif /* ACE_HAS_PRUSAGE_T */
// Compute the amount of time that has elapsed between start and stop.
int
ACE_Profile_Timer::elapsed_time (ACE_Elapsed_Time &et)
{
@@ -268,13 +226,9 @@ ACE_Profile_Timer::elapsed_time (ACE_Elapsed_Time &et)
this->compute_times (et);
return 0;
}
ACE_END_VERSIONED_NAMESPACE_DECL
#elif defined (ACE_WIN32) /* defined (ACE_HAS_PRUSAGE_T) || defined (ACE_HAS_GETRUSAGE) */
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
void
ACE_Profile_Timer::dump (void) const
{
@@ -283,29 +237,24 @@ ACE_Profile_Timer::dump (void) const
timer_.dump ();
#endif /* ACE_HAS_DUMP */
}
// Initialize interval timer.
ACE_Profile_Timer::ACE_Profile_Timer (void)
: timer_ ()
{
ACE_TRACE ("ACE_Profile_Timer::ACE_Profile_Timer");
# if defined (ACE_HAS_GETRUSAGE)
ACE_OS::memset (&this->end_usage_, 0, sizeof this->end_usage_);
ACE_OS::memset (&this->begin_usage_, 0, sizeof this->begin_usage_);
ACE_OS::memset (&this->last_usage_, 0, sizeof this->last_usage_);
ACE_OS::memset (&this->begin_time_, 0, sizeof this->begin_time_);
ACE_OS::memset (&this->end_time_, 0, sizeof this->end_time_);
ACE_OS::memset (&this->last_time_, 0, sizeof this->last_time_);
# endif /* ACE_HAS_GETRUSAGE */
}
int
ACE_Profile_Timer::elapsed_time (ACE_Elapsed_Time &et)
{
ACE_TRACE ("ACE_Profile_Timer::elapsed_time");
ACE_hrtime_t delta_t; // nanoseconds
timer_.elapsed_time (delta_t);
# if defined (ACE_LACKS_LONGLONG_T)
@@ -317,7 +266,6 @@ ACE_Profile_Timer::elapsed_time (ACE_Elapsed_Time &et)
ACE_Time_Value atv = ACE_Time_Value (this->end_usage_.ru_utime)
- ACE_Time_Value (this->begin_usage_.ru_utime);
et.user_time = atv.sec () + ((double) atv.usec ()) / ACE_ONE_SECOND_IN_USECS;
atv = ACE_Time_Value (this->end_usage_.ru_stime)
- ACE_Time_Value (this->begin_usage_.ru_stime);
et.system_time = atv.sec () + ((double) atv.usec ()) / ACE_ONE_SECOND_IN_USECS;
@@ -325,12 +273,9 @@ ACE_Profile_Timer::elapsed_time (ACE_Elapsed_Time &et)
et.user_time = 0;
et.system_time = 0;
# endif /* ACE_HAS_GETRUSAGE */
return 0;
}
// Return the resource utilization.
void
ACE_Profile_Timer::get_rusage (ACE_Profile_Timer::Rusage &usage)
{
@@ -341,14 +286,11 @@ ACE_Profile_Timer::get_rusage (ACE_Profile_Timer::Rusage &usage)
usage = 0;
# endif /* ACE_HAS_GETRUSAGE */
}
// Compute the amount of resource utilization since the start time.
void
ACE_Profile_Timer::elapsed_rusage (ACE_Profile_Timer::Rusage &usage)
{
ACE_TRACE ("ACE_Profile_Timer::elapsed_rusage");
# if defined (ACE_HAS_GETRUSAGE)
// Use ACE_Time_Value's as intermediate because the type of ru_utime can
// be multiple types and using the - operator is not safe when this are
@@ -356,7 +298,6 @@ ACE_Profile_Timer::elapsed_rusage (ACE_Profile_Timer::Rusage &usage)
ACE_Time_Value end_ru_utime (this->end_usage_.ru_utime);
ACE_Time_Value begin_ru_utime (this->begin_usage_.ru_utime);
usage.ru_utime = end_ru_utime - begin_ru_utime;
ACE_Time_Value end_ru_stime (this->end_usage_.ru_stime);
ACE_Time_Value begin_ru_stime (this->begin_usage_.ru_stime);
usage.ru_stime = end_ru_stime - begin_ru_stime;
@@ -364,19 +305,15 @@ ACE_Profile_Timer::elapsed_rusage (ACE_Profile_Timer::Rusage &usage)
usage = 0;
# endif /* ACE_HAS_GETRUSAGE */
}
# if defined (ACE_HAS_GETRUSAGE)
// Determine the difference between T1 and T2.
void
ACE_Profile_Timer::subtract (timeval &tdiff, timeval &t1, timeval &t0)
{
ACE_TRACE ("ACE_Profile_Timer::subtract");
tdiff.tv_sec = t1.tv_sec - t0.tv_sec;
tdiff.tv_usec = t1.tv_usec - t0.tv_usec;
// Normalize the time.
while (tdiff.tv_usec < 0)
{
tdiff.tv_sec--;
@@ -384,13 +321,9 @@ ACE_Profile_Timer::subtract (timeval &tdiff, timeval &t1, timeval &t0)
}
}
# endif /* ACE_HAS_GETRUSAGE */
ACE_END_VERSIONED_NAMESPACE_DECL
#else
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
void
ACE_Profile_Timer::dump (void) const
{
@@ -399,29 +332,22 @@ ACE_Profile_Timer::dump (void) const
timer_.dump ();
#endif /* ACE_HAS_DUMP */
}
ACE_Profile_Timer::ACE_Profile_Timer (void)
: timer_ ()
{
ACE_TRACE ("ACE_Profile_Timer::ACE_Profile_Timer");
}
int
ACE_Profile_Timer::elapsed_time (ACE_Elapsed_Time &et)
{
ACE_TRACE ("ACE_Profile_Timer::elapsed_time");
ACE_hrtime_t delta_t; /* nanoseconds */
timer_.elapsed_time (delta_t);
et.real_time = delta_t / (double) ACE_ONE_SECOND_IN_NSECS;
et.user_time = 0;
et.system_time = 0;
return 0;
}
void
ACE_Profile_Timer::get_rusage (ACE_Profile_Timer::Rusage &usage)
{
@@ -429,16 +355,13 @@ ACE_Profile_Timer::get_rusage (ACE_Profile_Timer::Rusage &usage)
usage = 0;
}
void
ACE_Profile_Timer::elapsed_rusage (ACE_Profile_Timer::Rusage &usage)
{
ACE_TRACE ("ACE_Profile_Timer::elapsed_rusage");
usage = 0;
}
ACE_END_VERSIONED_NAMESPACE_DECL
#endif /* defined (ACE_HAS_PRUSAGE_T) ||
defined (ACE_HAS_GETRUSAGE) && !defined (ACE_WIN32) */