Blender V5.3
wayland_dynload_egl.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
10
11#include <stdlib.h> /* `atexit`. */
12
13#include "wayland_dynload_API.h"
15
16#include "wayland_dynload_egl.h" /* Own include. */
17
18/* Public handle. */
20
21static DynamicLibrary lib = NULL;
22
23bool wayland_dynload_egl_init(const bool verbose)
24{
25 /* NOTE: returning false must call exit to prevent leaking `lib`
26 * once it has been opened. */
27
28 /* Library paths. */
29 const char *paths[] = {
30 "libwayland-egl.so.1",
31 "libwayland-egl.so",
32 };
33 const int paths_num = sizeof(paths) / sizeof(*paths);
34 int path_found = 0;
35 if (!(lib = dynamic_library_open_array_with_error(paths, paths_num, verbose, &path_found))) {
36 return false;
37 }
38 if (atexit(wayland_dynload_egl_exit)) {
40 return false;
41 }
42
43#define WAYLAND_DYNLOAD_FN(symbol) \
44 if (!(wayland_dynload_egl.symbol = dynamic_library_find_with_error( \
45 lib, #symbol, paths[path_found], verbose))) \
46 { \
47 wayland_dynload_egl_exit(); \
48 return false; \
49 }
50#include "wayland_dynload_egl.h"
51#undef WAYLAND_DYNLOAD_FN
52
53 return true;
54}
55
57{
58 if (lib != NULL) {
59 dynamic_library_close(lib); /* Ignore errors. */
60 lib = NULL;
61 }
62}
63
64/* Validate local signatures against the original header. */
65#pragma GCC diagnostic push
66#pragma GCC diagnostic ignored "-Wredundant-decls"
67#define WAYLAND_DYNLOAD_VALIDATE
68#include "wayland_dynload_egl.h"
69#pragma GCC diagnostic pop
static DynamicLibrary lib
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)
void * DynamicLibrary
void wayland_dynload_egl_exit(void)
struct WaylandDynload_EGL wayland_dynload_egl