/*
* 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 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <strings.h>
#include <stdarg.h>
#include <signal.h>
#include <libintl.h>
#include <dirent.h>
#include <sys/cpc_impl.h>
#include "libcpc.h"
#include "libcpc_impl.h"
/*
* CPC library handle for use by CPCv1 implementation.
*/
#ifdef __sparc
#else
#endif /* __sparc */
int
__cpc_init(void)
{
(void) mutex_lock(&__cpc_lock);
"Couldn't open CPC library handle\n"));
(void) mutex_unlock(&__cpc_lock);
return (-1);
}
(void) mutex_unlock(&__cpc_lock);
return (0);
}
int
{
int ret;
(void) cpc_rele();
return (0);
}
if (__cpc_init() != 0) {
return (-1);
}
/*
* The cpuver and control fields of the cpc_event_t must be saved off
* for later. The user may call cpc_take_sample(), expecting these to
* be copied into a different cpc_event_t struct by the kernel. We have
* to fake that behavior for CPCv1 clients.
*/
#ifdef __sparc
#else
#endif /* __sparc */
return (-1);
}
/*
* Convert flags to CPC2.
*/
if (flags & CPC_BIND_EMT_OVF) {
flags &= ~CPC_BIND_EMT_OVF;
}
return (ret);
}
int
{
#ifdef __sparc
#else
#endif /* __sparc */
&CPC_TICKREG(this), 0));
}
int
{
}
int
{
}
int
cpc_rele(void)
{
}
/*
* See if the system call is working and installed.
*
* We invoke the system call with nonsense arguments - if it's
* there and working correctly, it will return EINVAL.
*
* (This avoids the user getting a SIGSYS core dump when they attempt
* to bind on older hardware)
*/
int
cpc_access(void)
{
void (*handler)(int);
int error = 0;
switch (error) {
case EAGAIN:
"sampling system-wide CPU statistics\n"));
break;
case ENOSYS:
"are inaccessible on this machine\n"));
break;
default:
break;
case 0:
return (0);
}
return (-1);
}
/*
* To look at the system-wide counters, we have to open the
* 'shared' device. Once that device is open, no further contexts
* can be installed (though one open is needed per CPU)
*/
int
cpc_shared_open(void)
{
}
void
{
(void) cpc_shared_rele(fd);
}
int
{
int ret;
char *packed_set;
int subcode;
(void) cpc_shared_rele(fd);
return (0);
} else if (flags != 0) {
return (-1);
}
if (__cpc_init() != 0) {
return (-1);
}
return (-1);
}
return (-1);
}
return (ret);
}
int
{
}
int
{
}
int
{
int ret;
if (__cpc_init() != 0) {
return (-1);
}
else if (flags != 0) {
return (-1);
}
return (-1);
}
/*
* The cpuver and control fields of the cpc_event_t must be saved off
* for later. The user may call cpc_take_sample(), expecting these to
* be copied into a different cpc_event_t struct by the kernel. We have
* to fake that behavior for CPCv1 clients.
*/
return (ret);
}
int
{
}
/*
* Given a process context and an lwpid, mark the CPU performance
* counter context as invalid.
*/
int
{
}
/*
* Given a process context and an lwpid, remove all our
* hardware context from it.
*/
int
{
}
/*PRINTFLIKE2*/
void
{
if (__cpc_uerrfn)
else {
}
}
void
{
}
/*
* cpc_version() is only for CPC1 clients.
*/
{
switch (ver) {
case CPC_VER_NONE:
case CPC_VER_CURRENT:
return (CPC_VER_CURRENT);
case CPC_VER_1:
/*
* As long as the client is using cpc_version() at all, it is
* a CPCv1 client. We still allow CPCv1 clients to compile on
* CPCv2 systems.
*/
return (CPC_VER_1);
}
return (CPC_VER_NONE);
}