libloading/os/unix/
consts.rs1use 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 = "freebsd",
73 target_os = "dragonfly",
74 target_os = "openbsd",
75 target_os = "netbsd",
76
77 target_os = "solaris",
78 target_os = "illumos",
79
80 target_env = "uclibc",
81 target_env = "newlib",
82
83 target_os = "fuchsia",
84 target_os = "redox",
85 ))] {
86 pub(super) const RTLD_LAZY: c_int = 1;
87 } else {
88 compile_error!(
89 "Target has no known `RTLD_LAZY` value. Please submit an issue or PR adding it."
90 );
91 }
92 }
93
94 cfg_if! {
95 if #[cfg(target_os = "haiku")] {
96 pub(super) const RTLD_NOW: c_int = 1;
97 } else if #[cfg(any(
98 target_os = "linux",
99 all(target_os = "android", target_pointer_width = "64"),
100 target_os = "emscripten",
101
102 target_os = "macos",
103 target_os = "ios",
104 target_os = "freebsd",
105 target_os = "dragonfly",
106 target_os = "openbsd",
107 target_os = "netbsd",
108
109 target_os = "aix",
110 target_os = "solaris",
111 target_os = "illumos",
112
113 target_env = "uclibc",
114 target_env = "newlib",
115
116 target_os = "fuchsia",
117 target_os = "redox",
118 ))] {
119 pub(super) const RTLD_NOW: c_int = 2;
120 } else if #[cfg(all(target_os = "android",target_pointer_width = "32"))] {
121 pub(super) const RTLD_NOW: c_int = 0;
122 } else {
123 compile_error!(
124 "Target has no known `RTLD_NOW` value. Please submit an issue or PR adding it."
125 );
126 }
127 }
128
129 cfg_if! {
130 if #[cfg(any(
131 target_os = "haiku",
132 all(target_os = "android",target_pointer_width = "32"),
133 ))] {
134 pub(super) const RTLD_GLOBAL: c_int = 2;
135 } else if #[cfg(target_os = "aix")] {
136 pub(super) const RTLD_GLOBAL: c_int = 0x10000;
137 } else if #[cfg(any(
138 target_env = "uclibc",
139 all(target_os = "linux", target_arch = "mips"),
140 all(target_os = "linux", target_arch = "mips64"),
141 ))] {
142 pub(super) const RTLD_GLOBAL: c_int = 4;
143 } else if #[cfg(any(
144 target_os = "macos",
145 target_os = "ios",
146 ))] {
147 pub(super) const RTLD_GLOBAL: c_int = 8;
148 } else if #[cfg(any(
149 target_os = "linux",
150 all(target_os = "android", target_pointer_width = "64"),
151 target_os = "emscripten",
152
153 target_os = "freebsd",
154 target_os = "dragonfly",
155 target_os = "openbsd",
156 target_os = "netbsd",
157
158 target_os = "solaris",
159 target_os = "illumos",
160
161 target_env = "newlib",
162
163 target_os = "fuchsia",
164 target_os = "redox",
165 ))] {
166 pub(super) const RTLD_GLOBAL: c_int = 0x100;
167 } else {
168 compile_error!(
169 "Target has no known `RTLD_GLOBAL` value. Please submit an issue or PR adding it."
170 );
171 }
172 }
173
174 cfg_if! {
175 if #[cfg(target_os = "netbsd")] {
176 pub(super) const RTLD_LOCAL: c_int = 0x200;
177 } else if #[cfg(target_os = "aix")] {
178 pub(super) const RTLD_LOCAL: c_int = 0x80000;
179 } else if #[cfg(any(
180 target_os = "macos",
181 target_os = "ios",
182 ))] {
183 pub(super) const RTLD_LOCAL: c_int = 4;
184 } else if #[cfg(any(
185 target_os = "linux",
186 target_os = "android",
187 target_os = "emscripten",
188
189 target_os = "freebsd",
190 target_os = "dragonfly",
191 target_os = "openbsd",
192
193 target_os = "haiku",
194
195 target_os = "solaris",
196 target_os = "illumos",
197
198 target_env = "uclibc",
199 target_env = "newlib",
200
201 target_os = "fuchsia",
202 target_os = "redox",
203 ))] {
204 pub(super) const RTLD_LOCAL: c_int = 0;
205 } else {
206 compile_error!(
207 "Target has no known `RTLD_LOCAL` value. Please submit an issue or PR adding it."
208 );
209 }
210 }
211}
212
213