Commit feeef1ef authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Remove be_sure_to_add_VLC_COMMOM_MEMBERS and check offset

This saves a bit of space (though the message becomes a bit more
confusing). This also ensures that VLC_COMMOM_MEMBERS is actually at the
top of the struct (in C only).
parent 702a970e
...@@ -540,9 +540,6 @@ typedef int ( * vlc_callback_t ) ( vlc_object_t *, /* variable's object */ ...@@ -540,9 +540,6 @@ typedef int ( * vlc_callback_t ) ( vlc_object_t *, /* variable's object */
volatile bool b_die; /**< set by the outside */ \ volatile bool b_die; /**< set by the outside */ \
bool b_force; /**< set by the outside (eg. module_need()) */ \ bool b_force; /**< set by the outside (eg. module_need()) */ \
\ \
/** Just a reminder so that people don't cast garbage */ \
bool be_sure_to_add_VLC_COMMON_MEMBERS_to_struct; \
\
/* Stuff related to the libvlc structure */ \ /* Stuff related to the libvlc structure */ \
libvlc_int_t *p_libvlc; /**< (root of all evil) - 1 */ \ libvlc_int_t *p_libvlc; /**< (root of all evil) - 1 */ \
\ \
...@@ -552,8 +549,15 @@ typedef int ( * vlc_callback_t ) ( vlc_object_t *, /* variable's object */ ...@@ -552,8 +549,15 @@ typedef int ( * vlc_callback_t ) ( vlc_object_t *, /* variable's object */
/* VLC_OBJECT: attempt at doing a clever cast */ /* VLC_OBJECT: attempt at doing a clever cast */
#ifdef __GNUC__ #ifdef __GNUC__
# define VLC_OBJECT( x ) \ # ifndef __cplusplus
(((vlc_object_t *)(x))+0*(((__typeof__(x))0)->be_sure_to_add_VLC_COMMON_MEMBERS_to_struct)) # define VLC_OBJECT( x ) \
__builtin_choose_expr(__builtin_offsetof(__typeof__(*x), psz_object_type), \
(void)0 /* screw you */, (vlc_object_t *)(x))
# else
# define VLC_OBJECT( x ) \
((vlc_object_t *)(x) \
+ 0 * __builtin_offsetof(__typeof__(*x), psz_object_type))
# endif
#else #else
# define VLC_OBJECT( x ) ((vlc_object_t *)(x)) # define VLC_OBJECT( x ) ((vlc_object_t *)(x))
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment