File: util-common.h

package info (click to toggle)
powercap 0.6.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 388 kB
  • sloc: ansic: 3,771; makefile: 6
file content (57 lines) | stat: -rw-r--r-- 1,111 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*
 * SPDX-License-Identifier: BSD-3-Clause
 *
 * Common utilities.
 *
 * @author Connor Imes
 * @date 2017-08-24
 */

#ifndef _UTIL_COMMON_H
#define _UTIL_COMMON_H

#ifdef __cplusplus
extern "C" {
#endif

#include <inttypes.h>

#ifndef MAX_ZONE_DEPTH
/* A large number */
#define MAX_ZONE_DEPTH 64
#endif // MAX_ZONE_DEPTH
#ifndef MAX_NAME_SIZE
#define MAX_NAME_SIZE 1024
#endif // MAX_NAME_SIZE

typedef struct u32_param {
  uint32_t val;
  int set;
} u32_param;

typedef struct u64_param {
  uint64_t val;
  int set;
} u64_param;

int set_u32_param(u32_param* p, const char* optarg, int* cont);

int set_u64_param(u64_param* p, const char* optarg, int* cont);

int parse_zones(const char* optarg, uint32_t* zones, uint32_t max_depth, uint32_t* depth, int* cont);

void indent(uint32_t n);

void str_or_verbose(int verbose, uint32_t in, const char* base, const char* val, int retval);

void u64_or_verbose(int verbose, uint32_t in, const char* base, uint64_t val, int retval);

int is_valid_powercap_control_type(const char* control_type);

int get_recurse(char* optarg);

#ifdef __cplusplus
}
#endif

#endif