[Mesa-dev] [PATCH 2/2] wayland-drm: constify the callbacks struct, take 2

Emil Velikov emil.l.velikov at gmail.com
Wed Sep 27 18:49:12 UTC 2017


From: Emil Velikov <emil.velikov at collabora.com>

Now that wayland-drm (correctly) keeps a local copy of the callbacks,
this should not longer cause explosions.

After all the symbol is a local, constant data.

Cc: Daniel Stone <daniels at collabora.com>
Cc: Derek Foreman <derekf at osg.samsung.com>
Signed-off-by: Emil Velikov <emil.velikov at collabora.com>
---
Derek, can you please check the series on your end.

I've ran this through wayland (xwayland and drm) + mpv and the simple
weston demos (simple-egl, simple-damage, flowers, smoke, editor)
---
 src/egl/drivers/dri2/egl_dri2.c           | 14 +++++---------
 src/egl/wayland/wayland-drm/wayland-drm.c |  2 +-
 src/egl/wayland/wayland-drm/wayland-drm.h |  2 +-
 3 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index adcaae0bab7..a0e8b0be5b0 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -2730,17 +2730,16 @@ dri2_wl_release_buffer(void *user_data, struct wl_drm_buffer *buffer)
    dri2_dpy->image->destroyImage(buffer->driver_buffer);
 }
 
-static struct wayland_drm_callbacks wl_drm_callbacks = {
-        .authenticate = NULL,
-        .reference_buffer = dri2_wl_reference_buffer,
-        .release_buffer = dri2_wl_release_buffer
-};
-
 static EGLBoolean
 dri2_bind_wayland_display_wl(_EGLDriver *drv, _EGLDisplay *disp,
                              struct wl_display *wl_dpy)
 {
    struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
+   const struct wayland_drm_callbacks wl_drm_callbacks = {
+      .authenticate = (int(*)(void *, uint32_t)) dri2_dpy->vtbl->authenticate,
+      .reference_buffer = dri2_wl_reference_buffer,
+      .release_buffer = dri2_wl_release_buffer
+   };
    int flags = 0;
    uint64_t cap;
 
@@ -2749,9 +2748,6 @@ dri2_bind_wayland_display_wl(_EGLDriver *drv, _EGLDisplay *disp,
    if (dri2_dpy->wl_server_drm)
            return EGL_FALSE;
 
-   wl_drm_callbacks.authenticate =
-      (int(*)(void *, uint32_t)) dri2_dpy->vtbl->authenticate;
-
    if (drmGetCap(dri2_dpy->fd, DRM_CAP_PRIME, &cap) == 0 &&
        cap == (DRM_PRIME_CAP_IMPORT | DRM_PRIME_CAP_EXPORT) &&
        dri2_dpy->image->base.version >= 7 &&
diff --git a/src/egl/wayland/wayland-drm/wayland-drm.c b/src/egl/wayland/wayland-drm/wayland-drm.c
index 0f0a2317c7e..73dfba9600e 100644
--- a/src/egl/wayland/wayland-drm/wayland-drm.c
+++ b/src/egl/wayland/wayland-drm/wayland-drm.c
@@ -259,7 +259,7 @@ wayland_drm_buffer_get(struct wl_drm *drm, struct wl_resource *resource)
 
 struct wl_drm *
 wayland_drm_init(struct wl_display *display, char *device_name,
-                 struct wayland_drm_callbacks *callbacks, void *user_data,
+                 const struct wayland_drm_callbacks *callbacks, void *user_data,
                  uint32_t flags)
 {
 	struct wl_drm *drm;
diff --git a/src/egl/wayland/wayland-drm/wayland-drm.h b/src/egl/wayland/wayland-drm/wayland-drm.h
index 77e8d273042..111383ff1d6 100644
--- a/src/egl/wayland/wayland-drm/wayland-drm.h
+++ b/src/egl/wayland/wayland-drm/wayland-drm.h
@@ -34,7 +34,7 @@ wayland_drm_buffer_get(struct wl_drm *drm, struct wl_resource *resource);
 
 struct wl_drm *
 wayland_drm_init(struct wl_display *display, char *device_name,
-		 struct wayland_drm_callbacks *callbacks, void *user_data,
+		 const struct wayland_drm_callbacks *callbacks, void *user_data,
                  uint32_t flags);
 
 void
-- 
2.14.1



More information about the mesa-dev mailing list