Re: [Boost-bugs] [Boost C++ Libraries] #9379: 'boost::chrono::steady_clock' has not been declared" on boost 1.55, hp-ux 11.23 IA, gcc 4.6

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #9379: 'boost::chrono::steady_clock' has not been declared" on boost 1.55, hp-ux 11.23 IA, gcc 4.6
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2015-01-25 14:10:02


#9379: 'boost::chrono::steady_clock' has not been declared" on boost 1.55, hp-ux
11.23 IA, gcc 4.6
-------------------------------+--------------------------
  Reporter: gengyonghui@… | Owner: viboes
      Type: Bugs | Status: reopened
 Milestone: To Be Determined | Component: chrono
   Version: Boost 1.55.0 | Severity: Problem
Resolution: | Keywords: steady_clock
-------------------------------+--------------------------

Comment (by 20313412@…):

 Hi Viboes, what a quick response!

 My test environment: HP-UX B.11.23 ia64, gcc 4.7.1, boost 1.53 and boost
 1.57

 my findings:
 1. there's no header file named user_time.h on hp-ux
 2. I didn't find any flag(in time.h) which controls the availability of
 function gethrtime, just use this function directly and everything works
 fine( or please kindly tell me how to find the Flag that you want);
 3. with some modification based on your patch, the bug is verified to be
 fixed!!!!
 4. please kindly let me know if you want any operation/verification under
 HP-UX, I'd like to do that.
 --------------------config.hpp------------------------------
 #ifndef BOOST_CHRONO_CONFIG_HPP
 #define BOOST_CHRONO_CONFIG_HPP

 #include <boost/config.hpp>

 #if !defined BOOST_CHRONO_VERSION
 #define BOOST_CHRONO_VERSION 1
 #else
 #if BOOST_CHRONO_VERSION!=1 && BOOST_CHRONO_VERSION!=2
 #error "BOOST_CHRONO_VERSION must be 1 or 2"
 #endif
 #endif

 #if defined(BOOST_CHRONO_SOURCE) && !defined(BOOST_USE_WINDOWS_H)
 #define BOOST_USE_WINDOWS_H
 #endif

 #if ! defined BOOST_CHRONO_PROVIDES_DATE_IO_FOR_SYSTEM_CLOCK_TIME_POINT \
     && ! defined
 BOOST_CHRONO_DONT_PROVIDE_DATE_IO_FOR_SYSTEM_CLOCK_TIME_POINT

 # define BOOST_CHRONO_PROVIDES_DATE_IO_FOR_SYSTEM_CLOCK_TIME_POINT

 #endif

 // BOOST_CHRONO_POSIX_API, BOOST_CHRONO_MAC_API, or
 BOOST_CHRONO_WINDOWS_API
 // can be defined by the user to specify which API should be used

 #if defined(BOOST_CHRONO_WINDOWS_API)
 # warning Boost.Chrono will use the Windows API
 #elif defined(BOOST_CHRONO_MAC_API)
 # warning Boost.Chrono will use the Mac API
 #elif defined(BOOST_CHRONO_POSIX_API)
 # warning Boost.Chrono will use the POSIX API
 #endif

 # if defined( BOOST_CHRONO_WINDOWS_API ) && defined(
 BOOST_CHRONO_POSIX_API )
 # error both BOOST_CHRONO_WINDOWS_API and BOOST_CHRONO_POSIX_API are
 defined
 # elif defined( BOOST_CHRONO_WINDOWS_API ) && defined(
 BOOST_CHRONO_MAC_API )
 # error both BOOST_CHRONO_WINDOWS_API and BOOST_CHRONO_MAC_API are
 defined
 # elif defined( BOOST_CHRONO_MAC_API ) && defined( BOOST_CHRONO_POSIX_API
 )
 # error both BOOST_CHRONO_MAC_API and BOOST_CHRONO_POSIX_API are defined
 # elif !defined( BOOST_CHRONO_WINDOWS_API ) && !defined(
 BOOST_CHRONO_MAC_API ) && !defined( BOOST_CHRONO_POSIX_API )
 # if (defined(_WIN32) || defined(__WIN32__) || defined(WIN32))
 # define BOOST_CHRONO_WINDOWS_API
 # elif defined(macintosh) || defined(__APPLE__) || defined(__APPLE_CC__)
 # define BOOST_CHRONO_MAC_API
 # else
 # define BOOST_CHRONO_POSIX_API
 # endif
 # endif

 # if defined( BOOST_CHRONO_WINDOWS_API )
 # ifndef UNDER_CE
 # define BOOST_CHRONO_HAS_PROCESS_CLOCKS
 # endif
 # define BOOST_CHRONO_HAS_CLOCK_STEADY
 # define BOOST_CHRONO_HAS_THREAD_CLOCK
 # define BOOST_CHRONO_THREAD_CLOCK_IS_STEADY true
 # endif

 # if defined( BOOST_CHRONO_MAC_API )
 # define BOOST_CHRONO_HAS_PROCESS_CLOCKS
 # define BOOST_CHRONO_HAS_CLOCK_STEADY
 # define BOOST_CHRONO_THREAD_CLOCK_IS_STEADY true
 # endif

 # if defined( BOOST_CHRONO_POSIX_API )
 # define BOOST_CHRONO_HAS_PROCESS_CLOCKS
 # include <time.h> //to check for CLOCK_REALTIME and CLOCK_MONOTONIC
 and _POSIX_THREAD_CPUTIME
 # if defined(CLOCK_MONOTONIC)
 # define BOOST_CHRONO_HAS_CLOCK_STEADY
 # elif (defined(__HP_aCC) || defined(__GNUC__)) && defined(__hpux)
 # if ! defined BOOST_CHRONO_HAS_GETHRTIME
 # define BOOST_CHRONO_HAS_GETHRTIME
 # define BOOST_CHRONO_HAS_CLOCK_STEADY
 # endif
 # endif

 # if defined(_POSIX_THREAD_CPUTIME) && !defined(BOOST_DISABLE_THREADS)
 # define BOOST_CHRONO_HAS_THREAD_CLOCK
 # define BOOST_CHRONO_THREAD_CLOCK_IS_STEADY true
 # endif
 # if defined(CLOCK_THREAD_CPUTIME_ID) && !defined(BOOST_DISABLE_THREADS)
 # define BOOST_CHRONO_HAS_THREAD_CLOCK
 # define BOOST_CHRONO_THREAD_CLOCK_IS_STEADY true
 # endif
 # if defined(sun) || defined(__sun)
 # undef BOOST_CHRONO_HAS_THREAD_CLOCK
 # undef BOOST_CHRONO_THREAD_CLOCK_IS_STEADY
 # endif
 # if (defined(__HP_aCC) || defined(__GNUC__)) && defined(__hpux)
 # undef BOOST_CHRONO_HAS_THREAD_CLOCK
 # undef BOOST_CHRONO_THREAD_CLOCK_IS_STEADY
 # endif
 # if defined(__VXWORKS__)
 # undef BOOST_CHRONO_HAS_PROCESS_CLOCKS
 # endif
 # endif

 #if defined(BOOST_CHRONO_THREAD_DISABLED) &&
 defined(BOOST_CHRONO_HAS_THREAD_CLOCK)
 #undef BOOST_CHRONO_HAS_THREAD_CLOCK
 #undef BOOST_CHRONO_THREAD_CLOCK_IS_STEADY
 #endif

 //#undef BOOST_CHRONO_HAS_PROCESS_CLOCKS

 // unicode support ------------------------------//

 #if defined(BOOST_NO_CXX11_UNICODE_LITERALS) ||
 defined(BOOST_NO_CXX11_CHAR16_T) || defined(BOOST_NO_CXX11_CHAR32_T)
 //~ #define BOOST_CHRONO_HAS_UNICODE_SUPPORT
 #else
 #define BOOST_CHRONO_HAS_UNICODE_SUPPORT 1
 #endif

 #if ! defined BOOST_NOEXCEPT
 #if defined(BOOST_NO_CXX11_NOEXCEPT)
 #define BOOST_NOEXCEPT
 #else
 #define BOOST_NOEXCEPT noexcept
 #endif
 #endif

 #if defined( BOOST_NO_CXX11_NUMERIC_LIMITS )
 #define BOOST_CHRONO_LIB_CONSTEXPR
 #else
 #define BOOST_CHRONO_LIB_CONSTEXPR BOOST_CONSTEXPR
 #endif

 #if defined( BOOST_NO_CXX11_NUMERIC_LIMITS )
 # define BOOST_CHRONO_LIB_NOEXCEPT_OR_THROW throw()
 #else
 #ifdef BOOST_NO_CXX11_NOEXCEPT
 # define BOOST_CHRONO_LIB_NOEXCEPT_OR_THROW throw()
 #else
 # define BOOST_CHRONO_LIB_NOEXCEPT_OR_THROW noexcept
 #endif
 #endif


 #if defined BOOST_CHRONO_PROVIDE_HYBRID_ERROR_HANDLING \
  && defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
 #error "BOOST_CHRONO_PROVIDE_HYBRID_ERROR_HANDLING &&
 BOOST_CHRONO_PROVIDE_HYBRID_ERROR_HANDLING defined"
 #endif

 #if defined BOOST_CHRONO_PROVIDES_DEPRECATED_IO_SINCE_V2_0_0 \
  && defined BOOST_CHRONO_DONT_PROVIDES_DEPRECATED_IO_SINCE_V2_0_0
 #error "BOOST_CHRONO_PROVIDES_DEPRECATED_IO_SINCE_V2_0_0 &&
 BOOST_CHRONO_DONT_PROVIDES_DEPRECATED_IO_SINCE_V2_0_0 defined"
 #endif

 #if ! defined BOOST_CHRONO_PROVIDE_HYBRID_ERROR_HANDLING \
  && ! defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
 #define BOOST_CHRONO_PROVIDE_HYBRID_ERROR_HANDLING
 #endif

 #if (BOOST_CHRONO_VERSION == 2)
 #if ! defined BOOST_CHRONO_PROVIDES_DEPRECATED_IO_SINCE_V2_0_0 \
  && ! defined BOOST_CHRONO_DONT_PROVIDES_DEPRECATED_IO_SINCE_V2_0_0
 #define BOOST_CHRONO_DONT_PROVIDES_DEPRECATED_IO_SINCE_V2_0_0
 #endif
 #endif

 #ifdef BOOST_CHRONO_HEADER_ONLY
 #define BOOST_CHRONO_INLINE inline
 #define BOOST_CHRONO_STATIC inline
 #define BOOST_CHRONO_DECL

 #else
 #define BOOST_CHRONO_INLINE
 #define BOOST_CHRONO_STATIC static

 // enable dynamic linking on Windows
 ---------------------------------------//

 // we need to import/export our code only if the user has specifically
 // asked for it by defining either BOOST_ALL_DYN_LINK if they want all
 boost
 // libraries to be dynamically linked, or BOOST_CHRONO_DYN_LINK
 // if they want just this one to be dynamically liked:
 #if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_CHRONO_DYN_LINK)
 // export if this is our own source, otherwise import:
 #ifdef BOOST_CHRONO_SOURCE
 # define BOOST_CHRONO_DECL BOOST_SYMBOL_EXPORT
 #else
 # define BOOST_CHRONO_DECL BOOST_SYMBOL_IMPORT
 #endif // BOOST_CHRONO_SOURCE
 #endif // DYN_LINK
 //
 // if BOOST_CHRONO_DECL isn't defined yet define it now:
 #ifndef BOOST_CHRONO_DECL
 #define BOOST_CHRONO_DECL
 #endif



 // enable automatic library variant selection
 ------------------------------//

 #if !defined(BOOST_CHRONO_SOURCE) && !defined(BOOST_ALL_NO_LIB) &&
 !defined(BOOST_CHRONO_NO_LIB)
 //
 // Set the name of our library; this will get undef'ed by auto_link.hpp
 // once it's done with it:
 //
 #define BOOST_LIB_NAME boost_chrono
 //
 // If we're importing code from a dll, then tell auto_link.hpp about it:
 //
 #if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_CHRONO_DYN_LINK)
 # define BOOST_DYN_LINK
 #endif
 //
 // And include the header that does the work:
 //
 #include <boost/config/auto_link.hpp>
 #endif // auto-linking disabled
 #endif // BOOST_CHRONO_HEADER_ONLY
 #endif // BOOST_CHRONO_CONFIG_HPP


 ---------------------------------chrono.hpp----------------------------------------------


 #include <time.h> // for clock_gettime

 namespace boost
 {
 namespace chrono
 {

   system_clock::time_point system_clock::now() BOOST_NOEXCEPT
   {
     timespec ts;
     if ( ::clock_gettime( CLOCK_REALTIME, &ts ) )
     {
       BOOST_ASSERT(0 && "Boost::Chrono - Internal Error");
     }

     return time_point(duration(
       static_cast<system_clock::rep>( ts.tv_sec ) * 1000000000 +
 ts.tv_nsec));
   }

 #if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
   system_clock::time_point system_clock::now(system::error_code & ec)
   {
     timespec ts;
     if ( ::clock_gettime( CLOCK_REALTIME, &ts ) )
     {
         if (BOOST_CHRONO_IS_THROWS(ec))
         {
             boost::throw_exception(
                     system::system_error(
                             errno,
                             BOOST_CHRONO_SYSTEM_CATEGORY,
                             "chrono::system_clock" ));
         }
         else
         {
             ec.assign( errno, BOOST_CHRONO_SYSTEM_CATEGORY );
             return time_point();
         }
     }

     if (!BOOST_CHRONO_IS_THROWS(ec))
     {
         ec.clear();
     }
     return time_point(duration(
       static_cast<system_clock::rep>( ts.tv_sec ) * 1000000000 +
 ts.tv_nsec));
   }
 #endif

   std::time_t system_clock::to_time_t(const system_clock::time_point& t)
 BOOST_NOEXCEPT
   {
       return static_cast<std::time_t>( t.time_since_epoch().count() /
 1000000000 );
   }

   system_clock::time_point system_clock::from_time_t(std::time_t t)
 BOOST_NOEXCEPT
   {
       return time_point(duration(static_cast<system_clock::rep>(t) *
 1000000000));
   }

 #ifdef BOOST_CHRONO_HAS_CLOCK_STEADY

   steady_clock::time_point steady_clock::now() BOOST_NOEXCEPT
   {
 #ifdef BOOST_CHRONO_HAS_GETHRTIME
     hrtime_t hrt = gethrtime();
     BOOST_ASSERT(hrt>=0);
     return time_point(nanoseconds(hrt));
 #else
     timespec ts;
     if ( ::clock_gettime( CLOCK_MONOTONIC, &ts ) )
     {
       BOOST_ASSERT(0 && "Boost::Chrono - Internal Error");
     }

     return time_point(duration(
       static_cast<steady_clock::rep>( ts.tv_sec ) * 1000000000 +
 ts.tv_nsec));
 #endif
   }

 #if !defined BOOST_CHRONO_DONT_PROVIDE_HYBRID_ERROR_HANDLING
   steady_clock::time_point steady_clock::now(system::error_code & ec)
   {
 #ifdef BOOST_CHRONO_HAS_GETHRTIME
     hrtime_t hrt = gethrtime();
     if (hrt<0)
     {
         boost::throw_exception(
                 system::system_error(
                         EFAULT,
                         BOOST_CHRONO_SYSTEM_CATEGORY,
                         "chrono::steady_clock" ));
     }
     else
     {
         ec.assign( EFAULT, BOOST_CHRONO_SYSTEM_CATEGORY );
         return time_point();
     }
     if (!BOOST_CHRONO_IS_THROWS(ec))
     {
         ec.clear();
     }
     return time_point(nanoseconds(hrt));
 #else
     timespec ts;
     if ( ::clock_gettime( CLOCK_MONOTONIC, &ts ) )
     {
         if (BOOST_CHRONO_IS_THROWS(ec))
         {
             boost::throw_exception(
                     system::system_error(
                             errno,
                             BOOST_CHRONO_SYSTEM_CATEGORY,
                             "chrono::steady_clock" ));
         }
         else
         {
             ec.assign( errno, BOOST_CHRONO_SYSTEM_CATEGORY );
             return time_point();
         }
     }

     if (!BOOST_CHRONO_IS_THROWS(ec))
     {
         ec.clear();
     }
     return time_point(duration(
       static_cast<steady_clock::rep>( ts.tv_sec ) * 1000000000 +
 ts.tv_nsec));
 #endif
   }
 #endif
 #endif

 } // namespace chrono
 } // namespace boost

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/9379#comment:19>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:17 UTC