GCC Code Coverage Report


Directory: ./
File: board/utils.h
Date: 2025-02-27 09:09:49
Exec Total Coverage
Lines: 1 1 100.0%
Functions: 1 1 100.0%
Branches: 0 0 -%

Line Branch Exec Source
1 // cppcheck-suppress-macro misra-c2012-1.2; allow __typeof__ extension
2 #define MIN(a, b) ({ \
3 __typeof__ (a) _a = (a); \
4 __typeof__ (b) _b = (b); \
5 (_a < _b) ? _a : _b; \
6 })
7
8 // cppcheck-suppress-macro misra-c2012-1.2; allow __typeof__ extension
9 #define MAX(a, b) ({ \
10 __typeof__ (a) _a = (a); \
11 __typeof__ (b) _b = (b); \
12 (_a > _b) ? _a : _b; \
13 })
14
15 // cppcheck-suppress-macro misra-c2012-1.2; allow __typeof__ extension
16 #define CLAMP(x, low, high) ({ \
17 __typeof__(x) __x = (x); \
18 __typeof__(low) __low = (low);\
19 __typeof__(high) __high = (high);\
20 (__x > __high) ? __high : ((__x < __low) ? __low : __x); \
21 })
22
23 // cppcheck-suppress-macro misra-c2012-1.2; allow __typeof__ extension
24 #define ABS(a) ({ \
25 __typeof__ (a) _a = (a); \
26 (_a > 0) ? _a : (-_a); \
27 })
28
29 #ifndef NULL
30 // this just provides a standard implementation of NULL
31 // in lieu of including libc in the panda build
32 // cppcheck-suppress [misra-c2012-21.1]
33 #define NULL ((void*)0)
34 #endif
35
36 // STM32 HAL defines this
37 #ifndef UNUSED
38 #define UNUSED(x) ((void)(x))
39 #endif
40
41 #define COMPILE_TIME_ASSERT(pred) ((void)sizeof(char[1 - (2 * (!(pred) ? 1 : 0))]))
42
43 // compute the time elapsed (in microseconds) from 2 counter samples
44 // case where ts < ts_last is ok: overflow is properly re-casted into uint32_t
45 uint32_t get_ts_elapsed(uint32_t ts, uint32_t ts_last) {
46 return ts - ts_last;
47 1976871 }
48