core: add macros NM_FLAGS_HAS(), NM_FLAGS_ANY() and NM_FLAGS_ALL()
Signed-off-by: Thomas Haller <thaller@redhat.com>
This commit is contained in:
@@ -38,6 +38,15 @@ int nm_spawn_process (const char *args);
|
||||
/* macro to return strlen() of a compile time string. */
|
||||
#define STRLEN(str) ( sizeof ("" str) - 1 )
|
||||
|
||||
/* check if @flags has exactly one flag (@check) set. You should call this
|
||||
* only with @check being a compile time constant and a power of two. */
|
||||
#define NM_FLAGS_HAS(flags, check) \
|
||||
( (G_STATIC_ASSERT_EXPR ( ((check) != 0) && ((check) & ((check)-1)) == 0 )), (NM_FLAGS_ANY ((flags), (check))) )
|
||||
|
||||
#define NM_FLAGS_ANY(flags, check) ( ( ((flags) & (check)) != 0 ) ? TRUE : FALSE )
|
||||
#define NM_FLAGS_ALL(flags, check) ( ( ((flags) & (check)) == (check) ) ? TRUE : FALSE )
|
||||
|
||||
|
||||
/**
|
||||
* str_if_set:
|
||||
* @str: input string that will be returned if @str is not %NULL
|
||||
|
Reference in New Issue
Block a user