Also use Objects as part of an operation but as a result don't generate Any operation...
[ACE_TAO.git] / ACE / ace / OS_NS_sys_time.inl
blob488e6a1f205e8d239544f2c270cdc318ecba54ff
1 // -*- C++ -*-
2 #include "ace/os_include/sys/os_time.h"
3 #include "ace/os_include/os_errno.h"
5 #if defined (ACE_VXWORKS) || defined (ACE_HAS_CLOCK_GETTIME_REALTIME) || defined (ACE_LACKS_GETTIMEOFDAY)
6 #  include "ace/OS_NS_time.h"
7 #endif /* ACE_VXWORKS || ACE_HAS_CLOCK_REALTIME */
9 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
11 ACE_INLINE ACE_Time_Value
12 ACE_OS::gettimeofday (void)
14   // ACE_OS_TRACE ("ACE_OS::gettimeofday");
16 #if !defined (ACE_WIN32) && !defined (ACE_LACKS_GETTIMEOFDAY)
17   timeval tv;
18   int result = 0;
19 #endif // !defined (ACE_WIN32)
21 #if defined (ACE_LACKS_GETTIMEOFDAY) && defined (ACE_HAS_CLOCK_GETTIME)
22   timespec ts;
23   if (ACE_OS::clock_gettime (CLOCK_REALTIME, &ts) == -1)
24     {
25       return ACE_Time_Value (-1);
26     }
28   return ACE_Time_Value (ts);
30 #elif defined (ACE_WIN32) && defined (ACE_LACKS_GETSYSTEMTIMEASFILETIME)
31   SYSTEMTIME tsys;
32   FILETIME   tfile;
33   ::GetSystemTime (&tsys);
34   ::SystemTimeToFileTime (&tsys, &tfile);
35   return ACE_Time_Value (tfile);
36 #elif defined (ACE_WIN32)
37   FILETIME   tfile;
38   ::GetSystemTimeAsFileTime (&tfile);
39   return ACE_Time_Value (tfile);
40 #elif defined (ACE_HAS_AIX_HI_RES_TIMER)
41   timebasestruct_t tb;
43   ::read_real_time (&tb, TIMEBASE_SZ);
44   ::time_base_to_time (&tb, TIMEBASE_SZ);
46   tv.tv_sec = tb.tb_high;
47   tv.tv_usec = tb.tb_low / 1000L;
48 #else
49 # if defined (ACE_HAS_TIMEZONE_GETTIMEOFDAY) || \
50   defined(ACE_HAS_VOIDPTR_GETTIMEOFDAY) || \
51   (defined (ACE_HAS_SVR4_GETTIMEOFDAY) && !defined (SCO))
52   ACE_OSCALL (::gettimeofday (&tv, 0), int, -1, result);
53 # elif defined (ACE_VXWORKS)
54   // Assumes that struct timespec is same size as struct timeval,
55   // which assumes that time_t is a long: it currently (VxWorks
56   // 5.2/5.3) is.
57   struct timespec ts;
59   ACE_OSCALL (ACE_OS::clock_gettime (CLOCK_REALTIME, &ts), int, -1, result);
60   tv.tv_sec = ts.tv_sec;
61   tv.tv_usec = ts.tv_nsec / 1000L;  // timespec has nsec, but timeval has usec
62 # elif defined (ACE_MQX)
63   TIME_STRUCT ts;
64   _time_get(&ts);
65   tv.tv_sec = ts.SECONDS;
66   tv.tv_usec = ts.MILLISECONDS * 1000;
67 # else
68 #  if defined (ACE_LACKS_GETTIMEOFDAY)
69   ACE_NOTSUP_RETURN (ACE_Time_Value ((time_t)-1));
70 #  else
71   ACE_OSCALL (::gettimeofday (&tv), int, -1, result);
72 #  endif /* ACE_LACKS_GETTIMEOFDAY */
73 # endif /* ACE_HAS_SVR4_GETTIMEOFDAY */
74 #endif /* 0 */
75 #if !defined (ACE_WIN32) && !defined (ACE_LACKS_GETTIMEOFDAY)
76   if (result == -1)
77     return ACE_Time_Value ((time_t)-1);
78   else
79     return ACE_Time_Value (tv);
80 #endif // !defined (ACE_WIN32)
83 ACE_INLINE ACE_Time_Value
84 ACE_OS::gettimeofday_ (void)
86   return ACE_OS::gettimeofday ();
89 ACE_END_VERSIONED_NAMESPACE_DECL