2 * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20 * DEALINGS IN THE SOFTWARE.
23 #include <stddef.h> // offsetof
24 #include <stdio.h> // printf
26 #include "wayland-egl-priv.h" // Current struct wl_egl_window implementation
29 * Following are previous implementations of wl_egl_window.
34 /* From: 214fc6e850 - Benjamin Franzke : egl: Implement libwayland-egl */
35 struct wl_egl_window_v0
{
36 struct wl_surface
*surface
;
47 /* From: ca3ed3e024 - Ander Conselvan de Oliveira : egl/wayland: Don't invalidate drawable on swap buffers */
48 struct wl_egl_window_v1
{
49 struct wl_surface
*surface
;
60 void (*resize_callback
)(struct wl_egl_window
*, void *);
63 /* From: 690ead4a13 - Stencel, Joanna : egl/wayland-egl: Fix for segfault in dri2_wl_destroy_surface. */
64 struct wl_egl_window_v2
{
65 struct wl_surface
*surface
;
76 void (*resize_callback
)(struct wl_egl_window
*, void *);
77 void (*destroy_window_callback
)(void *);
81 /* This program checks we keep a backwards-compatible struct wl_egl_window
82 * definition whenever it is modified in wayland-egl-priv.h.
84 * The previous definition should be added above as a new struct
85 * wl_egl_window_vN, and the appropriate checks should be added below
88 #define MEMBER_SIZE(type, member) sizeof(((type *)0)->member)
90 #define CHECK_MEMBERS(a_ver, b_ver, a_member, b_member) \
92 if (offsetof(struct wl_egl_window ## a_ver, a_member) != \
93 offsetof(struct wl_egl_window ## b_ver, b_member)) { \
94 printf("Backards incompatible change detected!\n " \
95 "offsetof(struct wl_egl_window" #a_ver "::" #a_member ") != " \
96 "offsetof(struct wl_egl_window" #b_ver "::" #b_member ")\n"); \
100 if (MEMBER_SIZE(struct wl_egl_window ## a_ver, a_member) != \
101 MEMBER_SIZE(struct wl_egl_window ## b_ver, b_member)) { \
102 printf("Backards incompatible change detected!\n " \
103 "MEMBER_SIZE(struct wl_egl_window" #a_ver "::" #a_member ") != " \
104 "MEMBER_SIZE(struct wl_egl_window" #b_ver "::" #b_member ")\n"); \
109 #define CHECK_MEMBER(a_ver, b_ver, member) CHECK_MEMBERS(a_ver, b_ver, member, member)
110 #define CHECK_MEMBER_CURRENT(a_ver, member) CHECK_MEMBER(a_ver,, member)
112 #define CHECK_SIZE(a_ver, b_ver) \
114 if (sizeof(struct wl_egl_window ## a_ver) > \
115 sizeof(struct wl_egl_window ## b_ver)) { \
116 printf("Backards incompatible change detected!\n " \
117 "sizeof(struct wl_egl_window" #a_ver ") > " \
118 "sizeof(struct wl_egl_window" #b_ver ")\n"); \
123 #define CHECK_SIZE_CURRENT(a_ver) \
125 if (sizeof(struct wl_egl_window ## a_ver) != \
126 sizeof(struct wl_egl_window)) { \
127 printf("Backards incompatible change detected!\n " \
128 "sizeof(struct wl_egl_window" #a_ver ") != " \
129 "sizeof(struct wl_egl_window)\n"); \
134 int main(int argc
, char **argv
)
136 /* Check wl_egl_window_v1 ABI against wl_egl_window_v0 */
137 CHECK_MEMBER(_v0
, _v1
, surface
);
138 CHECK_MEMBER(_v0
, _v1
, width
);
139 CHECK_MEMBER(_v0
, _v1
, height
);
140 CHECK_MEMBER(_v0
, _v1
, dx
);
141 CHECK_MEMBER(_v0
, _v1
, dy
);
142 CHECK_MEMBER(_v0
, _v1
, attached_width
);
143 CHECK_MEMBER(_v0
, _v1
, attached_height
);
145 CHECK_SIZE(_v0
, _v1
);
147 /* Check wl_egl_window_v2 ABI against wl_egl_window_v1 */
148 CHECK_MEMBER(_v1
, _v2
, surface
);
149 CHECK_MEMBER(_v1
, _v2
, width
);
150 CHECK_MEMBER(_v1
, _v2
, height
);
151 CHECK_MEMBER(_v1
, _v2
, dx
);
152 CHECK_MEMBER(_v1
, _v2
, dy
);
153 CHECK_MEMBER(_v1
, _v2
, attached_width
);
154 CHECK_MEMBER(_v1
, _v2
, attached_height
);
155 CHECK_MEMBER(_v1
, _v2
, private);
156 CHECK_MEMBER(_v1
, _v2
, resize_callback
);
158 CHECK_SIZE(_v1
, _v2
);
160 /* Check current wl_egl_window ABI against wl_egl_window_v2 */
161 CHECK_MEMBER_CURRENT(_v2
, surface
);
162 CHECK_MEMBER_CURRENT(_v2
, width
);
163 CHECK_MEMBER_CURRENT(_v2
, height
);
164 CHECK_MEMBER_CURRENT(_v2
, dx
);
165 CHECK_MEMBER_CURRENT(_v2
, dy
);
166 CHECK_MEMBER_CURRENT(_v2
, attached_width
);
167 CHECK_MEMBER_CURRENT(_v2
, attached_height
);
168 CHECK_MEMBER_CURRENT(_v2
, private);
169 CHECK_MEMBER_CURRENT(_v2
, resize_callback
);
170 CHECK_MEMBER_CURRENT(_v2
, destroy_window_callback
);
172 CHECK_SIZE_CURRENT(_v2
);