On Mon, Jun 9, 2014 at 5:50 PM, Ian Romanick <i...@freedesktop.org> wrote: > On 06/08/2014 03:17 PM, Jordan Justen wrote: >> This will allow us to utilize the early MESA_EXTENSION_OVERRIDE >> parsing at the later extension string initialization step. >> >> Signed-off-by: Jordan Justen <jordan.l.jus...@intel.com> >> --- >> src/mesa/main/extensions.c | 38 ++++++++++++++++++++++++++++++++++++++ >> 1 file changed, 38 insertions(+) >> >> diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c >> index 4e2205d..2617ca9 100644 >> --- a/src/mesa/main/extensions.c >> +++ b/src/mesa/main/extensions.c >> @@ -39,6 +39,7 @@ >> >> struct gl_extensions _mesa_extension_override_enables; >> struct gl_extensions _mesa_extension_override_disables; >> +static char *extra_extensions = NULL; >> >> enum { >> DISABLE = 0, >> @@ -589,6 +590,19 @@ get_extension_override( struct gl_context *ctx ) >> >> >> /** >> + * \brief Free extra_extensions string >> + * >> + * This string is allocated early during the first context creation by >> + * _mesa_one_time_init_extension_overrides. >> + */ >> +static void >> +free_unknown_extensions_strings(void) >> +{ >> + free(extra_extensions); >> +} >> + >> + >> +/** >> * \brief Initialize extension override tables. >> * >> * This should be called one time early during first context initialization. >> @@ -599,8 +613,11 @@ _mesa_one_time_init_extension_overrides(void) >> const char *env_const = _mesa_getenv("MESA_EXTENSION_OVERRIDE"); >> char *env; >> char *ext; >> + int len; >> size_t offset; >> >> + atexit(free_unknown_extensions_strings); > > I have some recollection that we could not use atexit. Maybe it was > incompatible with some applications or something? I can't remember the > details, but I'd swear we had a problem with this in the past...
It is only used to free two strings, so not all that important. We do seem to use it already (and some of the comments hint at possible issues): $ git grep atexit src/egl/main/egldisplay.c: /* atexit function is called with global mutex locked */ src/egl/main/egldriver.c: * XXX At this point (atexit), the module might be the last reference to src/egl/main/egldriver.c: /* XXX Windows unloads DLLs before atexit */ src/egl/main/egldriver.c: /* this is called at atexit time */ src/egl/main/eglglobals.c: atexit(_eglAtExit); src/gallium/drivers/trace/tr_dump.c: atexit(trace_dump_trace_close); src/glsl/ralloc.c: atexit(autofree); src/glsl/ralloc.h: * to free it using \c atexit. This may cause trouble if used in a library src/mesa/main/context.c: /* Hopefully atexit() is widely available. If not, we may need some src/mesa/main/context.c: atexit(_mesa_destroy_shader_compiler); -Jordan > >> + >> memset(&_mesa_extension_override_enables, 0, sizeof(struct >> gl_extensions)); >> memset(&_mesa_extension_override_disables, 0, sizeof(struct >> gl_extensions)); >> >> @@ -608,10 +625,14 @@ _mesa_one_time_init_extension_overrides(void) >> return; >> } >> >> + /* extra_exts: List of unrecognized extensions. */ >> + extra_extensions = calloc(ALIGN(strlen(env_const) + 2, 4), sizeof(char)); >> + >> /* Copy env_const because strtok() is destructive. */ >> env = strdup(env_const); >> for (ext = strtok(env, " "); ext != NULL; ext = strtok(NULL, " ")) { >> int enable; >> + bool recognized; >> switch (ext[0]) { >> case '+': >> enable = 1; >> @@ -629,10 +650,27 @@ _mesa_one_time_init_extension_overrides(void) >> offset = set_extension(&_mesa_extension_override_enables, ext, >> enable); >> if (offset != 0 && (offset != o(dummy_true) || enable != GL_FALSE)) { >> ((GLboolean *) &_mesa_extension_override_disables)[offset] = >> !enable; >> + recognized = true; >> + } else { >> + recognized = false; >> + } >> + >> + if (!recognized && enable) { >> + strcat(extra_extensions, ext); >> + strcat(extra_extensions, " "); >> } >> } >> >> free(env); >> + >> + /* Remove trailing space, and free if unused. */ >> + len = strlen(extra_extensions); >> + if (len == 0) { >> + free(extra_extensions); >> + extra_extensions = NULL; >> + } else if (extra_extensions[len - 1] == ' ') { >> + extra_extensions[len - 1] = '\0'; >> + } >> } >> >> >> > > _______________________________________________ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/mesa-dev _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev