[Mesa-dev] [PATCH v2] darwin: Suppress type conversion warnings for GLhandleARB

Jose Fonseca jfonseca at vmware.com
Thu Jul 2 07:15:03 PDT 2015


On 02/07/15 13:16, Emil Velikov wrote:
> On 1 July 2015 at 00:33, Julien Isorce <julien.isorce at gmail.com> wrote:
>> darwin: silence GLhandleARB convertions from and to GLuint
>>
>> This patch and its description are inspired from Jose Fonseca
>> explanations and suggestions.
>>
>> With this patch the following logic applies and only if __APPLE__:
>>
>> When building mesa, GLhandleARB is defined as unsigned long and
>> at some point casted to GLuint in gl fuction implementations.
>> These exact points are where these errors and warnings appear.
>>
>> When building an application GLhandleARB is defined as void*.
>> Later when calling a gl function, for example glBindAttribLocationARB,
>> it will be dispatched to _mesa_BindAttribLocation. So internally
>> void* will be treated as unsigned long which has the same size.
>> So the same truncation happens when casting it to GLuint.
>>
>> Same when GLhandleARB appears as return value.
>> For mesa it will be GLuint -> unsigned long.
>> For an application it will be GLuint -> unsigned long -> void*.
>> Note that the value will be preserved when casting back to GLuint.
>>
>> When GLhandleARB appears as a pointer there are also separate
>> entry-points, i.e. _mesa_FuncNameARB. So the same logic can
>> be applied.
>>
>> https://bugs.freedesktop.org/show_bug.cgi?id=66346
>> Signed-off-by: Julien Isorce <julien.isorce at gmail.com>
>> ---
>>   configure.ac       | 2 +-
>>   include/GL/glext.h | 5 +++++
>>   2 files changed, 6 insertions(+), 1 deletion(-)
>>
>> diff --git a/configure.ac b/configure.ac
>> index 7661bd9..1cd8e77 100644
>> --- a/configure.ac
>> +++ b/configure.ac
>> @@ -1357,7 +1357,7 @@ if test "x$enable_dri" = xyes; then
>>           fi
>>           ;;
>>       darwin*)
>> -        DEFINES="$DEFINES -DGLX_ALIAS_UNSUPPORTED"
>> +        DEFINES="$DEFINES -DGLX_ALIAS_UNSUPPORTED -DBUILDING_MESA"
>>           if test "x$with_dri_drivers" = "xyes"; then
>>               with_dri_drivers="swrast"
>>           fi
>> diff --git a/include/GL/glext.h b/include/GL/glext.h
>> index a3873a6..e5f1d89 100644
>> --- a/include/GL/glext.h
>> +++ b/include/GL/glext.h
>> @@ -3879,7 +3879,12 @@ GLAPI void APIENTRY glMinSampleShadingARB (GLfloat value);
>>   #ifndef GL_ARB_shader_objects
>>   #define GL_ARB_shader_objects 1
>>   #ifdef __APPLE__
>> +#ifdef BUILDING_MESA
>> +/* Avoid uint <-> void* warnings */
>> +typedef unsigned long GLhandleARB;
>> +#else
>>   typedef void *GLhandleARB;
>> +#endif
> Ideally we'll ship a header without this change, but that evolves
> adding a hook at the build/install stage into the autotools build.

I don't think that complexity is justifiable.  There is even a 
precedent, e.g., from the top of mesa/include/GL/gl.h:

#  if (defined(_MSC_VER) || defined(__MINGW32__)) && defined(BUILD_GL32) 
/* tag specify we're building mesa as a DLL */

Many other open-sources projects have public headers that react 
different when building vs external use, and I have yet seen one that 
has install hooks to filter that stuff out.

Jose


More information about the mesa-dev mailing list