mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-26 12:20:09 +01:00
std-aux: add _NM_INT_IS_SIGNED() and _NM_INT_SAME_SIGNEDNESS() macros
This commit is contained in:
parent
5ff1468717
commit
3732f08319
2 changed files with 13 additions and 0 deletions
|
|
@ -32,6 +32,13 @@ G_STATIC_ASSERT(_nm_alignof(NMEtherAddr) <= _nm_alignof(NMIPAddr));
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
G_STATIC_ASSERT(_NM_INT_IS_SIGNED(1));
|
||||
G_STATIC_ASSERT(!_NM_INT_IS_SIGNED(1u));
|
||||
G_STATIC_ASSERT(_NM_INT_SAME_SIGNEDNESS((short) 1, 1l));
|
||||
G_STATIC_ASSERT(!_NM_INT_SAME_SIGNEDNESS((unsigned short) 1, 1l));
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
test_nm_static_assert(void)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -154,6 +154,12 @@ typedef uint64_t _nm_bitwise nm_be64_t;
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
#define _NM_INT_IS_SIGNED(arg) (!(((typeof(arg)) -1) > 0))
|
||||
|
||||
#define _NM_INT_SAME_SIGNEDNESS(arg1, arg2) (_NM_INT_IS_SIGNED(arg1) == _NM_INT_IS_SIGNED(arg2))
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#define NM_PASTE_ARGS(identifier1, identifier2) identifier1##identifier2
|
||||
#define NM_PASTE(identifier1, identifier2) NM_PASTE_ARGS(identifier1, identifier2)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue