Skip to content

Commit b33dcdd

Browse files
authored
Enable v0.1 std-trait workaround for additional targets (#169)
1 parent 445e929 commit b33dcdd

File tree

5 files changed

+41
-26
lines changed

5 files changed

+41
-26
lines changed

.travis.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,9 @@ matrix:
145145
- cargo build --target=x86_64-unknown-netbsd
146146
- cargo build --target=x86_64-unknown-redox
147147
- cargo build --target=x86_64-fortanix-unknown-sgx
148-
- cargo xbuild --target=x86_64-unknown-cloudabi
148+
# This builds currently fails with:
149+
# Could not find specification for target "x86_64-unknown-cloudabi"
150+
#- cargo xbuild --target=x86_64-unknown-cloudabi
149151
- cargo xbuild --target=x86_64-unknown-uefi
150152
- cargo xbuild --target=x86_64-unknown-hermit
151153
- cargo xbuild --target=x86_64-unknown-l4re-uclibc
@@ -158,7 +160,7 @@ matrix:
158160
- cargo build --target=x86_64-unknown-netbsd
159161
- cargo build --target=x86_64-unknown-redox
160162
- cargo build --target=x86_64-fortanix-unknown-sgx
161-
- cargo xbuild --target=x86_64-unknown-cloudabi
163+
#- cargo xbuild --target=x86_64-unknown-cloudabi
162164
- cargo xbuild --target=x86_64-unknown-uefi
163165
- cargo xbuild --target=x86_64-unknown-hermit
164166
- cargo xbuild --target=x86_64-unknown-l4re-uclibc
@@ -229,3 +231,4 @@ notifications:
229231
branches:
230232
only:
231233
- master
234+
- 0.1

appveyor.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,4 @@ test_script:
5050
branches:
5151
only:
5252
- master
53+
- 0.1

src/lib.rs

Lines changed: 33 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -158,75 +158,85 @@ cfg_if! {
158158
mod error;
159159
pub use crate::error::Error;
160160

161-
#[allow(dead_code)]
162161
mod util;
163162

164-
#[cfg(target_os = "vxworks")]
165-
#[allow(dead_code)]
166-
mod util_libc;
167-
168-
cfg_if! {
169-
// Unlike the other Unix, Fuchsia and iOS don't use the libc to make any calls.
170-
if #[cfg(any(target_os = "android", target_os = "dragonfly", target_os = "emscripten",
171-
target_os = "freebsd", target_os = "haiku", target_os = "illumos",
172-
target_os = "linux", target_os = "macos", target_os = "netbsd",
173-
target_os = "openbsd", target_os = "redox", target_os = "solaris"))] {
174-
#[allow(dead_code)]
175-
mod util_libc;
176-
// Keep std-only trait definitions for backwards compatibility
177-
mod error_impls;
178-
} else if #[cfg(feature = "std")] {
179-
mod error_impls;
180-
}
181-
}
182-
183-
// These targets read from a file as a fallback method.
163+
// For backwards compatibility, we provide the std-only trait implementations
164+
// for some platforms, even if they don't enable the "std" feature.
184165
#[cfg(any(
166+
feature = "std",
167+
all(windows, not(getrandom_uwp)),
185168
target_os = "android",
169+
target_os = "dragonfly",
170+
target_os = "emscripten",
171+
target_os = "freebsd",
172+
target_os = "fuchsia",
173+
target_os = "haiku",
174+
target_os = "illumos",
175+
target_os = "ios",
186176
target_os = "linux",
187177
target_os = "macos",
178+
target_os = "netbsd",
179+
target_os = "openbsd",
180+
target_os = "redox",
188181
target_os = "solaris",
189-
target_os = "illumos",
190182
))]
191-
mod use_file;
183+
mod error_impls;
192184

193185
// System-specific implementations.
194186
//
195187
// These should all provide getrandom_inner with the same signature as getrandom.
196188
cfg_if! {
197189
if #[cfg(target_os = "android")] {
190+
mod util_libc;
191+
mod use_file;
198192
#[path = "linux_android.rs"] mod imp;
199193
} else if #[cfg(target_os = "cloudabi")] {
200194
#[path = "cloudabi.rs"] mod imp;
201195
} else if #[cfg(target_os = "dragonfly")] {
196+
mod util_libc;
202197
#[path = "use_file.rs"] mod imp;
203198
} else if #[cfg(target_os = "emscripten")] {
199+
mod util_libc;
204200
#[path = "use_file.rs"] mod imp;
205201
} else if #[cfg(target_os = "freebsd")] {
202+
mod util_libc;
206203
#[path = "bsd_arandom.rs"] mod imp;
207204
} else if #[cfg(target_os = "fuchsia")] {
208205
#[path = "fuchsia.rs"] mod imp;
209206
} else if #[cfg(target_os = "haiku")] {
207+
mod util_libc;
210208
#[path = "use_file.rs"] mod imp;
211209
} else if #[cfg(target_os = "illumos")] {
210+
mod util_libc;
211+
mod use_file;
212212
#[path = "solaris_illumos.rs"] mod imp;
213213
} else if #[cfg(target_os = "ios")] {
214214
#[path = "ios.rs"] mod imp;
215215
} else if #[cfg(target_os = "linux")] {
216+
mod util_libc;
217+
mod use_file;
216218
#[path = "linux_android.rs"] mod imp;
217219
} else if #[cfg(target_os = "macos")] {
220+
mod util_libc;
221+
mod use_file;
218222
#[path = "macos.rs"] mod imp;
219223
} else if #[cfg(target_os = "netbsd")] {
224+
mod util_libc;
220225
#[path = "bsd_arandom.rs"] mod imp;
221226
} else if #[cfg(target_os = "openbsd")] {
227+
mod util_libc;
222228
#[path = "openbsd.rs"] mod imp;
223229
} else if #[cfg(target_os = "redox")] {
230+
mod util_libc;
224231
#[path = "use_file.rs"] mod imp;
225232
} else if #[cfg(target_os = "solaris")] {
233+
mod util_libc;
234+
mod use_file;
226235
#[path = "solaris_illumos.rs"] mod imp;
227236
} else if #[cfg(target_os = "wasi")] {
228237
#[path = "wasi.rs"] mod imp;
229238
} else if #[cfg(target_os = "vxworks")] {
239+
mod util_libc;
230240
#[path = "vxworks.rs"] mod imp;
231241
} else if #[cfg(all(windows, getrandom_uwp))] {
232242
#[path = "windows_uwp.rs"] mod imp;

src/util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
66
// option. This file may not be copied, modified, or distributed
77
// except according to those terms.
8-
8+
#![allow(dead_code)]
99
use core::sync::atomic::{AtomicUsize, Ordering::Relaxed};
1010

1111
// This structure represents a lazily initialized static usize value. Useful

src/util_libc.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
66
// option. This file may not be copied, modified, or distributed
77
// except according to those terms.
8+
#![allow(dead_code)]
89
use crate::error::ERRNO_NOT_POSITIVE;
910
use crate::util::LazyUsize;
1011
use crate::Error;

0 commit comments

Comments
 (0)