[Mesa-dev] [PATCH] egl: initialise dummy_thread via _eglInitThreadInfo

Ilia Mirkin imirkin at alum.mit.edu
Sat Apr 29 14:07:34 UTC 2017


On Sat, Apr 29, 2017 at 10:04 AM, Emil Velikov <emil.l.velikov at gmail.com> wrote:
> On 29 April 2017 at 14:51, Ilia Mirkin <imirkin at alum.mit.edu> wrote:
>> On Tue, Apr 25, 2017 at 12:07 PM, Emil Velikov <emil.l.velikov at gmail.com> wrote:
>>> From: Emil Velikov <emil.velikov at collabora.com>
>>>
>>> Considering we cannot make dummy_thread a constant we might as well,
>>> initialise by the same function that handles the actual thread info.
>>>
>>> This way we don't need to worry about mismatch between the initialiser
>>> and initialising function.
>>>
>>> Signed-off-by: Emil Velikov <emil.velikov at collabora.com>
>>> ---
>>>  src/egl/main/eglcurrent.c | 13 ++++---------
>>>  1 file changed, 4 insertions(+), 9 deletions(-)
>>>
>>> diff --git a/src/egl/main/eglcurrent.c b/src/egl/main/eglcurrent.c
>>> index eae7bdcea15..26f42761e26 100644
>>> --- a/src/egl/main/eglcurrent.c
>>> +++ b/src/egl/main/eglcurrent.c
>>> @@ -37,12 +37,8 @@
>>>  #include "eglcurrent.h"
>>>  #include "eglglobals.h"
>>>
>>> -/* This should be kept in sync with _eglInitThreadInfo() */
>>> -#define _EGL_THREAD_INFO_INITIALIZER \
>>> -   { EGL_SUCCESS, NULL, EGL_OPENGL_ES_API, NULL, NULL, NULL }
>>> -
>>>  /* a fallback thread info to guarantee that every thread always has one */
>>> -static _EGLThreadInfo dummy_thread = _EGL_THREAD_INFO_INITIALIZER;
>>> +static _EGLThreadInfo dummy_thread;
>>
>> Are statics initialized to 0? I didn't think they were... I think you
>> need a "= {};" here. Did you test this by forcing allocation failures?
>>
> Static variables are implicitly initialized with zero/NULL [1]. The
> .bss size is increased while the actual [complete] binary size remains
> small.
>
> Consider the following:
>
>  static int foo[2000] = {};
>  static int foo[2000];
>
> The former will/should produce a very large binary, while the
> following will not. In both case the array will be filled with zeros
> ;-)

OK, I thought there was some subtlety in that situation, but I guess
not. Excellent.


More information about the mesa-dev mailing list