nmtst: add nmtst_initialized()
Signed-off-by: Thomas Haller <thaller@redhat.com>
This commit is contained in:
@@ -40,10 +40,18 @@ extern struct __nmtst_internal __nmtst_internal;
|
|||||||
#define NMTST_DEFINE() \
|
#define NMTST_DEFINE() \
|
||||||
struct __nmtst_internal __nmtst_internal = { 0 };
|
struct __nmtst_internal __nmtst_internal = { 0 };
|
||||||
|
|
||||||
|
|
||||||
|
inline static gboolean
|
||||||
|
nmtst_initialized (void)
|
||||||
|
{
|
||||||
|
return !!__nmtst_internal.rand0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
inline static void
|
inline static void
|
||||||
nmtst_init (int *argc, char ***argv, const char *log_level, const char *log_domains)
|
nmtst_init (int *argc, char ***argv, const char *log_level, const char *log_domains)
|
||||||
{
|
{
|
||||||
g_assert (!__nmtst_internal.rand0);
|
g_assert (!nmtst_initialized ());
|
||||||
|
|
||||||
g_assert (!((!!argc) ^ (!!argv)));
|
g_assert (!((!!argc) ^ (!!argv)));
|
||||||
if (argc) {
|
if (argc) {
|
||||||
@@ -71,13 +79,15 @@ nmtst_init (int *argc, char ***argv, const char *log_level, const char *log_doma
|
|||||||
inline static GRand *
|
inline static GRand *
|
||||||
nmtst_get_rand0 ()
|
nmtst_get_rand0 ()
|
||||||
{
|
{
|
||||||
g_assert (__nmtst_internal.rand0);
|
g_assert (nmtst_initialized ());
|
||||||
return __nmtst_internal.rand0;
|
return __nmtst_internal.rand0;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline static GRand *
|
inline static GRand *
|
||||||
nmtst_get_rand ()
|
nmtst_get_rand ()
|
||||||
{
|
{
|
||||||
|
g_assert (nmtst_initialized ());
|
||||||
|
|
||||||
if (G_UNLIKELY (!__nmtst_internal.rand)) {
|
if (G_UNLIKELY (!__nmtst_internal.rand)) {
|
||||||
guint32 seed;
|
guint32 seed;
|
||||||
const char *str;
|
const char *str;
|
||||||
|
Reference in New Issue
Block a user