Blender V4.3
wayland_dynload_client.c
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2022 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
11#include <stdlib.h> /* `atexit`. */
12#include <string.h>
13
14#include "wayland_dynload_API.h"
16
17#include "wayland_dynload_client.h" /* Own include. */
18
19/* Public handle. */
21
23
24#define WAYLAND_DYNLOAD_IFACE(symbol) \
25 extern struct wl_interface symbol; \
26 struct wl_interface symbol;
28#undef WAYLAND_DYNLOAD_IFACE
29
31{
32 /* Library paths. */
33 const char *paths[] = {
34 "libwayland-client.so.0",
35 "libwayland-client.so",
36 };
37 const int paths_num = sizeof(paths) / sizeof(*paths);
38 int path_found;
39 if (!(lib = dynamic_library_open_array_with_error(paths, paths_num, verbose, &path_found))) {
40 return false;
41 }
42 if (atexit(wayland_dynload_client_exit)) {
43 return false;
44 }
45
46#define WAYLAND_DYNLOAD_IFACE(symbol) \
47 { \
48 const void *symbol_val; \
49 if (!(symbol_val = dynamic_library_find_with_error( \
50 lib, #symbol, paths[path_found], verbose))) { \
51 return false; \
52 } \
53 memcpy(&symbol, symbol_val, sizeof(symbol)); \
54 }
56#undef WAYLAND_DYNLOAD_IFACE
57
58#define WAYLAND_DYNLOAD_FN(symbol) \
59 if (!(wayland_dynload_client.symbol = dynamic_library_find_with_error( \
60 lib, #symbol, paths[path_found], verbose))) \
61 { \
62 return false; \
63 }
65#undef WAYLAND_DYNLOAD_FN
66
67 return true;
68}
69
71{
72 if (lib != NULL) {
73 dynamic_library_close(lib); /* Ignore errors. */
74 lib = NULL;
75 }
76}
77
78/* Validate local signatures against the original header. */
79#pragma GCC diagnostic push
80#pragma GCC diagnostic ignored "-Wredundant-decls"
81#define WAYLAND_DYNLOAD_VALIDATE
83#pragma GCC diagnostic pop
static int verbose
Definition cineonlib.cc:31
#define NULL
void wayland_dynload_client_exit(void)
static DynamicLibrary lib
bool wayland_dynload_client_init(const bool verbose)
struct WaylandDynload_Client wayland_dynload_client
DynamicLibrary dynamic_library_open_array_with_error(const char **paths, const int paths_num, const bool verbose, int *r_path_index)
#define dynamic_library_close(lib)