xref: /openbmc/linux/tools/perf/trace/beauty/timespec.c (revision 5efb685b)
1 // SPDX-License-Identifier: LGPL-2.1
2 // Copyright (C) 2022, Red Hat Inc, Arnaldo Carvalho de Melo <acme@redhat.com>
3 
4 #include "trace/beauty/beauty.h"
5 #include <inttypes.h>
6 #include <time.h>
7 
8 static size_t syscall_arg__scnprintf_augmented_timespec(struct syscall_arg *arg, char *bf, size_t size)
9 {
10 	struct timespec *ts = (struct timespec *)arg->augmented.args;
11 
12 	return scnprintf(bf, size, "{ .tv_sec: %" PRIu64 ", .tv_nsec: %" PRIu64 " }", ts->tv_sec, ts->tv_nsec);
13 }
14 
15 size_t syscall_arg__scnprintf_timespec(char *bf, size_t size, struct syscall_arg *arg)
16 {
17 	if (arg->augmented.args)
18 		return syscall_arg__scnprintf_augmented_timespec(arg, bf, size);
19 
20 	return scnprintf(bf, size, "%#lx", arg->val);
21 }
22