| 1 | // SPDX-License-Identifier: GPL-2.0-or-latercxx . . $ `<file>/src/include/rt-utils.h`/ |
| 2 | #ifndef __RT_UTILS_H |
| 3 | #define __RT_UTILS_Hcxx . . $ `src/include/rt-utils.h:3:9`! |
| 4 | |
| 5 | #include <stdint.h> |
| 6 | |
| 7 | #define _STRcxx . . $ `src/include/rt-utils.h:7:9`!(x) #x |
| 8 | #define STRcxx . . $ `src/include/rt-utils.h:8:9`!(x) _STR(x) |
| 9 | #define MAX_PATHcxx . . $ `src/include/rt-utils.h:9:9`! 256 |
| 10 | |
| 11 | #define ARRAY_SIZEcxx . . $ `src/include/rt-utils.h:11:9`!(x) (sizeof(x) / sizeof((x)[0])) |
| 12 | |
| 13 | int check_privscxx . . $ check_privs(b126dc7c1de90089).(void); |
| 14 | char *get_tracefs_prefixcxx . . $ get_tracefs_prefix(41208ce6ca65dd58).(void); |
| 15 | int get_tracerscxx . . $ get_tracers(c293f0ab5a5bee95).(char ***); |
| 16 | int valid_tracercxx . . $ valid_tracer(1ef8e6ec083aabb9).(char *); |
| 17 | |
| 18 | int seteventcxx . . $ setevent(e99f026884c896d5).(char *event, char *val); |
| 19 | int event_enablecxx . . $ event_enable(1ef8e6ec083aabb9).(char *event); |
| 20 | int event_disablecxx . . $ event_disable(1ef8e6ec083aabb9).(char *event); |
| 21 | int event_enable_allcxx . . $ event_enable_all(b126dc7c1de90089).(void); |
| 22 | int event_disable_allcxx . . $ event_disable_all(b126dc7c1de90089).(void); |
| 23 | |
| 24 | const char *policy_to_stringcxx . . $ policy_to_string(f7ae7e56280f18ae).(int policy); |
| 25 | uint32_tcxx . . $ uint32_t# string_to_policycxx . . $ string_to_policy(c61c63047ce273de).(const char *str); |
| 26 | |
| 27 | pid_tcxx . . $ pid_t# gettidcxx . . $ gettid(b126dc7c1de90089).(void); |
| 28 | |
| 29 | int parse_time_stringcxx . . $ parse_time_string(1ef8e6ec083aabb9).(char *val); |
| 30 | int parse_mem_stringcxx . . $ parse_mem_string(bd93ee2296053586).(char *str, uint64_tcxx . . $ uint64_t# *val); |
| 31 | |
| 32 | void enable_trace_markcxx . . $ enable_trace_mark(49f6e7a06ebc5aa8).(void); |
| 33 | void tracemarkcxx . . $ tracemark(d5d9ff45db7b5d36).(char *fmt, ...) __attribute__((format(printf, 1, 2))); |
| 34 | void tracing_stopcxx . . $ tracing_stop(49f6e7a06ebc5aa8).(void); |
| 35 | void disable_trace_markcxx . . $ disable_trace_mark(49f6e7a06ebc5aa8).(void); |
| 36 | |
| 37 | #define MSEC_PER_SECcxx . . $ `src/include/rt-utils.h:37:9`! 1000 |
| 38 | #define USEC_PER_SECcxx . . $ `src/include/rt-utils.h:38:9`! 1000000 |
| 39 | #define NSEC_PER_SECcxx . . $ `src/include/rt-utils.h:39:9`! 1000000000 |
| 40 | #define USEC_TO_NSECcxx . . $ `src/include/rt-utils.h:40:9`!(u) ((u) * 1000) |
| 41 | #define USEC_TO_SECcxx . . $ `src/include/rt-utils.h:41:9`!(u) (u) / USEC_PER_SEC) |
| 42 | #define NSEC_TO_USECcxx . . $ `src/include/rt-utils.h:42:9`!(n) ((n) / 1000) |
| 43 | #define SEC_TO_NSECcxx . . $ `src/include/rt-utils.h:43:9`!(s) ((s) * NSEC_PER_SEC) |
| 44 | #define SEC_TO_USECcxx . . $ `src/include/rt-utils.h:44:9`!(s) ((s) * USEC_PER_SEC) |
| 45 | |
| 46 | static inline void tsnormcxx . . $ tsnorm(70b8fb3bc03a57b2).(struct timespeccxx . . $ timespec# *ts) |
| 47 | { |
| 48 | while (ts->tv_nseccxx . . $ timespec#tv_nsec. >= NSEC_PER_SECcxx . . $ `src/include/rt-utils.h:39:9`!) { |
| 49 | ts->tv_nseccxx . . $ timespec#tv_nsec. -= NSEC_PER_SECcxx . . $ `src/include/rt-utils.h:39:9`!; |
| 50 | ts->tv_seccxx . . $ timespec#tv_sec.++; |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | static inline int tsgreatercxx . . $ tsgreater(cb715bf0a026b675).(struct timespeccxx . . $ timespec# *a, struct timespeccxx . . $ timespec# *b) |
| 55 | { |
| 56 | return ((a->tv_seccxx . . $ timespec#tv_sec. > b->tv_seccxx . . $ timespec#tv_sec.) || |
| 57 | (a->tv_seccxx . . $ timespec#tv_sec. == b->tv_seccxx . . $ timespec#tv_sec. && a->tv_nseccxx . . $ timespec#tv_nsec. > b->tv_nseccxx . . $ timespec#tv_nsec.)); |
| 58 | } |
| 59 | |
| 60 | static inline int64_tcxx . . $ int64_t# calcdiffcxx . . $ calcdiff(a7174a6ca78cf3cd).(struct timespeccxx . . $ timespec# t1, struct timespeccxx . . $ timespec# t2) |
| 61 | { |
| 62 | int64_tcxx . . $ int64_t# diff = USEC_PER_SECcxx . . $ `src/include/rt-utils.h:38:9`! * (long long)((int) t1.tv_seccxx . . $ timespec#tv_sec. - (int) t2.tv_seccxx . . $ timespec#tv_sec.); |
| 63 | diff += ((int) t1.tv_nseccxx . . $ timespec#tv_nsec. - (int) t2.tv_nseccxx . . $ timespec#tv_nsec.) / 1000; |
| 64 | return diff; |
| 65 | } |
| 66 | |
| 67 | static inline int64_tcxx . . $ int64_t# calcdiff_nscxx . . $ calcdiff_ns(a7174a6ca78cf3cd).(struct timespeccxx . . $ timespec# t1, struct timespeccxx . . $ timespec# t2) |
| 68 | { |
| 69 | int64_tcxx . . $ int64_t# diff; |
| 70 | diff = NSEC_PER_SECcxx . . $ `src/include/rt-utils.h:39:9`! * (int64_tcxx . . $ int64_t#)((int) t1.tv_seccxx . . $ timespec#tv_sec. - (int) t2.tv_seccxx . . $ timespec#tv_sec.); |
| 71 | diff += ((int) t1.tv_nseccxx . . $ timespec#tv_nsec. - (int) t2.tv_nseccxx . . $ timespec#tv_nsec.); |
| 72 | return diff; |
| 73 | } |
| 74 | |
| 75 | static inline int64_tcxx . . $ int64_t# calctimecxx . . $ calctime(e44ff8b8ef2f070d).(struct timespeccxx . . $ timespec# t) |
| 76 | { |
| 77 | int64_tcxx . . $ int64_t# time; |
| 78 | time = USEC_PER_SECcxx . . $ `src/include/rt-utils.h:38:9`! * t.tv_seccxx . . $ timespec#tv_sec.; |
| 79 | time += ((int) t.tv_nseccxx . . $ timespec#tv_nsec.) / 1000; |
| 80 | return time; |
| 81 | } |
| 82 | |
| 83 | void rt_initcxx . . $ rt_init(c759356ac01a31e7).(int argc, char *argv[]); |
| 84 | |
| 85 | void rt_write_jsoncxx . . $ rt_write_json(969c696bbc9a09ad).(const char *filename, int return_code, |
| 86 | void (*cb)(FILEcxx . . $ FILE# *, void *), |
| 87 | void *data); |
| 88 | |
| 89 | #endif /* __RT_UTILS.H */ |