1PMEXTRACTVALUE(3)          Library Functions Manual          PMEXTRACTVALUE(3)
2
3
4

NAME

6       pmExtractValue  -  extract  a  performance metric value from a pmResult
7       structure
8

C SYNOPSIS

10       #include <pcp/pmapi.h>
11
12       int pmExtractValue(int valfmt, const pmValue *ival, int itype,  pmAtom‐
13       Value *oval, int otype)
14
15       cc ... -lpcp
16

DESCRIPTION

18       The pmValue structure is embedded within the pmResult structure that is
19       used to return one or more performance metrics; see pmFetch(3).
20
21       All performance metric values may be encoded in  a  pmAtomValue  union,
22       defined as follows;
23
24            typedef union {
25                __int32_t    l;     /* 32-bit signed */
26                __uint32_t   ul;    /* 32-bit unsigned */
27                __int64_t    ll;    /* 64-bit signed */
28                __uint64_t   ull;   /* 64-bit unsigned */
29                float        f;     /* 32-bit floating point */
30                double       d;     /* 64-bit floating point */
31                char         *cp;   /* char ptr */
32                void         *vp;   /* void ptr */
33            } pmAtomValue;
34
35       The routine pmExtractValue provides a convenient mechanism for extract‐
36       ing values from the pmValue part of a  pmResult  structure,  optionally
37       converting the data type, and making the result available to the appli‐
38       cation programmer.
39
40       itype defines the data type of the input value held in  ival  according
41       to  the  storage  format  defined  by  valfmt  (see pmFetch(3)).  otype
42       defines the data type of the result to be placed in oval.
43
44       The value for itype is typically extracted  from  a  pmDesc  structure,
45       following  a  call to pmLookupDesc(3) for a particular performance met‐
46       ric.
47
48       The otype value should be one of the defined PM_TYPE_...  values,  that
49       have a 1:1 correspondence with the fields in the pmAtomValue union.
50
51       Normally  the  valfmt parameter would be plucked from the same pmResult
52       structure that provides the ival parameter,  and  if  valfmt  specifies
53       PM_VAL_INSITU,  then the following types are not allowed, as these can‐
54       not be encoded in 32-bits; __int64_t, __uint64_t, double,  char  *  and
55       void  *  (the  corresponding  itype values are PM_TYPE_64, PM_TYPE_U64,
56       PM_TYPE_DOUBLE, PM_TYPE_STRING and PM_TYPE_AGGREGATE respectively).  If
57       valfmt  specifies PM_VAL_PTR, then the value will be extracted from the
58       associated pmValueBlock structure, and the  __int32_t,  __uint32_t  and
59       float  options  (itype  being PM_TYPE_32, PM_TYPE_U32 and PM_TYPE_FLOAT
60       respectively) are not allowed,  as  PM_VAL_INSITU  is  the  appropriate
61       encoding for these.
62
63       The following table defines the various possibilities for the type con‐
64       version -- the input type (itype) is shown vertically, and  the  output
65       type  (otype)  is shown horizontally.  Y means the conversion is always
66       acceptable, N means the conversion can never be performed (the function
67       returns  PM_ERR_CONV), P means the conversion may lose accuracy (but no
68       error status is returned), T means the result may be subject  to  high-
69       order  truncation (in which case the function returns PM_ERR_TRUNC) and
70       S means the conversion may be impossible due to the sign of  the  input
71       value  (in  which  case the function returns PM_ERR_SIGN).  If an error
72       occurs, the value represented by oval will be  zero  (or  NULL).   Note
73       that   although   some   of   the   conversions   involving  the  types
74       PM_TYPE_STRING and  PM_TYPE_AGGREGATE  are  indeed  possible,  but  are
75       marked  N - the rationale is that pmExtractValue should not be attempt‐
76       ing to duplicate functionality already available in the C  library  via
77       sscanf(3S) and sprintf(3S).
78
79              | 32  |  U32  | 64  |  U64  | FLOAT | DBLE | STRING | AGGR |
80       =======|=====|=======|=====|=======|=======|======|========|======|
81       32     |  Y  |   S   |  Y  |   S   |   P   |  P   |   N    |  N   |
82       U32    |  T  |   Y   |  Y  |   Y   |   P   |  P   |   N    |  N   |
83       64     |  T  |  T,S  |  Y  |   S   |   P   |  P   |   N    |  N   |
84       U64    |  T  |   T   |  T  |   Y   |   P   |  P   |   N    |  N   |
85       FLOAT  | P,T | P,T,S | P,T | P,T,S |   Y   |  Y   |   N    |  N   |
86       DBLE   | P,T | P,T,S | P,T | P,T,S |   P   |  Y   |   N    |  N   |
87       STRING |  N  |   N   |  N  |   N   |   N   |  N   |   Y    |  N   |
88       AGGR   |  N  |   N   |  N  |   N   |   N   |  N   |   N    |  Y   |
89
90       In  the  cases  where multiple conversion errors could occur, the first
91       encountered error will be notified, and the order of  checking  is  not
92       defined.
93
94       If  the output conversion is to one of the pointer types, i.e. otype is
95       PM_TYPE_STRING or PM_TYPE_AGGREGATE, then the value  buffer  will  have
96       been  allocated  by  pmExtractValue(3)  using malloc(3C), and it is the
97       caller's responsibility  to  free  the  space  when  it  is  no  longer
98       required.
99
100       Although  this function appears rather complex, it has been constructed
101       to assist the development of performance tools  that  wish  to  convert
102       values,  whose type is only known via the type field in a pmDesc struc‐
103       ture, into a canonical type for local processing.
104

SEE ALSO

106       PMAPI(3), pmAtomStr(3),  pmConvScale(3),  pmFetch(3),  pmLookupDesc(3),
107       pmPrintValue(3), pmTypeStr(3) and pmUnitsStr(3).
108

DIAGNOSTICS

110       PM_ERR_CONV
111
112              Impossible conversion, marked by N in above table
113
114       PM_ERR_TRUNC
115
116              High-order truncation occurred
117
118       PM_ERR_SIGN
119
120              Conversion of negative value to unsigned type attempted
121
122
123
124Performance Co-Pilot                  SGI                    PMEXTRACTVALUE(3)
Impressum