Cleanup: Remove whiteline
[lttng-ust.git] / include / ust-dlfcn.h
CommitLineData
f02baefb 1/*
c0c0989a 2 * SPDX-License-Identifier: MIT
f02baefb 3 *
c0c0989a 4 * Copyright (C) 2014 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
f02baefb
MD
5 *
6 * dlfcn.h compatibility layer.
f02baefb
MD
7 */
8
c0c0989a
MJ
9#ifndef _LTTNG_UST_DLFCN_H
10#define _LTTNG_UST_DLFCN_H
11
f02baefb 12#ifdef _DLFCN_H
ae4b659d 13#error "Please include ust-dlfcn.h before dlfcn.h."
f02baefb
MD
14#endif /* _DLFCN_H */
15
30307a67 16#ifdef __GLIBC__
f02baefb
MD
17/*
18 * glibc declares dlsym() and dlerror() with __attribute__((leaf)) (see
19 * THROW annotation). Unfortunately, this is not in sync with reality,
20 * as those functions call the memory allocator. Work-around this glibc
21 * bug by declaring our own symbols.
22 *
23 * There has been a similar issue for dlopen() and dlclose(), as
24 * constructors and destructors are called from these functions, so they
25 * are clearly non-leaf. Work-around the issue for those too for older
26 * glibc where these have not been fixed.
27 */
28#define dlopen glibc_dlopen_proto_lies_about_leafness
29#define dlclose glibc_dlclose_proto_lies_about_leafness
30#define dlsym glibc_dlsym_proto_lies_about_leafness
31#define dlerror glibc_dlerror_proto_lies_about_leafness
7b0fdd83
MD
32#define dlmopen glibc_dlmopen_proto_lies_about_leafness
33#define dlvsym glibc_dlvsym_proto_lies_about_leafness
f02baefb 34#include <dlfcn.h>
7b0fdd83
MD
35#undef dlvsym
36#undef dlmopen
f02baefb
MD
37#undef dlerror
38#undef dlsym
39#undef dlclose
40#undef dlopen
41
42extern void *dlopen(__const char *__file, int __mode);
43extern int dlclose(void *__handle) __nonnull ((1));
44extern void *dlsym(void *__restrict __handle,
45 __const char *__restrict __name) __nonnull ((2));
39ec1582 46extern char *dlerror(void);
7b0fdd83
MD
47#ifdef __USE_GNU
48extern void *dlmopen(Lmid_t __nsid, const char *__file, int __mode);
49extern void *dlvsym(void *__restrict __handle,
50 __const char *__restrict __name,
51 __const char *__restrict __version);
52#endif
30307a67
MJ
53#else
54#include <dlfcn.h>
55#endif /* __GLIBC__ */
f02baefb
MD
56
57#endif /* _LTTNG_UST_DLFCN_H */
This page took 0.045741 seconds and 4 git commands to generate.