getconf: don't include xpg4 bits, gcc7 includes xpg6 bits for us
[unleashed.git] / share / man / man3cpc / cpc_enable.3cpc
blob34f549719d7eab6d4055f1eeb60e402082974d86
1 '\" te
2 .\" Copyright (c) 2005, Sun Microsystems, Inc. All Rights Reserved.
3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
4 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
5 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
6 .TH CPC_ENABLE 3CPC "Jan 31, 2005"
7 .SH NAME
8 cpc_enable, cpc_disable \- enable and disable performance counters
9 .SH SYNOPSIS
10 .LP
11 .nf
12 cc [ \fIflag\fR\&.\|.\|. ] \fIfile\fR\&.\|.\|. \fB-lcpc\fR [ \fIlibrary\fR\&.\|.\|. ]
13 #include <libcpc.h>
15 \fBint\fR \fBcpc_enable\fR(\fBcpc_t *\fR\fIcpc\fR);
16 .fi
18 .LP
19 .nf
20 \fBint\fR \fBcpc_disable\fR(\fBcpc_t *\fR\fIcpc\fR);
21 .fi
23 .SH DESCRIPTION
24 .sp
25 .LP
26 In certain applications, it can be useful to explicitly enable and disable
27 performance counters at different times so that the performance of a critical
28 algorithm can be examined. The \fBcpc_enable()\fR and \fBcpc_disable()\fR
29 functions can be used to enable and disable the performance counters without
30 otherwise disturbing the invoking LWP's performance hardware configuration.
31 .SH RETURN VALUES
32 .sp
33 .LP
34 Upon successful completion, \fBcpc_enable()\fR and \fBcpc_disable()\fR return
35 0. Otherwise, they return -1 and set \fBerrno\fR to indicate the error.
36 .SH ERRORS
37 .sp
38 .LP
39 These functions will fail if:
40 .sp
41 .ne 2
42 .na
43 \fB\fBEAGAIN\fR\fR
44 .ad
45 .RS 10n
46 The associated performance counter context has been invalidated by another
47 process.
48 .RE
50 .sp
51 .ne 2
52 .na
53 \fB\fBEINVAL\fR\fR
54 .ad
55 .RS 10n
56 No performance counter context has been created for the calling LWP.
57 .RE
59 .SH EXAMPLES
60 .LP
61 \fBExample 1 \fRUse cpc_enable and cpc_disable to minimize code needed by
62 application.
63 .sp
64 .LP
65 In the following example, the \fBcpc_enable()\fR and \fBcpc_disable()\fR
66 functions are used to minimize the amount of code that needs to be added to the
67 application. The \fBcputrack\fR(1) command can be used in conjunction with
68 these functions to provide event programming, sampling, and reporting
69 facilities.
71 .sp
72 .LP
73 If the application is instrumented in this way and then started by
74 \fBcputrack\fR with the \fBnouser\fR flag set in the event specification,
75 counting of user events will only be enabled around the critical code section
76 of interest. If the program is run normally, no harm will ensue.
78 .sp
79 .in +2
80 .nf
81 int
82 main(int argc, char *argv[])
84    cpc_t *cpc = cpc_open(CPC_VER_CURRENT);
85     /* ... application code ... */
87    if (cpc != NULL)
88            (void) cpc_enable(cpc);
90     /* ==> Code to be measured goes here <== */
92    if (cpc != NULL)
93            (void) cpc_disable(cpc);
95     /* ... other application code */
97 .fi
98 .in -2
100 .SH ATTRIBUTES
103 See \fBattributes\fR(5) for descriptions of the following attributes:
108 box;
109 c | c
110 l | l .
111 ATTRIBUTE TYPE  ATTRIBUTE VALUE
113 Interface Stability     Evolving
115 MT-Level        Safe
118 .SH SEE ALSO
121 \fBcputrack\fR(1), \fBcpc\fR(3CPC), \fBcpc_open\fR(3CPC), \fBlibcpc\fR(3LIB),
122 \fBattributes\fR(5)