xref: /kernel/linux/linux-5.10/tools/perf/arch/nds32/util/header.c
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /kernel/linux/linux-5.10/tools/perf/arch/nds32/util/
18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0
28c2ecf20Sopenharmony_ci// Copyright (C) 2005-2017 Andes Technology Corporation
38c2ecf20Sopenharmony_ci
48c2ecf20Sopenharmony_ci#include <stdio.h>
58c2ecf20Sopenharmony_ci#include <stdlib.h>
68c2ecf20Sopenharmony_ci#include <api/fs/fs.h>
78c2ecf20Sopenharmony_ci#include "header.h"
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#define STR_LEN 1024
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_cichar *get_cpuid_str(struct perf_pmu *pmu)
128c2ecf20Sopenharmony_ci{
138c2ecf20Sopenharmony_ci	/* In nds32, we only have one cpu */
148c2ecf20Sopenharmony_ci	char *buf = NULL;
158c2ecf20Sopenharmony_ci	struct cpu_map *cpus;
168c2ecf20Sopenharmony_ci	const char *sysfs = sysfs__mountpoint();
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ci	if (!sysfs || !pmu || !pmu->cpus)
198c2ecf20Sopenharmony_ci		return NULL;
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_ci	buf = malloc(STR_LEN);
228c2ecf20Sopenharmony_ci	if (!buf)
238c2ecf20Sopenharmony_ci		return NULL;
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_ci	cpus = cpu_map__get(pmu->cpus);
268c2ecf20Sopenharmony_ci	sprintf(buf, "0x%x", cpus->nr - 1);
278c2ecf20Sopenharmony_ci	cpu_map__put(cpus);
288c2ecf20Sopenharmony_ci	return buf;
298c2ecf20Sopenharmony_ci}
30

Indexes created Thu Nov 07 10:32:03 CST 2024