summaryrefslogtreecommitdiffstats
path: root/src/egl/wayland/wayland-egl
diff options
context:
space:
mode:
authorMiguel A. Vico <[email protected]>2017-07-19 17:22:44 -0700
committerEmil Velikov <[email protected]>2017-07-24 10:27:10 +0100
commitdad0c5d2d7ef91accc768a7192f6c9284080ab6f (patch)
treeb6a16f80e248823ca109b0463c0e14c66e775098 /src/egl/wayland/wayland-egl
parent4d53b16f555b2d33216518100fb2cd578428512d (diff)
wayland-egl: Add wl_egl_window ABI checker
Add a small ABI checker for wl_egl_window so that we can check for backwards incompatible changes at 'make check' time. Signed-off-by: Miguel A. Vico <[email protected]> Reviewed-by: James Jones <[email protected]> Acked-by: Daniel Stone <[email protected]> Reviewed-by: Emil Velikov <[email protected]>
Diffstat (limited to 'src/egl/wayland/wayland-egl')
-rw-r--r--src/egl/wayland/wayland-egl/Makefile.am6
-rw-r--r--src/egl/wayland/wayland-egl/wayland-egl-abi-check.c175
2 files changed, 180 insertions, 1 deletions
diff --git a/src/egl/wayland/wayland-egl/Makefile.am b/src/egl/wayland/wayland-egl/Makefile.am
index 8c45e8e26d7..846fa6247b2 100644
--- a/src/egl/wayland/wayland-egl/Makefile.am
+++ b/src/egl/wayland/wayland-egl/Makefile.am
@@ -14,7 +14,11 @@ libwayland_egl_la_LDFLAGS = \
$(GC_SECTIONS) \
$(LD_NO_UNDEFINED)
-TESTS = wayland-egl-symbols-check
+TESTS = wayland-egl-symbols-check \
+ wayland-egl-abi-check
+
EXTRA_DIST = wayland-egl-symbols-check
+check_PROGRAMS = wayland-egl-abi-check
+
include $(top_srcdir)/install-lib-links.mk
diff --git a/src/egl/wayland/wayland-egl/wayland-egl-abi-check.c b/src/egl/wayland/wayland-egl/wayland-egl-abi-check.c
new file mode 100644
index 00000000000..9701ea14531
--- /dev/null
+++ b/src/egl/wayland/wayland-egl/wayland-egl-abi-check.c
@@ -0,0 +1,175 @@
+/*
+ * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#include <stddef.h> // offsetof
+#include <stdio.h> // printf
+
+#include "wayland-egl-priv.h" // Current struct wl_egl_window implementation
+
+/*
+ * Following are previous implementations of wl_egl_window.
+ *
+ * DO NOT EVER CHANGE!
+ */
+
+/* From: 214fc6e850 - Benjamin Franzke : egl: Implement libwayland-egl */
+struct wl_egl_window_v0 {
+ struct wl_surface *surface;
+
+ int width;
+ int height;
+ int dx;
+ int dy;
+
+ int attached_width;
+ int attached_height;
+};
+
+/* From: ca3ed3e024 - Ander Conselvan de Oliveira : egl/wayland: Don't invalidate drawable on swap buffers */
+struct wl_egl_window_v1 {
+ struct wl_surface *surface;
+
+ int width;
+ int height;
+ int dx;
+ int dy;
+
+ int attached_width;
+ int attached_height;
+
+ void *private;
+ void (*resize_callback)(struct wl_egl_window *, void *);
+};
+
+/* From: 690ead4a13 - Stencel, Joanna : egl/wayland-egl: Fix for segfault in dri2_wl_destroy_surface. */
+struct wl_egl_window_v2 {
+ struct wl_surface *surface;
+
+ int width;
+ int height;
+ int dx;
+ int dy;
+
+ int attached_width;
+ int attached_height;
+
+ void *private;
+ void (*resize_callback)(struct wl_egl_window *, void *);
+ void (*destroy_window_callback)(void *);
+};
+
+
+/* This program checks we keep a backwards-compatible struct wl_egl_window
+ * definition whenever it is modified in wayland-egl-priv.h.
+ *
+ * The previous definition should be added above as a new struct
+ * wl_egl_window_vN, and the appropriate checks should be added below
+ */
+
+#define MEMBER_SIZE(type, member) sizeof(((type *)0)->member)
+
+#define CHECK_MEMBERS(a_ver, b_ver, a_member, b_member) \
+ do { \
+ if (offsetof(struct wl_egl_window ## a_ver, a_member) != \
+ offsetof(struct wl_egl_window ## b_ver, b_member)) { \
+ printf("Backards incompatible change detected!\n " \
+ "offsetof(struct wl_egl_window" #a_ver "::" #a_member ") != " \
+ "offsetof(struct wl_egl_window" #b_ver "::" #b_member ")\n"); \
+ return 1; \
+ } \
+ \
+ if (MEMBER_SIZE(struct wl_egl_window ## a_ver, a_member) != \
+ MEMBER_SIZE(struct wl_egl_window ## b_ver, b_member)) { \
+ printf("Backards incompatible change detected!\n " \
+ "MEMBER_SIZE(struct wl_egl_window" #a_ver "::" #a_member ") != " \
+ "MEMBER_SIZE(struct wl_egl_window" #b_ver "::" #b_member ")\n"); \
+ return 1; \
+ } \
+ } while (0)
+
+#define CHECK_MEMBER(a_ver, b_ver, member) CHECK_MEMBERS(a_ver, b_ver, member, member)
+#define CHECK_MEMBER_CURRENT(a_ver, member) CHECK_MEMBER(a_ver,, member)
+
+#define CHECK_SIZE(a_ver, b_ver) \
+ do { \
+ if (sizeof(struct wl_egl_window ## a_ver) > \
+ sizeof(struct wl_egl_window ## b_ver)) { \
+ printf("Backards incompatible change detected!\n " \
+ "sizeof(struct wl_egl_window" #a_ver ") > " \
+ "sizeof(struct wl_egl_window" #b_ver ")\n"); \
+ return 1; \
+ } \
+ } while (0)
+
+#define CHECK_SIZE_CURRENT(a_ver) \
+ do { \
+ if (sizeof(struct wl_egl_window ## a_ver) != \
+ sizeof(struct wl_egl_window)) { \
+ printf("Backards incompatible change detected!\n " \
+ "sizeof(struct wl_egl_window" #a_ver ") != " \
+ "sizeof(struct wl_egl_window)\n"); \
+ return 1; \
+ } \
+ } while (0)
+
+int main(int argc, char **argv)
+{
+ /* Check wl_egl_window_v1 ABI against wl_egl_window_v0 */
+ CHECK_MEMBER(_v0, _v1, surface);
+ CHECK_MEMBER(_v0, _v1, width);
+ CHECK_MEMBER(_v0, _v1, height);
+ CHECK_MEMBER(_v0, _v1, dx);
+ CHECK_MEMBER(_v0, _v1, dy);
+ CHECK_MEMBER(_v0, _v1, attached_width);
+ CHECK_MEMBER(_v0, _v1, attached_height);
+
+ CHECK_SIZE(_v0, _v1);
+
+ /* Check wl_egl_window_v2 ABI against wl_egl_window_v1 */
+ CHECK_MEMBER(_v1, _v2, surface);
+ CHECK_MEMBER(_v1, _v2, width);
+ CHECK_MEMBER(_v1, _v2, height);
+ CHECK_MEMBER(_v1, _v2, dx);
+ CHECK_MEMBER(_v1, _v2, dy);
+ CHECK_MEMBER(_v1, _v2, attached_width);
+ CHECK_MEMBER(_v1, _v2, attached_height);
+ CHECK_MEMBER(_v1, _v2, private);
+ CHECK_MEMBER(_v1, _v2, resize_callback);
+
+ CHECK_SIZE(_v1, _v2);
+
+ /* Check current wl_egl_window ABI against wl_egl_window_v2 */
+ CHECK_MEMBER_CURRENT(_v2, surface);
+ CHECK_MEMBER_CURRENT(_v2, width);
+ CHECK_MEMBER_CURRENT(_v2, height);
+ CHECK_MEMBER_CURRENT(_v2, dx);
+ CHECK_MEMBER_CURRENT(_v2, dy);
+ CHECK_MEMBER_CURRENT(_v2, attached_width);
+ CHECK_MEMBER_CURRENT(_v2, attached_height);
+ CHECK_MEMBER_CURRENT(_v2, private);
+ CHECK_MEMBER_CURRENT(_v2, resize_callback);
+ CHECK_MEMBER_CURRENT(_v2, destroy_window_callback);
+
+ CHECK_SIZE_CURRENT(_v2);
+
+ return 0;
+}