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)
00009 # include "ace/OS_NS_time.h"
00010 #endif
00011
00012 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00013
00014 #if defined (ACE_WIN32) && defined (_WIN32_WCE)
00015
00016
00017
00018
00019
00020
00021 extern "C++" {
00022 #endif
00023
00024 ACE_INLINE ACE_Time_Value
00025 ACE_OS::gettimeofday (void)
00026 {
00027
00028
00029 #if !defined (ACE_HAS_WINCE)&& !defined (ACE_WIN32)
00030 timeval tv;
00031 int result = 0;
00032 #endif // !defined (ACE_HAS_WINCE)&& !defined (ACE_WIN32)
00033
00034 #if (0)
00035 struct timespec ts;
00036
00037 ACE_OSCALL (ACE_OS::clock_gettime (CLOCK_REALTIME, &ts), int, -1, result);
00038 tv.tv_sec = ts.tv_sec;
00039 tv.tv_usec = ts.tv_nsec / 1000L;
00040
00041 #elif defined (ACE_HAS_WINCE)
00042 SYSTEMTIME tsys;
00043 FILETIME tfile;
00044 ::GetSystemTime (&tsys);
00045 ::SystemTimeToFileTime (&tsys, &tfile);
00046 return ACE_Time_Value (tfile);
00047 #elif defined (ACE_WIN32)
00048 FILETIME tfile;
00049 ::GetSystemTimeAsFileTime (&tfile);
00050 return ACE_Time_Value (tfile);
00051 #if 0
00052
00053 struct _timeb tb;
00054 ::_ftime (&tb);
00055 tv.tv_sec = tb.time;
00056 tv.tv_usec = 1000 * tb.millitm;
00057 #endif
00058 #elif defined (ACE_HAS_AIX_HI_RES_TIMER)
00059 timebasestruct_t tb;
00060
00061 ::read_real_time (&tb, TIMEBASE_SZ);
00062 ::time_base_to_time (&tb, TIMEBASE_SZ);
00063
00064 tv.tv_sec = tb.tb_high;
00065 tv.tv_usec = tb.tb_low / 1000L;
00066 #else
00067 # if defined (ACE_HAS_TIMEZONE_GETTIMEOFDAY) || \
00068 defined(ACE_HAS_VOIDPTR_GETTIMEOFDAY) || \
00069 (defined (ACE_HAS_SVR4_GETTIMEOFDAY) && !defined (m88k) && !defined (SCO))
00070 ACE_OSCALL (::gettimeofday (&tv, 0), int, -1, result);
00071 # elif defined (ACE_VXWORKS)
00072
00073
00074
00075 struct timespec ts;
00076
00077 ACE_OSCALL (ACE_OS::clock_gettime (CLOCK_REALTIME, &ts), int, -1, result);
00078 tv.tv_sec = ts.tv_sec;
00079 tv.tv_usec = ts.tv_nsec / 1000L;
00080 # else
00081 ACE_OSCALL (::gettimeofday (&tv), int, -1, result);
00082 # endif
00083 #endif
00084 #if !defined (ACE_HAS_WINCE)&& !defined (ACE_WIN32)
00085 if (result == -1)
00086 return ACE_Time_Value (-1);
00087 else
00088 return ACE_Time_Value (tv);
00089 #endif // !defined (ACE_HAS_WINCE)&& !defined (ACE_WIN32)
00090 }
00091
00092 #if defined (ACE_WIN32) && defined (_WIN32_WCE)
00093 }
00094 #endif
00095
00096 ACE_END_VERSIONED_NAMESPACE_DECL