Skip to content

Commit 489424d

Browse files
authored
Merge pull request #2436 from jwillemsen/jwi-timevaluebcc64x2
Fixed runtime crashes when using ACE_Time_Value::zero
2 parents e19f8f8 + c716ddd commit 489424d

3 files changed

Lines changed: 9 additions & 7 deletions

File tree

ACE/ace/Time_Value.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,10 @@ class ACE_Export ACE_Time_Value
452452
time_t tv_sec;
453453
suseconds_t tv_usec;
454454
} tv_;
455-
timeval ext_tv_;
455+
// Must be mutable as the zero and max static members are const, but are modified
456+
// in the timeval operations, having it not mutable will cause an access violation
457+
// with some compilers as they put these in the const section.
458+
mutable timeval ext_tv_;
456459
#else
457460
timeval tv_;
458461
#endif /* ACE_HAS_TIME_T_LONG_MISMATCH */

ACE/ace/Time_Value.inl

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@ ACE_Time_Value::operator timeval () const
1010
// ACE_OS_TRACE ("ACE_Time_Value::operator timeval");
1111
#if defined (ACE_HAS_TIME_T_LONG_MISMATCH)
1212
// Recall that on some Windows we substitute another type for timeval in tv_
13-
ACE_Time_Value *me = const_cast<ACE_Time_Value*> (this);
14-
me->ext_tv_.tv_sec = ACE_Utils::truncate_cast<long> (this->tv_.tv_sec);
15-
me->ext_tv_.tv_usec = ACE_Utils::truncate_cast<long> (this->tv_.tv_usec);
13+
this->ext_tv_.tv_sec = this->tv_.tv_sec;
14+
this->ext_tv_.tv_usec = this->tv_.tv_usec;
1615
return this->ext_tv_;
1716
#else
1817
return this->tv_;
@@ -42,9 +41,8 @@ ACE_Time_Value::operator const timeval * () const
4241
// ACE_OS_TRACE ("ACE_Time_Value::operator const timeval *");
4342
#if defined (ACE_HAS_TIME_T_LONG_MISMATCH)
4443
// Recall that on some Windows we substitute another type for timeval in tv_
45-
ACE_Time_Value *me = const_cast<ACE_Time_Value*> (this);
46-
me->ext_tv_.tv_sec = ACE_Utils::truncate_cast<long> (this->tv_.tv_sec);
47-
me->ext_tv_.tv_usec = ACE_Utils::truncate_cast<long> (this->tv_.tv_usec);
44+
this->ext_tv_.tv_sec = this->tv_.tv_sec;
45+
this->ext_tv_.tv_usec = this->tv_.tv_usec;
4846
return (const timeval *) &this->ext_tv_;
4947
#else
5048
return (const timeval *) &this->tv_;

ACE/ace/config-win32-borland.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
#define ACE_HAS_DIRENT
5656

5757
#define ACE_HAS_WIN32_STRUCTURED_EXCEPTIONS
58+
#define ACE_HAS_TIME_T_LONG_MISMATCH
5859

5960
#define ACE_LACKS_TERMIOS_H
6061
#define ACE_LACKS_NETINET_TCP_H

0 commit comments

Comments
 (0)