[MPlayer-dev-eng] [PATCH] libvo/gl_common.c: Use RTLD_DEFAULT instead of 0 for dlsym to increase portability

Reimar Döffinger Reimar.Doeffinger at gmx.de
Thu Apr 23 11:52:43 CEST 2009


On Thu, Apr 23, 2009 at 02:31:59AM -0700, Jeremy Huddleston wrote:
> RTLD_DEFAULT is not always 0.  It's 0 on linux, but it's -2 on darwin.
> 
> --- libvo/gl_common.c	2009-04-23 02:09:43.000000000 -0700
> +++ libvo/gl_common.c	2009-04-23 02:10:18.000000000 -0700
> @@ -1547,7 +1547,7 @@ static void *getdladdr(const char *s) {
>       handle = dlopen(NULL, RTLD_LAZY);
>     return dlsym(handle, s);
>   #else
> -  return dlsym(0, s);
> +  return dlsym(RTLD_DEFAULT, s);
>   #endif
>   #else
>     return NULL;

This was intended to be 0, not RTLD_DEFAULT. Unfortunately, I was
mistaken to believe that dlsym(0, ...) has a specified behaviour.
Still, RTLD_DEFAULT is a gnuism and isn't acceptable either.
Always using the
> #if defined(__sun) || defined(__sgi)
code would be an issue, but it leaks a handle.
It might be better to just bite the performance bullet and just always
use
> void *handle = dlopen(NULL, RTLD_LAZY);
> void *ret = dlsym(handle, s);
> dclose(handle);
> return ret;

_But_ I think this had issues on some other systems - they may be gone
nowadays though.



More information about the MPlayer-dev-eng mailing list