Use appropriate C++ chrono library functions to convert the event
timestamp from a struct timespec to ::std::chrono::nanoseconds to
ensure correct conversion independent of platform.
Fixes: 8078a4a2ad90 ("bindings: implement C++ bindings")
Reported-by: Florian Evers <florian-evers@gmx.de>
Signed-off-by: Kent Gibson <warthog618@gmail.com>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
else if (event.event_type == GPIOD_LINE_EVENT_FALLING_EDGE)
ret.event_type = line_event::FALLING_EDGE;
- ret.timestamp = ::std::chrono::nanoseconds(
- event.ts.tv_nsec + (event.ts.tv_sec * 1000000000));
+ ret.timestamp = ::std::chrono::duration_cast<::std::chrono::nanoseconds>(
+ ::std::chrono::seconds(event.ts.tv_sec)) +
+ ::std::chrono::nanoseconds(event.ts.tv_nsec);
ret.source = *this;