~ubuntu-branches/ubuntu/wily/performous/wily

« back to all changes in this revision

Viewing changes to .pc/use-Boost-TIME_UTC_-constant-unconditionally.patch/game/xtime.hh

  • Committer: Package Import Robot
  • Author(s): Markus Koschany
  • Date: 2013-06-30 11:59:10 UTC
  • mfrom: (9.1.6 sid)
  • Revision ID: package-import@ubuntu.com-20130630115910-o8sfqnbkpss0my71
Tags: 0.7.0-2
* Team upload.
* debian/control:
  - Use canonical VCS-URI.
  - Remove versioned dependencies on boost libraries because they are
    trivially satisfied now.
  - Remove superfluous ${shlibs:Depends} substvar from performous-dbg
    package.
  - Bump Standards-Version to 3.9.4, no changes.
* debian/copyright: Fix lintian issue copyright-refers-to-symlink-license and
  point to GPL-2 license.
* Add use-Boost-TIME_UTC_-constant-unconditionally.patch. Use always the new
  Boost constant TIME_UTC_ and fix FTBFS with libboost1.49. (Closes: #710625)
* Drop boost_filesystem_v2.patch. Not necessary for newer boost versions.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#pragma once
 
2
 
 
3
#include <boost/version.hpp>
 
4
#include <boost/thread/xtime.hpp>
 
5
#include <cmath>
 
6
 
 
7
namespace {
 
8
        // Boost WTF time format, directly from C...
 
9
        boost::xtime& operator+=(boost::xtime& time, double seconds) {
 
10
                double nsec = 1e9 * (time.sec + seconds) + time.nsec;
 
11
                time.sec = boost::xtime::xtime_sec_t(nsec / 1e9);
 
12
                time.nsec = boost::xtime::xtime_nsec_t(std::fmod(nsec, 1e9));
 
13
                return time;
 
14
        }
 
15
        boost::xtime operator+(boost::xtime const& left, double seconds) {
 
16
                boost::xtime time = left;
 
17
                return time += seconds;
 
18
        }
 
19
        double operator-(boost::xtime const& a, boost::xtime const& b) {
 
20
                return a.sec - b.sec + 1e-9 * (a.nsec - b.nsec);
 
21
        }
 
22
        boost::xtime now() {
 
23
                boost::xtime time;
 
24
#if (BOOST_VERSION / 100 % 1000 >= 50)
 
25
                boost::xtime_get(&time, boost::TIME_UTC_);
 
26
#else
 
27
                boost::xtime_get(&time, boost::TIME_UTC);
 
28
#endif
 
29
                return time;
 
30
        }
 
31
        double seconds(boost::xtime const& time) {
 
32
                return time.sec + time.nsec * 1e-9;
 
33
        }
 
34
}