util: add dlfcn-util.h

This just adds a _cleanup_ helper call encapsulating dlclose().

This also means libsystemd-shared is linked against libdl now. I don't
think this is much of an issue, since libdl is part of glibc anyway, and
anything from exotic. It's not an optional part of the OS (think: NSS
requires dynamic linking), hence this pulls in no deps and is almost
certainly loaded into all process' memory anyway.

[zj: use DEFINE_TRIVIAL_CLEANUP_FUNC().]
This commit is contained in:
Lennart Poettering
2020-06-23 17:23:27 +02:00
committed by Zbigniew Jędrzejewski-Szmek
parent 69876f94ab
commit 88d775b734
4 changed files with 14 additions and 4 deletions
+8
View File
@@ -0,0 +1,8 @@
/* SPDX-License-Identifier: LGPL-2.1+ */
#pragma once
#include <dlfcn.h>
#include "macro.h"
DEFINE_TRIVIAL_CLEANUP_FUNC(void*, dlclose);
+3 -1
View File
@@ -39,6 +39,7 @@ basic_sources = files('''
device-nodes.h
dirent-util.c
dirent-util.h
dlfcn-util.h
efivars.c
efivars.h
env-file.c
@@ -328,7 +329,8 @@ libbasic = static_library(
threads,
libcap,
libselinux,
libm],
libm,
libdl],
c_args : ['-fvisibility=default'],
install : false)