1cpc_getcpuver(3CPC)CPU Performance Counters Library Functionscpc_getcpuver(3CPC)
2
3
4
6 cpc_getcpuver, cpc_getcciname, cpc_getcpuref, cpc_getusage, cpc_get‐
7 npic, cpc_walk_names - determine CPU performance counter configuration
8
10 cc [ flag... ] file... −lcpc [ library... ]
11 #include <libcpc.h>
12
13 int cpc_getcpuver(void);
14
15
16 const char *cpc_getcciname(int cpuver);
17
18
19 const char *cpc_getcpuref(int cpuver);
20
21
22 const char *cpc_getusage(int cpuver);
23
24
25 uint_t cpc_getnpic(int cpuver);
26
27
28 void cpc_walk_names(int cpuver, int regno, void *arg,
29 void (*action)(void *arg, int regno, const char *name,
30 uint8_t bits));
31
32
34 The cpc_getcpuver() function returns an abstract integer that corre‐
35 sponds to the distinguished version of the underlying processor. The
36 library distinguishes between processors solely on the basis of their
37 support for performance counters, so the version returned should not be
38 interpreted in any other way. The set of values returned by the library
39 is unique across all processor implementations.
40
41
42 The cpc_getcpuver() function returns −1 if the library cannot support
43 CPU performance counters on the current architecture. This may be
44 because the processor has no such counter hardware, or because the
45 library is unable to recognize it. Either way, such a return value
46 indicates that the configuration functions described on this manual
47 page cannot be used.
48
49
50 The cpc_getcciname() function returns a printable description of the
51 processor performance counter interfaces-for example, the string Ultra‐
52 SPARC I&II. Note that this name should not be assumed to be the same as
53 the name the manufacturer might otherwise ascribe to the processor. It
54 simply names the performance counter interfaces as understood by the
55 library, and thus names the set of performance counter events that can
56 be described by that interface. If the cpuver argument is unrecognized,
57 the function returns NULL.
58
59
60 The cpc_getcpuref() function returns a string that describes a refer‐
61 ence work that should be consulted to (allow a human to) understand the
62 semantics of the performance counter events that are known to the
63 library. If the cpuver argument is unrecognized, the function returns
64 NULL. The string returned might be substantially longer than 80 charac‐
65 ters. Callers printing to a terminal might want to insert line breaks
66 as appropriate.
67
68
69 The cpc_getusage() function returns a compact description of the get‐
70 subopt()-oriented syntax that is consumed by cpc_strtoevent(3CPC). It
71 is returned as a space-separated set of tokens to allow the caller to
72 wrap lines at convenient boundaries. If the cpuver argument is unrecog‐
73 nized, the function returns NULL.
74
75
76 The cpc_getnpic() function returns the number of valid fields in the
77 ce_pic[] array of a cpc_event_t data structure.
78
79
80 The library maintains a list of events that it believes the processor
81 capable of measuring, along with the bit patterns that must be set in
82 the corresponding control register, and which counter the result will
83 appear in. The cpc_walk_names() function calls the action() function
84 on each element of the list so that an application can print appropri‐
85 ate help on the set of events known to the library. The arg parameter
86 is passed uninterpreted from the caller on each invocation of the
87 action() function.
88
89
90 If the parameters specify an invalid or unknown CPU or register number,
91 the function silently returns without invoking the action function.
92
94 Prior to calling any of these functions, applications should call
95 cpc_access(3CPC) to determine if the counters are accessible on the
96 system.
97
99 See attributes(5) for descriptions of the following attributes:
100
101
102
103
104 ┌─────────────────────────────┬─────────────────────────────┐
105 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
106 ├─────────────────────────────┼─────────────────────────────┤
107 │MT-Level │MT-Safe │
108 ├─────────────────────────────┼─────────────────────────────┤
109 │Interface Stability │Obsolete │
110 └─────────────────────────────┴─────────────────────────────┘
111
113 cpc(3CPC), cpc_access(3CPC), cpc_cciname(3CPC), cpc_cpuref(3CPC),
114 cpc_npic(3CPC), cpc_walk_events_all(3CPC)libcpc(3LIB), attributes(5)
115
117 The cpc_getcpuver(), cpc_getcciname(), cpc_getcpuref(), cpc_getusage(),
118 cpc_getnpic(), and cpc_walk_names() functions exist for binary compati‐
119 bility only. Source containing these functions will not compile. These
120 functions are obsolete and might be removed in a future release. Appli‐
121 cations should use cpc_cciname(3CPC), cpc_cpuref(3CPC), cpc_npic(3CPC),
122 and cpc_npic(3CPC) instead.
123
124
125 Only SPARC processors are described by the SPARC version of the
126 library, and only x86 processors are described by the x86 version of
127 the library.
128
129
130
131SunOS 5.11 28 Mar 2005 cpc_getcpuver(3CPC)