mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-07 21:50:18 +01:00
shared: add _NM_GET_PRIVATE() macro
(cherry picked from commit 2cae9ba348)
This commit is contained in:
parent
811aaead4c
commit
5bac57496c
1 changed files with 18 additions and 0 deletions
|
|
@ -372,6 +372,24 @@ _notify (obj_type *obj, _PropertyEnums prop) \
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
#define __NM_GET_PRIVATE(self, type, is_check, result_cmd) \
|
||||
({ \
|
||||
/* preserve the const-ness of self. Unfortunately, that
|
||||
* way, @self cannot be a void pointer */ \
|
||||
typeof (self) _self = (self); \
|
||||
\
|
||||
/* Get compiler error if variable is of wrong type */ \
|
||||
_nm_unused const type *_self2 = (_self); \
|
||||
\
|
||||
nm_assert (is_check (_self)); \
|
||||
( result_cmd ); \
|
||||
})
|
||||
|
||||
#define _NM_GET_PRIVATE(self, type, is_check) __NM_GET_PRIVATE(self, type, is_check, &_self->_priv)
|
||||
#define _NM_GET_PRIVATE_PTR(self, type, is_check) __NM_GET_PRIVATE(self, type, is_check, _self->_priv)
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static inline gpointer
|
||||
nm_g_object_ref (gpointer obj)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue