1 // Copyright 2019 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "platform/impl/timeval_posix.h"
6 
7 #include <chrono>
8 
9 #include "util/chrono_helpers.h"
10 
11 namespace openscreen {
12 
ToTimeval(const Clock::duration & timeout)13 struct timeval ToTimeval(const Clock::duration& timeout) {
14   struct timeval tv;
15   const auto whole_seconds = to_seconds(timeout);
16   tv.tv_sec = whole_seconds.count();
17   tv.tv_usec = to_microseconds(timeout - whole_seconds).count();
18 
19   return tv;
20 }
21 
22 }  // namespace openscreen
23