Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mesa
Path: blob/21.2-virgl/src/tool/pps/pps.h
7097 views
1
/*
2
* Copyright © 2020 Collabora, Ltd.
3
* Author: Antonio Caggiano <[email protected]>
4
*
5
* SPDX-License-Identifier: MIT
6
*/
7
8
#pragma once
9
10
#include <perfetto.h>
11
12
#define PPS_LOG PERFETTO_LOG
13
#define PPS_LOG_IMPORTANT PERFETTO_ILOG
14
#define PPS_LOG_ERROR PERFETTO_ELOG
15
#define PPS_LOG_FATAL PERFETTO_FATAL
16
17
namespace pps
18
{
19
enum class State {
20
Stop, // initial state, or stopped by the tracing service
21
Start, // running, sampling data
22
};
23
24
/// @brief Checks whether a return value is valid
25
/// @param res Result from a syscall
26
/// @param msg Message to prepend to strerror
27
/// @return True if ok, false otherwise
28
bool check(int res, const char *msg);
29
30
/// @param num Numerator
31
/// @param den Denominator
32
/// @return A ratio between two floating point numbers, or 0 if the denominator is 0
33
constexpr double ratio(double num, double den)
34
{
35
return den > 0.0 ? num / den : 0.0;
36
}
37
38
} // namespace pps
39
40