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