1use core::ffi::c_int;
2
3pub const RTLD_LAZY: c_int = posix::RTLD_LAZY;
16
17pub const RTLD_NOW: c_int = posix::RTLD_NOW;
29
30pub const RTLD_GLOBAL: c_int = posix::RTLD_GLOBAL;
39
40pub const RTLD_LOCAL: c_int = posix::RTLD_LOCAL;
45
46#[cfg(all(libloading_docs, not(unix)))]
47mod posix {
48 use super::c_int;
49 pub(super) const RTLD_LAZY: c_int = !0;
50 pub(super) const RTLD_NOW: c_int = !0;
51 pub(super) const RTLD_GLOBAL: c_int = !0;
52 pub(super) const RTLD_LOCAL: c_int = !0;
53}
54
55#[cfg(any(not(libloading_docs), unix))]
56mod posix {
57 use cfg_if::cfg_if;
58 use super::c_int;
59 cfg_if! {
60 if #[cfg(target_os = "haiku")] {
61 pub(super) const RTLD_LAZY: c_int = 0;
62 } else if #[cfg(target_os = "aix")] {
63 pub(super) const RTLD_LAZY: c_int = 4;
64 } else if #[cfg(any(
65 target_os = "linux",
66 target_os = "android",
67 target_os = "emscripten",
68
69 target_os = "macos",
70 target_os = "ios",
71 target_os = "tvos",
72 target_os = "visionos",
73 target_os = "watchos",
74
75 target_os = "freebsd",
76 target_os = "dragonfly",
77 target_os = "openbsd",
78 target_os = "netbsd",
79
80 target_os = "solaris",
81 target_os = "illumos",
82
83 target_env = "uclibc",
84 target_env = "newlib",
85
86 target_os = "fuchsia",
87 target_os = "redox",
88 target_os = "nto",
89 target_os = "hurd",
90 target_os = "cygwin",
91 ))] {
92 pub(super) const RTLD_LAZY: c_int = 1;
93 } else {
94 compile_error!(
95 "Target has no known `RTLD_LAZY` value. Please submit an issue or PR adding it."
96 );
97 }
98 }
99
100 cfg_if! {
101 if #[cfg(target_os = "haiku")] {
102 pub(super) const RTLD_NOW: c_int = 1;
103 } else if #[cfg(any(
104 target_os = "linux",
105 all(target_os = "android", target_pointer_width = "64"),
106 target_os = "emscripten",
107
108 target_os = "macos",
109 target_os = "ios",
110 target_os = "tvos",
111 target_os = "visionos",
112 target_os = "watchos",
113
114 target_os = "freebsd",
115 target_os = "dragonfly",
116 target_os = "openbsd",
117 target_os = "netbsd",
118
119 target_os = "aix",
120 target_os = "solaris",
121 target_os = "illumos",
122
123 target_env = "uclibc",
124 target_env = "newlib",
125
126 target_os = "fuchsia",
127 target_os = "redox",
128 target_os = "nto",
129 target_os = "hurd",
130 target_os = "cygwin",
131 ))] {
132 pub(super) const RTLD_NOW: c_int = 2;
133 } else if #[cfg(all(target_os = "android",target_pointer_width = "32"))] {
134 pub(super) const RTLD_NOW: c_int = 0;
135 } else {
136 compile_error!(
137 "Target has no known `RTLD_NOW` value. Please submit an issue or PR adding it."
138 );
139 }
140 }
141
142 cfg_if! {
143 if #[cfg(any(
144 target_os = "haiku",
145 all(target_os = "android",target_pointer_width = "32"),
146 ))] {
147 pub(super) const RTLD_GLOBAL: c_int = 2;
148 } else if #[cfg(target_os = "aix")] {
149 pub(super) const RTLD_GLOBAL: c_int = 0x10000;
150 } else if #[cfg(any(
151 target_env = "uclibc",
152 all(target_os = "linux", target_arch = "mips"),
153 all(target_os = "linux", target_arch = "mips64"),
154 target_os = "cygwin",
155 ))] {
156 pub(super) const RTLD_GLOBAL: c_int = 4;
157 } else if #[cfg(any(
158 target_os = "macos",
159 target_os = "ios",
160 target_os = "tvos",
161 target_os = "visionos",
162 target_os = "watchos",
163 ))] {
164 pub(super) const RTLD_GLOBAL: c_int = 8;
165 } else if #[cfg(any(
166 target_os = "linux",
167 all(target_os = "android", target_pointer_width = "64"),
168 target_os = "emscripten",
169
170 target_os = "freebsd",
171 target_os = "dragonfly",
172 target_os = "openbsd",
173 target_os = "netbsd",
174
175 target_os = "solaris",
176 target_os = "illumos",
177
178 target_env = "newlib",
179
180 target_os = "fuchsia",
181 target_os = "redox",
182 target_os = "nto",
183 target_os = "hurd",
184 ))] {
185 pub(super) const RTLD_GLOBAL: c_int = 0x100;
186 } else {
187 compile_error!(
188 "Target has no known `RTLD_GLOBAL` value. Please submit an issue or PR adding it."
189 );
190 }
191 }
192
193 cfg_if! {
194 if #[cfg(any(
195 target_os = "netbsd",
196 target_os = "nto",
197 ))] {
198 pub(super) const RTLD_LOCAL: c_int = 0x200;
199 } else if #[cfg(target_os = "aix")] {
200 pub(super) const RTLD_LOCAL: c_int = 0x80000;
201 } else if #[cfg(any(
202 target_os = "macos",
203 target_os = "ios",
204 target_os = "tvos",
205 target_os = "visionos",
206 target_os = "watchos",
207 ))] {
208 pub(super) const RTLD_LOCAL: c_int = 4;
209 } else if #[cfg(any(
210 target_os = "linux",
211 target_os = "android",
212 target_os = "emscripten",
213
214 target_os = "freebsd",
215 target_os = "dragonfly",
216 target_os = "openbsd",
217
218 target_os = "haiku",
219
220 target_os = "solaris",
221 target_os = "illumos",
222
223 target_env = "uclibc",
224 target_env = "newlib",
225
226 target_os = "fuchsia",
227 target_os = "redox",
228 target_os = "hurd",
229 target_os = "cygwin",
230 ))] {
231 pub(super) const RTLD_LOCAL: c_int = 0;
232 } else {
233 compile_error!(
234 "Target has no known `RTLD_LOCAL` value. Please submit an issue or PR adding it."
235 );
236 }
237 }
238}
239
240