MINOR: global: define tainted flag

Add a global flag named 'tainted'. Its purpose is to report various
status about experimental features used for the current process
lifetime.

By default it is initialized to 0. It can be set/retrieve by a couple of
new functions mark_tainted()/get_tainted(). Once a flag is set, it
cannot be resetted.

Currently, no tainted status is implemented, it will be the subject of
the following commits.
This commit is contained in:
Amaury Denoyelle 2021-05-05 16:18:45 +02:00
parent ea86083718
commit 484454d906
2 changed files with 21 additions and 0 deletions

View File

@ -96,6 +96,13 @@ static inline unsigned long thread_mask(unsigned long mask)
return mask ? mask : all_threads_mask;
}
/* handle 'tainted' status */
enum tainted_flags {
TAINTED_UNIMPLEMENTED, // TO REMOVE once an enum value is implemented
};
void mark_tainted(const enum tainted_flags flag);
unsigned int get_tainted();
/* simplified way to declare static build options in a file */
#define REGISTER_BUILD_OPTS(str) \
INITCALL2(STG_REGISTER, hap_register_build_opts, (str), 0)

View File

@ -259,6 +259,9 @@ static void *run_thread_poll_loop(void *data);
/* bitfield of a few warnings to emit just once (WARN_*) */
unsigned int warned = 0;
/* set if experimental features have been used for the current process */
static unsigned int tainted = 0;
/* master CLI configuration (-S flag) */
struct list mworker_cli_conf = LIST_HEAD_INIT(mworker_cli_conf);
@ -1417,6 +1420,17 @@ static int check_if_maxsock_permitted(int maxsock)
return ret == 0;
}
void mark_tainted(const enum tainted_flags flag)
{
HA_ATOMIC_OR(&tainted, flag);
}
unsigned int get_tainted()
{
int tainted_state;
HA_ATOMIC_STORE(&tainted_state, tainted);
return tainted_state;
}
/*
* This function initializes all the necessary variables. It only returns