diff options
-rw-r--r-- | cb/elogind.cbp | 5 | ||||
-rw-r--r-- | meson.build | 16 | ||||
-rw-r--r-- | src/shared/musl_missing.c | 8 | ||||
-rw-r--r-- | src/shared/musl_missing.h | 5 |
4 files changed, 25 insertions, 9 deletions
diff --git a/cb/elogind.cbp b/cb/elogind.cbp index f612e9176..387e057e3 100644 --- a/cb/elogind.cbp +++ b/cb/elogind.cbp @@ -1118,6 +1118,11 @@ <Option target="all" /> <Option target="clean" /> </Unit> + <Unit filename="../tools/meson-build.sh" /> + <Unit filename="../tools/meson-check-compilation.sh" /> + <Unit filename="../tools/meson-link-test.c"> + <Option compilerVar="CC" /> + </Unit> <Extensions> <envvars /> <code_completion /> diff --git a/meson.build b/meson.build index 550d7a674..fdc4f7d79 100644 --- a/meson.build +++ b/meson.build @@ -589,6 +589,22 @@ else conf.set10('HAVE_GETRANDOM', have) endif +#if 1 /// elogind shall be usable with non-glibc libc variations +##################################################################### +# Find out whether program_invocation[_short]_name is supported +have_pisn = cc.links(''' + #define _GNU_SOURCE 1 + #include <errno.h> + int main(void) { + if (program_invocation_name && program_invocation_short_name) + return 0; + return 1; + } +''', name : 'program_invocation[_short]_name test') +conf.set10('HAVE_PROGRAM_INVOCATION_NAME', have_pisn, + description : 'program_invocation[_short]_name is provided by libc') + +#endif // 1 ##################################################################### sed = find_program('sed') diff --git a/src/shared/musl_missing.c b/src/shared/musl_missing.c index ffa0ff78f..0f8b4d1ad 100644 --- a/src/shared/musl_missing.c +++ b/src/shared/musl_missing.c @@ -23,10 +23,10 @@ #include "alloc-util.h" -#ifndef __GLIBC__ +#if HAVE_PROGRAM_INVOCATION_NAME == 0 char *program_invocation_name = NULL; char *program_invocation_short_name = NULL; -#endif // __GLIBC__ +#endif // libc does not provide these variables const char *program_arg_name = NULL; @@ -55,8 +55,8 @@ void elogind_set_program_name(const char* pcall) { program_invocation_name = strdup(program_arg_name); if (NULL == program_invocation_short_name) program_invocation_short_name = strdup(basename(program_arg_name)); -#ifndef __GLIBC__ +#if HAVE_PROGRAM_INVOCATION_NAME == 0 atexit(elogind_free_program_name); -#endif // __GLIBC__ +#endif // libc does not provide these variables } diff --git a/src/shared/musl_missing.h b/src/shared/musl_missing.h index 15f5f8473..cf5a01481 100644 --- a/src/shared/musl_missing.h +++ b/src/shared/musl_missing.h @@ -27,11 +27,6 @@ void elogind_set_program_name(const char* pcall); #define strerror_r(e, m, k) (strerror_r(e, m, k) < 0 ? strdup("strerror_r() failed") : m); -#ifndef _ERRNO_H -extern char *program_invocation_name; -extern char *program_invocation_short_name; -#endif // errno.h included beforehand - /* * Possibly TODO according to http://man7.org/linux/man-pages/man3/getenv.3.html * + test if the process's effective user ID does not match its real user ID or |