summaryrefslogtreecommitdiffstats
path: root/tools/perf/trace/beauty/timespec.c
blob: e1a61f092aad8b23064fb797dc9f855a7e97cac7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// SPDX-License-Identifier: LGPL-2.1
// Copyright (C) 2022, Red Hat Inc, Arnaldo Carvalho de Melo <acme@redhat.com>

#include "trace/beauty/beauty.h"
#include <inttypes.h>
#include <time.h>

static size_t syscall_arg__scnprintf_augmented_timespec(struct syscall_arg *arg, char *bf, size_t size)
{
	struct timespec *ts = (struct timespec *)arg->augmented.args;

	return scnprintf(bf, size, "{ .tv_sec: %" PRIu64 ", .tv_nsec: %" PRIu64 " }", ts->tv_sec, ts->tv_nsec);
}

size_t syscall_arg__scnprintf_timespec(char *bf, size_t size, struct syscall_arg *arg)
{
	if (arg->augmented.args)
		return syscall_arg__scnprintf_augmented_timespec(arg, bf, size);

	return scnprintf(bf, size, "%#lx", arg->val);
}