Staging
v0.8.1
swh:1:snp:a902887e4be9191b7c6c4406aa06b31c1ce2c7cc
Raw File
Tip revision: c517d838eb7d07bbe9507871fab3931deccff539 authored by Linus Torvalds on 23 February 2015, 02:21:14 UTC
Linux 4.0-rc1
Tip revision: c517d83
perf_regs.c
#include <errno.h>
#include "perf_regs.h"
#include "event.h"

int perf_reg_value(u64 *valp, struct regs_dump *regs, int id)
{
	int i, idx = 0;
	u64 mask = regs->mask;

	if (regs->cache_mask & (1 << id))
		goto out;

	if (!(mask & (1 << id)))
		return -EINVAL;

	for (i = 0; i < id; i++) {
		if (mask & (1 << i))
			idx++;
	}

	regs->cache_mask |= (1 << id);
	regs->cache_regs[id] = regs->regs[idx];

out:
	*valp = regs->cache_regs[id];
	return 0;
}
back to top