attribute.c 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.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*LINTLIBRARY*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <papi_impl.h>
static void
{
switch (type) {
case PAPI_STRING:
break;
case PAPI_COLLECTION:
int i;
}
break;
default: /* don't need to free anything extra */
break;
}
}
}
static void
{
int i;
}
}
static void
{
}
}
void
{
int i;
papiAttributeFree(list[i]);
}
}
static papi_attribute_t **
{
/* allows a NULL collection that is "empty" or "no value" */
if (collection != NULL) {
int i;
for (i = 0; collection[i] != NULL; i++) {
papi_attribute_t *a = collection[i];
int j;
a->values[j]);
}
}
}
return (result);
}
static papi_attribute_value_t *
const papi_attribute_value_t *v)
{
switch (type) {
case PAPI_STRING:
} else
break;
case PAPI_INTEGER:
break;
case PAPI_BOOLEAN:
break;
case PAPI_RANGE:
break;
case PAPI_RESOLUTION:
break;
case PAPI_DATETIME:
break;
case PAPI_COLLECTION:
break;
default: /* unknown type, fail to duplicate */
}
}
return (result);
}
static papi_attribute_t *
{
}
return (result);
}
static papi_status_t
const papi_attribute_value_type_t type,
const papi_attribute_value_t *value)
{
return (PAPI_BAD_ARGUMENT);
return (PAPI_TEMPORARY_ERROR);
}
return (PAPI_OK);
}
const papi_attribute_value_t *value)
{
return (PAPI_BAD_ARGUMENT);
return (PAPI_BAD_ARGUMENT); /* RANGE must have min <= max */
if (flags == 0) /* if it wasn't set, set a default behaviour */
/* look for an existing one */
return (PAPI_CONFLICT); /* EXISTS */
return (PAPI_CONFLICT); /* TYPE CONFLICT */
/* if we don't have one, create it and add it to the list */
/* if we don't have one by now, it's most likely an alloc fail */
return (PAPI_TEMPORARY_ERROR);
/*
* if we are replacing, clear any existing values, but don't free
* until after we have replaced the values, in case we are replacing
* a collection with a relocated version of the original collection.
*/
}
/* free old values if we replaced them */
return (result);
}
{
}
{
}
{
}
{
}
const papi_resolution_unit_t units)
{
}
{
}
{
}
{
return (PAPI_BAD_ARGUMENT);
return (PAPI_NOT_FOUND);
return (PAPI_OK);
}
{
int i;
return ((papi_attribute_t *)list[i]);
}
return (NULL);
}
{
return (NULL);
return (result);
}
{
return (PAPI_BAD_ARGUMENT);
return (PAPI_NOT_FOUND);
return (PAPI_NOT_POSSIBLE);
} else
return (PAPI_NOT_FOUND);
return (PAPI_GONE);
return (PAPI_OK);
}
{
return (PAPI_BAD_ARGUMENT);
PAPI_STRING, &value);
return (status);
}
{
return (PAPI_BAD_ARGUMENT);
PAPI_INTEGER, &value);
return (status);
}
{
return (PAPI_BAD_ARGUMENT);
PAPI_BOOLEAN, &value);
return (status);
}
{
return (PAPI_BAD_ARGUMENT);
PAPI_RANGE, &value);
}
return (status);
}
const char *name, int *x, int *y,
{
return (PAPI_BAD_ARGUMENT);
PAPI_RESOLUTION, &value);
}
return (status);
}
{
return (PAPI_BAD_ARGUMENT);
PAPI_DATETIME, &value);
}
return (status);
}
{
if (collection == NULL)
return (PAPI_BAD_ARGUMENT);
PAPI_COLLECTION, &value);
}
return (status);
}
/*
* *****************************************************************************
*
* Description: The given string contains one or more attributes, in the
* following form:
* "aaaa=true bbbbb=1 ccccc=abcd"
* extract the next attribute from that string; the 'next'
* parameter should be set to zero to extract the first attribute
* in the string.
*
* *****************************************************************************
*/
static char *
{
int len = 0;
{
{
start++;
}
{
{
}
}
{
}
else
{
}
else
{
}
else
{
}
if (len == 0)
{
}
if (len > 0)
{
{
}
}
}
return (result);
} /* _getNextAttr() */
/*
* *****************************************************************************
*
* Description: Parse the given attribute string value and transform it into
* the papi_attribute_value_t in the papi_attribute_t structure.
*
* *****************************************************************************
*/
static papi_status_t
{
int len = 0;
int i = 0;
char *papiString = NULL;
{
return (result);
}
{
return (result);
}
/*
* TODO - need to sort out 'resolution', 'dateandtime' & 'collection' values
*/
{
if ((len >= 2) &&
{
/* string value */
if (papiString != NULL)
{
}
else
{
}
}
else
{
/* boolean = true */
}
else
{
/* boolean = false */
}
else
{
/* is value an integer or a range? */
i = 0;
(value[i] == '-'))
{
if (value[i] == '-')
{
tmp1[i] = '\0';
}
i++;
}
{
{
}
else
{
}
}
else
{
/* is value a resolution? */
i = 0;
while (((value[i] >= '0') &&
(value[i] <= '9')) ||
(value[i] == 'x'))
{
if (value[i] == 'x')
{
tmp1[i] = '\0';
{
}
else
{
}
}
i++;
}
{
{
{
avalues[0]->
}
else
{
avalues[0]->
0;
}
}
}
{
{
}
}
}
}
}
else
{
}
{
i = 0;
{
i++;
}
}
else
{
}
return (result);
} /* _parseAttrValue() */
/*
* *****************************************************************************
*
* Description: Parse the given attribute string and transform it into the
* papi_attribute_t structure.
*
* *****************************************************************************
*/
static papi_status_t
{
char *p = NULL;
{
{
if (p != NULL)
{
*p = '\0';
p++; /* pointer to value */
}
else
{
/* boolean - no value so assume 'true' */
avalues =
sizeof (papi_attribute_value_t *) * 2);
{
}
else
{
avalues[0] =
sizeof (papi_attribute_value_t));
{
}
else
{
}
}
}
}
}
else
{
}
return (result);
} /* _parseAttributeString() */
{
int next = 0;
char *attrString = NULL;
((flags &
/* add this attribute to the list */
} else {
}
}
}
}
else
{
}
return (result);
}
{
return (PAPI_OPERATION_NOT_SUPPORTED);
}
/* for debugging, not part of the public API */
static char *
{
switch (type) {
case PAPI_STRING:
return ("string");
case PAPI_INTEGER:
return ("integer");
case PAPI_BOOLEAN:
return ("boolean");
case PAPI_RANGE:
return ("range");
case PAPI_RESOLUTION:
return ("resolution");
case PAPI_DATETIME:
return ("datetime");
case PAPI_COLLECTION:
return ("collection");
}
return ("unknown");
}
void
{
prefix = "";
/*
* fprintf(fp, "%s'%s' (%s) =\n", prefix, (name ? name : "(NULL)"),
* typeString(attribute->type));
*/
int i;
/*
* if (attribute->type != PAPI_COLLECTION)
* fprintf(fp, "%s\t", prefix);
*/
case PAPI_STRING:
!= NULL) ||
!= NULL)) {
/* quote the string */
} else {
}
break;
case PAPI_INTEGER:
break;
case PAPI_BOOLEAN:
"true" : "false"));
break;
case PAPI_RANGE:
break;
case PAPI_RESOLUTION:
break;
case PAPI_DATETIME: {
char buf[64];
"%C", tm);
}}
break;
case PAPI_COLLECTION: {
char s[64];
values[i]->collection);
}
break;
default:
}
}
}
}
}
void
{
int i;
}
}