aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/include
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2012-09-06 08:49:13 +0200
committermarha <marha@users.sourceforge.net>2012-09-06 08:49:13 +0200
commitccc8a492607df715b08d27c6bb3b9d13b1ff48a2 (patch)
tree4311d252acd49786ceed60cb55343af0a9294a2f /xorg-server/include
parenta4d007b9b60f2fc7c8de46533e2f47ecb24f3c9c (diff)
parentaa10a08696cae93799fcddae3f0245ceee905e01 (diff)
downloadvcxsrv-ccc8a492607df715b08d27c6bb3b9d13b1ff48a2.tar.gz
vcxsrv-ccc8a492607df715b08d27c6bb3b9d13b1ff48a2.tar.bz2
vcxsrv-ccc8a492607df715b08d27c6bb3b9d13b1ff48a2.zip
Merge remote-tracking branch 'origin/released'
Diffstat (limited to 'xorg-server/include')
-rw-r--r--xorg-server/include/dix-config.h.in3
-rw-r--r--xorg-server/include/list.h21
2 files changed, 20 insertions, 4 deletions
diff --git a/xorg-server/include/dix-config.h.in b/xorg-server/include/dix-config.h.in
index 77681a953..578f249b3 100644
--- a/xorg-server/include/dix-config.h.in
+++ b/xorg-server/include/dix-config.h.in
@@ -423,6 +423,9 @@
/* Define to 64-bit byteswap macro */
#undef bswap_64
+/* Define to 1 if typeof works with your compiler. */
+#undef HAVE_TYPEOF
+
/* The compiler supported TLS storage class, prefering initial-exec if tls_model is supported */
#undef TLS
diff --git a/xorg-server/include/list.h b/xorg-server/include/list.h
index d04f65745..61b10bd2a 100644
--- a/xorg-server/include/list.h
+++ b/xorg-server/include/list.h
@@ -26,6 +26,8 @@
#ifndef _XORG_LIST_H_
#define _XORG_LIST_H_
+#include <stddef.h> /* offsetof() */
+
/**
* @file Classic doubly-link circular list implementation.
* For real usage examples of the linked list, see the file test/list.c
@@ -232,7 +234,7 @@ xorg_list_is_empty(struct xorg_list *head)
*/
#ifndef container_of
#define container_of(ptr, type, member) \
- (type *)((char *)(ptr) - (char *) &((type *)0)->member)
+ (type *)((char *)(ptr) - offsetof(type, member))
#endif
/**
@@ -271,9 +273,20 @@ xorg_list_is_empty(struct xorg_list *head)
#define xorg_list_last_entry(ptr, type, member) \
xorg_list_entry((ptr)->prev, type, member)
-#define __container_of(ptr, sample, member) \
- (void *)((char *)(ptr) \
- - ((char *)&(sample)->member - (char *)(sample)))
+#ifdef HAVE_TYPEOF
+#define __container_of(ptr, sample, member) \
+ container_of(ptr, typeof(*sample), member)
+#else
+/* This implementation of __container_of has undefined behavior according
+ * to the C standard, but it works in many cases. If your compiler doesn't
+ * support typeof() and fails with this implementation, please try a newer
+ * compiler.
+ */
+#define __container_of(ptr, sample, member) \
+ (void *)((char *)(ptr) \
+ - ((char *)&(sample)->member - (char *)(sample)))
+#endif
+
/**
* Loop through the list given by head and set pos to struct in the list.
*