From 194e29d0dcfd90c7966f0258dac876d74eedcca2 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 30 Jul 2021 10:35:18 +0200 Subject: [PATCH] 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 . --- src/libnm-glib-aux/nm-macros-internal.h | 4 ---- src/libnm-std-aux/nm-std-aux.h | 9 +++++++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/libnm-glib-aux/nm-macros-internal.h b/src/libnm-glib-aux/nm-macros-internal.h index ce2a54de91..c394a6206a 100644 --- a/src/libnm-glib-aux/nm-macros-internal.h +++ b/src/libnm-glib-aux/nm-macros-internal.h @@ -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 diff --git a/src/libnm-std-aux/nm-std-aux.h b/src/libnm-std-aux/nm-std-aux.h index a7bfc37ea4..3bac75aa64 100644 --- a/src/libnm-std-aux/nm-std-aux.h +++ b/src/libnm-std-aux/nm-std-aux.h @@ -10,6 +10,7 @@ #include #include #include +#include /*****************************************************************************/ @@ -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