diff options
| author | Michael Biebl <biebl@debian.org> | 2017-07-12 17:58:09 +0200 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2017-07-12 17:58:09 +0200 |
| commit | 1c106aa806930113c6773992fa4ddce13e295ead (patch) | |
| tree | 2242b717e4060d33794b94d9c45f81e4007e3a3f /shared/nm-utils/nm-macros-internal.h | |
| parent | eb2473a843f46fae54f981c822fcace18d8f6fdf (diff) | |
| parent | b9f0451fa35393ceedf6d9d20b78c43578ebea5d (diff) | |
Updated version 1.8.2 from 'upstream/1.8.2'
with Debian dir 0d04ce142632bf08356d8d906289b6fc2de9e7c1
Diffstat (limited to 'shared/nm-utils/nm-macros-internal.h')
| -rw-r--r-- | shared/nm-utils/nm-macros-internal.h | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/shared/nm-utils/nm-macros-internal.h b/shared/nm-utils/nm-macros-internal.h index 6ca66d29..5fe4bc50 100644 --- a/shared/nm-utils/nm-macros-internal.h +++ b/shared/nm-utils/nm-macros-internal.h @@ -609,18 +609,13 @@ nm_clear_g_cancellable (GCancellable **cancellable) /*****************************************************************************/ /* Determine whether @x is a power of two (@x being an integer type). - * For the special cases @x equals zero or one, it also returns true. - * In case @x being a signed type, for negative @x always return FALSE. */ + * Basically, this returns TRUE, if @x has exactly one bit set. + * For negative values and zero, this always returns FALSE. */ #define nm_utils_is_power_of_two(x) ({ \ typeof(x) __x = (x); \ \ - /* Check if the value is negative. In that case, return FALSE. - * The first expression is a compile time constant, depending on whether - * the type is signed. The second expression is a clumsy way for (__x >= 0), - * which otherwise causes a compiler warning for unsigned types. */ \ - ( (((typeof(__x)) -1) > ((typeof(__x)) 0)) \ - || (__x > 0 || __x == 0) ) \ - && ((__x & (__x - 1)) == 0); \ + ( (__x > ((typeof(__x)) 0)) \ + && ((__x & (__x - (((typeof(__x)) 1)))) == ((typeof(__x)) 0))); \ }) /*****************************************************************************/ |