diff options
author | schmidt <douglascraigschmidt@users.noreply.github.com> | 2010-02-22 15:00:48 +0000 |
---|---|---|
committer | schmidt <douglascraigschmidt@users.noreply.github.com> | 2010-02-22 15:00:48 +0000 |
commit | 9686a2da05dc79d3785d69ab92dbda1ad731f770 (patch) | |
tree | 820056d9a57dcd6a5b121812aa66ce216bdba8a1 | |
parent | 9d8c32991742a6b1b01e24578c7902b004d14081 (diff) | |
download | ATCD-9686a2da05dc79d3785d69ab92dbda1ad731f770.tar.gz |
ChangeLogTag:Mon
-rw-r--r-- | ACE/ChangeLog | 7 | ||||
-rw-r--r-- | ACE/ace/Time_Value.cpp | 138 |
2 files changed, 67 insertions, 78 deletions
diff --git a/ACE/ChangeLog b/ACE/ChangeLog index a1706d8b3dd..676642e336d 100644 --- a/ACE/ChangeLog +++ b/ACE/ChangeLog @@ -1,8 +1,7 @@ -Mon Feb 22 14:46:53 UTC 2010 Douglas C. Schmidt <schmidt@dre.vanderbilt.edu> +Mon Feb 22 15:00:11 UTC 2010 Douglas C. Schmidt <schmidt@dre.vanderbilt.edu> - * ace/Time_Value.{h,cpp} (ACE_Time_Value::normalize): - Reformatted/renamed the code to conform to ACE programming - guidelines. + * ace/Time_Value.{h,cpp}: Reformatted/renamed the code to conform + to ACE programming guidelines. Mon Feb 22 13:40:14 UTC 2010 Douglas C. Schmidt <schmidt@dre.vanderbilt.edu> diff --git a/ACE/ace/Time_Value.cpp b/ACE/ace/Time_Value.cpp index ffd533e2c05..5b5479ed919 100644 --- a/ACE/ace/Time_Value.cpp +++ b/ACE/ace/Time_Value.cpp @@ -15,7 +15,7 @@ ACE_RCSID (ace, #ifdef ACE_HAS_CPP98_IOSTREAMS #include <ostream> #include <iomanip> -#endif +#endif /* ACE_HAS_CPP98_IOSTREAMS */ ACE_BEGIN_VERSIONED_NAMESPACE_DECL @@ -241,19 +241,19 @@ ACE_Time_Value::operator *= (double d) // a 64-bits time_t + 6 digits after the decimal point for the usec part, // we perform the multiplication of the 2 timeval parts separately. // - // This extra precision step is adding a cost when - // transfering the seconds resulting from the usec multiplication. - // This operation correspond to the normalization process performed in - // normalize() but we must absolutly do it here because the - // usec multiplication result value could exceed what can be stored - // in a suseconds_t type variable. + // This extra precision step is adding a cost when transfering the + // seconds resulting from the usec multiplication. This operation + // correspond to the normalization process performed in normalize() + // but we must absolutly do it here because the usec multiplication + // result value could exceed what can be stored in a suseconds_t + // type variable. // // Since this is a costly operation, we try to detect as soon as - // possible if we are having a saturation in order to abort the - // rest of the computation. + // possible if we are having a saturation in order to abort the rest + // of the computation. typedef ACE::If_Then_Else<(sizeof (double) > sizeof (time_t)), - double, - long double>::result_type float_type; + double, + long double>::result_type float_type; float_type sec_total = this->sec(); sec_total *= d; @@ -265,89 +265,79 @@ ACE_Time_Value::operator *= (double d) ACE_Numeric_Limits<time_t>::min() - 0.999999; if (sec_total > max_int) - { - this->set(ACE_Numeric_Limits<time_t>::max(),ACE_ONE_SECOND_IN_USECS-1); - } + this->set(ACE_Numeric_Limits<time_t>::max(), ACE_ONE_SECOND_IN_USECS-1); else if (sec_total < min_int) - { - this->set(ACE_Numeric_Limits<time_t>::min(),-ACE_ONE_SECOND_IN_USECS+1); - } + this->set(ACE_Numeric_Limits<time_t>::min(), -ACE_ONE_SECOND_IN_USECS+1); else - { - time_t time_sec = static_cast<time_t> (sec_total); + { + time_t time_sec = static_cast<time_t> (sec_total); - float_type usec_total = this->usec(); - usec_total *= d; + float_type usec_total = this->usec(); + usec_total *= d; - // adding usec resulting from tv_sec mult - usec_total += (sec_total-time_sec)*ACE_ONE_SECOND_IN_USECS; + // adding usec resulting from tv_sec mult + usec_total += (sec_total-time_sec) * ACE_ONE_SECOND_IN_USECS; - // extract seconds component of the usec mult - sec_total = usec_total / ACE_ONE_SECOND_IN_USECS; - // keep remaining usec - if (sec_total > 0) - usec_total = (sec_total - ACE_OS::floor(sec_total)); - else - usec_total = (sec_total - ACE_OS::ceil(sec_total)); + // extract seconds component of the usec mult + sec_total = usec_total / ACE_ONE_SECOND_IN_USECS; + // keep remaining usec + if (sec_total > 0) + usec_total = (sec_total - ACE_OS::floor(sec_total)); + else + usec_total = (sec_total - ACE_OS::ceil(sec_total)); - sec_total -= usec_total; - usec_total *= ACE_ONE_SECOND_IN_USECS; + sec_total -= usec_total; + usec_total *= ACE_ONE_SECOND_IN_USECS; - // add the seconds component of the usec mult with the tv_sec mult prod. - sec_total += time_sec; + // add the seconds component of the usec mult with the tv_sec mult prod. + sec_total += time_sec; - // recheck for saturation - if (sec_total > max_int) - { - this->set(ACE_Numeric_Limits<time_t>::max(),ACE_ONE_SECOND_IN_USECS-1); - } - else if (sec_total < min_int) - { - this->set(ACE_Numeric_Limits<time_t>::min(),-ACE_ONE_SECOND_IN_USECS+1); - } - else - { - time_sec = sec_total; - suseconds_t time_usec = static_cast<suseconds_t> (usec_total); - - // round up the result to save the last usec - if (time_usec > 0 && (usec_total - time_usec) >= 0.5) - ++time_usec; - else if (time_usec < 0 && (usec_total - time_usec) <= -0.5) - --time_usec; - - this->set(time_sec,time_usec); + // recheck for saturation + if (sec_total > max_int) + this->set (ACE_Numeric_Limits<time_t>::max(), ACE_ONE_SECOND_IN_USECS - 1); + else if (sec_total < min_int) + this->set (ACE_Numeric_Limits<time_t>::min(), -ACE_ONE_SECOND_IN_USECS + 1); + else + { + time_sec = sec_total; + suseconds_t time_usec = static_cast<suseconds_t> (usec_total); + + // round up the result to save the last usec + if (time_usec > 0 && (usec_total - time_usec) >= 0.5) + ++time_usec; + else if (time_usec < 0 && (usec_total - time_usec) <= -0.5) + --time_usec; + + this->set (time_sec, time_usec); + } } - } return *this; } #ifdef ACE_HAS_CPP98_IOSTREAMS ostream &operator<<(ostream &o, const ACE_Time_Value &v) { - char oldFiller = o.fill(); - o.fill('0'); - const timeval *tv = v; - if( tv->tv_sec ) + char oldFiller = o.fill (); + o.fill ('0'); + const timeval *tv = v; + if (tv->tv_sec) { - o << tv->tv_sec; - if( tv->tv_usec ) - o << '.' << std::setw(6) << abs(tv->tv_usec); + o << tv->tv_sec; + if (tv->tv_usec) + o << '.' << std::setw (6) << abs (tv->tv_usec); } - else if( tv->tv_usec < 0 ) - { - o << "-0." << std::setw(6) << -tv->tv_usec; - } - else + else if (tv->tv_usec < 0) + o << "-0." << std::setw (6) << -tv->tv_usec; + else { - o << '0'; - if( tv->tv_usec > 0 ) - o << '.'<< std::setw(6) << tv->tv_usec; + o << '0'; + if (tv->tv_usec > 0) + o << '.'<< std::setw (6) << tv->tv_usec; } - o.fill(oldFiller); - return o; + o.fill (oldFiller); + return o; } -#endif +#endif /* ACE_HAS_CPP98_IOSTREAMS */ ACE_END_VERSIONED_NAMESPACE_DECL |