libcpc.h revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* 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]
*
* CDDL HEADER END
*/
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _LIBCPC_H
#define _LIBCPC_H
#pragma ident "%Z%%M% %I% %E% SMI"
#include <sys/cpc_impl.h>
#include <inttypes.h>
#include <libpctx.h>
#include <stdarg.h>
#include <signal.h>
#include <string.h>
#include <ucontext.h>
#include <sys/processor.h>
/*
* This library allows hardware performance counters present in
* certain processors to be used by applications to monitor their
* own statistics, the statistics of others, or the statistics of a given CPU.
*/
#ifdef __cplusplus
extern "C" {
#endif
/*
* Current library version must be passed to cpc_open().
*/
#define CPC_VER_CURRENT 2
/*
* Initializes the library for use and returns a pointer to an identifier that
* must be used as the cpc argument in subsequent libcpc calls.
*/
/*
* Query information about the underlying processor.
*/
/*
* A vprintf-like error handling routine can be passed to the
* library for use by more sophisticated callers.
* If specified as NULL, errors are written to stderr.
*/
/*
* If successful, returns an index for the new request within the set which is
* needed later to retrieve the request's data.
* Returns -1 if unsuccessful and sets errno to indicate the error.
*/
/*
* Binds the set to the current LWP.
*/
/*
* Binds the set to the specified LWP in a process controlled via libpctx.
*/
/*
* Binds the set to the specified CPU. The process must have sufficient
* privileges to bind to the CPU via processor_bind(2). An LWP can only
* bind to one CPU at a time. To measure more than one CPU simultaneously,
* one LWP must be created for each CPU.
*/
/*
* Set the starting value for the indexed counter, and restart counting for a
* set that was frozen by a counter overflow.
*/
/*
* Unbinds the set and frees up associated resources. cpc_buf_t's must be
* explicitly freed via cpc_buf_destroy().
*/
/*
* Samples a set into a cpc_buf_t. The provided set must be bound, and the
* buf must have been created with the set being sampled.
*/
/*
* Gets or sets the value of the request specified by index.
*/
/*
* Obsolete libcpc interfaces.
*/
#define CPC_VER_NONE 0
typedef struct _cpc_event cpc_event_t;
extern int cpc_access();
extern int cpc_getcpuver(void);
extern const char *cpc_getcciname(int cpuver);
extern const char *cpc_getcpuref(int cpuver);
extern const char *cpc_getusage(int cpuver);
extern int cpc_count_usr_events(int enable);
extern int cpc_count_sys_events(int enable);
extern int cpc_rele(void);
extern int cpc_shared_open(void);
extern void cpc_shared_close(int fd);
extern int cpc_shared_rele(int fd);
#endif /* __sparc || __i386 */
#ifdef __cplusplus
}
#endif
#endif /* _LIBCPC_H */