Skip to content

Rollup of 8 pull requests #62372

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
bb26e07
Add debug assertions to write_bytes and copy*
nitnelave Feb 27, 2019
0533f12
Handle null from LLVMRustGetSectionName
nitnelave Mar 27, 2019
8a4573f
format a bit
RalfJung Jun 24, 2019
4159b27
order things more traditionally
RalfJung Jun 24, 2019
a68afc5
ignore some codegen tests in debug mode
RalfJung Jun 25, 2019
d3e1bf9
nits
RalfJung Jun 25, 2019
1c6b4d5
rustc: codegen: Build import library for all windows targets
chouquette May 27, 2019
c1b6716
libstd: windows: compat: Allow use of attributes
chouquette May 27, 2019
863cd6b
bootstrap: Build startup object for all windows-gnu target
chouquette May 27, 2019
e5d7043
std: Link UWP with allowed libraries only
chouquette May 27, 2019
98f9bba
libunwind: Use libunwind when targeting UWP
chouquette May 27, 2019
20eb746
std: rand: Use BCrypt on UWP
chouquette May 27, 2019
0f15466
std: win: Don't use SetHandleInformation on UWP
chouquette May 27, 2019
5466e9f
std: win: Don't expose link() on UWP
chouquette May 27, 2019
b514557
std: win: Don't use GetUserProfileDirectoryW on UWP
chouquette May 27, 2019
07d11ae
std: win: Don't use GetFileInformationByHandle on UWP
chouquette May 27, 2019
a7ad699
std: win: Don't use console APIs on UWP
chouquette May 27, 2019
1a0a263
std: win: Disable stack overflow handling on UWP
chouquette May 27, 2019
1726259
Add UWP targets
chouquette May 27, 2019
0ffb643
Make sure `#[rustc_doc_only_macro]` and other rustc attributes are re…
petrochenkov Jun 29, 2019
e4e7eb2
Feature gate `rustc` attributes harder
petrochenkov Jun 30, 2019
069c52f
Check if the archive has already been added to avoid duplicates
petrhosek Jul 2, 2019
ec8c2e1
Use a single CtxtInterners
Zoxc May 31, 2019
de8bf5b
libstd: windows: Use qualified path for cfg_if
chouquette Jul 3, 2019
848962f
libstd: windows: Use cfg_if instead of NIH ifdef macro
chouquette Jul 3, 2019
096a2a2
libstd: windows: Reindent after last change
chouquette Jul 3, 2019
bb7fbb9
Add separate 'async_closure' feature gate.
Centril Jul 2, 2019
43315bc
Adjust tests wrt. 'async_closure' feature gate.
Centril Jul 2, 2019
830ff4a
remove StringReader::peek
matklad Jul 2, 2019
e9dc95c
remove peek_token from StringReader
matklad Jul 2, 2019
256df83
remove peek_span_src_raw from StringReader
matklad Jul 3, 2019
601bad8
cleanup lexer constructors
matklad Jul 3, 2019
30fa99e
move constructors to top
matklad Jul 3, 2019
1c6eb19
slightly comment lexer API
matklad Jul 3, 2019
8bea334
don't rely on spans when checking tokens for jointness
matklad Jul 3, 2019
3035a05
remove unused mk_sp_and_raw
matklad Jul 3, 2019
3e362a4
make unwrap_or_abort non-generic again
matklad Jul 3, 2019
55bd214
Add tracking issue for Box::into_pin
Nemo157 Jul 4, 2019
356a8a7
Rollup merge of #60260 - videolabs:rust_uwp2, r=alexcrichton
Mark-Simulacrum Jul 4, 2019
bfe2925
Rollup merge of #61392 - Zoxc:single-interner, r=eddyb
Mark-Simulacrum Jul 4, 2019
7bae0b7
Rollup merge of #62103 - RalfJung:debug-assert, r=alexcrichton
Mark-Simulacrum Jul 4, 2019
b5246fd
Rollup merge of #62133 - petrochenkov:norustc, r=eddyb
Mark-Simulacrum Jul 4, 2019
30d5f41
Rollup merge of #62286 - petrhosek:rustc-no-duplicate-archives, r=cra…
Mark-Simulacrum Jul 4, 2019
99366a9
Rollup merge of #62292 - Centril:split-async-closures, r=cramertj
Mark-Simulacrum Jul 4, 2019
7854e9e
Rollup merge of #62329 - matklad:no-peeking, r=petrochenkov
Mark-Simulacrum Jul 4, 2019
866233b
Rollup merge of #62371 - Nemo157:fix-62288, r=Centril
Mark-Simulacrum Jul 4, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
std: rand: Use BCrypt on UWP
As Rtl* functions are not allowed there
  • Loading branch information
