diff options
Diffstat (limited to 'ace/OS.i')
-rw-r--r-- | ace/OS.i | 164 |
1 files changed, 162 insertions, 2 deletions
@@ -187,6 +187,166 @@ extern "C" void ace_mutex_lock_cleanup_adapter (void *args); #define ACE_OSCALL(OP,TYPE,FAILVALUE,RESULT) do { RESULT = (TYPE) OP; } while (0) #endif /* ACE_HAS_SIGNAL_SAFE_OS_CALLS */ +// Don't put this in the class since it will expand the size! Also, +// can't make this an enum due to compiler bugs on some platforms... +static const long ONE_SECOND = 1000000L; + +// Initializes the ACE_Time_Value object. + +// Initializes a timestruc_t. Note that this approach loses precision +// since it converts the nano-seconds into micro-seconds. But then +// again, do any real systems have nano-second timer precision +// anyway?! + +ACE_INLINE void +ACE_Time_Value::set (const timestruc_t &tv) +{ + // ACE_TRACE ("ACE_Time_Value::set"); + this->tv_sec_ = tv.tv_sec; + this->tv_usec_ = tv.tv_nsec / 1000; + + this->normalize (); +} + +// Returns the value of the object as a timestruc_t. + +ACE_INLINE +ACE_Time_Value::operator timestruc_t () const +{ + // ACE_TRACE ("ACE_Time_Value::operator timestruc_t"); + timestruc_t tv; + tv.tv_sec = this->tv_sec_; + tv.tv_nsec = this->tv_usec_ * 1000; + return tv; +} + +// Initializes the ACE_Time_Value object from a timestruc_t. + +ACE_INLINE +ACE_Time_Value::ACE_Time_Value (const timestruc_t &tv) +{ + // ACE_TRACE ("ACE_Time_Value::ACE_Time_Value"); + this->set (tv); +} + +ACE_INLINE void +ACE_Time_Value::set (const timeval &tv) +{ + // ACE_TRACE ("ACE_Time_Value::set"); + this->tv_sec_ = tv.tv_sec; + this->tv_usec_ = tv.tv_usec; + + this->normalize (); +} + +// Initializes the ACE_Time_Value object from another ACE_Time_Value + +ACE_INLINE +ACE_Time_Value::ACE_Time_Value (const ACE_Time_Value &tv) + : tv_sec_ (tv.tv_sec_), + tv_usec_ (tv.tv_usec_) +{ + // ACE_TRACE ("ACE_Time_Value::ACE_Time_Value"); +} + +// Returns number of seconds. + +ACE_INLINE long +ACE_Time_Value::sec (void) const +{ + // ACE_TRACE ("ACE_Time_Value::sec"); + return this->tv_sec_; +} + +// Sets the number of seconds. + +ACE_INLINE void +ACE_Time_Value::sec (long sec) +{ + // ACE_TRACE ("ACE_Time_Value::sec"); + this->tv_sec_ = sec; +} + +// Converts from Time_Value format into milli-seconds format. + +ACE_INLINE long +ACE_Time_Value::msec (void) const +{ + // ACE_TRACE ("ACE_Time_Value::msec"); + return this->tv_sec_ * 1000 + this->tv_usec_ / 1000; +} + +// Converts from milli-seconds format into Time_Value format. + +ACE_INLINE void +ACE_Time_Value::msec (long milliseconds) +{ + // ACE_TRACE ("ACE_Time_Value::msec"); + // Convert millisecond units to seconds; + this->tv_sec_ = milliseconds / 1000; + // Convert remainder to microseconds; + this->tv_usec_ = (milliseconds - (this->tv_sec_ * 1000)) * 1000; +} + +// Returns number of micro-seconds. + +ACE_INLINE long +ACE_Time_Value::usec (void) const +{ + // ACE_TRACE ("ACE_Time_Value::usec"); + return this->tv_usec_; +} + +// Sets the number of micro-seconds. + +ACE_INLINE void +ACE_Time_Value::usec (long usec) +{ + // ACE_TRACE ("ACE_Time_Value::usec"); + this->tv_usec_ = usec; +} + +// True if tv1 < tv2. + +ACE_INLINE int +operator < (const ACE_Time_Value &tv1, + const ACE_Time_Value &tv2) +{ + // ACE_TRACE ("operator <"); + return tv2 > tv1; +} + +// True if tv1 >= tv2. + +ACE_INLINE int +operator <= (const ACE_Time_Value &tv1, + const ACE_Time_Value &tv2) +{ + // ACE_TRACE ("operator <="); + return tv2 >= tv1; +} + +// True if tv1 == tv2. + +ACE_INLINE int +operator == (const ACE_Time_Value &tv1, + const ACE_Time_Value &tv2) +{ + // ACE_TRACE ("operator =="); + return tv1.tv_sec_ == tv2.tv_sec_ + && tv1.tv_usec_ == tv2.tv_usec_; +} + +// True if tv1 != tv2. + +ACE_INLINE int +operator != (const ACE_Time_Value &tv1, + const ACE_Time_Value &tv2) +{ + // ACE_TRACE ("operator !="); + return !(tv1 == tv2); +} + ACE_INLINE int ACE_OS::chdir (const char *path) { @@ -3071,7 +3231,7 @@ ACE_OS::sema_post (ACE_sema_t *s) else result = 0; - this->count_++; + s->count_++; ACE_OS::mutex_unlock (&s->lock_); } return result; @@ -3314,9 +3474,9 @@ ACE_OS::thr_getprio (ACE_hthread_t thr_id, int &prio) return prio == THREAD_PRIORITY_ERROR_RETURN ? -1 : 0; #elif defined (VXWORKS) ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::taskPriorityGet (thr_id, &prio), ace_result_), int, -1); -#endif /* ACE_HAS_STHREADS */ #else ACE_NOTSUP_RETURN (-1); +#endif /* ACE_HAS_STHREADS */ #endif /* ACE_HAS_THREADS */ } |