~thomas-voss/location-service/ramp-up-abi-stability

« back to all changes in this revision

Viewing changes to src/location/time_since_boot.cpp

  • Committer: Thomas Voß
  • Date: 2016-06-27 11:05:34 UTC
  • mfrom: (258.1.3 simplify-namespaces)
  • Revision ID: thomas.voss@canonical.com-20160627110534-vgl06rzgh7if12uo
Merge lp:~thomas-voss/location-service/simplify-namespaces

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 * Authored by: Thomas Voß <thomas.voss@canonical.com>
17
17
 */
18
18
 
19
 
#include <com/ubuntu/location/time_since_boot.h>
20
 
#include <com/ubuntu/location/logging.h>
 
19
#include <location/time_since_boot.h>
 
20
#include <location/logging.h>
21
21
 
22
 
#if defined(COM_UBUNTU_LOCATION_SERVICE_HAVE_UBUNTU_PLATFORM_HARDWARE_API)
 
22
#if defined(LOCATION_HAVE_UBUNTU_PLATFORM_HARDWARE_API)
23
23
#include <ubuntu/hardware/alarm.h>
24
 
#endif // COM_UBUNTU_LOCATION_SERVICE_HAVE_UBUNTU_PLATFORM_HARDWARE_API
 
24
#endif // LOCATION_HAVE_UBUNTU_PLATFORM_HARDWARE_API
25
25
 
26
26
#include <fstream>
27
27
#include <sstream>
28
28
#include <stdexcept>
29
29
#include <system_error>
30
30
 
31
 
namespace location = com::ubuntu::location;
32
 
 
33
31
namespace
34
32
{
35
33
bool have_ubuntu_hardware_alarm()
36
34
{
37
 
#if defined(COM_UBUNTU_LOCATION_SERVICE_HAVE_UBUNTU_PLATFORM_HARDWARE_API)
 
35
#if defined(LOCATION_HAVE_UBUNTU_PLATFORM_HARDWARE_API)
38
36
    return true;
39
37
#else
40
38
    return false;
41
 
#endif // COM_UBUNTU_LOCATION_SERVICE_HAVE_UBUNTU_PLATFORM_HARDWARE_API
 
39
#endif // LOCATION_HAVE_UBUNTU_PLATFORM_HARDWARE_API
42
40
}
43
41
 
44
42
std::chrono::nanoseconds from_ubuntu_hardware_alarm()
45
43
{
46
 
#if defined(COM_UBUNTU_LOCATION_SERVICE_HAVE_UBUNTU_PLATFORM_HARDWARE_API)
 
44
#if defined(LOCATION_HAVE_UBUNTU_PLATFORM_HARDWARE_API)
47
45
    struct Scope
48
46
    {
49
47
        Scope() : alarm{u_hardware_alarm_create()}
70
68
    return std::chrono::seconds{ts.tv_sec} + std::chrono::nanoseconds{ts.tv_nsec};
71
69
#else
72
70
    throw std::logic_error{"not implemented"};
73
 
#endif // COM_UBUNTU_LOCATION_SERVICE_HAVE_UBUNTU_PLATFORM_HARDWARE_API
 
71
#endif // LOCATION_HAVE_UBUNTU_PLATFORM_HARDWARE_API
74
72
}
75
73
 
76
74