summaryrefslogtreecommitdiffstats
path: root/linux/PerfCounter.h
blob: 26352ecacdeb9fd234e2fb1db95e649d66c40b82 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/* Do not edit this file. It was automatically generated. */

#ifndef HEADER_PerfCounter
#define HEADER_PerfCounter
/*
 * This file is based on tiptop.
 * by Erven ROHOU
 * Copyright (c) 2011, 2012, 2014 Inria
 * License: GNU General Public License version 2.
 */
 


#include <config.h>
#include <sys/types.h>
#include <unistd.h>
#include <asm/unistd.h>
#include <inttypes.h>
#include <stdbool.h>
// The sys_perf_counter_open syscall and header files changed names
// between Linux 2.6.31 and 2.6.32. Do the mangling here.
#ifdef HAVE_LINUX_PERF_COUNTER_H
#include <linux/perf_counter.h>
#define STRUCT_NAME perf_counter_attr
#define SYSCALL_NUM __NR_perf_counter_open

#elif HAVE_LINUX_PERF_EVENT_H
#include <linux/perf_event.h>
#define STRUCT_NAME perf_event_attr
#define SYSCALL_NUM __NR_perf_event_open

#else
#error Sorry, performance counters not supported on this system.
#endif

typedef struct PerfCounter_ {
   struct STRUCT_NAME events;
   pid_t pid;
   int fd;
   uint64_t prevValue;
   uint64_t value;
} PerfCounter;

#define PerfCounter_delta(pc_) ((pc_)->value - (pc_)->prevValue)


extern int PerfCounter_openFds;
PerfCounter* PerfCounter_new(pid_t pid, uint32_t type, uint64_t config);

void PerfCounter_delete(PerfCounter* this);

bool PerfCounter_read(PerfCounter* this);

#endif

© 2014-2024 Faster IT GmbH | imprint | privacy policy