1bf215546Sopenharmony_ci/* 2bf215546Sopenharmony_ci * Copyright © 2020 Collabora, Ltd. 3bf215546Sopenharmony_ci * Author: Antonio Caggiano <antonio.caggiano@collabora.com> 4bf215546Sopenharmony_ci * 5bf215546Sopenharmony_ci * SPDX-License-Identifier: MIT 6bf215546Sopenharmony_ci */ 7bf215546Sopenharmony_ci 8bf215546Sopenharmony_ci#pragma once 9bf215546Sopenharmony_ci 10bf215546Sopenharmony_ci#include <perfetto.h> 11bf215546Sopenharmony_ci 12bf215546Sopenharmony_ci#define PPS_LOG PERFETTO_LOG 13bf215546Sopenharmony_ci#define PPS_LOG_IMPORTANT PERFETTO_ILOG 14bf215546Sopenharmony_ci#define PPS_LOG_ERROR PERFETTO_ELOG 15bf215546Sopenharmony_ci#define PPS_LOG_FATAL PERFETTO_FATAL 16bf215546Sopenharmony_ci 17bf215546Sopenharmony_cinamespace pps 18bf215546Sopenharmony_ci{ 19bf215546Sopenharmony_cienum class State { 20bf215546Sopenharmony_ci Stop, // initial state, or stopped by the tracing service 21bf215546Sopenharmony_ci Start, // running, sampling data 22bf215546Sopenharmony_ci}; 23bf215546Sopenharmony_ci 24bf215546Sopenharmony_ci/// @brief Checks whether a return value is valid 25bf215546Sopenharmony_ci/// @param res Result from a syscall 26bf215546Sopenharmony_ci/// @param msg Message to prepend to strerror 27bf215546Sopenharmony_ci/// @return True if ok, false otherwise 28bf215546Sopenharmony_cibool check(int res, const char *msg); 29bf215546Sopenharmony_ci 30bf215546Sopenharmony_ci/// @param num Numerator 31bf215546Sopenharmony_ci/// @param den Denominator 32bf215546Sopenharmony_ci/// @return A ratio between two floating point numbers, or 0 if the denominator is 0 33bf215546Sopenharmony_ciconstexpr double ratio(double num, double den) 34bf215546Sopenharmony_ci{ 35bf215546Sopenharmony_ci return den > 0.0 ? num / den : 0.0; 36bf215546Sopenharmony_ci} 37bf215546Sopenharmony_ci 38bf215546Sopenharmony_ci} // namespace pps 39