os/ossrv/ossrv_pub/boost_apis/boost/thread/xtime.hpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 // Copyright (C) 2001-2003
     2 // William E. Kempf
     3 //
     4 //  Distributed under the Boost Software License, Version 1.0. (See accompanying 
     5 //  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
     6 
     7 #ifndef BOOST_XTIME_WEK070601_HPP
     8 #define BOOST_XTIME_WEK070601_HPP
     9 
    10 #include <boost/thread/detail/config.hpp>
    11 
    12 #include <boost/cstdint.hpp>
    13 
    14 namespace boost {
    15 
    16 enum xtime_clock_types
    17 {
    18     TIME_UTC=1
    19 //    TIME_TAI,
    20 //    TIME_MONOTONIC,
    21 //    TIME_PROCESS,
    22 //    TIME_THREAD,
    23 //    TIME_LOCAL,
    24 //    TIME_SYNC,
    25 //    TIME_RESOLUTION
    26 };
    27 
    28 struct xtime
    29 {
    30 #if defined(BOOST_NO_INT64_T)
    31     typedef int_fast32_t xtime_sec_t; //INT_FAST32_MIN <= sec <= INT_FAST32_MAX
    32 #else
    33     typedef int_fast64_t xtime_sec_t; //INT_FAST64_MIN <= sec <= INT_FAST64_MAX
    34 #endif
    35 
    36     typedef int_fast32_t xtime_nsec_t; //0 <= xtime.nsec < NANOSECONDS_PER_SECOND
    37 
    38     xtime_sec_t sec;
    39     xtime_nsec_t nsec;
    40 };
    41 
    42 int BOOST_THREAD_DECL xtime_get(struct xtime* xtp, int clock_type);
    43 
    44 inline int xtime_cmp(const xtime& xt1, const xtime& xt2)
    45 {
    46     if (xt1.sec == xt2.sec)
    47         return (int)(xt1.nsec - xt2.nsec);
    48     else 
    49         return (xt1.sec > xt2.sec) ? 1 : -1;
    50 }
    51 
    52 } // namespace boost
    53 
    54 #endif //BOOST_XTIME_WEK070601_HPP