Use wl_container_of internally

Rather than have two versions of the macro with slightly different
interfaces, just use wl_container_of internally.

This also removes use of statement expressions, a GNU C extension.

Signed-off-by: Michael Forney <mforney@mforney.org>
diff --git a/src/event-loop.c b/src/event-loop.c
index 54c8474..017ab27 100644
--- a/src/event-loop.c
+++ b/src/event-loop.c
@@ -595,8 +595,8 @@
 	struct wl_event_source_idle *source;
 
 	while (!wl_list_empty(&loop->idle_list)) {
-		source = container_of(loop->idle_list.next,
-				      struct wl_event_source_idle, base.link);
+		source = wl_container_of(loop->idle_list.next,
+					 source, base.link);
 		source->func(source->base.data);
 		wl_event_source_remove(&source->base);
 	}
diff --git a/src/wayland-client.c b/src/wayland-client.c
index b0805f1..38756f1 100644
--- a/src/wayland-client.c
+++ b/src/wayland-client.c
@@ -298,8 +298,8 @@
 	struct wl_closure *closure;
 
 	while (!wl_list_empty(&queue->event_list)) {
-		closure = container_of(queue->event_list.next,
-				       struct wl_closure, link);
+		closure = wl_container_of(queue->event_list.next,
+					  closure, link);
 		wl_list_remove(&closure->link);
 		destroy_queued_closure(closure);
 	}
@@ -1400,8 +1400,7 @@
 	int opcode;
 	bool proxy_destroyed;
 
-	closure = container_of(queue->event_list.next,
-			       struct wl_closure, link);
+	closure = wl_container_of(queue->event_list.next, closure, link);
 	wl_list_remove(&closure->link);
 	opcode = closure->opcode;
 
diff --git a/src/wayland-private.h b/src/wayland-private.h
index 29516ec..8a97fab 100644
--- a/src/wayland-private.h
+++ b/src/wayland-private.h
@@ -42,10 +42,6 @@
 
 #define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0])
 
-#define container_of(ptr, type, member) ({				\
-	const __typeof__( ((type *)0)->member ) *__mptr = (ptr);	\
-	(type *)( (char *)__mptr - offsetof(type,member) );})
-
 #define WL_MAP_SERVER_SIDE 0
 #define WL_MAP_CLIENT_SIDE 1
 #define WL_SERVER_ID_START 0xff000000
diff --git a/src/wayland-server.c b/src/wayland-server.c
index 884a5a3..83b984f 100644
--- a/src/wayland-server.c
+++ b/src/wayland-server.c
@@ -1899,7 +1899,9 @@
 WL_EXPORT struct wl_client *
 wl_client_from_link(struct wl_list *link)
 {
-	return container_of(link, struct wl_client, link);
+	struct wl_client *client;
+
+	return wl_container_of(link, client, link);
 }
 
 /** Add a listener for the client's resource creation signal
diff --git a/tests/client-test.c b/tests/client-test.c
index 2e332f8..960cfa9 100644
--- a/tests/client-test.c
+++ b/tests/client-test.c
@@ -47,7 +47,7 @@
 client_destroy_notify(struct wl_listener *l, void *data)
 {
 	struct client_destroy_listener *listener =
-		container_of(l, struct client_destroy_listener, listener);
+		wl_container_of(l, listener, listener);
 
 	listener->done = 1;
 }
diff --git a/tests/display-test.c b/tests/display-test.c
index 6d98cc7..74a24f1 100644
--- a/tests/display-test.c
+++ b/tests/display-test.c
@@ -60,7 +60,7 @@
 {
 	struct display_destroy_listener *listener;
 
-	listener = container_of(l, struct display_destroy_listener, listener);
+	listener = wl_container_of(l, listener, listener);
 	listener->done = 1;
 }
 
diff --git a/tests/event-loop-test.c b/tests/event-loop-test.c
index 33566b4..9659815 100644
--- a/tests/event-loop-test.c
+++ b/tests/event-loop-test.c
@@ -339,7 +339,7 @@
 event_loop_destroy_notify(struct wl_listener *l, void *data)
 {
 	struct event_loop_destroy_listener *listener =
-		container_of(l, struct event_loop_destroy_listener, listener);
+		wl_container_of(l, listener, listener);
 
 	listener->done = 1;
 }