mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-22 14:40:21 +01:00
shared: add NM_CMP_DIRECT_PTR() macro
(cherry picked from commit 95ccfdb69a)
This commit is contained in:
parent
93b130c05a
commit
198563ad93
1 changed files with 8 additions and 0 deletions
|
|
@ -280,6 +280,14 @@ gboolean nm_utils_ipaddr_is_normalized (int addr_family,
|
|||
return (_a < _b) ? -1 : 1; \
|
||||
} G_STMT_END
|
||||
|
||||
/* In the general case, direct pointer comparison is undefined behavior in C.
|
||||
* Avoid that by casting pointers to void* and then to uintptr_t. This comparison
|
||||
* is not really meaningful, except that it provides some kind of stable sort order
|
||||
* between pointers (that can otherwise not be compared). */
|
||||
#define NM_CMP_DIRECT_PTR(a, b) \
|
||||
NM_CMP_DIRECT ((uintptr_t) ((void *) (a)), \
|
||||
(uintptr_t) ((void *) (b)))
|
||||
|
||||
#define NM_CMP_DIRECT_MEMCMP(a, b, size) \
|
||||
NM_CMP_RETURN (memcmp ((a), (b), (size)))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue