Commit 517da44e authored by Sebastian Lackner's avatar Sebastian Lackner Committed by Vitaly Lipatov

include: Check element type in CONTAINING_RECORD and similar macros.

parent 16c867ca
......@@ -228,7 +228,13 @@ static inline void list_move_head( struct list *dst, struct list *src )
/* get pointer to object containing list element */
#undef LIST_ENTRY
#define LIST_ENTRY(elem, type, field) \
((type *)((char *)(elem) - offsetof(type, field)))
#ifdef __GNUC__
# define LIST_ENTRY(elem, type, field) ({ \
const typeof(((type *)0)->field) *__ptr = (elem); \
(type *)((char *)__ptr - offsetof(type, field)); })
#else
# define LIST_ENTRY(elem, type, field) \
((type *)((char *)(elem) - offsetof(type, field)))
#endif
#endif /* __WINE_SERVER_LIST_H */
......@@ -23,8 +23,14 @@
#ifndef __WINE_WINE_RBTREE_H
#define __WINE_WINE_RBTREE_H
#define RB_ENTRY_VALUE(element, type, field) \
((type *)((char *)(element) - offsetof(type, field)))
#ifdef __GNUC__
# define RB_ENTRY_VALUE(element, type, field) ({ \
const typeof(((type *)0)->field) *__ptr = (element); \
(type *)((char *)__ptr - offsetof(type, field)); })
#else
# define RB_ENTRY_VALUE(element, type, field) \
((type *)((char *)(element) - offsetof(type, field)))
#endif
struct rb_entry
{
......
......@@ -853,8 +853,14 @@ typedef struct DECLSPEC_ALIGN(8) MEM_EXTENDED_PARAMETER {
#define RTL_FIELD_SIZE(type, field) (sizeof(((type *)0)->field))
#define RTL_SIZEOF_THROUGH_FIELD(type, field) (FIELD_OFFSET(type, field) + RTL_FIELD_SIZE(type, field))
#define CONTAINING_RECORD(address, type, field) \
((type *)((PCHAR)(address) - offsetof(type, field)))
#ifdef __GNUC__
# define CONTAINING_RECORD(address, type, field) ({ \
const typeof(((type *)0)->field) *__ptr = (address); \
(type *)((PCHAR)__ptr - offsetof(type, field)); })
#else
# define CONTAINING_RECORD(address, type, field) \
((type *)((PCHAR)(address) - offsetof(type, field)))
#endif
#define ARRAYSIZE(x) (sizeof(x) / sizeof((x)[0]))
#ifdef __WINESRC__
......
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