File: core-parse-opts.h

package info (click to toggle)
stress-ng 0.19.02-1
  • links: PTS
  • area: main
  • in suites: trixie
  • size: 17,068 kB
  • sloc: ansic: 192,232; makefile: 818; sh: 808; cpp: 254
file content (80 lines) | stat: -rw-r--r-- 3,544 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*
 * Copyright (C) 2024-2025 Colin Ian King.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 */
#ifndef CORE_PARSE_OPTS_H
#define CORE_PARSE_OPTS_H

#include "core-attribute.h"
#include "core-setting.h"

typedef struct {
	const int opt;			/* optarg option */
	const char *opt_name;		/* optarg name */
	stress_type_id_t type_id;	/* option setting type */
	uint64_t min;			/* option min */
	uint64_t max;			/* option max */
	void *data;			/* option specific data */
} stress_opt_t;

#define END_OPT { 0, NULL, TYPE_ID_UNDEFINED, (uint64_t)0, (uint64_t)0, NULL }

/* Scale lookup mapping, suffix -> scale by */
typedef struct {
	const char	ch;		/* Scaling suffix */
	const uint64_t	scale;		/* Amount to scale by */
} stress_scale_t;

extern void stress_check_max_stressors(const char *const msg, const int val);
extern void stress_check_signed_range(const char *const opt, const int64_t val,
	const int64_t lo, const int64_t hi);
extern void stress_check_range(const char *const opt, const uint64_t val,
	const uint64_t lo, const uint64_t hi);
extern void stress_check_range_bytes(const char *const opt, const uint64_t val,
	const uint64_t lo, const uint64_t hi);

extern WARN_UNUSED int stress_get_int(const char *const str);
extern WARN_UNUSED int8_t stress_get_int8(const char *const str);
extern WARN_UNUSED int16_t stress_get_int16(const char *const str);
extern WARN_UNUSED int32_t stress_get_int32(const char *const str);
extern WARN_UNUSED int64_t stress_get_int64(const char *const str);

extern WARN_UNUSED unsigned int stress_get_uint(const char *const str);
extern WARN_UNUSED uint8_t stress_get_uint8(const char *const str);
extern WARN_UNUSED uint16_t stress_get_uint16(const char *const str);
extern WARN_UNUSED uint32_t stress_get_uint32(const char *const str);
extern WARN_UNUSED uint64_t stress_get_uint64(const char *const str);

extern WARN_UNUSED uint64_t stress_get_uint64_scale(const char *const str,
	const stress_scale_t scales[], const char *const msg);

extern WARN_UNUSED int32_t stress_get_int32_instance_percent(const char *const str);

extern WARN_UNUSED uint64_t stress_get_uint64_byte_scale(const char *const str);

extern WARN_UNUSED uint64_t stress_get_uint64_byte(const char *const str);
extern WARN_UNUSED uint64_t stress_get_uint64_percent(const char *const str,
	const uint32_t instances, const uint64_t max, const char *const errmsg);
extern WARN_UNUSED uint64_t stress_get_uint64_byte_memory(const char *const str,
	const uint32_t instances);
extern WARN_UNUSED uint64_t stress_get_uint64_byte_filesystem(const char *const str,
	const uint32_t instances);
extern WARN_UNUSED uint64_t stress_get_uint64_time(const char *const str);
extern WARN_UNUSED int stress_parse_opt(const char *stressor_name, const char *optarg, const stress_opt_t *opt);
extern WARN_UNUSED const char *stress_unimplemented_method(const size_t i);

#endif