Go to the documentation of this file.00001
00002
00003
00004
00005 #include "ace/os_include/sys/os_time.h"
00006 #include "ace/os_include/os_errno.h"
00007
00008 #if defined (ACE_VXWORKS) || defined (ACE_HAS_CLOCK_GETTIME_REALTIME)
00009 # include "ace/OS_NS_time.h"
00010 #endif
00011
00012 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00013
00014 ACE_INLINE ACE_Time_Value
00015 ACE_OS::gettimeofday (void)
00016 {
00017
00018
00019 #if !defined (ACE_WIN32)
00020 timeval tv;
00021 int result = 0;
00022 #endif // !defined (ACE_WIN32)
00023
00024 #if defined (ACE_HAS_CLOCK_GETTIME_REALTIME)
00025 struct timespec ts;
00026
00027 ACE_OSCALL (ACE_OS::clock_gettime (CLOCK_REALTIME, &ts), int, -1, result);
00028 tv.tv_sec = ts.tv_sec;
00029 tv.tv_usec = ts.tv_nsec / 1000L;
00030
00031 #elif defined (ACE_WIN32) && defined (ACE_LACKS_GETSYSTEMTIMEASFILETIME)
00032 SYSTEMTIME tsys;
00033 FILETIME tfile;
00034 ::GetSystemTime (&tsys);
00035 ::SystemTimeToFileTime (&tsys, &tfile);
00036 return ACE_Time_Value (tfile);
00037 #elif defined (ACE_WIN32)
00038 FILETIME tfile;
00039 ::GetSystemTimeAsFileTime (&tfile);
00040 return ACE_Time_Value (tfile);
00041 #elif defined (ACE_HAS_AIX_HI_RES_TIMER)
00042 timebasestruct_t tb;
00043
00044 ::read_real_time (&tb, TIMEBASE_SZ);
00045 ::time_base_to_time (&tb, TIMEBASE_SZ);
00046
00047 tv.tv_sec = tb.tb_high;
00048 tv.tv_usec = tb.tb_low / 1000L;
00049 #else
00050 # if defined (ACE_HAS_TIMEZONE_GETTIMEOFDAY) || \
00051 defined(ACE_HAS_VOIDPTR_GETTIMEOFDAY) || \
00052 (defined (ACE_HAS_SVR4_GETTIMEOFDAY) && !defined (SCO))
00053 ACE_OSCALL (::gettimeofday (&tv, 0), int, -1, result);
00054 # elif defined (ACE_VXWORKS)
00055
00056
00057
00058 struct timespec ts;
00059
00060 ACE_OSCALL (ACE_OS::clock_gettime (CLOCK_REALTIME, &ts), int, -1, result);
00061 tv.tv_sec = ts.tv_sec;
00062 tv.tv_usec = ts.tv_nsec / 1000L;
00063 # else
00064 ACE_OSCALL (::gettimeofday (&tv), int, -1, result);
00065 # endif
00066 #endif
00067 #if !defined (ACE_WIN32)
00068 if (result == -1)
00069 return ACE_Time_Value ((time_t)-1);
00070 else
00071 return ACE_Time_Value (tv);
00072 #endif // !defined (ACE_WIN32)
00073 }
00074
00075 ACE_END_VERSIONED_NAMESPACE_DECL