chouquette committed Jun 25, 2019
commit 20eb746f3d0b32eed95c4c8464e6a16b552eee5b
2 changes: 2 additions & 0 deletions src/libstd/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ fn main() {
println!("cargo:rustc-link-lib=resolv");
} else if target.contains("uwp") {
println!("cargo:rustc-link-lib=ws2_32");
// For BCryptGenRandom
println!("cargo:rustc-link-lib=bcrypt");
} else if target.contains("windows") {
println!("cargo:rustc-link-lib=advapi32");
println!("cargo:rustc-link-lib=ws2_32");
Expand Down
27 changes: 25 additions & 2 deletions src/libstd/sys/windows/c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
#![cfg_attr(test, allow(dead_code))]
#![unstable(issue = "0", feature = "windows_c")]

macro_rules! ifdef {
($($t:tt)*) => ($($t)*)
}

use crate::os::raw::{c_int, c_uint, c_ulong, c_long, c_longlong, c_ushort, c_char};
use crate::ptr;

Expand Down Expand Up @@ -655,6 +659,27 @@ pub struct timeval {
pub tv_usec: c_long,
}

// Functions forbidden when targeting UWP
#[cfg(not(target_vendor = "uwp"))]
ifdef! {
extern "system" {
#[link_name = "SystemFunction036"]
pub fn RtlGenRandom(RandomBuffer: *mut u8, RandomBufferLength: ULONG) -> BOOLEAN;
}
}

// UWP specific functions & types
#[cfg(target_vendor = "uwp")]
ifdef! {
pub const BCRYPT_USE_SYSTEM_PREFERRED_RNG: DWORD = 0x00000002;

extern "system" {
pub fn BCryptGenRandom(hAlgorithm: LPVOID, pBuffer: *mut u8,
cbBuffer: ULONG, dwFlags: ULONG) -> LONG;
}
}

// Shared between Desktop & UWP
extern "system" {
pub fn WSAStartup(wVersionRequested: WORD,
lpWSAData: LPWSADATA) -> c_int;
Expand Down Expand Up @@ -950,8 +975,6 @@ extern "system" {
exceptfds: *mut fd_set,
timeout: *const timeval) -> c_int;

#[link_name = "SystemFunction036"]
pub fn RtlGenRandom(RandomBuffer: *mut u8, RandomBufferLength: ULONG) -> BOOLEAN;

pub fn GetProcessHeap() -> HANDLE;
pub fn HeapAlloc(hHeap: HANDLE, dwFlags: DWORD, dwBytes: SIZE_T) -> LPVOID;
Expand Down
18 changes: 18 additions & 0 deletions src/libstd/sys/windows/rand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use crate::io;
use crate::mem;
use crate::sys::c;

#[cfg(not(target_vendor = "uwp"))]
pub fn hashmap_random_keys() -> (u64, u64) {
let mut v = (0, 0);
let ret = unsafe {
Expand All @@ -14,3 +15,20 @@ pub fn hashmap_random_keys() -> (u64, u64) {
}
return v
}

#[cfg(target_vendor = "uwp")]
pub fn hashmap_random_keys() -> (u64, u64) {
use crate::ptr;

let mut v = (0, 0);
let ret = unsafe {
c::BCryptGenRandom(ptr::null_mut(), &mut v as *mut _ as *mut u8,
mem::size_of_val(&v) as c::ULONG,
c::BCRYPT_USE_SYSTEM_PREFERRED_RNG)
};
if ret != 0 {
panic!("couldn't generate random bytes: {}",
io::Error::last_os_error());
}
return v
}