efl proc/exe envrion work again - after a break earlier on freebsd

efl seemingly has been broken on freebsd for a while - environ the
symbol does not exist for SHARED LIBS on freebsd (discussin had been
had on this already, but i gave up). use dlsym as the escape mechanism
so we build on freebsd again.
This commit is contained in:
Carsten Haitzler 2019-06-04 02:14:20 +02:00
parent 768bb43ed3
commit 223ba9acc3
2 changed files with 32 additions and 2 deletions

View File

@ -13,7 +13,12 @@
#define MY_CLASS EFL_CORE_PROC_ENV_CLASS
#if defined (__FreeBSD__) || defined (__OpenBSD__)
# include <dlfcn.h>
static char ***_dl_environ;
#else
extern char **environ;
#endif
static Efl_Core_Env *env = NULL;
@ -27,6 +32,7 @@ _sync(Efl_Core_Env *obj, Efl_Core_Proc_Env_Data *pd)
Eina_List *existing_keys = NULL, *n;
Eina_Iterator *content;
const char *key;
char **env = NULL;
pd->in_sync = EINA_TRUE;
content = efl_core_env_content_get(obj);
@ -36,11 +42,18 @@ _sync(Efl_Core_Env *obj, Efl_Core_Proc_Env_Data *pd)
existing_keys = eina_list_append(existing_keys, key);
}
if (environ)
#if defined (__FreeBSD__) || defined (__OpenBSD__)
_dl_environ = dlsym(NULL, "environ");
if (_dl_environ) env = *_dl_environ;
else ERR("Can't find envrion symbol");
#else
env = environ;
#endif
if (env)
{
char **p;
for (p = environ; *p; p++)
for (p = env; *p; p++)
{
char **values;
@ -104,7 +117,13 @@ _efl_core_proc_env_efl_core_env_clear(Eo *obj, Efl_Core_Proc_Env_Data *pd)
#ifdef HAVE_CLEARENV
clearenv();
#else
# if defined (__FreeBSD__) || defined (__OpenBSD__)
_dl_environ = dlsym(NULL, "environ");
if (_dl_environ) *_dl_environ = NULL;
else ERR("Can't find envrion symbol");
# else
environ = NULL;
# endif
#endif
}
}

View File

@ -30,7 +30,12 @@
# include <sys/wait.h>
# endif
# ifndef HAVE_CLEARENV
# if defined (__FreeBSD__) || defined (__OpenBSD__)
# include <dlfcn.h>
static char ***_dl_environ;
# else
extern char **environ;
# endif
# endif
#endif
@ -579,7 +584,13 @@ _efl_exe_efl_task_run(Eo *obj, Efl_Exe_Data *pd)
# ifdef HAVE_CLEARENV
clearenv();
# else
# if defined (__FreeBSD__) || defined (__OpenBSD__)
_dl_environ = dlsym(NULL, "environ");
if (_dl_environ) *_dl_environ = NULL;
else ERR("Can't find envrion symbol");
# else
environ = NULL;
# endif
# endif
itr = efl_core_env_content_get(pd->env);