[Piglit] [PATCH 25/29] tests/egl: Add missing type cast

Pauli pauli.nieminen at linux.intel.com
Thu May 24 07:44:20 PDT 2012

On 23/05/12 23:46, Chad Versace wrote:
> On 05/23/2012 07:55 AM, Pauli Nieminen wrote:
>> On Tue, May 22, 2012 at 03:43:46PM -0700, Chad Versace wrote:
>>> On 05/21/2012 11:09 AM, Pauli Nieminen wrote:
>>>> Protable code should cast to EGL native types always before passing
>>>> variables to functions taking a native parameter.
>>>> Signed-off-by: Pauli Nieminen<pauli.nieminen at linux.intel.com>
>>>> ---
>>>>   tests/egl/egl-util.c |    2 +-
>>>>   1 files changed, 1 insertions(+), 1 deletions(-)
>>>> diff --git a/tests/egl/egl-util.c b/tests/egl/egl-util.c
>>>> index 41fc31f..639515e 100644
>>>> --- a/tests/egl/egl-util.c
>>>> +++ b/tests/egl/egl-util.c
>>>> @@ -179,7 +179,7 @@ egl_util_run(const struct egl_test *test, int argc, char *argv[])
>>>>   	}
>>>> -	state.egl_dpy = eglGetDisplay(state.dpy);
>>>> +	state.egl_dpy = eglGetDisplay((EGLNativeDisplayType)state.dpy);
>>>>   	if (state.egl_dpy == EGL_NO_DISPLAY) {
>>>>   		fprintf(stderr, "eglGetDisplay() failed\n");
>>>>   		piglit_report_result(PIGLIT_FAIL);
>>> I think that this indicates that there is a type mismatch somewhere.
>>> I don't believe such casting is ever necessary. In fact, I believe such
>>> casts will mask real bugs.
>> The bugs like eglplatform.h having matching integer types instead of
>> pointers or vice-versa. But that probably should be considred in
>> eglplatform.h.
>>> Waffle never makes casts for EGLNative types, and it compiles without any warnings.
>>> For example, in the x11_egl backend, Waffle passes a Display* to eglGetDisplay without any typecast;
>>> see the two lines below:
>>> line 54, http://cgit.freedesktop.org/~chadversary/waffle/tree/src/waffle/x11_egl/xegl_display.c?id=0.3#n54
>>> line 29, http://cgit.freedesktop.org/~chadversary/waffle/tree/src/waffle/egl/egl_native_template.c?id=0.3
>>> What problem did you encounter that prompted this patch?
>> There is problem that EGLNative* types vary between platform but are
>> defined in dispatch. Including EGL/eglplatform.h did feel like a
>> working solution to provide platform independ interface.
>> I had a idea that dispatch could defined native types to uintptr_t
>> and generate platform specific wrappers to truncate types back to
>> platform specific types behind dispatch.
>> Another option would be filtering out native types from dispatch. Too
>> bad that prevents user of dispatch from using egl native types in same
>> C file as egl functions use through dispatch. Or at least makes it a
>> lot more complex than it should be.
> This is a difficult thing to solve without introducing lots of complexity.
> I think I need to better understand your dispatch patches before discussing
> this more.
Now that I remember to check the system V 64bit ABI I noticed that we 
can simple make all native types 64bit wide. They will be handled 
correctly because parameters are passed in registers. That probably 
isn't true for big-endian system if there is some byte swapping magic 
required to get lowest 32bits from a 64bit integer register to correct 
place for 32bit access.

32bit systems won't have problems because everything is 32bit pointers 
or integers.


More information about the Piglit mailing list