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