PAPI
7.1.0.0
Loading...
Searching...
No Matches
pfmlib_priv.c
Go to the documentation of this file.
1
/*
2
* pfmlib_priv.c: set of internal utility functions for all architectures
3
*
4
* Copyright (c) 2006 Hewlett-Packard Development Company, L.P.
5
* Contributed by Stephane Eranian <eranian@hpl.hp.com>
6
*
7
* Permission is hereby granted, free of charge, to any person obtaining a copy
8
* of this software and associated documentation files (the "Software"), to deal
9
* in the Software without restriction, including without limitation the rights
10
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
11
* of the Software, and to permit persons to whom the Software is furnished to do so,
12
* subject to the following conditions:
13
*
14
* The above copyright notice and this permission notice shall be included in all
15
* copies or substantial portions of the Software.
16
*
17
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
18
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
19
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
21
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
22
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
*/
24
#include <sys/types.h>
25
#include <ctype.h>
26
#include <string.h>
27
#include <stdio.h>
28
#include <stdlib.h>
29
#include <stdarg.h>
30
#include <limits.h>
31
32
#include <
perfmon/pfmlib.h
>
33
34
#include "
pfmlib_priv.h
"
35
36
/*
37
* file for all libpfm verbose and debug output
38
*
39
* By default, it is set to stderr, unless the
40
* PFMLIB_DEBUG_STDOUT environment variable is set
41
*/
42
FILE *
libpfm_fp
;
43
44
/*
45
* by convention all internal utility function must be prefixed by __
46
*/
47
48
/*
49
* debug printf
50
*/
51
void
52
__pfm_vbprintf
(
const
char
*
fmt
, ...)
53
{
54
va_list
ap;
55
56
if
(
pfm_config
.
options
.
pfm_verbose
== 0)
57
return
;
58
59
va_start
(ap,
fmt
);
60
vfprintf(
libpfm_fp
,
fmt
, ap);
61
va_end
(ap);
62
}
63
64
int
65
__pfm_check_event
(
pfmlib_event_t
*e)
66
{
67
unsigned
int
n, j;
68
69
if
(e->
event
>=
pfm_current
->pme_count)
70
return
PFMLIB_ERR_INVAL
;
71
72
n =
pfm_num_masks
(e->
event
);
73
if
(n == 0 && e->
num_masks
)
74
return
PFMLIB_ERR_UMASK
;
75
76
for
(j=0; j < e->
num_masks
; j++) {
77
if
(e->
unit_masks
[j] >= n)
78
return
PFMLIB_ERR_UMASK
;
79
}
80
/*
81
* if event has umask, but non specified by user, then
82
* return:
83
* - error if no default umask is defined
84
* - success if default umask exists for event
85
*/
86
if
(n && j == 0) {
87
if
(
pfm_current
->has_umask_default
88
&&
pfm_current
->has_umask_default(e->
event
))
89
return
PFMLIB_SUCCESS
;
90
return
PFMLIB_ERR_UMASK
;
91
}
92
return
PFMLIB_SUCCESS
;
93
}
va_list
__gnuc_va_list va_list
Definition:
papi_fwrappers_.c:307
pfmlib.h
PFMLIB_ERR_UMASK
#define PFMLIB_ERR_UMASK
Definition:
pfmlib.h:306
PFMLIB_SUCCESS
#define PFMLIB_SUCCESS
Definition:
pfmlib.h:283
PFMLIB_ERR_INVAL
#define PFMLIB_ERR_INVAL
Definition:
pfmlib.h:285
pfm_config
pfm_config_t pfm_config
Definition:
pfmlib_common.c:104
__pfm_vbprintf
void __pfm_vbprintf(const char *fmt,...)
Definition:
pfmlib_priv.c:52
__pfm_check_event
int __pfm_check_event(pfmlib_event_t *e)
Definition:
pfmlib_priv.c:65
libpfm_fp
FILE * libpfm_fp
Definition:
pfmlib_priv.c:42
pfmlib_priv.h
pfm_current
#define pfm_current
Definition:
pfmlib_priv.h:78
pfm_num_masks
static unsigned int pfm_num_masks(int e)
Definition:
pfmlib_priv.h:125
fmt
const char * fmt
Definition:
pscanf.h:10
va_end
va_end(arg_list)
va_start
va_start(arg_list, fmt)
pfm_config_t::options
pfmlib_options_t options
Definition:
pfmlib_priv.h:67
pfmlib_event_t
Definition:
pfmlib.h:85
pfmlib_event_t::num_masks
unsigned int num_masks
Definition:
pfmlib.h:90
pfmlib_event_t::unit_masks
unsigned int unit_masks[PFMLIB_MAX_MASKS_PER_EVENT]
Definition:
pfmlib.h:89
pfmlib_event_t::event
unsigned int event
Definition:
pfmlib.h:86
pfmlib_options_t::pfm_verbose
unsigned int pfm_verbose
Definition:
pfmlib.h:139
src
libperfnec
lib
pfmlib_priv.c
Generated on Wed Dec 20 2023 18:12:52 for PAPI by
1.9.6