OS_NS_sys_time.inl

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // OS_NS_sys_time.inl,v 1.11 2006/05/30 10:30:56 jwillemsen Exp
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 /* ACE_VXWORKS */
00011 
00012 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00013 
00014 #if defined (ACE_WIN32) && defined (_WIN32_WCE)
00015 // Something is a bit brain-damaged here and I'm not sure what... this code
00016 // compiled before the OS reorg for ACE 5.4. Since then it hasn't - eVC
00017 // complains that the operators that return ACE_Time_Value are C-linkage
00018 // functions that can't return a C++ class. The only way I've found to
00019 // defeat this is to wrap the whole class in extern "C++".
00020 //    - Steve Huston, 23-Aug-2004
00021 extern "C++" {
00022 #endif
00023 
00024 ACE_INLINE ACE_Time_Value
00025 ACE_OS::gettimeofday (void)
00026 {
00027   // ACE_OS_TRACE ("ACE_OS::gettimeofday");
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;  // timespec has nsec, but timeval has usec
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   // From Todd Montgomery...
00053   struct _timeb tb;
00054   ::_ftime (&tb);
00055   tv.tv_sec = tb.time;
00056   tv.tv_usec = 1000 * tb.millitm;
00057 #endif /* 0 */
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   // Assumes that struct timespec is same size as struct timeval,
00073   // which assumes that time_t is a long: it currently (VxWorks
00074   // 5.2/5.3) is.
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;  // timespec has nsec, but timeval has usec
00080 # else
00081   ACE_OSCALL (::gettimeofday (&tv), int, -1, result);
00082 # endif /* ACE_HAS_SVR4_GETTIMEOFDAY */
00083 #endif /* 0 */
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

Generated on Thu Nov 9 09:41:58 2006 for ACE by doxygen 1.3.6