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