<div dir="ltr">If I understood it right, Dmitry, you are working on an EGL implementation that should dynamically detect the type of the object passed to eglGetDisplay. Mesa already does that, but it is ugly and just a hack that should be avoided. eglGetDisplay was not designed to support multiple platforms, hence why the EGL_EXT_platform_base[1] extension was conceived. Consider implementing and switching to it - which, by the way, is part of EGL 1.5.<div><br></div><div>1: <a href="https://www.khronos.org/registry/egl/extensions/EXT/EGL_EXT_platform_base.txt">https://www.khronos.org/registry/egl/extensions/EXT/EGL_EXT_platform_base.txt</a></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Oct 17, 2014 at 9:00 PM, Bill Spitzak <span dir="ltr"><<a href="mailto:spitzak@gmail.com" target="_blank">spitzak@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 10/16/2014 11:16 PM, Pekka Paalanen wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
...adding a function int/bool wl_is_wl_display_pointer(void *p) into<br>
libwayland-client.so. As that function would be built into<br>
libwayland-client.so, it naturally uses the client.so version of<br>
wl_display_interface symbol (unless dynamic linking miraculously<br>
manages to mess that up?).<br>
<br>
'p' would be the tentative 'struct wl_display *', so that the<br>
implementation details of struct wl_display would be contained in<br>
libwayland-client.so, and not leaked elsewhere like e.g. in Mesa.<br>
</blockquote>
<br></span>
Might be better if the function was more like a cast. It returns either (wl_display*)p or NULL depending on the test. The reason is so the user can just assign it to a correct pointer without doing the cast themselves. This might be important if more of these casts are added in the future, it makes it harder to accidentally run the wrong test for the cast you want to do:<br>
<br>
struct wl_display* wl_display_dynamic_cast (void* p) {<br>
if (test(p)) return (struct wl_display*)p;<br>
else return 0;<span class=""><br>
}<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I am unsure about the exact definition of wl_is_wl_display_pointer():<br>
can it do the dereferencability check itself, or should we require the<br>
caller to guarantee that dereferencing cannot crash. The latter would<br>
leave the portability burden on the callers rather than libwayland.<br>
</blockquote>
<br></span>
Probably it should handle NULL.<br>
<br>
Maybe it should check alignment if wl_display has stricter alignment restrictions than some other plausable arguments.<br>
<br>
It does not seem to me that a check for pointing to valid memory is necessary.<div class="HOEnZb"><div class="h5"><br>
______________________________<u></u>_________________<br>
wayland-devel mailing list<br>
<a href="mailto:wayland-devel@lists.freedesktop.org" target="_blank">wayland-devel@lists.<u></u>freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/wayland-devel" target="_blank">http://lists.freedesktop.org/<u></u>mailman/listinfo/wayland-devel</a><br>
</div></div></blockquote></div><br></div>