[Mesa-dev] [PATCH] egl: fix android logger compilation

Tapani Pälli tapani.palli at intel.com
Fri May 12 06:28:54 UTC 2017



On 05/12/2017 09:19 AM, Chih-Wei Huang wrote:
> 2017-05-12 14:15 GMT+08:00 Tapani Pälli <tapani.palli at intel.com>:
>>
>>
>> On 05/12/2017 09:13 AM, Chih-Wei Huang wrote:
>>>
>>> 2017-05-12 13:37 GMT+08:00 Tapani Pälli <tapani.palli at intel.com>:
>>>>
>>>> this patch is a partial revert of 1ce5853 that break compilation
>>>> since LOG_ERROR etc are not defined and also macro expansion won't
>>>> work as planned (expands to 'ANDROID_egl2alog[level]')
>>>>
>>>> Fixes: 1ce5853 ("egl: simplify the Android logger")
>>>> Signed-off-by: Tapani Pälli <tapani.palli at intel.com>
>>>> ---
>>>>    src/egl/main/egllog.c | 21 ++++++++++++++-------
>>>>    1 file changed, 14 insertions(+), 7 deletions(-)
>>>>
>>>> diff --git a/src/egl/main/egllog.c b/src/egl/main/egllog.c
>>>> index 6de2a50..51ab76f 100644
>>>> --- a/src/egl/main/egllog.c
>>>> +++ b/src/egl/main/egllog.c
>>>> @@ -81,13 +81,20 @@ static void
>>>>    _eglDefaultLogger(EGLint level, const char *msg)
>>>>    {
>>>>    #ifdef HAVE_ANDROID_PLATFORM
>>>> -   static const int egl2alog[] = {
>>>> -      [_EGL_FATAL] = LOG_ERROR,
>>>> -      [_EGL_WARNING]  = LOG_WARN,
>>>> -      [_EGL_INFO] = LOG_INFO,
>>>> -      [_EGL_DEBUG] = LOG_DEBUG,
>>>
>>>
>>> How about just change LOG_* to ANDROID_LOG_* ?
>>> You also need to include "android/log.h".
> 
> Correction: this has already included (from cutils/log.h)
> 
>>> LOG_* are not real macros defined in Android headers.
>>> They are concatenated to ANDROID_LOG_*
>>> defined in android/log.h. (in system/core/include/)
>>
>>
>> problem is that ALOG stringifies (is that a word?) the first argument and
>> concats that with 'ANDROID_', so currently you get 'ANDROID_egl2alog[level]'
>> which does not exist. With ANDROID applied, you would get 'ANDROID_ANDROID
>> ..'
> 
> Ah, I see. Then change ALOG to LOG_PRI
> (or android_printLog).

yeah, adding ANDROID and using LOG_PRI should do it as well, although 
I'm kind of missing the point of playing with such small LUT here 
instead of just using a simple and clear switch

>>
>>
>>>> -   };
>>>> -   ALOG(egl2alog[level], LOG_TAG, "%s", msg);
>>>> +   switch (level) {
>>>> +   case _EGL_FATAL:
>>>> +      ALOGE("%s", msg);
>>>> +      break;
>>>> +   case _EGL_WARNING:
>>>> +      ALOGW("%s", msg);
>>>> +      break;
>>>> +   case _EGL_INFO:
>>>> +      ALOGI("%s", msg);
>>>> +      break;
>>>> +   case _EGL_DEBUG:
>>>> +      ALOGD("%s", msg);
>>>> +      break;
>>>> +   }
>>>>    #else
>>>>       fprintf(stderr, "libEGL %s: %s\n", level_strings[level], msg);
>>>>    #endif /* HAVE_ANDROID_PLATFORM */
> 
> 


More information about the mesa-dev mailing list