1
1
/*
2
- * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
2
+ * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved.
3
3
* Copyright (c) 2012, 2018 SAP SE. All rights reserved.
4
4
* Copyright (c) 2022, IBM Corp.
5
5
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
30
30
#include < dlfcn.h>
31
31
32
32
// Handle to the libperfstat.
33
- static void * g_libhandle = NULL ;
33
+ static void * g_libhandle = nullptr ;
34
34
35
35
typedef int (*fun_perfstat_cpu_t ) (perfstat_id_t *name, PERFSTAT_CPU_T_LATEST* userbuff,
36
36
int sizeof_userbuff, int desired_number);
@@ -60,15 +60,15 @@ typedef void (*fun_perfstat_reset_t) ();
60
60
61
61
typedef cid_t (*fun_wpar_getcid_t ) ();
62
62
63
- static fun_perfstat_cpu_total_t g_fun_perfstat_cpu_total = NULL ;
64
- static fun_perfstat_cpu_t g_fun_perfstat_cpu = NULL ;
65
- static fun_perfstat_memory_total_t g_fun_perfstat_memory_total = NULL ;
66
- static fun_perfstat_netinterface_t g_fun_perfstat_netinterface = NULL ;
67
- static fun_perfstat_partition_total_t g_fun_perfstat_partition_total = NULL ;
68
- static fun_perfstat_process_t g_fun_perfstat_process = NULL ;
69
- static fun_perfstat_wpar_total_t g_fun_perfstat_wpar_total = NULL ;
70
- static fun_perfstat_reset_t g_fun_perfstat_reset = NULL ;
71
- static fun_wpar_getcid_t g_fun_wpar_getcid = NULL ;
63
+ static fun_perfstat_cpu_total_t g_fun_perfstat_cpu_total = nullptr ;
64
+ static fun_perfstat_cpu_t g_fun_perfstat_cpu = nullptr ;
65
+ static fun_perfstat_memory_total_t g_fun_perfstat_memory_total = nullptr ;
66
+ static fun_perfstat_netinterface_t g_fun_perfstat_netinterface = nullptr ;
67
+ static fun_perfstat_partition_total_t g_fun_perfstat_partition_total = nullptr ;
68
+ static fun_perfstat_process_t g_fun_perfstat_process = nullptr ;
69
+ static fun_perfstat_wpar_total_t g_fun_perfstat_wpar_total = nullptr ;
70
+ static fun_perfstat_reset_t g_fun_perfstat_reset = nullptr ;
71
+ static fun_wpar_getcid_t g_fun_wpar_getcid = nullptr ;
72
72
73
73
bool libperfstat::init () {
74
74
@@ -114,29 +114,29 @@ void libperfstat::cleanup() {
114
114
115
115
if (g_libhandle) {
116
116
dlclose (g_libhandle);
117
- g_libhandle = NULL ;
117
+ g_libhandle = nullptr ;
118
118
}
119
119
120
- g_fun_perfstat_cpu_total = NULL ;
121
- g_fun_perfstat_memory_total = NULL ;
122
- g_fun_perfstat_partition_total = NULL ;
123
- g_fun_perfstat_wpar_total = NULL ;
124
- g_fun_perfstat_reset = NULL ;
125
- g_fun_wpar_getcid = NULL ;
120
+ g_fun_perfstat_cpu_total = nullptr ;
121
+ g_fun_perfstat_memory_total = nullptr ;
122
+ g_fun_perfstat_partition_total = nullptr ;
123
+ g_fun_perfstat_wpar_total = nullptr ;
124
+ g_fun_perfstat_reset = nullptr ;
125
+ g_fun_wpar_getcid = nullptr ;
126
126
127
127
}
128
128
129
129
int libperfstat::perfstat_cpu_total (perfstat_id_t *name, PERFSTAT_CPU_TOTAL_T_LATEST* userbuff,
130
130
int sizeof_userbuff, int desired_number) {
131
- if (g_fun_perfstat_cpu_total == NULL ) {
131
+ if (g_fun_perfstat_cpu_total == nullptr ) {
132
132
return -1 ;
133
133
}
134
134
return g_fun_perfstat_cpu_total (name, userbuff, sizeof_userbuff, desired_number);
135
135
}
136
136
137
137
int libperfstat::perfstat_cpu (perfstat_id_t *name, PERFSTAT_CPU_T_LATEST* userbuff,
138
138
int sizeof_userbuff, int desired_number) {
139
- if (g_fun_perfstat_cpu == NULL ) {
139
+ if (g_fun_perfstat_cpu == nullptr ) {
140
140
return -1 ;
141
141
}
142
142
return g_fun_perfstat_cpu (name, userbuff, sizeof_userbuff, desired_number);
@@ -145,7 +145,7 @@ int libperfstat::perfstat_cpu(perfstat_id_t *name, PERFSTAT_CPU_T_LATEST* userbu
145
145
int libperfstat::perfstat_memory_total (perfstat_id_t *name,
146
146
perfstat_memory_total_t * userbuff,
147
147
int sizeof_userbuff, int desired_number) {
148
- if (g_fun_perfstat_memory_total == NULL ) {
148
+ if (g_fun_perfstat_memory_total == nullptr ) {
149
149
return -1 ;
150
150
}
151
151
return g_fun_perfstat_memory_total (name, userbuff, sizeof_userbuff, desired_number);
@@ -154,44 +154,44 @@ int libperfstat::perfstat_memory_total(perfstat_id_t *name,
154
154
int libperfstat::perfstat_netinterface (perfstat_id_t *name,
155
155
perfstat_netinterface_t * userbuff,
156
156
int sizeof_userbuff, int desired_number) {
157
- if (g_fun_perfstat_netinterface == NULL ) {
157
+ if (g_fun_perfstat_netinterface == nullptr ) {
158
158
return -1 ;
159
159
}
160
160
return g_fun_perfstat_netinterface (name, userbuff, sizeof_userbuff, desired_number);
161
161
}
162
162
163
163
int libperfstat::perfstat_partition_total (perfstat_id_t *name, PERFSTAT_PARTITON_TOTAL_T_LATEST* userbuff,
164
164
int sizeof_userbuff, int desired_number) {
165
- if (g_fun_perfstat_partition_total == NULL ) {
165
+ if (g_fun_perfstat_partition_total == nullptr ) {
166
166
return -1 ;
167
167
}
168
168
return g_fun_perfstat_partition_total (name, userbuff, sizeof_userbuff, desired_number);
169
169
}
170
170
171
171
int libperfstat::perfstat_process (perfstat_id_t *name, perfstat_process_t * userbuff,
172
172
int sizeof_userbuff, int desired_number) {
173
- if (g_fun_perfstat_process == NULL ) {
173
+ if (g_fun_perfstat_process == nullptr ) {
174
174
return -1 ;
175
175
}
176
176
return g_fun_perfstat_process (name, userbuff, sizeof_userbuff, desired_number);
177
177
}
178
178
179
179
int libperfstat::perfstat_wpar_total (perfstat_id_wpar_t *name, PERFSTAT_WPAR_TOTAL_T_LATEST* userbuff,
180
180
int sizeof_userbuff, int desired_number) {
181
- if (g_fun_perfstat_wpar_total == NULL ) {
181
+ if (g_fun_perfstat_wpar_total == nullptr ) {
182
182
return -1 ;
183
183
}
184
184
return g_fun_perfstat_wpar_total (name, userbuff, sizeof_userbuff, desired_number);
185
185
}
186
186
187
187
void libperfstat::perfstat_reset () {
188
- if (g_fun_perfstat_reset != NULL ) {
188
+ if (g_fun_perfstat_reset != nullptr ) {
189
189
g_fun_perfstat_reset ();
190
190
}
191
191
}
192
192
193
193
cid_t libperfstat::wpar_getcid () {
194
- if (g_fun_wpar_getcid == NULL ) {
194
+ if (g_fun_wpar_getcid == nullptr ) {
195
195
return (cid_t ) -1 ;
196
196
}
197
197
return g_fun_wpar_getcid ();
@@ -210,10 +210,10 @@ bool libperfstat::get_cpuinfo(cpuinfo_t* pci) {
210
210
PERFSTAT_CPU_TOTAL_T_LATEST psct;
211
211
memset (&psct, ' \0 ' , sizeof (psct));
212
212
213
- if (-1 == libperfstat::perfstat_cpu_total (NULL , &psct, sizeof (PERFSTAT_CPU_TOTAL_T_LATEST), 1 )) {
214
- if (-1 == libperfstat::perfstat_cpu_total (NULL , &psct, sizeof (perfstat_cpu_total_t_71), 1 )) {
215
- if (-1 == libperfstat::perfstat_cpu_total (NULL , &psct, sizeof (perfstat_cpu_total_t_61), 1 )) {
216
- if (-1 == libperfstat::perfstat_cpu_total (NULL , &psct, sizeof (perfstat_cpu_total_t_53), 1 )) {
213
+ if (-1 == libperfstat::perfstat_cpu_total (nullptr , &psct, sizeof (PERFSTAT_CPU_TOTAL_T_LATEST), 1 )) {
214
+ if (-1 == libperfstat::perfstat_cpu_total (nullptr , &psct, sizeof (perfstat_cpu_total_t_71), 1 )) {
215
+ if (-1 == libperfstat::perfstat_cpu_total (nullptr , &psct, sizeof (perfstat_cpu_total_t_61), 1 )) {
216
+ if (-1 == libperfstat::perfstat_cpu_total (nullptr , &psct, sizeof (perfstat_cpu_total_t_53), 1 )) {
217
217
trcVerbose (" perfstat_cpu_total() failed (errno=%d)" , errno);
218
218
return false ;
219
219
}
@@ -248,12 +248,12 @@ bool libperfstat::get_partitioninfo(partitioninfo_t* ppi) {
248
248
249
249
bool ame_details = true ;
250
250
251
- if (-1 == libperfstat::perfstat_partition_total (NULL , &pspt, sizeof (PERFSTAT_PARTITON_TOTAL_T_LATEST), 1 )) {
252
- if (-1 == libperfstat::perfstat_partition_total (NULL , &pspt, sizeof (perfstat_partition_total_t_71), 1 )) {
251
+ if (-1 == libperfstat::perfstat_partition_total (nullptr , &pspt, sizeof (PERFSTAT_PARTITON_TOTAL_T_LATEST), 1 )) {
252
+ if (-1 == libperfstat::perfstat_partition_total (nullptr , &pspt, sizeof (perfstat_partition_total_t_71), 1 )) {
253
253
ame_details = false ;
254
- if (-1 == libperfstat::perfstat_partition_total (NULL , &pspt, sizeof (perfstat_partition_total_t_61), 1 )) {
255
- if (-1 == libperfstat::perfstat_partition_total (NULL , &pspt, sizeof (perfstat_partition_total_t_53), 1 )) {
256
- if (-1 == libperfstat::perfstat_partition_total (NULL , &pspt, sizeof (perfstat_partition_total_t_53_5), 1 )) {
254
+ if (-1 == libperfstat::perfstat_partition_total (nullptr , &pspt, sizeof (perfstat_partition_total_t_61), 1 )) {
255
+ if (-1 == libperfstat::perfstat_partition_total (nullptr , &pspt, sizeof (perfstat_partition_total_t_53), 1 )) {
256
+ if (-1 == libperfstat::perfstat_partition_total (nullptr , &pspt, sizeof (perfstat_partition_total_t_53_5), 1 )) {
257
257
trcVerbose (" perfstat_partition_total() failed (errno=%d)" , errno);
258
258
return false ;
259
259
}
@@ -322,8 +322,8 @@ bool libperfstat::get_wparinfo(wparinfo_t* pwi) {
322
322
PERFSTAT_WPAR_TOTAL_T_LATEST pswt;
323
323
memset (&pswt, ' \0 ' , sizeof (pswt));
324
324
325
- if (-1 == libperfstat::perfstat_wpar_total (NULL , &pswt, sizeof (PERFSTAT_WPAR_TOTAL_T_LATEST), 1 )) {
326
- if (-1 == libperfstat::perfstat_wpar_total (NULL , &pswt, sizeof (perfstat_wpar_total_t_61), 1 )) {
325
+ if (-1 == libperfstat::perfstat_wpar_total (nullptr , &pswt, sizeof (PERFSTAT_WPAR_TOTAL_T_LATEST), 1 )) {
326
+ if (-1 == libperfstat::perfstat_wpar_total (nullptr , &pswt, sizeof (perfstat_wpar_total_t_61), 1 )) {
327
327
trcVerbose (" perfstat_wpar_total() failed (errno=%d)" , errno);
328
328
return false ;
329
329
}
0 commit comments