1*6fa2df46SAndroid Build Coastguard Worker // Copyright (C) 2021 The Android Open Source Project 2*6fa2df46SAndroid Build Coastguard Worker // 3*6fa2df46SAndroid Build Coastguard Worker // Licensed under the Apache License, Version 2.0 (the "License"); 4*6fa2df46SAndroid Build Coastguard Worker // you may not use this file except in compliance with the License. 5*6fa2df46SAndroid Build Coastguard Worker // You may obtain a copy of the License at 6*6fa2df46SAndroid Build Coastguard Worker // 7*6fa2df46SAndroid Build Coastguard Worker // http://www.apache.org/licenses/LICENSE-2.0 8*6fa2df46SAndroid Build Coastguard Worker // 9*6fa2df46SAndroid Build Coastguard Worker // Unless required by applicable law or agreed to in writing, software 10*6fa2df46SAndroid Build Coastguard Worker // distributed under the License is distributed on an "AS IS" BASIS, 11*6fa2df46SAndroid Build Coastguard Worker // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12*6fa2df46SAndroid Build Coastguard Worker // See the License for the specific language governing permissions and 13*6fa2df46SAndroid Build Coastguard Worker // limitations under the License. 14*6fa2df46SAndroid Build Coastguard Worker 15*6fa2df46SAndroid Build Coastguard Worker #pragma once 16*6fa2df46SAndroid Build Coastguard Worker 17*6fa2df46SAndroid Build Coastguard Worker #include <cstdint> 18*6fa2df46SAndroid Build Coastguard Worker #include <ctime> 19*6fa2df46SAndroid Build Coastguard Worker 20*6fa2df46SAndroid Build Coastguard Worker #include <iomanip> 21*6fa2df46SAndroid Build Coastguard Worker 22*6fa2df46SAndroid Build Coastguard Worker int64_t TimespecToNanos(const timespec& t); 23*6fa2df46SAndroid Build Coastguard Worker double TimespecToDoubleNanos(const timespec& t); 24*6fa2df46SAndroid Build Coastguard Worker std::vector<int64_t> TimespecToNanos(const std::vector<timespec>& tv); 25*6fa2df46SAndroid Build Coastguard Worker std::vector<double> TimespecToDoubleNanos(const std::vector<timespec>& tv); 26*6fa2df46SAndroid Build Coastguard Worker timespec NanosToTimespec(int64_t time_ns); 27*6fa2df46SAndroid Build Coastguard Worker timespec MicrosToTimespec(int64_t time_us); 28*6fa2df46SAndroid Build Coastguard Worker std::string TimespecToString(const timespec& ts); 29*6fa2df46SAndroid Build Coastguard Worker 30*6fa2df46SAndroid Build Coastguard Worker bool operator==(const timespec& t1, const timespec& t2); 31*6fa2df46SAndroid Build Coastguard Worker bool operator!=(const timespec& t1, const timespec& t2); 32*6fa2df46SAndroid Build Coastguard Worker bool operator<(const timespec& t1, const timespec& t2); 33*6fa2df46SAndroid Build Coastguard Worker bool operator<=(const timespec& t1, const timespec& t2); 34*6fa2df46SAndroid Build Coastguard Worker bool operator>(const timespec& t1, const timespec& t2); 35*6fa2df46SAndroid Build Coastguard Worker bool operator>=(const timespec& t1, const timespec& t2); 36*6fa2df46SAndroid Build Coastguard Worker timespec operator-(const timespec& t1, const timespec& t2); 37*6fa2df46SAndroid Build Coastguard Worker timespec operator+(const timespec& t1, const timespec& t2); 38*6fa2df46SAndroid Build Coastguard Worker timespec operator/(const timespec& t1, uint64_t n); 39*6fa2df46SAndroid Build Coastguard Worker timespec operator/(const timespec& t1, const timespec& t2); 40