Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 33 additions & 2 deletions ACE/ace/Time_Value.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,51 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL

/// Static constant representing `zero-time'.
/// Note: this object requires static construction.
const ACE_Time_Value ACE_Time_Value::zero;
#if !defined (ACE_HAS_TIME_T_LONG_MISMATCH)
const
#endif
ACE_Time_Value ACE_Time_Value::zero;

/// Constant for maximum time representable. Note that this time
/// is not intended for use with select () or other calls that may
/// have *their own* implementation-specific maximum time representations.
/// Its primary use is in time computations such as those used by the
/// dynamic subpriority strategies in the ACE_Dynamic_Message_Queue class.
/// Note: this object requires static construction.
const ACE_Time_Value ACE_Time_Value::max_time (
#if !defined (ACE_HAS_TIME_T_LONG_MISMATCH)
const
#endif
ACE_Time_Value ACE_Time_Value::max_time (
ACE_Numeric_Limits<time_t>::max (),
ACE_ONE_SECOND_IN_USECS - 1);

ACE_ALLOC_HOOK_DEFINE (ACE_Time_Value)

#if defined (ACE_HAS_TIME_T_LONG_MISMATCH)
/// Returns the value of the object as a timeval.
ACE_Time_Value::operator timeval () const
{
// ACE_OS_TRACE ("ACE_Time_Value::operator timeval");
// Recall that on some Windows we substitute another type for timeval in tv_
ACE_Time_Value *me = const_cast<ACE_Time_Value*> (this);
me->ext_tv_.tv_sec = ACE_Utils::truncate_cast<long> (this->tv_.tv_sec);
me->ext_tv_.tv_usec = ACE_Utils::truncate_cast<long> (this->tv_.tv_usec);
return this->ext_tv_;
}
#endif /* ACE_HAS_TIME_T_LONG_MISMATCH */

#if defined (ACE_HAS_TIME_T_LONG_MISMATCH)
ACE_Time_Value::operator const timeval * () const
{
// ACE_OS_TRACE ("ACE_Time_Value::operator const timeval *");
// Recall that on some Windows we substitute another type for timeval in tv_
ACE_Time_Value *me = const_cast<ACE_Time_Value*> (this);
me->ext_tv_.tv_sec = ACE_Utils::truncate_cast<long> (this->tv_.tv_sec);
me->ext_tv_.tv_usec = ACE_Utils::truncate_cast<long> (this->tv_.tv_usec);
return (const timeval *) std::addressof(this->ext_tv_);
}
#endif /* ACE_HAS_TIME_T_LONG_MISMATCH */

/// Increment microseconds (the only reason this is here is to allow
/// the use of ACE_Atomic_Op with ACE_Time_Value).
ACE_Time_Value
Expand Down
10 changes: 10 additions & 0 deletions ACE/ace/Time_Value.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,13 @@ class ACE_Export ACE_Time_Value
{
public:
/// Constant "0".
#if defined (ACE_HAS_TIME_T_LONG_MISMATCH)
// In this case the timeval operation will do a const cast, this will
// cause an access violation with clang due to its optimizations
static ACE_Time_Value zero;
#else
static const ACE_Time_Value zero;
#endif

/**
* Constant for maximum time representable. Note that this time is
Expand All @@ -59,7 +65,11 @@ class ACE_Export ACE_Time_Value
* dynamic subpriority strategies in the ACE_Dynamic_Message_Queue
* class.
*/
#if defined (ACE_HAS_TIME_T_LONG_MISMATCH)
static ACE_Time_Value max_time;
#else
static const ACE_Time_Value max_time;
#endif

/// Default Constructor.
ACE_Time_Value ();
Expand Down
35 changes: 11 additions & 24 deletions ACE/ace/Time_Value.inl
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,23 @@

ACE_BEGIN_VERSIONED_NAMESPACE_DECL

#if !defined (ACE_HAS_TIME_T_LONG_MISMATCH)
/// Returns the value of the object as a timeval.
ACE_INLINE
ACE_Time_Value::operator timeval () const
{
// ACE_OS_TRACE ("ACE_Time_Value::operator timeval");
#if defined (ACE_HAS_TIME_T_LONG_MISMATCH)
// Recall that on some Windows we substitute another type for timeval in tv_
ACE_Time_Value *me = const_cast<ACE_Time_Value*> (this);
me->ext_tv_.tv_sec = ACE_Utils::truncate_cast<long> (this->tv_.tv_sec);
me->ext_tv_.tv_usec = ACE_Utils::truncate_cast<long> (this->tv_.tv_usec);
return this->ext_tv_;
#else
return this->tv_;
#endif /* ACE_HAS_TIME_T_LONG_MISMATCH */
}
#endif /* !ACE_HAS_TIME_T_LONG_MISMATCH */

#if !defined (ACE_HAS_TIME_T_LONG_MISMATCH)
ACE_INLINE
ACE_Time_Value::operator const timeval * () const
{
// ACE_OS_TRACE ("ACE_Time_Value::operator const timeval *");
return (const timeval *) std::addressof(this->tv_);
}
#endif /* !ACE_HAS_TIME_T_LONG_MISMATCH */

ACE_INLINE void
ACE_Time_Value::set (const timeval &tv)
Expand All @@ -36,21 +38,6 @@ ACE_Time_Value::ACE_Time_Value (const struct timeval &tv)
this->set (tv);
}

ACE_INLINE
ACE_Time_Value::operator const timeval * () const
{
// ACE_OS_TRACE ("ACE_Time_Value::operator const timeval *");
#if defined (ACE_HAS_TIME_T_LONG_MISMATCH)
// Recall that on some Windows we substitute another type for timeval in tv_
ACE_Time_Value *me = const_cast<ACE_Time_Value*> (this);
me->ext_tv_.tv_sec = ACE_Utils::truncate_cast<long> (this->tv_.tv_sec);
me->ext_tv_.tv_usec = ACE_Utils::truncate_cast<long> (this->tv_.tv_usec);
return (const timeval *) &this->ext_tv_;
#else
return (const timeval *) &this->tv_;
#endif /* ACE_HAS_TIME_T_LONG_MISMATCH */
}

ACE_INLINE void
ACE_Time_Value::set (time_t sec, suseconds_t usec)
{
Expand Down
1 change: 1 addition & 0 deletions ACE/ace/config-win32-borland.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
#define ACE_HAS_DIRENT

#define ACE_HAS_WIN32_STRUCTURED_EXCEPTIONS
#define ACE_HAS_TIME_T_LONG_MISMATCH

#define ACE_LACKS_TERMIOS_H
#define ACE_LACKS_NETINET_TCP_H
Expand Down
Loading