From 16bf132c2a884b3f3c576935dbc75e26e0f0fa37 Mon Sep 17 00:00:00 2001 From: Denis Pronin Date: Wed, 1 Mar 2023 11:05:33 +0300 Subject: [PATCH] introduce container_.of.h Signed-off-by: Denis Pronin --- container_of.h | 26 ++++++++++++++++++++++++++ flist.h | 11 ++--------- options.cpp | 16 ++++++++-------- 3 files changed, 36 insertions(+), 17 deletions(-) create mode 100644 container_of.h diff --git a/container_of.h b/container_of.h new file mode 100644 index 0000000000..b5e6d2070e --- /dev/null +++ b/container_of.h @@ -0,0 +1,26 @@ +#ifndef _CONTAINER_OF_H +#define _CONTAINER_OF_H + +#ifdef __cplusplus + +#include +#include + +extern "C" { + +#define container_of(ptr, type, member) ({ \ + auto const *__mptr = static_cast<__typeof__( ((type *)0)->member ) const*>(ptr); \ + (type *)( (char *)__mptr - offsetof(type,member) );}) +} + +#else // __cplusplus + +#include +#include + +#define container_of(ptr, type, member) ({ \ + const __typeof__( ((type *)0)->member ) *__mptr = (ptr); \ + (type *)( (char *)__mptr - offsetof(type,member) );}) +#endif + +#endif // _CONTAINER_OF_H diff --git a/flist.h b/flist.h index 6c06f50155..39a9c3f1bf 100644 --- a/flist.h +++ b/flist.h @@ -4,17 +4,10 @@ #include #include -#ifdef __cplusplus +#include "container_of.h" +#ifdef __cplusplus extern "C" { - -#define container_of(ptr, type, member) ({ \ - auto const *__mptr = static_cast<__typeof__( ((type *)0)->member ) const*>(ptr); \ - (type *)( (char *)__mptr - offsetof(type,member) );}) -#else -#define container_of(ptr, type, member) ({ \ - const __typeof__( ((type *)0)->member ) *__mptr = (ptr); \ - (type *)( (char *)__mptr - offsetof(type,member) );}) #endif /* diff --git a/options.cpp b/options.cpp index fa9a3ea117..12a7c89d46 100644 --- a/options.cpp +++ b/options.cpp @@ -2473,8 +2473,8 @@ struct fio_option fio_options[FIO_MAX_OPTS] = { }, { .name = "randrepeat", - .alias = "allrandrepeat", .lname = "Random repeatable", + .alias = "allrandrepeat", .type = FIO_OPT_BOOL, .off1 = offsetof(struct thread_options, rand_repeatable), .help = "Use repeatable random IO pattern", @@ -3694,8 +3694,6 @@ struct fio_option fio_options[FIO_MAX_OPTS] = { .off1 = offsetof(struct thread_options, fdp_pli_select), .help = "Select which FDP placement ID to use next", .def = "roundrobin", - .category = FIO_OPT_C_IO, - .group = FIO_OPT_G_INVALID, .posval = { { .ival = "random", .oval = FIO_FDP_RANDOM, @@ -3706,6 +3704,8 @@ struct fio_option fio_options[FIO_MAX_OPTS] = { .help = "Round robin select Placement IDs", }, }, + .category = FIO_OPT_C_IO, + .group = FIO_OPT_G_INVALID, }, { .name = "fdp_pli", @@ -3819,10 +3819,10 @@ struct fio_option fio_options[FIO_MAX_OPTS] = { .lname = "I/O nice priority hint", .type = FIO_OPT_INT, .off1 = offsetof(struct thread_options, ioprio_hint), - .help = "Set job IO priority hint", - .minval = IOPRIO_MIN_PRIO_HINT, .maxval = IOPRIO_MAX_PRIO_HINT, + .minval = IOPRIO_MIN_PRIO_HINT, .interval = 1, + .help = "Set job IO priority hint", .category = FIO_OPT_C_GENERAL, .group = FIO_OPT_G_CRED, }, @@ -5276,15 +5276,15 @@ struct fio_option fio_options[FIO_MAX_OPTS] = { .name = "steadystate_check_interval", .lname = "Steady state check interval", .alias = "ss_interval", - .parent = "steadystate", .type = FIO_OPT_STR_VAL_TIME, .off1 = offsetof(struct thread_options, ss_check_interval), .help = "Polling interval for the steady state check (too low means steadystate will not converge)", .def = "1", - .is_seconds = 1, - .is_time = 1, + .parent = "steadystate", .category = FIO_OPT_C_GENERAL, .group = FIO_OPT_G_RUNTIME, + .is_seconds = 1, + .is_time = 1, }, { .name = NULL,