mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-29 08:00:18 +01:00
std-aux: move nm_offsetof_end() to std-aux and add nm_offsetof()
In std-aux, we cannot use G_STRUCT_OFFSET(). I guess, we could use offsetof() directly. Instead, add an nm_offsetof() macro. This requires <stddef.h>.
This commit is contained in:
parent
91a36478f6
commit
194e29d0dc
2 changed files with 9 additions and 4 deletions
|
|
@ -43,10 +43,6 @@
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
#define nm_offsetofend(t, m) (G_STRUCT_OFFSET(t, m) + sizeof(((t *) NULL)->m))
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#define gs_free nm_auto_g_free
|
||||
#define gs_unref_object nm_auto_unref_object
|
||||
#define gs_unref_variant nm_auto_unref_variant
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <stddef.h>
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
|
|
@ -222,6 +223,14 @@ typedef uint64_t _nm_bitwise nm_be64_t;
|
|||
|
||||
#define NM_N_ELEMENTS(arr) (sizeof(arr) / sizeof((arr)[0]))
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#define nm_offsetof(t, m) offsetof(t, m)
|
||||
|
||||
#define nm_offsetofend(t, m) (nm_offsetof(t, m) + sizeof(((t *) NULL)->m))
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/* This does a compile time check that "type" is a suitable C type. It either
|
||||
* returns a compile time constant of 1 or it fails compilation. The point
|
||||
* is only in macros to check that a macro parameter (what we might pass to
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue