authorbors <bors@rust-lang.org> 2024-07-05 11:32:40 UTC
committerbors <bors@rust-lang.org> 2024-07-05 11:32:40 UTC
log11dd90f7613a4b160ed8398a3f1c7c129ad1a372
tree81cfa92ddffd6bfd8e36eac442c62085216ee7aa
parent2ad66306738f8fb4b88f7ac19f3a80491ce28e29
parent4fd3b123bc4c25833d2270a428c1ba05e807af09

Auto merge of #127360 - GuillaumeGomez:rollup-f0zs1qr, r=GuillaumeGomez

Rollup of 7 pull requests Successful merges: - #124290 (DependencyList: removed outdated comment) - #126709 (Migrate `include_bytes_deps`, `optimization-remarks-dir-pgo`, `optimization-remarks-dir`, `issue-40535` and `rmeta-preferred` `run-make` tests to rmake) - #127214 (Use the native unwind function in miri where possible) - #127320 (Update windows-bindgen to 0.58.0) - #127349 (Tweak `-1 as usize` suggestion) - #127352 (coverage: Rename `mir::coverage::BranchInfo` to `CoverageInfoHi`) - #127359 (Improve run make llvm ident code) r? `@ghost` `@rustbot` modify labels: rollup

51 files changed, 532 insertions(+), 1079 deletions(-)

Cargo.lock+4-4
......@@ -6356,9 +6356,9 @@ dependencies = [
63566356
63576357[[package]]
63586358name = "windows-bindgen"
6359version = "0.57.0"
6359version = "0.58.0"
63606360source = "registry+https://github.com/rust-lang/crates.io-index"
6361checksum = "1ccb96113d6277ba543c0f77e1c5494af8094bf9daf9b85acdc3f1b620e7c7b4"
6361checksum = "91cd28d93c692351f3a6e5615567c56756e330bee1c99c6bdd57bfc5ab15f589"
63626362dependencies = [
63636363 "proc-macro2",
63646364 "rayon",
......@@ -6379,9 +6379,9 @@ dependencies = [
63796379
63806380[[package]]
63816381name = "windows-metadata"
6382version = "0.57.0"
6382version = "0.58.0"
63836383source = "registry+https://github.com/rust-lang/crates.io-index"
6384checksum = "8308d076825b9d9e5abc64f8113e96d02b2aeeba869b20fdd65c7e70cda13dfc"
6384checksum = "2e837f3c3012cfe9e7086302a93f441a7999439be1ad4c530d55d2f6d2921809"
63856385
63866386[[package]]
63876387name = "windows-sys"
compiler/rustc_hir_typeck/src/op.rs+11-2
......@@ -838,8 +838,17 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
838838 },
839839 ) = ex.kind
840840 {
841 err.span_suggestion(
842 ex.span,
841 let span = if let hir::Node::Expr(parent) =
842 self.tcx.parent_hir_node(ex.hir_id)
843 && let hir::ExprKind::Cast(..) = parent.kind
844 {
845 // `-1 as usize` -> `usize::MAX`
846 parent.span
847 } else {
848 ex.span
849 };
850 err.span_suggestion_verbose(
851 span,
843852 format!(
844853 "you may have meant the maximum value of `{actual}`",
845854 ),
compiler/rustc_middle/src/middle/dependency_format.rs+3-3
......@@ -4,15 +4,15 @@
44//! For all the gory details, see the provider of the `dependency_formats`
55//! query.
66
7// FIXME: move this file to rustc_metadata::dependency_format, but
8// this will introduce circular dependency between rustc_metadata and rustc_middle
9
710use rustc_macros::{Decodable, Encodable, HashStable};
811use rustc_session::config::CrateType;
912
1013/// A list of dependencies for a certain crate type.
1114///
1215/// The length of this vector is the same as the number of external crates used.
13/// The value is None if the crate does not need to be linked (it was found
14/// statically in another dylib), or Some(kind) if it needs to be linked as
15/// `kind` (either static or dynamic).
1616pub type DependencyList = Vec<Linkage>;
1717
1818/// A mapping of all required dependencies for a particular flavor of output.
compiler/rustc_middle/src/mir/coverage.rs+8-3
......@@ -103,7 +103,7 @@ pub enum CoverageKind {
103103 SpanMarker,
104104
105105 /// Marks its enclosing basic block with an ID that can be referred to by
106 /// side data in [`BranchInfo`].
106 /// side data in [`CoverageInfoHi`].
107107 ///
108108 /// Should be erased before codegen (at some point after `InstrumentCoverage`).
109109 BlockMarker { id: BlockMarkerId },
......@@ -274,10 +274,15 @@ pub struct FunctionCoverageInfo {
274274 pub mcdc_num_condition_bitmaps: usize,
275275}
276276
277/// Branch information recorded during THIR-to-MIR lowering, and stored in MIR.
277/// Coverage information for a function, recorded during MIR building and
278/// attached to the corresponding `mir::Body`. Used by the `InstrumentCoverage`
279/// MIR pass.
280///
281/// ("Hi" indicates that this is "high-level" information collected at the
282/// THIR/MIR boundary, before the MIR-based coverage instrumentation pass.)
278283#[derive(Clone, Debug)]
279284#[derive(TyEncodable, TyDecodable, Hash, HashStable, TypeFoldable, TypeVisitable)]
280pub struct BranchInfo {
285pub struct CoverageInfoHi {
281286 /// 1 more than the highest-numbered [`CoverageKind::BlockMarker`] that was
282287 /// injected into the MIR body. This makes it possible to allocate per-ID
283288 /// data structures without having to scan the entire body first.
compiler/rustc_middle/src/mir/mod.rs+7-6
......@@ -430,11 +430,12 @@ pub struct Body<'tcx> {
430430
431431 pub tainted_by_errors: Option<ErrorGuaranteed>,
432432
433 /// Branch coverage information collected during MIR building, to be used by
434 /// the `InstrumentCoverage` pass.
433 /// Coverage information collected from THIR/MIR during MIR building,
434 /// to be used by the `InstrumentCoverage` pass.
435435 ///
436 /// Only present if branch coverage is enabled and this function is eligible.
437 pub coverage_branch_info: Option<Box<coverage::BranchInfo>>,
436 /// Only present if coverage is enabled and this function is eligible.
437 /// Boxed to limit space overhead in non-coverage builds.
438 pub coverage_info_hi: Option<Box<coverage::CoverageInfoHi>>,
438439
439440 /// Per-function coverage information added by the `InstrumentCoverage`
440441 /// pass, to be used in conjunction with the coverage statements injected
......@@ -484,7 +485,7 @@ impl<'tcx> Body<'tcx> {
484485 is_polymorphic: false,
485486 injection_phase: None,
486487 tainted_by_errors,
487 coverage_branch_info: None,
488 coverage_info_hi: None,
488489 function_coverage_info: None,
489490 };
490491 body.is_polymorphic = body.has_non_region_param();
......@@ -515,7 +516,7 @@ impl<'tcx> Body<'tcx> {
515516 is_polymorphic: false,
516517 injection_phase: None,
517518 tainted_by_errors: None,
518 coverage_branch_info: None,
519 coverage_info_hi: None,
519520 function_coverage_info: None,
520521 };
521522 body.is_polymorphic = body.has_non_region_param();
compiler/rustc_middle/src/mir/pretty.rs+17-8
......@@ -473,8 +473,8 @@ pub fn write_mir_intro<'tcx>(
473473 // Add an empty line before the first block is printed.
474474 writeln!(w)?;
475475
476 if let Some(branch_info) = &body.coverage_branch_info {
477 write_coverage_branch_info(branch_info, w)?;
476 if let Some(coverage_info_hi) = &body.coverage_info_hi {
477 write_coverage_info_hi(coverage_info_hi, w)?;
478478 }
479479 if let Some(function_coverage_info) = &body.function_coverage_info {
480480 write_function_coverage_info(function_coverage_info, w)?;
......@@ -483,18 +483,26 @@ pub fn write_mir_intro<'tcx>(
483483 Ok(())
484484}
485485
486fn write_coverage_branch_info(
487 branch_info: &coverage::BranchInfo,
486fn write_coverage_info_hi(
487 coverage_info_hi: &coverage::CoverageInfoHi,
488488 w: &mut dyn io::Write,
489489) -> io::Result<()> {
490 let coverage::BranchInfo { branch_spans, mcdc_branch_spans, mcdc_decision_spans, .. } =
491 branch_info;
490 let coverage::CoverageInfoHi {
491 num_block_markers: _,
492 branch_spans,
493 mcdc_branch_spans,
494 mcdc_decision_spans,
495 } = coverage_info_hi;
496
497 // Only add an extra trailing newline if we printed at least one thing.
498 let mut did_print = false;
492499
493500 for coverage::BranchSpan { span, true_marker, false_marker } in branch_spans {
494501 writeln!(
495502 w,
496503 "{INDENT}coverage branch {{ true: {true_marker:?}, false: {false_marker:?} }} => {span:?}",
497504 )?;
505 did_print = true;
498506 }
499507
500508 for coverage::MCDCBranchSpan {
......@@ -510,6 +518,7 @@ fn write_coverage_branch_info(
510518 "{INDENT}coverage mcdc branch {{ condition_id: {:?}, true: {true_marker:?}, false: {false_marker:?}, depth: {decision_depth:?} }} => {span:?}",
511519 condition_info.map(|info| info.condition_id)
512520 )?;
521 did_print = true;
513522 }
514523
515524 for coverage::MCDCDecisionSpan { span, num_conditions, end_markers, decision_depth } in
......@@ -519,10 +528,10 @@ fn write_coverage_branch_info(
519528 w,
520529 "{INDENT}coverage mcdc decision {{ num_conditions: {num_conditions:?}, end: {end_markers:?}, depth: {decision_depth:?} }} => {span:?}"
521530 )?;
531 did_print = true;
522532 }
523533
524 if !branch_spans.is_empty() || !mcdc_branch_spans.is_empty() || !mcdc_decision_spans.is_empty()
525 {
534 if did_print {
526535 writeln!(w)?;
527536 }
528537
compiler/rustc_mir_build/src/build/coverageinfo.rs+60-47
......@@ -2,7 +2,7 @@ use std::assert_matches::assert_matches;
22use std::collections::hash_map::Entry;
33
44use rustc_data_structures::fx::FxHashMap;
5use rustc_middle::mir::coverage::{BlockMarkerId, BranchSpan, CoverageKind};
5use rustc_middle::mir::coverage::{BlockMarkerId, BranchSpan, CoverageInfoHi, CoverageKind};
66use rustc_middle::mir::{self, BasicBlock, SourceInfo, UnOp};
77use rustc_middle::thir::{ExprId, ExprKind, Pat, Thir};
88use rustc_middle::ty::TyCtxt;
......@@ -13,16 +13,25 @@ use crate::build::{Builder, CFG};
1313
1414mod mcdc;
1515
16pub(crate) struct BranchInfoBuilder {
16/// Collects coverage-related information during MIR building, to eventually be
17/// turned into a function's [`CoverageInfoHi`] when MIR building is complete.
18pub(crate) struct CoverageInfoBuilder {
1719 /// Maps condition expressions to their enclosing `!`, for better instrumentation.
1820 nots: FxHashMap<ExprId, NotInfo>,
1921
2022 markers: BlockMarkerGen,
21 branch_spans: Vec<BranchSpan>,
2223
24 /// Present if branch coverage is enabled.
25 branch_info: Option<BranchInfo>,
26 /// Present if MC/DC coverage is enabled.
2327 mcdc_info: Option<MCDCInfoBuilder>,
2428}
2529
30#[derive(Default)]
31struct BranchInfo {
32 branch_spans: Vec<BranchSpan>,
33}
34
2635#[derive(Clone, Copy)]
2736struct NotInfo {
2837 /// When visiting the associated expression as a branch condition, treat this
......@@ -62,20 +71,20 @@ impl BlockMarkerGen {
6271 }
6372}
6473
65impl BranchInfoBuilder {
66 /// Creates a new branch info builder, but only if branch coverage instrumentation
74impl CoverageInfoBuilder {
75 /// Creates a new coverage info builder, but only if coverage instrumentation
6776 /// is enabled and `def_id` represents a function that is eligible for coverage.
6877 pub(crate) fn new_if_enabled(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Option<Self> {
69 if tcx.sess.instrument_coverage_branch() && tcx.is_eligible_for_coverage(def_id) {
70 Some(Self {
71 nots: FxHashMap::default(),
72 markers: BlockMarkerGen::default(),
73 branch_spans: vec![],
74 mcdc_info: tcx.sess.instrument_coverage_mcdc().then(MCDCInfoBuilder::new),
75 })
76 } else {
77 None
78 if !tcx.sess.instrument_coverage() || !tcx.is_eligible_for_coverage(def_id) {
79 return None;
7880 }
81
82 Some(Self {
83 nots: FxHashMap::default(),
84 markers: BlockMarkerGen::default(),
85 branch_info: tcx.sess.instrument_coverage_branch().then(BranchInfo::default),
86 mcdc_info: tcx.sess.instrument_coverage_mcdc().then(MCDCInfoBuilder::new),
87 })
7988 }
8089
8190 /// Unary `!` expressions inside an `if` condition are lowered by lowering
......@@ -88,6 +97,12 @@ impl BranchInfoBuilder {
8897 pub(crate) fn visit_unary_not(&mut self, thir: &Thir<'_>, unary_not: ExprId) {
8998 assert_matches!(thir[unary_not].kind, ExprKind::Unary { op: UnOp::Not, .. });
9099
100 // The information collected by this visitor is only needed when branch
101 // coverage or higher is enabled.
102 if self.branch_info.is_none() {
103 return;
104 }
105
91106 self.visit_with_not_info(
92107 thir,
93108 unary_not,
......@@ -137,40 +152,40 @@ impl BranchInfoBuilder {
137152 false_block,
138153 inject_block_marker,
139154 );
140 } else {
141 let true_marker = self.markers.inject_block_marker(cfg, source_info, true_block);
142 let false_marker = self.markers.inject_block_marker(cfg, source_info, false_block);
143
144 self.branch_spans.push(BranchSpan {
145 span: source_info.span,
146 true_marker,
147 false_marker,
148 });
155 return;
149156 }
157
158 // Bail out if branch coverage is not enabled.
159 let Some(branch_info) = self.branch_info.as_mut() else { return };
160
161 let true_marker = self.markers.inject_block_marker(cfg, source_info, true_block);
162 let false_marker = self.markers.inject_block_marker(cfg, source_info, false_block);
163
164 branch_info.branch_spans.push(BranchSpan {
165 span: source_info.span,
166 true_marker,
167 false_marker,
168 });
150169 }
151170
152 pub(crate) fn into_done(self) -> Option<Box<mir::coverage::BranchInfo>> {
153 let Self {
154 nots: _,
155 markers: BlockMarkerGen { num_block_markers },
156 branch_spans,
157 mcdc_info,
158 } = self;
171 pub(crate) fn into_done(self) -> Box<CoverageInfoHi> {
172 let Self { nots: _, markers: BlockMarkerGen { num_block_markers }, branch_info, mcdc_info } =
173 self;
159174
160 if num_block_markers == 0 {
161 assert!(branch_spans.is_empty());
162 return None;
163 }
175 let branch_spans =
176 branch_info.map(|branch_info| branch_info.branch_spans).unwrap_or_default();
164177
165178 let (mcdc_decision_spans, mcdc_branch_spans) =
166179 mcdc_info.map(MCDCInfoBuilder::into_done).unwrap_or_default();
167180
168 Some(Box::new(mir::coverage::BranchInfo {
181 // For simplicity, always return an info struct (without Option), even
182 // if there's nothing interesting in it.
183 Box::new(CoverageInfoHi {
169184 num_block_markers,
170185 branch_spans,
171186 mcdc_branch_spans,
172187 mcdc_decision_spans,
173 }))
188 })
174189 }
175190}
176191
......@@ -184,7 +199,7 @@ impl<'tcx> Builder<'_, 'tcx> {
184199 block: &mut BasicBlock,
185200 ) {
186201 // Bail out if condition coverage is not enabled for this function.
187 let Some(branch_info) = self.coverage_branch_info.as_mut() else { return };
202 let Some(coverage_info) = self.coverage_info.as_mut() else { return };
188203 if !self.tcx.sess.instrument_coverage_condition() {
189204 return;
190205 };
......@@ -224,7 +239,7 @@ impl<'tcx> Builder<'_, 'tcx> {
224239 );
225240
226241 // Separate path for handling branches when MC/DC is enabled.
227 branch_info.register_two_way_branch(
242 coverage_info.register_two_way_branch(
228243 self.tcx,
229244 &mut self.cfg,
230245 source_info,
......@@ -247,12 +262,12 @@ impl<'tcx> Builder<'_, 'tcx> {
247262 mut then_block: BasicBlock,
248263 mut else_block: BasicBlock,
249264 ) {
250 // Bail out if branch coverage is not enabled for this function.
251 let Some(branch_info) = self.coverage_branch_info.as_mut() else { return };
265 // Bail out if coverage is not enabled for this function.
266 let Some(coverage_info) = self.coverage_info.as_mut() else { return };
252267
253268 // If this condition expression is nested within one or more `!` expressions,
254269 // replace it with the enclosing `!` collected by `visit_unary_not`.
255 if let Some(&NotInfo { enclosing_not, is_flipped }) = branch_info.nots.get(&expr_id) {
270 if let Some(&NotInfo { enclosing_not, is_flipped }) = coverage_info.nots.get(&expr_id) {
256271 expr_id = enclosing_not;
257272 if is_flipped {
258273 std::mem::swap(&mut then_block, &mut else_block);
......@@ -261,7 +276,7 @@ impl<'tcx> Builder<'_, 'tcx> {
261276
262277 let source_info = SourceInfo { span: self.thir[expr_id].span, scope: self.source_scope };
263278
264 branch_info.register_two_way_branch(
279 coverage_info.register_two_way_branch(
265280 self.tcx,
266281 &mut self.cfg,
267282 source_info,
......@@ -280,13 +295,11 @@ impl<'tcx> Builder<'_, 'tcx> {
280295 true_block: BasicBlock,
281296 false_block: BasicBlock,
282297 ) {
283 // Bail out if branch coverage is not enabled for this function.
284 let Some(branch_info) = self.coverage_branch_info.as_mut() else { return };
285
286 // FIXME(#124144) This may need special handling when MC/DC is enabled.
298 // Bail out if coverage is not enabled for this function.
299 let Some(coverage_info) = self.coverage_info.as_mut() else { return };
287300
288301 let source_info = SourceInfo { span: pattern.span, scope: self.source_scope };
289 branch_info.register_two_way_branch(
302 coverage_info.register_two_way_branch(
290303 self.tcx,
291304 &mut self.cfg,
292305 source_info,
compiler/rustc_mir_build/src/build/coverageinfo/mcdc.rs+6-6
......@@ -250,24 +250,24 @@ impl MCDCInfoBuilder {
250250
251251impl Builder<'_, '_> {
252252 pub(crate) fn visit_coverage_branch_operation(&mut self, logical_op: LogicalOp, span: Span) {
253 if let Some(branch_info) = self.coverage_branch_info.as_mut()
254 && let Some(mcdc_info) = branch_info.mcdc_info.as_mut()
253 if let Some(coverage_info) = self.coverage_info.as_mut()
254 && let Some(mcdc_info) = coverage_info.mcdc_info.as_mut()
255255 {
256256 mcdc_info.state.record_conditions(logical_op, span);
257257 }
258258 }
259259
260260 pub(crate) fn mcdc_increment_depth_if_enabled(&mut self) {
261 if let Some(branch_info) = self.coverage_branch_info.as_mut()
262 && let Some(mcdc_info) = branch_info.mcdc_info.as_mut()
261 if let Some(coverage_info) = self.coverage_info.as_mut()
262 && let Some(mcdc_info) = coverage_info.mcdc_info.as_mut()
263263 {
264264 mcdc_info.state.decision_ctx_stack.push(MCDCDecisionCtx::default());
265265 };
266266 }
267267
268268 pub(crate) fn mcdc_decrement_depth_if_enabled(&mut self) {
269 if let Some(branch_info) = self.coverage_branch_info.as_mut()
270 && let Some(mcdc_info) = branch_info.mcdc_info.as_mut()
269 if let Some(coverage_info) = self.coverage_info.as_mut()
270 && let Some(mcdc_info) = coverage_info.mcdc_info.as_mut()
271271 {
272272 if mcdc_info.state.decision_ctx_stack.pop().is_none() {
273273 bug!("Unexpected empty decision stack");
compiler/rustc_mir_build/src/build/custom/mod.rs+1-1
......@@ -62,7 +62,7 @@ pub(super) fn build_custom_mir<'tcx>(
6262 tainted_by_errors: None,
6363 injection_phase: None,
6464 pass_count: 0,
65 coverage_branch_info: None,
65 coverage_info_hi: None,
6666 function_coverage_info: None,
6767 };
6868
compiler/rustc_mir_build/src/build/matches/mod.rs+2-2
......@@ -160,8 +160,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
160160 // Improve branch coverage instrumentation by noting conditions
161161 // nested within one or more `!` expressions.
162162 // (Skipped if branch coverage is not enabled.)
163 if let Some(branch_info) = this.coverage_branch_info.as_mut() {
164 branch_info.visit_unary_not(this.thir, expr_id);
163 if let Some(coverage_info) = this.coverage_info.as_mut() {
164 coverage_info.visit_unary_not(this.thir, expr_id);
165165 }
166166
167167 let local_scope = this.local_scope();
compiler/rustc_mir_build/src/build/mod.rs+4-4
......@@ -218,8 +218,8 @@ struct Builder<'a, 'tcx> {
218218 lint_level_roots_cache: GrowableBitSet<hir::ItemLocalId>,
219219
220220 /// Collects additional coverage information during MIR building.
221 /// Only present if branch coverage is enabled and this function is eligible.
222 coverage_branch_info: Option<coverageinfo::BranchInfoBuilder>,
221 /// Only present if coverage is enabled and this function is eligible.
222 coverage_info: Option<coverageinfo::CoverageInfoBuilder>,
223223}
224224
225225type CaptureMap<'tcx> = SortedIndexMultiMap<usize, HirId, Capture<'tcx>>;
......@@ -773,7 +773,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
773773 unit_temp: None,
774774 var_debug_info: vec![],
775775 lint_level_roots_cache: GrowableBitSet::new_empty(),
776 coverage_branch_info: coverageinfo::BranchInfoBuilder::new_if_enabled(tcx, def),
776 coverage_info: coverageinfo::CoverageInfoBuilder::new_if_enabled(tcx, def),
777777 };
778778
779779 assert_eq!(builder.cfg.start_new_block(), START_BLOCK);
......@@ -802,7 +802,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
802802 self.coroutine,
803803 None,
804804 );
805 body.coverage_branch_info = self.coverage_branch_info.and_then(|b| b.into_done());
805 body.coverage_info_hi = self.coverage_info.map(|b| b.into_done());
806806 body
807807 }
808808
compiler/rustc_mir_transform/src/coverage/mappings.rs+12-10
......@@ -3,7 +3,9 @@ use std::collections::BTreeSet;
33use rustc_data_structures::graph::DirectedGraph;
44use rustc_index::bit_set::BitSet;
55use rustc_index::IndexVec;
6use rustc_middle::mir::coverage::{BlockMarkerId, BranchSpan, ConditionInfo, CoverageKind};
6use rustc_middle::mir::coverage::{
7 BlockMarkerId, BranchSpan, ConditionInfo, CoverageInfoHi, CoverageKind,
8};
79use rustc_middle::mir::{self, BasicBlock, StatementKind};
810use rustc_middle::ty::TyCtxt;
911use rustc_span::Span;
......@@ -157,12 +159,12 @@ impl ExtractedMappings {
157159}
158160
159161fn resolve_block_markers(
160 branch_info: &mir::coverage::BranchInfo,
162 coverage_info_hi: &CoverageInfoHi,
161163 mir_body: &mir::Body<'_>,
162164) -> IndexVec<BlockMarkerId, Option<BasicBlock>> {
163165 let mut block_markers = IndexVec::<BlockMarkerId, Option<BasicBlock>>::from_elem_n(
164166 None,
165 branch_info.num_block_markers,
167 coverage_info_hi.num_block_markers,
166168 );
167169
168170 // Fill out the mapping from block marker IDs to their enclosing blocks.
......@@ -188,11 +190,11 @@ pub(super) fn extract_branch_pairs(
188190 hir_info: &ExtractedHirInfo,
189191 basic_coverage_blocks: &CoverageGraph,
190192) -> Vec<BranchPair> {
191 let Some(branch_info) = mir_body.coverage_branch_info.as_deref() else { return vec![] };
193 let Some(coverage_info_hi) = mir_body.coverage_info_hi.as_deref() else { return vec![] };
192194
193 let block_markers = resolve_block_markers(branch_info, mir_body);
195 let block_markers = resolve_block_markers(coverage_info_hi, mir_body);
194196
195 branch_info
197 coverage_info_hi
196198 .branch_spans
197199 .iter()
198200 .filter_map(|&BranchSpan { span: raw_span, true_marker, false_marker }| {
......@@ -222,9 +224,9 @@ pub(super) fn extract_mcdc_mappings(
222224 mcdc_branches: &mut impl Extend<MCDCBranch>,
223225 mcdc_decisions: &mut impl Extend<MCDCDecision>,
224226) {
225 let Some(branch_info) = mir_body.coverage_branch_info.as_deref() else { return };
227 let Some(coverage_info_hi) = mir_body.coverage_info_hi.as_deref() else { return };
226228
227 let block_markers = resolve_block_markers(branch_info, mir_body);
229 let block_markers = resolve_block_markers(coverage_info_hi, mir_body);
228230
229231 let bcb_from_marker =
230232 |marker: BlockMarkerId| basic_coverage_blocks.bcb_from_bb(block_markers[marker]?);
......@@ -243,7 +245,7 @@ pub(super) fn extract_mcdc_mappings(
243245 Some((span, true_bcb, false_bcb))
244246 };
245247
246 mcdc_branches.extend(branch_info.mcdc_branch_spans.iter().filter_map(
248 mcdc_branches.extend(coverage_info_hi.mcdc_branch_spans.iter().filter_map(
247249 |&mir::coverage::MCDCBranchSpan {
248250 span: raw_span,
249251 condition_info,
......@@ -257,7 +259,7 @@ pub(super) fn extract_mcdc_mappings(
257259 },
258260 ));
259261
260 mcdc_decisions.extend(branch_info.mcdc_decision_spans.iter().filter_map(
262 mcdc_decisions.extend(coverage_info_hi.mcdc_decision_spans.iter().filter_map(
261263 |decision: &mir::coverage::MCDCDecisionSpan| {
262264 let span = unexpand_into_body_span(decision.span, body_span)?;
263265
library/panic_unwind/src/lib.rs+13-21
......@@ -36,18 +36,14 @@ use core::panic::PanicPayload;
3636cfg_if::cfg_if! {
3737 if #[cfg(target_os = "emscripten")] {
3838 #[path = "emcc.rs"]
39 mod real_imp;
39 mod imp;
4040 } else if #[cfg(target_os = "hermit")] {
4141 #[path = "hermit.rs"]
42 mod real_imp;
42 mod imp;
4343 } else if #[cfg(target_os = "l4re")] {
4444 // L4Re is unix family but does not yet support unwinding.
4545 #[path = "dummy.rs"]
46 mod real_imp;
47 } else if #[cfg(all(target_env = "msvc", not(target_arch = "arm")))] {
48 // LLVM does not support unwinding on 32 bit ARM msvc (thumbv7a-pc-windows-msvc)
49 #[path = "seh.rs"]
50 mod real_imp;
46 mod imp;
5147 } else if #[cfg(any(
5248 all(target_family = "windows", target_env = "gnu"),
5349 target_os = "psp",
......@@ -58,7 +54,16 @@ cfg_if::cfg_if! {
5854 target_family = "wasm",
5955 ))] {
6056 #[path = "gcc.rs"]
61 mod real_imp;
57 mod imp;
58 } else if #[cfg(miri)] {
59 // Use the Miri runtime on Windows as miri doesn't support funclet based unwinding,
60 // only landingpad based unwinding. Also use the Miri runtime on unsupported platforms.
61 #[path = "miri.rs"]
62 mod imp;
63 } else if #[cfg(all(target_env = "msvc", not(target_arch = "arm")))] {
64 // LLVM does not support unwinding on 32 bit ARM msvc (thumbv7a-pc-windows-msvc)
65 #[path = "seh.rs"]
66 mod imp;
6267 } else {
6368 // Targets that don't support unwinding.
6469 // - os=none ("bare metal" targets)
......@@ -67,20 +72,7 @@ cfg_if::cfg_if! {
6772 // - nvptx64-nvidia-cuda
6873 // - arch=avr
6974 #[path = "dummy.rs"]
70 mod real_imp;
71 }
72}
73
74cfg_if::cfg_if! {
75 if #[cfg(miri)] {
76 // Use the Miri runtime.
77 // We still need to also load the normal runtime above, as rustc expects certain lang
78 // items from there to be defined.
79 #[path = "miri.rs"]
8075 mod imp;
81 } else {
82 // Use the real runtime.
83 use real_imp as imp;
8476 }
8577}
8678
library/std/src/sys/pal/windows/c.rs+4-5
......@@ -13,6 +13,8 @@ use crate::os::raw::{c_char, c_long, c_longlong, c_uint, c_ulong, c_ushort, c_vo
1313use crate::os::windows::io::{AsRawHandle, BorrowedHandle};
1414use crate::ptr;
1515
16mod windows_targets;
17
1618mod windows_sys;
1719pub use windows_sys::*;
1820
......@@ -504,11 +506,8 @@ if #[cfg(not(target_vendor = "uwp"))] {
504506 #[cfg(target_arch = "arm")]
505507 pub enum CONTEXT {}
506508}}
507
508#[link(name = "ws2_32")]
509extern "system" {
510 pub fn WSAStartup(wversionrequested: u16, lpwsadata: *mut WSADATA) -> i32;
511}
509// WSAStartup is only redefined here so that we can override WSADATA for Arm32
510windows_targets::link!("ws2_32.dll" "system" fn WSAStartup(wversionrequested: u16, lpwsadata: *mut WSADATA) -> i32);
512511#[cfg(target_arch = "arm")]
513512#[repr(C)]
514513pub struct WSADATA {
library/std/src/sys/pal/windows/c/bindings.txt+1-1
......@@ -1,5 +1,5 @@
11--out windows_sys.rs
2--config flatten std
2--config flatten sys
33--filter
44!Windows.Win32.Foundation.INVALID_HANDLE_VALUE
55Windows.Wdk.Storage.FileSystem.FILE_COMPLETE_IF_OPLOCKED
library/std/src/sys/pal/windows/c/windows_sys.rs+132-838
......@@ -1,843 +1,136 @@
1// Bindings generated by `windows-bindgen` 0.57.0
1// Bindings generated by `windows-bindgen` 0.58.0
22
33#![allow(non_snake_case, non_upper_case_globals, non_camel_case_types, dead_code, clippy::all)]
4#[link(name = "advapi32")]
5extern "system" {
6 pub fn OpenProcessToken(
7 processhandle: HANDLE,
8 desiredaccess: TOKEN_ACCESS_MASK,
9 tokenhandle: *mut HANDLE,
10 ) -> BOOL;
11}
12#[link(name = "advapi32")]
13extern "system" {
14 #[link_name = "SystemFunction036"]
15 pub fn RtlGenRandom(randombuffer: *mut core::ffi::c_void, randombufferlength: u32) -> BOOLEAN;
16}
17#[link(name = "kernel32")]
18extern "system" {
19 pub fn AcquireSRWLockExclusive(srwlock: *mut SRWLOCK);
20}
21#[link(name = "kernel32")]
22extern "system" {
23 pub fn AcquireSRWLockShared(srwlock: *mut SRWLOCK);
24}
25#[link(name = "kernel32")]
26extern "system" {
27 pub fn CancelIo(hfile: HANDLE) -> BOOL;
28}
29#[link(name = "kernel32")]
30extern "system" {
31 pub fn CloseHandle(hobject: HANDLE) -> BOOL;
32}
33#[link(name = "kernel32")]
34extern "system" {
35 pub fn CompareStringOrdinal(
36 lpstring1: PCWSTR,
37 cchcount1: i32,
38 lpstring2: PCWSTR,
39 cchcount2: i32,
40 bignorecase: BOOL,
41 ) -> COMPARESTRING_RESULT;
42}
43#[link(name = "kernel32")]
44extern "system" {
45 pub fn CopyFileExW(
46 lpexistingfilename: PCWSTR,
47 lpnewfilename: PCWSTR,
48 lpprogressroutine: LPPROGRESS_ROUTINE,
49 lpdata: *const core::ffi::c_void,
50 pbcancel: *mut BOOL,
51 dwcopyflags: u32,
52 ) -> BOOL;
53}
54#[link(name = "kernel32")]
55extern "system" {
56 pub fn CreateDirectoryW(
57 lppathname: PCWSTR,
58 lpsecurityattributes: *const SECURITY_ATTRIBUTES,
59 ) -> BOOL;
60}
61#[link(name = "kernel32")]
62extern "system" {
63 pub fn CreateEventW(
64 lpeventattributes: *const SECURITY_ATTRIBUTES,
65 bmanualreset: BOOL,
66 binitialstate: BOOL,
67 lpname: PCWSTR,
68 ) -> HANDLE;
69}
70#[link(name = "kernel32")]
71extern "system" {
72 pub fn CreateFileW(
73 lpfilename: PCWSTR,
74 dwdesiredaccess: u32,
75 dwsharemode: FILE_SHARE_MODE,
76 lpsecurityattributes: *const SECURITY_ATTRIBUTES,
77 dwcreationdisposition: FILE_CREATION_DISPOSITION,
78 dwflagsandattributes: FILE_FLAGS_AND_ATTRIBUTES,
79 htemplatefile: HANDLE,
80 ) -> HANDLE;
81}
82#[link(name = "kernel32")]
83extern "system" {
84 pub fn CreateHardLinkW(
85 lpfilename: PCWSTR,
86 lpexistingfilename: PCWSTR,
87 lpsecurityattributes: *const SECURITY_ATTRIBUTES,
88 ) -> BOOL;
89}
90#[link(name = "kernel32")]
91extern "system" {
92 pub fn CreateNamedPipeW(
93 lpname: PCWSTR,
94 dwopenmode: FILE_FLAGS_AND_ATTRIBUTES,
95 dwpipemode: NAMED_PIPE_MODE,
96 nmaxinstances: u32,
97 noutbuffersize: u32,
98 ninbuffersize: u32,
99 ndefaulttimeout: u32,
100 lpsecurityattributes: *const SECURITY_ATTRIBUTES,
101 ) -> HANDLE;
102}
103#[link(name = "kernel32")]
104extern "system" {
105 pub fn CreateProcessW(
106 lpapplicationname: PCWSTR,
107 lpcommandline: PWSTR,
108 lpprocessattributes: *const SECURITY_ATTRIBUTES,
109 lpthreadattributes: *const SECURITY_ATTRIBUTES,
110 binherithandles: BOOL,
111 dwcreationflags: PROCESS_CREATION_FLAGS,
112 lpenvironment: *const core::ffi::c_void,
113 lpcurrentdirectory: PCWSTR,
114 lpstartupinfo: *const STARTUPINFOW,
115 lpprocessinformation: *mut PROCESS_INFORMATION,
116 ) -> BOOL;
117}
118#[link(name = "kernel32")]
119extern "system" {
120 pub fn CreateSymbolicLinkW(
121 lpsymlinkfilename: PCWSTR,
122 lptargetfilename: PCWSTR,
123 dwflags: SYMBOLIC_LINK_FLAGS,
124 ) -> BOOLEAN;
125}
126#[link(name = "kernel32")]
127extern "system" {
128 pub fn CreateThread(
129 lpthreadattributes: *const SECURITY_ATTRIBUTES,
130 dwstacksize: usize,
131 lpstartaddress: LPTHREAD_START_ROUTINE,
132 lpparameter: *const core::ffi::c_void,
133 dwcreationflags: THREAD_CREATION_FLAGS,
134 lpthreadid: *mut u32,
135 ) -> HANDLE;
136}
137#[link(name = "kernel32")]
138extern "system" {
139 pub fn CreateWaitableTimerExW(
140 lptimerattributes: *const SECURITY_ATTRIBUTES,
141 lptimername: PCWSTR,
142 dwflags: u32,
143 dwdesiredaccess: u32,
144 ) -> HANDLE;
145}
146#[link(name = "kernel32")]
147extern "system" {
148 pub fn DeleteFileW(lpfilename: PCWSTR) -> BOOL;
149}
150#[link(name = "kernel32")]
151extern "system" {
152 pub fn DeleteProcThreadAttributeList(lpattributelist: LPPROC_THREAD_ATTRIBUTE_LIST);
153}
154#[link(name = "kernel32")]
155extern "system" {
156 pub fn DeviceIoControl(
157 hdevice: HANDLE,
158 dwiocontrolcode: u32,
159 lpinbuffer: *const core::ffi::c_void,
160 ninbuffersize: u32,
161 lpoutbuffer: *mut core::ffi::c_void,
162 noutbuffersize: u32,
163 lpbytesreturned: *mut u32,
164 lpoverlapped: *mut OVERLAPPED,
165 ) -> BOOL;
166}
167#[link(name = "kernel32")]
168extern "system" {
169 pub fn DuplicateHandle(
170 hsourceprocesshandle: HANDLE,
171 hsourcehandle: HANDLE,
172 htargetprocesshandle: HANDLE,
173 lptargethandle: *mut HANDLE,
174 dwdesiredaccess: u32,
175 binherithandle: BOOL,
176 dwoptions: DUPLICATE_HANDLE_OPTIONS,
177 ) -> BOOL;
178}
179#[link(name = "kernel32")]
180extern "system" {
181 pub fn ExitProcess(uexitcode: u32) -> !;
182}
183#[link(name = "kernel32")]
184extern "system" {
185 pub fn FindClose(hfindfile: HANDLE) -> BOOL;
186}
187#[link(name = "kernel32")]
188extern "system" {
189 pub fn FindFirstFileW(lpfilename: PCWSTR, lpfindfiledata: *mut WIN32_FIND_DATAW) -> HANDLE;
190}
191#[link(name = "kernel32")]
192extern "system" {
193 pub fn FindNextFileW(hfindfile: HANDLE, lpfindfiledata: *mut WIN32_FIND_DATAW) -> BOOL;
194}
195#[link(name = "kernel32")]
196extern "system" {
197 pub fn FlushFileBuffers(hfile: HANDLE) -> BOOL;
198}
199#[link(name = "kernel32")]
200extern "system" {
201 pub fn FormatMessageW(
202 dwflags: FORMAT_MESSAGE_OPTIONS,
203 lpsource: *const core::ffi::c_void,
204 dwmessageid: u32,
205 dwlanguageid: u32,
206 lpbuffer: PWSTR,
207 nsize: u32,
208 arguments: *const *const i8,
209 ) -> u32;
210}
211#[link(name = "kernel32")]
212extern "system" {
213 pub fn FreeEnvironmentStringsW(penv: PCWSTR) -> BOOL;
214}
215#[link(name = "kernel32")]
216extern "system" {
217 pub fn GetActiveProcessorCount(groupnumber: u16) -> u32;
218}
219#[link(name = "kernel32")]
220extern "system" {
221 pub fn GetCommandLineW() -> PCWSTR;
222}
223#[link(name = "kernel32")]
224extern "system" {
225 pub fn GetConsoleMode(hconsolehandle: HANDLE, lpmode: *mut CONSOLE_MODE) -> BOOL;
226}
227#[link(name = "kernel32")]
228extern "system" {
229 pub fn GetCurrentDirectoryW(nbufferlength: u32, lpbuffer: PWSTR) -> u32;
230}
231#[link(name = "kernel32")]
232extern "system" {
233 pub fn GetCurrentProcess() -> HANDLE;
234}
235#[link(name = "kernel32")]
236extern "system" {
237 pub fn GetCurrentProcessId() -> u32;
238}
239#[link(name = "kernel32")]
240extern "system" {
241 pub fn GetCurrentThread() -> HANDLE;
242}
243#[link(name = "kernel32")]
244extern "system" {
245 pub fn GetEnvironmentStringsW() -> PWSTR;
246}
247#[link(name = "kernel32")]
248extern "system" {
249 pub fn GetEnvironmentVariableW(lpname: PCWSTR, lpbuffer: PWSTR, nsize: u32) -> u32;
250}
251#[link(name = "kernel32")]
252extern "system" {
253 pub fn GetExitCodeProcess(hprocess: HANDLE, lpexitcode: *mut u32) -> BOOL;
254}
255#[link(name = "kernel32")]
256extern "system" {
257 pub fn GetFileAttributesW(lpfilename: PCWSTR) -> u32;
258}
259#[link(name = "kernel32")]
260extern "system" {
261 pub fn GetFileInformationByHandle(
262 hfile: HANDLE,
263 lpfileinformation: *mut BY_HANDLE_FILE_INFORMATION,
264 ) -> BOOL;
265}
266#[link(name = "kernel32")]
267extern "system" {
268 pub fn GetFileInformationByHandleEx(
269 hfile: HANDLE,
270 fileinformationclass: FILE_INFO_BY_HANDLE_CLASS,
271 lpfileinformation: *mut core::ffi::c_void,
272 dwbuffersize: u32,
273 ) -> BOOL;
274}
275#[link(name = "kernel32")]
276extern "system" {
277 pub fn GetFileType(hfile: HANDLE) -> FILE_TYPE;
278}
279#[link(name = "kernel32")]
280extern "system" {
281 pub fn GetFinalPathNameByHandleW(
282 hfile: HANDLE,
283 lpszfilepath: PWSTR,
284 cchfilepath: u32,
285 dwflags: GETFINALPATHNAMEBYHANDLE_FLAGS,
286 ) -> u32;
287}
288#[link(name = "kernel32")]
289extern "system" {
290 pub fn GetFullPathNameW(
291 lpfilename: PCWSTR,
292 nbufferlength: u32,
293 lpbuffer: PWSTR,
294 lpfilepart: *mut PWSTR,
295 ) -> u32;
296}
297#[link(name = "kernel32")]
298extern "system" {
299 pub fn GetLastError() -> WIN32_ERROR;
300}
301#[link(name = "kernel32")]
302extern "system" {
303 pub fn GetModuleFileNameW(hmodule: HMODULE, lpfilename: PWSTR, nsize: u32) -> u32;
304}
305#[link(name = "kernel32")]
306extern "system" {
307 pub fn GetModuleHandleA(lpmodulename: PCSTR) -> HMODULE;
308}
309#[link(name = "kernel32")]
310extern "system" {
311 pub fn GetModuleHandleW(lpmodulename: PCWSTR) -> HMODULE;
312}
313#[link(name = "kernel32")]
314extern "system" {
315 pub fn GetOverlappedResult(
316 hfile: HANDLE,
317 lpoverlapped: *const OVERLAPPED,
318 lpnumberofbytestransferred: *mut u32,
319 bwait: BOOL,
320 ) -> BOOL;
321}
322#[link(name = "kernel32")]
323extern "system" {
324 pub fn GetProcAddress(hmodule: HMODULE, lpprocname: PCSTR) -> FARPROC;
325}
326#[link(name = "kernel32")]
327extern "system" {
328 pub fn GetProcessId(process: HANDLE) -> u32;
329}
330#[link(name = "kernel32")]
331extern "system" {
332 pub fn GetStdHandle(nstdhandle: STD_HANDLE) -> HANDLE;
333}
334#[link(name = "kernel32")]
335extern "system" {
336 pub fn GetSystemDirectoryW(lpbuffer: PWSTR, usize: u32) -> u32;
337}
338#[link(name = "kernel32")]
339extern "system" {
340 pub fn GetSystemInfo(lpsysteminfo: *mut SYSTEM_INFO);
341}
342#[link(name = "kernel32")]
343extern "system" {
344 pub fn GetSystemTimeAsFileTime(lpsystemtimeasfiletime: *mut FILETIME);
345}
346#[link(name = "kernel32")]
347extern "system" {
348 pub fn GetSystemTimePreciseAsFileTime(lpsystemtimeasfiletime: *mut FILETIME);
349}
350#[link(name = "kernel32")]
351extern "system" {
352 pub fn GetTempPathW(nbufferlength: u32, lpbuffer: PWSTR) -> u32;
353}
354#[link(name = "kernel32")]
355extern "system" {
356 pub fn GetWindowsDirectoryW(lpbuffer: PWSTR, usize: u32) -> u32;
357}
358#[link(name = "kernel32")]
359extern "system" {
360 pub fn InitOnceBeginInitialize(
361 lpinitonce: *mut INIT_ONCE,
362 dwflags: u32,
363 fpending: *mut BOOL,
364 lpcontext: *mut *mut core::ffi::c_void,
365 ) -> BOOL;
366}
367#[link(name = "kernel32")]
368extern "system" {
369 pub fn InitOnceComplete(
370 lpinitonce: *mut INIT_ONCE,
371 dwflags: u32,
372 lpcontext: *const core::ffi::c_void,
373 ) -> BOOL;
374}
375#[link(name = "kernel32")]
376extern "system" {
377 pub fn InitializeProcThreadAttributeList(
378 lpattributelist: LPPROC_THREAD_ATTRIBUTE_LIST,
379 dwattributecount: u32,
380 dwflags: u32,
381 lpsize: *mut usize,
382 ) -> BOOL;
383}
384#[link(name = "kernel32")]
385extern "system" {
386 pub fn LocalFree(hmem: HLOCAL) -> HLOCAL;
387}
388#[link(name = "kernel32")]
389extern "system" {
390 pub fn MoveFileExW(
391 lpexistingfilename: PCWSTR,
392 lpnewfilename: PCWSTR,
393 dwflags: MOVE_FILE_FLAGS,
394 ) -> BOOL;
395}
396#[link(name = "kernel32")]
397extern "system" {
398 pub fn MultiByteToWideChar(
399 codepage: u32,
400 dwflags: MULTI_BYTE_TO_WIDE_CHAR_FLAGS,
401 lpmultibytestr: PCSTR,
402 cbmultibyte: i32,
403 lpwidecharstr: PWSTR,
404 cchwidechar: i32,
405 ) -> i32;
406}
407#[link(name = "kernel32")]
408extern "system" {
409 pub fn QueryPerformanceCounter(lpperformancecount: *mut i64) -> BOOL;
410}
411#[link(name = "kernel32")]
412extern "system" {
413 pub fn QueryPerformanceFrequency(lpfrequency: *mut i64) -> BOOL;
414}
415#[link(name = "kernel32")]
416extern "system" {
417 pub fn ReadConsoleW(
418 hconsoleinput: HANDLE,
419 lpbuffer: *mut core::ffi::c_void,
420 nnumberofcharstoread: u32,
421 lpnumberofcharsread: *mut u32,
422 pinputcontrol: *const CONSOLE_READCONSOLE_CONTROL,
423 ) -> BOOL;
424}
425#[link(name = "kernel32")]
426extern "system" {
427 pub fn ReadFile(
428 hfile: HANDLE,
429 lpbuffer: *mut u8,
430 nnumberofbytestoread: u32,
431 lpnumberofbytesread: *mut u32,
432 lpoverlapped: *mut OVERLAPPED,
433 ) -> BOOL;
434}
435#[link(name = "kernel32")]
436extern "system" {
437 pub fn ReadFileEx(
438 hfile: HANDLE,
439 lpbuffer: *mut u8,
440 nnumberofbytestoread: u32,
441 lpoverlapped: *mut OVERLAPPED,
442 lpcompletionroutine: LPOVERLAPPED_COMPLETION_ROUTINE,
443 ) -> BOOL;
444}
445#[link(name = "kernel32")]
446extern "system" {
447 pub fn ReleaseSRWLockExclusive(srwlock: *mut SRWLOCK);
448}
449#[link(name = "kernel32")]
450extern "system" {
451 pub fn ReleaseSRWLockShared(srwlock: *mut SRWLOCK);
452}
453#[link(name = "kernel32")]
454extern "system" {
455 pub fn RemoveDirectoryW(lppathname: PCWSTR) -> BOOL;
456}
457#[link(name = "kernel32")]
458extern "system" {
459 pub fn SetCurrentDirectoryW(lppathname: PCWSTR) -> BOOL;
460}
461#[link(name = "kernel32")]
462extern "system" {
463 pub fn SetEnvironmentVariableW(lpname: PCWSTR, lpvalue: PCWSTR) -> BOOL;
464}
465#[link(name = "kernel32")]
466extern "system" {
467 pub fn SetFileAttributesW(
468 lpfilename: PCWSTR,
469 dwfileattributes: FILE_FLAGS_AND_ATTRIBUTES,
470 ) -> BOOL;
471}
472#[link(name = "kernel32")]
473extern "system" {
474 pub fn SetFileInformationByHandle(
475 hfile: HANDLE,
476 fileinformationclass: FILE_INFO_BY_HANDLE_CLASS,
477 lpfileinformation: *const core::ffi::c_void,
478 dwbuffersize: u32,
479 ) -> BOOL;
480}
481#[link(name = "kernel32")]
482extern "system" {
483 pub fn SetFilePointerEx(
484 hfile: HANDLE,
485 lidistancetomove: i64,
486 lpnewfilepointer: *mut i64,
487 dwmovemethod: SET_FILE_POINTER_MOVE_METHOD,
488 ) -> BOOL;
489}
490#[link(name = "kernel32")]
491extern "system" {
492 pub fn SetFileTime(
493 hfile: HANDLE,
494 lpcreationtime: *const FILETIME,
495 lplastaccesstime: *const FILETIME,
496 lplastwritetime: *const FILETIME,
497 ) -> BOOL;
498}
499#[link(name = "kernel32")]
500extern "system" {
501 pub fn SetHandleInformation(hobject: HANDLE, dwmask: u32, dwflags: HANDLE_FLAGS) -> BOOL;
502}
503#[link(name = "kernel32")]
504extern "system" {
505 pub fn SetLastError(dwerrcode: WIN32_ERROR);
506}
507#[link(name = "kernel32")]
508extern "system" {
509 pub fn SetThreadStackGuarantee(stacksizeinbytes: *mut u32) -> BOOL;
510}
511#[link(name = "kernel32")]
512extern "system" {
513 pub fn SetWaitableTimer(
514 htimer: HANDLE,
515 lpduetime: *const i64,
516 lperiod: i32,
517 pfncompletionroutine: PTIMERAPCROUTINE,
518 lpargtocompletionroutine: *const core::ffi::c_void,
519 fresume: BOOL,
520 ) -> BOOL;
521}
522#[link(name = "kernel32")]
523extern "system" {
524 pub fn Sleep(dwmilliseconds: u32);
525}
526#[link(name = "kernel32")]
527extern "system" {
528 pub fn SleepConditionVariableSRW(
529 conditionvariable: *mut CONDITION_VARIABLE,
530 srwlock: *mut SRWLOCK,
531 dwmilliseconds: u32,
532 flags: u32,
533 ) -> BOOL;
534}
535#[link(name = "kernel32")]
536extern "system" {
537 pub fn SleepEx(dwmilliseconds: u32, balertable: BOOL) -> u32;
538}
539#[link(name = "kernel32")]
540extern "system" {
541 pub fn SwitchToThread() -> BOOL;
542}
543#[link(name = "kernel32")]
544extern "system" {
545 pub fn TerminateProcess(hprocess: HANDLE, uexitcode: u32) -> BOOL;
546}
547#[link(name = "kernel32")]
548extern "system" {
549 pub fn TlsAlloc() -> u32;
550}
551#[link(name = "kernel32")]
552extern "system" {
553 pub fn TlsFree(dwtlsindex: u32) -> BOOL;
554}
555#[link(name = "kernel32")]
556extern "system" {
557 pub fn TlsGetValue(dwtlsindex: u32) -> *mut core::ffi::c_void;
558}
559#[link(name = "kernel32")]
560extern "system" {
561 pub fn TlsSetValue(dwtlsindex: u32, lptlsvalue: *const core::ffi::c_void) -> BOOL;
562}
563#[link(name = "kernel32")]
564extern "system" {
565 pub fn TryAcquireSRWLockExclusive(srwlock: *mut SRWLOCK) -> BOOLEAN;
566}
567#[link(name = "kernel32")]
568extern "system" {
569 pub fn TryAcquireSRWLockShared(srwlock: *mut SRWLOCK) -> BOOLEAN;
570}
571#[link(name = "kernel32")]
572extern "system" {
573 pub fn UpdateProcThreadAttribute(
574 lpattributelist: LPPROC_THREAD_ATTRIBUTE_LIST,
575 dwflags: u32,
576 attribute: usize,
577 lpvalue: *const core::ffi::c_void,
578 cbsize: usize,
579 lppreviousvalue: *mut core::ffi::c_void,
580 lpreturnsize: *const usize,
581 ) -> BOOL;
582}
583#[link(name = "kernel32")]
584extern "system" {
585 pub fn WaitForMultipleObjects(
586 ncount: u32,
587 lphandles: *const HANDLE,
588 bwaitall: BOOL,
589 dwmilliseconds: u32,
590 ) -> WAIT_EVENT;
591}
592#[link(name = "kernel32")]
593extern "system" {
594 pub fn WaitForSingleObject(hhandle: HANDLE, dwmilliseconds: u32) -> WAIT_EVENT;
595}
596#[link(name = "kernel32")]
597extern "system" {
598 pub fn WakeAllConditionVariable(conditionvariable: *mut CONDITION_VARIABLE);
599}
600#[link(name = "kernel32")]
601extern "system" {
602 pub fn WakeConditionVariable(conditionvariable: *mut CONDITION_VARIABLE);
603}
604#[link(name = "kernel32")]
605extern "system" {
606 pub fn WideCharToMultiByte(
607 codepage: u32,
608 dwflags: u32,
609 lpwidecharstr: PCWSTR,
610 cchwidechar: i32,
611 lpmultibytestr: PSTR,
612 cbmultibyte: i32,
613 lpdefaultchar: PCSTR,
614 lpuseddefaultchar: *mut BOOL,
615 ) -> i32;
616}
617#[link(name = "kernel32")]
618extern "system" {
619 pub fn WriteConsoleW(
620 hconsoleoutput: HANDLE,
621 lpbuffer: *const core::ffi::c_void,
622 nnumberofcharstowrite: u32,
623 lpnumberofcharswritten: *mut u32,
624 lpreserved: *const core::ffi::c_void,
625 ) -> BOOL;
626}
627#[link(name = "kernel32")]
628extern "system" {
629 pub fn WriteFileEx(
630 hfile: HANDLE,
631 lpbuffer: *const u8,
632 nnumberofbytestowrite: u32,
633 lpoverlapped: *mut OVERLAPPED,
634 lpcompletionroutine: LPOVERLAPPED_COMPLETION_ROUTINE,
635 ) -> BOOL;
636}
637#[link(name = "ntdll")]
638extern "system" {
639 pub fn NtCreateFile(
640 filehandle: *mut HANDLE,
641 desiredaccess: FILE_ACCESS_RIGHTS,
642 objectattributes: *const OBJECT_ATTRIBUTES,
643 iostatusblock: *mut IO_STATUS_BLOCK,
644 allocationsize: *const i64,
645 fileattributes: FILE_FLAGS_AND_ATTRIBUTES,
646 shareaccess: FILE_SHARE_MODE,
647 createdisposition: NTCREATEFILE_CREATE_DISPOSITION,
648 createoptions: NTCREATEFILE_CREATE_OPTIONS,
649 eabuffer: *const core::ffi::c_void,
650 ealength: u32,
651 ) -> NTSTATUS;
652}
653#[link(name = "ntdll")]
654extern "system" {
655 pub fn NtReadFile(
656 filehandle: HANDLE,
657 event: HANDLE,
658 apcroutine: PIO_APC_ROUTINE,
659 apccontext: *const core::ffi::c_void,
660 iostatusblock: *mut IO_STATUS_BLOCK,
661 buffer: *mut core::ffi::c_void,
662 length: u32,
663 byteoffset: *const i64,
664 key: *const u32,
665 ) -> NTSTATUS;
666}
667#[link(name = "ntdll")]
668extern "system" {
669 pub fn NtWriteFile(
670 filehandle: HANDLE,
671 event: HANDLE,
672 apcroutine: PIO_APC_ROUTINE,
673 apccontext: *const core::ffi::c_void,
674 iostatusblock: *mut IO_STATUS_BLOCK,
675 buffer: *const core::ffi::c_void,
676 length: u32,
677 byteoffset: *const i64,
678 key: *const u32,
679 ) -> NTSTATUS;
680}
681#[link(name = "ntdll")]
682extern "system" {
683 pub fn RtlNtStatusToDosError(status: NTSTATUS) -> u32;
684}
685#[link(name = "userenv")]
686extern "system" {
687 pub fn GetUserProfileDirectoryW(
688 htoken: HANDLE,
689 lpprofiledir: PWSTR,
690 lpcchsize: *mut u32,
691 ) -> BOOL;
692}
693#[link(name = "ws2_32")]
694extern "system" {
695 pub fn WSACleanup() -> i32;
696}
697#[link(name = "ws2_32")]
698extern "system" {
699 pub fn WSADuplicateSocketW(
700 s: SOCKET,
701 dwprocessid: u32,
702 lpprotocolinfo: *mut WSAPROTOCOL_INFOW,
703 ) -> i32;
704}
705#[link(name = "ws2_32")]
706extern "system" {
707 pub fn WSAGetLastError() -> WSA_ERROR;
708}
709#[link(name = "ws2_32")]
710extern "system" {
711 pub fn WSARecv(
712 s: SOCKET,
713 lpbuffers: *const WSABUF,
714 dwbuffercount: u32,
715 lpnumberofbytesrecvd: *mut u32,
716 lpflags: *mut u32,
717 lpoverlapped: *mut OVERLAPPED,
718 lpcompletionroutine: LPWSAOVERLAPPED_COMPLETION_ROUTINE,
719 ) -> i32;
720}
721#[link(name = "ws2_32")]
722extern "system" {
723 pub fn WSASend(
724 s: SOCKET,
725 lpbuffers: *const WSABUF,
726 dwbuffercount: u32,
727 lpnumberofbytessent: *mut u32,
728 dwflags: u32,
729 lpoverlapped: *mut OVERLAPPED,
730 lpcompletionroutine: LPWSAOVERLAPPED_COMPLETION_ROUTINE,
731 ) -> i32;
732}
733#[link(name = "ws2_32")]
734extern "system" {
735 pub fn WSASocketW(
736 af: i32,
737 r#type: i32,
738 protocol: i32,
739 lpprotocolinfo: *const WSAPROTOCOL_INFOW,
740 g: u32,
741 dwflags: u32,
742 ) -> SOCKET;
743}
744#[link(name = "ws2_32")]
745extern "system" {
746 pub fn accept(s: SOCKET, addr: *mut SOCKADDR, addrlen: *mut i32) -> SOCKET;
747}
748#[link(name = "ws2_32")]
749extern "system" {
750 pub fn bind(s: SOCKET, name: *const SOCKADDR, namelen: i32) -> i32;
751}
752#[link(name = "ws2_32")]
753extern "system" {
754 pub fn closesocket(s: SOCKET) -> i32;
755}
756#[link(name = "ws2_32")]
757extern "system" {
758 pub fn connect(s: SOCKET, name: *const SOCKADDR, namelen: i32) -> i32;
759}
760#[link(name = "ws2_32")]
761extern "system" {
762 pub fn freeaddrinfo(paddrinfo: *const ADDRINFOA);
763}
764#[link(name = "ws2_32")]
765extern "system" {
766 pub fn getaddrinfo(
767 pnodename: PCSTR,
768 pservicename: PCSTR,
769 phints: *const ADDRINFOA,
770 ppresult: *mut *mut ADDRINFOA,
771 ) -> i32;
772}
773#[link(name = "ws2_32")]
774extern "system" {
775 pub fn getpeername(s: SOCKET, name: *mut SOCKADDR, namelen: *mut i32) -> i32;
776}
777#[link(name = "ws2_32")]
778extern "system" {
779 pub fn getsockname(s: SOCKET, name: *mut SOCKADDR, namelen: *mut i32) -> i32;
780}
781#[link(name = "ws2_32")]
782extern "system" {
783 pub fn getsockopt(s: SOCKET, level: i32, optname: i32, optval: PSTR, optlen: *mut i32) -> i32;
784}
785#[link(name = "ws2_32")]
786extern "system" {
787 pub fn ioctlsocket(s: SOCKET, cmd: i32, argp: *mut u32) -> i32;
788}
789#[link(name = "ws2_32")]
790extern "system" {
791 pub fn listen(s: SOCKET, backlog: i32) -> i32;
792}
793#[link(name = "ws2_32")]
794extern "system" {
795 pub fn recv(s: SOCKET, buf: PSTR, len: i32, flags: SEND_RECV_FLAGS) -> i32;
796}
797#[link(name = "ws2_32")]
798extern "system" {
799 pub fn recvfrom(
800 s: SOCKET,
801 buf: PSTR,
802 len: i32,
803 flags: i32,
804 from: *mut SOCKADDR,
805 fromlen: *mut i32,
806 ) -> i32;
807}
808#[link(name = "ws2_32")]
809extern "system" {
810 pub fn select(
811 nfds: i32,
812 readfds: *mut FD_SET,
813 writefds: *mut FD_SET,
814 exceptfds: *mut FD_SET,
815 timeout: *const TIMEVAL,
816 ) -> i32;
817}
818#[link(name = "ws2_32")]
819extern "system" {
820 pub fn send(s: SOCKET, buf: PCSTR, len: i32, flags: SEND_RECV_FLAGS) -> i32;
821}
822#[link(name = "ws2_32")]
823extern "system" {
824 pub fn sendto(
825 s: SOCKET,
826 buf: PCSTR,
827 len: i32,
828 flags: i32,
829 to: *const SOCKADDR,
830 tolen: i32,
831 ) -> i32;
832}
833#[link(name = "ws2_32")]
834extern "system" {
835 pub fn setsockopt(s: SOCKET, level: i32, optname: i32, optval: PCSTR, optlen: i32) -> i32;
836}
837#[link(name = "ws2_32")]
838extern "system" {
839 pub fn shutdown(s: SOCKET, how: WINSOCK_SHUTDOWN_HOW) -> i32;
840}
4windows_targets::link!("advapi32.dll" "system" fn OpenProcessToken(processhandle : HANDLE, desiredaccess : TOKEN_ACCESS_MASK, tokenhandle : *mut HANDLE) -> BOOL);
5windows_targets::link!("advapi32.dll" "system" "SystemFunction036" fn RtlGenRandom(randombuffer : *mut core::ffi::c_void, randombufferlength : u32) -> BOOLEAN);
6windows_targets::link!("kernel32.dll" "system" fn AcquireSRWLockExclusive(srwlock : *mut SRWLOCK));
7windows_targets::link!("kernel32.dll" "system" fn AcquireSRWLockShared(srwlock : *mut SRWLOCK));
8windows_targets::link!("kernel32.dll" "system" fn CancelIo(hfile : HANDLE) -> BOOL);
9windows_targets::link!("kernel32.dll" "system" fn CloseHandle(hobject : HANDLE) -> BOOL);
10windows_targets::link!("kernel32.dll" "system" fn CompareStringOrdinal(lpstring1 : PCWSTR, cchcount1 : i32, lpstring2 : PCWSTR, cchcount2 : i32, bignorecase : BOOL) -> COMPARESTRING_RESULT);
11windows_targets::link!("kernel32.dll" "system" fn CopyFileExW(lpexistingfilename : PCWSTR, lpnewfilename : PCWSTR, lpprogressroutine : LPPROGRESS_ROUTINE, lpdata : *const core::ffi::c_void, pbcancel : *mut BOOL, dwcopyflags : u32) -> BOOL);
12windows_targets::link!("kernel32.dll" "system" fn CreateDirectoryW(lppathname : PCWSTR, lpsecurityattributes : *const SECURITY_ATTRIBUTES) -> BOOL);
13windows_targets::link!("kernel32.dll" "system" fn CreateEventW(lpeventattributes : *const SECURITY_ATTRIBUTES, bmanualreset : BOOL, binitialstate : BOOL, lpname : PCWSTR) -> HANDLE);
14windows_targets::link!("kernel32.dll" "system" fn CreateFileW(lpfilename : PCWSTR, dwdesiredaccess : u32, dwsharemode : FILE_SHARE_MODE, lpsecurityattributes : *const SECURITY_ATTRIBUTES, dwcreationdisposition : FILE_CREATION_DISPOSITION, dwflagsandattributes : FILE_FLAGS_AND_ATTRIBUTES, htemplatefile : HANDLE) -> HANDLE);
15windows_targets::link!("kernel32.dll" "system" fn CreateHardLinkW(lpfilename : PCWSTR, lpexistingfilename : PCWSTR, lpsecurityattributes : *const SECURITY_ATTRIBUTES) -> BOOL);
16windows_targets::link!("kernel32.dll" "system" fn CreateNamedPipeW(lpname : PCWSTR, dwopenmode : FILE_FLAGS_AND_ATTRIBUTES, dwpipemode : NAMED_PIPE_MODE, nmaxinstances : u32, noutbuffersize : u32, ninbuffersize : u32, ndefaulttimeout : u32, lpsecurityattributes : *const SECURITY_ATTRIBUTES) -> HANDLE);
17windows_targets::link!("kernel32.dll" "system" fn CreateProcessW(lpapplicationname : PCWSTR, lpcommandline : PWSTR, lpprocessattributes : *const SECURITY_ATTRIBUTES, lpthreadattributes : *const SECURITY_ATTRIBUTES, binherithandles : BOOL, dwcreationflags : PROCESS_CREATION_FLAGS, lpenvironment : *const core::ffi::c_void, lpcurrentdirectory : PCWSTR, lpstartupinfo : *const STARTUPINFOW, lpprocessinformation : *mut PROCESS_INFORMATION) -> BOOL);
18windows_targets::link!("kernel32.dll" "system" fn CreateSymbolicLinkW(lpsymlinkfilename : PCWSTR, lptargetfilename : PCWSTR, dwflags : SYMBOLIC_LINK_FLAGS) -> BOOLEAN);
19windows_targets::link!("kernel32.dll" "system" fn CreateThread(lpthreadattributes : *const SECURITY_ATTRIBUTES, dwstacksize : usize, lpstartaddress : LPTHREAD_START_ROUTINE, lpparameter : *const core::ffi::c_void, dwcreationflags : THREAD_CREATION_FLAGS, lpthreadid : *mut u32) -> HANDLE);
20windows_targets::link!("kernel32.dll" "system" fn CreateWaitableTimerExW(lptimerattributes : *const SECURITY_ATTRIBUTES, lptimername : PCWSTR, dwflags : u32, dwdesiredaccess : u32) -> HANDLE);
21windows_targets::link!("kernel32.dll" "system" fn DeleteFileW(lpfilename : PCWSTR) -> BOOL);
22windows_targets::link!("kernel32.dll" "system" fn DeleteProcThreadAttributeList(lpattributelist : LPPROC_THREAD_ATTRIBUTE_LIST));
23windows_targets::link!("kernel32.dll" "system" fn DeviceIoControl(hdevice : HANDLE, dwiocontrolcode : u32, lpinbuffer : *const core::ffi::c_void, ninbuffersize : u32, lpoutbuffer : *mut core::ffi::c_void, noutbuffersize : u32, lpbytesreturned : *mut u32, lpoverlapped : *mut OVERLAPPED) -> BOOL);
24windows_targets::link!("kernel32.dll" "system" fn DuplicateHandle(hsourceprocesshandle : HANDLE, hsourcehandle : HANDLE, htargetprocesshandle : HANDLE, lptargethandle : *mut HANDLE, dwdesiredaccess : u32, binherithandle : BOOL, dwoptions : DUPLICATE_HANDLE_OPTIONS) -> BOOL);
25windows_targets::link!("kernel32.dll" "system" fn ExitProcess(uexitcode : u32) -> !);
26windows_targets::link!("kernel32.dll" "system" fn FindClose(hfindfile : HANDLE) -> BOOL);
27windows_targets::link!("kernel32.dll" "system" fn FindFirstFileW(lpfilename : PCWSTR, lpfindfiledata : *mut WIN32_FIND_DATAW) -> HANDLE);
28windows_targets::link!("kernel32.dll" "system" fn FindNextFileW(hfindfile : HANDLE, lpfindfiledata : *mut WIN32_FIND_DATAW) -> BOOL);
29windows_targets::link!("kernel32.dll" "system" fn FlushFileBuffers(hfile : HANDLE) -> BOOL);
30windows_targets::link!("kernel32.dll" "system" fn FormatMessageW(dwflags : FORMAT_MESSAGE_OPTIONS, lpsource : *const core::ffi::c_void, dwmessageid : u32, dwlanguageid : u32, lpbuffer : PWSTR, nsize : u32, arguments : *const *const i8) -> u32);
31windows_targets::link!("kernel32.dll" "system" fn FreeEnvironmentStringsW(penv : PCWSTR) -> BOOL);
32windows_targets::link!("kernel32.dll" "system" fn GetActiveProcessorCount(groupnumber : u16) -> u32);
33windows_targets::link!("kernel32.dll" "system" fn GetCommandLineW() -> PCWSTR);
34windows_targets::link!("kernel32.dll" "system" fn GetConsoleMode(hconsolehandle : HANDLE, lpmode : *mut CONSOLE_MODE) -> BOOL);
35windows_targets::link!("kernel32.dll" "system" fn GetCurrentDirectoryW(nbufferlength : u32, lpbuffer : PWSTR) -> u32);
36windows_targets::link!("kernel32.dll" "system" fn GetCurrentProcess() -> HANDLE);
37windows_targets::link!("kernel32.dll" "system" fn GetCurrentProcessId() -> u32);
38windows_targets::link!("kernel32.dll" "system" fn GetCurrentThread() -> HANDLE);
39windows_targets::link!("kernel32.dll" "system" fn GetEnvironmentStringsW() -> PWSTR);
40windows_targets::link!("kernel32.dll" "system" fn GetEnvironmentVariableW(lpname : PCWSTR, lpbuffer : PWSTR, nsize : u32) -> u32);
41windows_targets::link!("kernel32.dll" "system" fn GetExitCodeProcess(hprocess : HANDLE, lpexitcode : *mut u32) -> BOOL);
42windows_targets::link!("kernel32.dll" "system" fn GetFileAttributesW(lpfilename : PCWSTR) -> u32);
43windows_targets::link!("kernel32.dll" "system" fn GetFileInformationByHandle(hfile : HANDLE, lpfileinformation : *mut BY_HANDLE_FILE_INFORMATION) -> BOOL);
44windows_targets::link!("kernel32.dll" "system" fn GetFileInformationByHandleEx(hfile : HANDLE, fileinformationclass : FILE_INFO_BY_HANDLE_CLASS, lpfileinformation : *mut core::ffi::c_void, dwbuffersize : u32) -> BOOL);
45windows_targets::link!("kernel32.dll" "system" fn GetFileType(hfile : HANDLE) -> FILE_TYPE);
46windows_targets::link!("kernel32.dll" "system" fn GetFinalPathNameByHandleW(hfile : HANDLE, lpszfilepath : PWSTR, cchfilepath : u32, dwflags : GETFINALPATHNAMEBYHANDLE_FLAGS) -> u32);
47windows_targets::link!("kernel32.dll" "system" fn GetFullPathNameW(lpfilename : PCWSTR, nbufferlength : u32, lpbuffer : PWSTR, lpfilepart : *mut PWSTR) -> u32);
48windows_targets::link!("kernel32.dll" "system" fn GetLastError() -> WIN32_ERROR);
49windows_targets::link!("kernel32.dll" "system" fn GetModuleFileNameW(hmodule : HMODULE, lpfilename : PWSTR, nsize : u32) -> u32);
50windows_targets::link!("kernel32.dll" "system" fn GetModuleHandleA(lpmodulename : PCSTR) -> HMODULE);
51windows_targets::link!("kernel32.dll" "system" fn GetModuleHandleW(lpmodulename : PCWSTR) -> HMODULE);
52windows_targets::link!("kernel32.dll" "system" fn GetOverlappedResult(hfile : HANDLE, lpoverlapped : *const OVERLAPPED, lpnumberofbytestransferred : *mut u32, bwait : BOOL) -> BOOL);
53windows_targets::link!("kernel32.dll" "system" fn GetProcAddress(hmodule : HMODULE, lpprocname : PCSTR) -> FARPROC);
54windows_targets::link!("kernel32.dll" "system" fn GetProcessId(process : HANDLE) -> u32);
55windows_targets::link!("kernel32.dll" "system" fn GetStdHandle(nstdhandle : STD_HANDLE) -> HANDLE);
56windows_targets::link!("kernel32.dll" "system" fn GetSystemDirectoryW(lpbuffer : PWSTR, usize : u32) -> u32);
57windows_targets::link!("kernel32.dll" "system" fn GetSystemInfo(lpsysteminfo : *mut SYSTEM_INFO));
58windows_targets::link!("kernel32.dll" "system" fn GetSystemTimeAsFileTime(lpsystemtimeasfiletime : *mut FILETIME));
59windows_targets::link!("kernel32.dll" "system" fn GetSystemTimePreciseAsFileTime(lpsystemtimeasfiletime : *mut FILETIME));
60windows_targets::link!("kernel32.dll" "system" fn GetTempPathW(nbufferlength : u32, lpbuffer : PWSTR) -> u32);
61windows_targets::link!("kernel32.dll" "system" fn GetWindowsDirectoryW(lpbuffer : PWSTR, usize : u32) -> u32);
62windows_targets::link!("kernel32.dll" "system" fn InitOnceBeginInitialize(lpinitonce : *mut INIT_ONCE, dwflags : u32, fpending : *mut BOOL, lpcontext : *mut *mut core::ffi::c_void) -> BOOL);
63windows_targets::link!("kernel32.dll" "system" fn InitOnceComplete(lpinitonce : *mut INIT_ONCE, dwflags : u32, lpcontext : *const core::ffi::c_void) -> BOOL);
64windows_targets::link!("kernel32.dll" "system" fn InitializeProcThreadAttributeList(lpattributelist : LPPROC_THREAD_ATTRIBUTE_LIST, dwattributecount : u32, dwflags : u32, lpsize : *mut usize) -> BOOL);
65windows_targets::link!("kernel32.dll" "system" fn LocalFree(hmem : HLOCAL) -> HLOCAL);
66windows_targets::link!("kernel32.dll" "system" fn MoveFileExW(lpexistingfilename : PCWSTR, lpnewfilename : PCWSTR, dwflags : MOVE_FILE_FLAGS) -> BOOL);
67windows_targets::link!("kernel32.dll" "system" fn MultiByteToWideChar(codepage : u32, dwflags : MULTI_BYTE_TO_WIDE_CHAR_FLAGS, lpmultibytestr : PCSTR, cbmultibyte : i32, lpwidecharstr : PWSTR, cchwidechar : i32) -> i32);
68windows_targets::link!("kernel32.dll" "system" fn QueryPerformanceCounter(lpperformancecount : *mut i64) -> BOOL);
69windows_targets::link!("kernel32.dll" "system" fn QueryPerformanceFrequency(lpfrequency : *mut i64) -> BOOL);
70windows_targets::link!("kernel32.dll" "system" fn ReadConsoleW(hconsoleinput : HANDLE, lpbuffer : *mut core::ffi::c_void, nnumberofcharstoread : u32, lpnumberofcharsread : *mut u32, pinputcontrol : *const CONSOLE_READCONSOLE_CONTROL) -> BOOL);
71windows_targets::link!("kernel32.dll" "system" fn ReadFile(hfile : HANDLE, lpbuffer : *mut u8, nnumberofbytestoread : u32, lpnumberofbytesread : *mut u32, lpoverlapped : *mut OVERLAPPED) -> BOOL);
72windows_targets::link!("kernel32.dll" "system" fn ReadFileEx(hfile : HANDLE, lpbuffer : *mut u8, nnumberofbytestoread : u32, lpoverlapped : *mut OVERLAPPED, lpcompletionroutine : LPOVERLAPPED_COMPLETION_ROUTINE) -> BOOL);
73windows_targets::link!("kernel32.dll" "system" fn ReleaseSRWLockExclusive(srwlock : *mut SRWLOCK));
74windows_targets::link!("kernel32.dll" "system" fn ReleaseSRWLockShared(srwlock : *mut SRWLOCK));
75windows_targets::link!("kernel32.dll" "system" fn RemoveDirectoryW(lppathname : PCWSTR) -> BOOL);
76windows_targets::link!("kernel32.dll" "system" fn SetCurrentDirectoryW(lppathname : PCWSTR) -> BOOL);
77windows_targets::link!("kernel32.dll" "system" fn SetEnvironmentVariableW(lpname : PCWSTR, lpvalue : PCWSTR) -> BOOL);
78windows_targets::link!("kernel32.dll" "system" fn SetFileAttributesW(lpfilename : PCWSTR, dwfileattributes : FILE_FLAGS_AND_ATTRIBUTES) -> BOOL);
79windows_targets::link!("kernel32.dll" "system" fn SetFileInformationByHandle(hfile : HANDLE, fileinformationclass : FILE_INFO_BY_HANDLE_CLASS, lpfileinformation : *const core::ffi::c_void, dwbuffersize : u32) -> BOOL);
80windows_targets::link!("kernel32.dll" "system" fn SetFilePointerEx(hfile : HANDLE, lidistancetomove : i64, lpnewfilepointer : *mut i64, dwmovemethod : SET_FILE_POINTER_MOVE_METHOD) -> BOOL);
81windows_targets::link!("kernel32.dll" "system" fn SetFileTime(hfile : HANDLE, lpcreationtime : *const FILETIME, lplastaccesstime : *const FILETIME, lplastwritetime : *const FILETIME) -> BOOL);
82windows_targets::link!("kernel32.dll" "system" fn SetHandleInformation(hobject : HANDLE, dwmask : u32, dwflags : HANDLE_FLAGS) -> BOOL);
83windows_targets::link!("kernel32.dll" "system" fn SetLastError(dwerrcode : WIN32_ERROR));
84windows_targets::link!("kernel32.dll" "system" fn SetThreadStackGuarantee(stacksizeinbytes : *mut u32) -> BOOL);
85windows_targets::link!("kernel32.dll" "system" fn SetWaitableTimer(htimer : HANDLE, lpduetime : *const i64, lperiod : i32, pfncompletionroutine : PTIMERAPCROUTINE, lpargtocompletionroutine : *const core::ffi::c_void, fresume : BOOL) -> BOOL);
86windows_targets::link!("kernel32.dll" "system" fn Sleep(dwmilliseconds : u32));
87windows_targets::link!("kernel32.dll" "system" fn SleepConditionVariableSRW(conditionvariable : *mut CONDITION_VARIABLE, srwlock : *mut SRWLOCK, dwmilliseconds : u32, flags : u32) -> BOOL);
88windows_targets::link!("kernel32.dll" "system" fn SleepEx(dwmilliseconds : u32, balertable : BOOL) -> u32);
89windows_targets::link!("kernel32.dll" "system" fn SwitchToThread() -> BOOL);
90windows_targets::link!("kernel32.dll" "system" fn TerminateProcess(hprocess : HANDLE, uexitcode : u32) -> BOOL);
91windows_targets::link!("kernel32.dll" "system" fn TlsAlloc() -> u32);
92windows_targets::link!("kernel32.dll" "system" fn TlsFree(dwtlsindex : u32) -> BOOL);
93windows_targets::link!("kernel32.dll" "system" fn TlsGetValue(dwtlsindex : u32) -> *mut core::ffi::c_void);
94windows_targets::link!("kernel32.dll" "system" fn TlsSetValue(dwtlsindex : u32, lptlsvalue : *const core::ffi::c_void) -> BOOL);
95windows_targets::link!("kernel32.dll" "system" fn TryAcquireSRWLockExclusive(srwlock : *mut SRWLOCK) -> BOOLEAN);
96windows_targets::link!("kernel32.dll" "system" fn TryAcquireSRWLockShared(srwlock : *mut SRWLOCK) -> BOOLEAN);
97windows_targets::link!("kernel32.dll" "system" fn UpdateProcThreadAttribute(lpattributelist : LPPROC_THREAD_ATTRIBUTE_LIST, dwflags : u32, attribute : usize, lpvalue : *const core::ffi::c_void, cbsize : usize, lppreviousvalue : *mut core::ffi::c_void, lpreturnsize : *const usize) -> BOOL);
98windows_targets::link!("kernel32.dll" "system" fn WaitForMultipleObjects(ncount : u32, lphandles : *const HANDLE, bwaitall : BOOL, dwmilliseconds : u32) -> WAIT_EVENT);
99windows_targets::link!("kernel32.dll" "system" fn WaitForSingleObject(hhandle : HANDLE, dwmilliseconds : u32) -> WAIT_EVENT);
100windows_targets::link!("kernel32.dll" "system" fn WakeAllConditionVariable(conditionvariable : *mut CONDITION_VARIABLE));
101windows_targets::link!("kernel32.dll" "system" fn WakeConditionVariable(conditionvariable : *mut CONDITION_VARIABLE));
102windows_targets::link!("kernel32.dll" "system" fn WideCharToMultiByte(codepage : u32, dwflags : u32, lpwidecharstr : PCWSTR, cchwidechar : i32, lpmultibytestr : PSTR, cbmultibyte : i32, lpdefaultchar : PCSTR, lpuseddefaultchar : *mut BOOL) -> i32);
103windows_targets::link!("kernel32.dll" "system" fn WriteConsoleW(hconsoleoutput : HANDLE, lpbuffer : PCWSTR, nnumberofcharstowrite : u32, lpnumberofcharswritten : *mut u32, lpreserved : *const core::ffi::c_void) -> BOOL);
104windows_targets::link!("kernel32.dll" "system" fn WriteFileEx(hfile : HANDLE, lpbuffer : *const u8, nnumberofbytestowrite : u32, lpoverlapped : *mut OVERLAPPED, lpcompletionroutine : LPOVERLAPPED_COMPLETION_ROUTINE) -> BOOL);
105windows_targets::link!("ntdll.dll" "system" fn NtCreateFile(filehandle : *mut HANDLE, desiredaccess : FILE_ACCESS_RIGHTS, objectattributes : *const OBJECT_ATTRIBUTES, iostatusblock : *mut IO_STATUS_BLOCK, allocationsize : *const i64, fileattributes : FILE_FLAGS_AND_ATTRIBUTES, shareaccess : FILE_SHARE_MODE, createdisposition : NTCREATEFILE_CREATE_DISPOSITION, createoptions : NTCREATEFILE_CREATE_OPTIONS, eabuffer : *const core::ffi::c_void, ealength : u32) -> NTSTATUS);
106windows_targets::link!("ntdll.dll" "system" fn NtReadFile(filehandle : HANDLE, event : HANDLE, apcroutine : PIO_APC_ROUTINE, apccontext : *const core::ffi::c_void, iostatusblock : *mut IO_STATUS_BLOCK, buffer : *mut core::ffi::c_void, length : u32, byteoffset : *const i64, key : *const u32) -> NTSTATUS);
107windows_targets::link!("ntdll.dll" "system" fn NtWriteFile(filehandle : HANDLE, event : HANDLE, apcroutine : PIO_APC_ROUTINE, apccontext : *const core::ffi::c_void, iostatusblock : *mut IO_STATUS_BLOCK, buffer : *const core::ffi::c_void, length : u32, byteoffset : *const i64, key : *const u32) -> NTSTATUS);
108windows_targets::link!("ntdll.dll" "system" fn RtlNtStatusToDosError(status : NTSTATUS) -> u32);
109windows_targets::link!("userenv.dll" "system" fn GetUserProfileDirectoryW(htoken : HANDLE, lpprofiledir : PWSTR, lpcchsize : *mut u32) -> BOOL);
110windows_targets::link!("ws2_32.dll" "system" fn WSACleanup() -> i32);
111windows_targets::link!("ws2_32.dll" "system" fn WSADuplicateSocketW(s : SOCKET, dwprocessid : u32, lpprotocolinfo : *mut WSAPROTOCOL_INFOW) -> i32);
112windows_targets::link!("ws2_32.dll" "system" fn WSAGetLastError() -> WSA_ERROR);
113windows_targets::link!("ws2_32.dll" "system" fn WSARecv(s : SOCKET, lpbuffers : *const WSABUF, dwbuffercount : u32, lpnumberofbytesrecvd : *mut u32, lpflags : *mut u32, lpoverlapped : *mut OVERLAPPED, lpcompletionroutine : LPWSAOVERLAPPED_COMPLETION_ROUTINE) -> i32);
114windows_targets::link!("ws2_32.dll" "system" fn WSASend(s : SOCKET, lpbuffers : *const WSABUF, dwbuffercount : u32, lpnumberofbytessent : *mut u32, dwflags : u32, lpoverlapped : *mut OVERLAPPED, lpcompletionroutine : LPWSAOVERLAPPED_COMPLETION_ROUTINE) -> i32);
115windows_targets::link!("ws2_32.dll" "system" fn WSASocketW(af : i32, r#type : i32, protocol : i32, lpprotocolinfo : *const WSAPROTOCOL_INFOW, g : u32, dwflags : u32) -> SOCKET);
116windows_targets::link!("ws2_32.dll" "system" fn accept(s : SOCKET, addr : *mut SOCKADDR, addrlen : *mut i32) -> SOCKET);
117windows_targets::link!("ws2_32.dll" "system" fn bind(s : SOCKET, name : *const SOCKADDR, namelen : i32) -> i32);
118windows_targets::link!("ws2_32.dll" "system" fn closesocket(s : SOCKET) -> i32);
119windows_targets::link!("ws2_32.dll" "system" fn connect(s : SOCKET, name : *const SOCKADDR, namelen : i32) -> i32);
120windows_targets::link!("ws2_32.dll" "system" fn freeaddrinfo(paddrinfo : *const ADDRINFOA));
121windows_targets::link!("ws2_32.dll" "system" fn getaddrinfo(pnodename : PCSTR, pservicename : PCSTR, phints : *const ADDRINFOA, ppresult : *mut *mut ADDRINFOA) -> i32);
122windows_targets::link!("ws2_32.dll" "system" fn getpeername(s : SOCKET, name : *mut SOCKADDR, namelen : *mut i32) -> i32);
123windows_targets::link!("ws2_32.dll" "system" fn getsockname(s : SOCKET, name : *mut SOCKADDR, namelen : *mut i32) -> i32);
124windows_targets::link!("ws2_32.dll" "system" fn getsockopt(s : SOCKET, level : i32, optname : i32, optval : PSTR, optlen : *mut i32) -> i32);
125windows_targets::link!("ws2_32.dll" "system" fn ioctlsocket(s : SOCKET, cmd : i32, argp : *mut u32) -> i32);
126windows_targets::link!("ws2_32.dll" "system" fn listen(s : SOCKET, backlog : i32) -> i32);
127windows_targets::link!("ws2_32.dll" "system" fn recv(s : SOCKET, buf : PSTR, len : i32, flags : SEND_RECV_FLAGS) -> i32);
128windows_targets::link!("ws2_32.dll" "system" fn recvfrom(s : SOCKET, buf : PSTR, len : i32, flags : i32, from : *mut SOCKADDR, fromlen : *mut i32) -> i32);
129windows_targets::link!("ws2_32.dll" "system" fn select(nfds : i32, readfds : *mut FD_SET, writefds : *mut FD_SET, exceptfds : *mut FD_SET, timeout : *const TIMEVAL) -> i32);
130windows_targets::link!("ws2_32.dll" "system" fn send(s : SOCKET, buf : PCSTR, len : i32, flags : SEND_RECV_FLAGS) -> i32);
131windows_targets::link!("ws2_32.dll" "system" fn sendto(s : SOCKET, buf : PCSTR, len : i32, flags : i32, to : *const SOCKADDR, tolen : i32) -> i32);
132windows_targets::link!("ws2_32.dll" "system" fn setsockopt(s : SOCKET, level : i32, optname : i32, optval : PCSTR, optlen : i32) -> i32);
133windows_targets::link!("ws2_32.dll" "system" fn shutdown(s : SOCKET, how : WINSOCK_SHUTDOWN_HOW) -> i32);
841134pub const ABOVE_NORMAL_PRIORITY_CLASS: PROCESS_CREATION_FLAGS = 32768u32;
842135pub type ADDRESS_FAMILY = u16;
843136#[repr(C)]
......@@ -3991,3 +3284,4 @@ pub struct XSAVE_FORMAT {
39913284 pub Reserved4: [u8; 224],
39923285}
39933286// ignore-tidy-filelength
3287use super::windows_targets;
library/std/src/sys/pal/windows/c/windows_targets.rs created+24
......@@ -0,0 +1,24 @@
1//! Provides the `link!` macro used by the generated windows bindings.
2//!
3//! This is a simple wrapper around an `extern` block with a `#[link]` attribute.
4//! It's very roughly equivalent to the windows-targets crate.
5
6pub macro link {
7 ($library:literal $abi:literal $($link_name:literal)? $(#[$doc:meta])? fn $($function:tt)*) => (
8 // Note: the windows-targets crate uses a pre-built Windows.lib import library which we don't
9 // have in this repo. So instead we always link kernel32.lib and add the rest of the import
10 // libraries below by using an empty extern block. This works because extern blocks are not
11 // connected to the library given in the #[link] attribute.
12 #[link(name = "kernel32")]
13 extern $abi {
14 $(#[link_name=$link_name])?
15 pub fn $($function)*;
16 }
17 )
18}
19
20#[link(name = "advapi32")]
21#[link(name = "ntdll")]
22#[link(name = "userenv")]
23#[link(name = "ws2_32")]
24extern "C" {}
library/std/src/sys/pal/windows/stdio.rs+1-7
......@@ -232,13 +232,7 @@ fn write_u16s(handle: c::HANDLE, data: &[u16]) -> io::Result<usize> {
232232 debug_assert!(data.len() < u32::MAX as usize);
233233 let mut written = 0;
234234 cvt(unsafe {
235 c::WriteConsoleW(
236 handle,
237 data.as_ptr() as c::LPCVOID,
238 data.len() as u32,
239 &mut written,
240 ptr::null_mut(),
241 )
235 c::WriteConsoleW(handle, data.as_ptr(), data.len() as u32, &mut written, ptr::null_mut())
242236 })?;
243237 Ok(written as usize)
244238}
src/tools/generate-windows-sys/Cargo.toml+1-1
......@@ -4,4 +4,4 @@ version = "0.1.0"
44edition = "2021"
55
66[dependencies.windows-bindgen]
7version = "0.57.0"
7version = "0.58.0"
src/tools/generate-windows-sys/src/main.rs+1
......@@ -17,6 +17,7 @@ fn main() -> Result<(), Box<dyn Error>> {
1717
1818 let mut f = std::fs::File::options().append(true).open("windows_sys.rs")?;
1919 writeln!(&mut f, "// ignore-tidy-filelength")?;
20 writeln!(&mut f, "use super::windows_targets;")?;
2021
2122 Ok(())
2223}
src/tools/miri/src/shims/windows/foreign_items.rs+16
......@@ -758,6 +758,22 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
758758 this.write_null(dest)?;
759759 }
760760
761 "_Unwind_RaiseException" => {
762 // This is not formally part of POSIX, but it is very wide-spread on POSIX systems.
763 // It was originally specified as part of the Itanium C++ ABI:
764 // https://itanium-cxx-abi.github.io/cxx-abi/abi-eh.html#base-throw.
765 // MinGW implements _Unwind_RaiseException on top of SEH exceptions.
766 if this.tcx.sess.target.env != "gnu" {
767 throw_unsup_format!(
768 "`_Unwind_RaiseException` is not supported on non-MinGW Windows",
769 );
770 }
771 // This function looks and behaves excatly like miri_start_unwind.
772 let [payload] = this.check_shim(abi, Abi::C { unwind: true }, link_name, args)?;
773 this.handle_miri_start_unwind(payload)?;
774 return Ok(EmulateItemResult::NeedsUnwind);
775 }
776
761777 _ => return Ok(EmulateItemResult::NotSupported),
762778 }
763779
src/tools/run-make-support/src/command.rs+3-2
......@@ -75,11 +75,12 @@ impl Command {
7575 /// Generic command arguments provider. Prefer specific helper methods if possible.
7676 /// Note that for some executables, arguments might be platform specific. For C/C++
7777 /// compilers, arguments might be platform *and* compiler specific.
78 pub fn args<S>(&mut self, args: &[S]) -> &mut Self
78 pub fn args<S, V>(&mut self, args: V) -> &mut Self
7979 where
8080 S: AsRef<ffi::OsStr>,
81 V: AsRef<[S]>,
8182 {
82 self.cmd.args(args);
83 self.cmd.args(args.as_ref());
8384 self
8485 }
8586
src/tools/run-make-support/src/lib.rs+34
......@@ -261,6 +261,40 @@ pub fn test_while_readonly<P: AsRef<Path>, F: FnOnce() + std::panic::UnwindSafe>
261261 success.unwrap();
262262}
263263
264/// Browse the directory `path` non-recursively and return all files which respect the parameters
265/// outlined by `closure`.
266#[track_caller]
267pub fn shallow_find_files<P: AsRef<Path>, F: Fn(&PathBuf) -> bool>(
268 path: P,
269 closure: F,
270) -> Vec<PathBuf> {
271 let mut matching_files = Vec::new();
272 for entry in fs_wrapper::read_dir(path) {
273 let entry = entry.expect("failed to read directory entry.");
274 let path = entry.path();
275
276 if path.is_file() && closure(&path) {
277 matching_files.push(path);
278 }
279 }
280 matching_files
281}
282
283/// Returns true if the filename at `path` starts with `prefix`.
284pub fn has_prefix<P: AsRef<Path>>(path: P, prefix: &str) -> bool {
285 path.as_ref().file_name().is_some_and(|name| name.to_str().unwrap().starts_with(prefix))
286}
287
288/// Returns true if the filename at `path` has the extension `extension`.
289pub fn has_extension<P: AsRef<Path>>(path: P, extension: &str) -> bool {
290 path.as_ref().extension().is_some_and(|ext| ext == extension)
291}
292
293/// Returns true if the filename at `path` does not contain `expected`.
294pub fn not_contains<P: AsRef<Path>>(path: P, expected: &str) -> bool {
295 !path.as_ref().file_name().is_some_and(|name| name.to_str().unwrap().contains(expected))
296}
297
264298/// Use `cygpath -w` on a path to get a Windows path string back. This assumes that `cygpath` is
265299/// available on the platform!
266300#[track_caller]
src/tools/tidy/src/allowed_run_make_makefiles.txt-5
......@@ -46,7 +46,6 @@ run-make/fmt-write-bloat/Makefile
4646run-make/foreign-double-unwind/Makefile
4747run-make/foreign-exceptions/Makefile
4848run-make/foreign-rust-exceptions/Makefile
49run-make/include_bytes_deps/Makefile
5049run-make/incr-add-rust-src-component/Makefile
5150run-make/incr-foreign-head-span/Makefile
5251run-make/interdependent-c-libraries/Makefile
......@@ -64,7 +63,6 @@ run-make/issue-33329/Makefile
6463run-make/issue-35164/Makefile
6564run-make/issue-36710/Makefile
6665run-make/issue-37839/Makefile
67run-make/issue-40535/Makefile
6866run-make/issue-47551/Makefile
6967run-make/issue-69368/Makefile
7068run-make/issue-83045/Makefile
......@@ -102,8 +100,6 @@ run-make/no-alloc-shim/Makefile
102100run-make/no-builtins-attribute/Makefile
103101run-make/no-duplicate-libs/Makefile
104102run-make/obey-crate-type-flag/Makefile
105run-make/optimization-remarks-dir-pgo/Makefile
106run-make/optimization-remarks-dir/Makefile
107103run-make/output-type-permutations/Makefile
108104run-make/panic-abort-eh_frame/Makefile
109105run-make/pass-linker-flags-flavor/Makefile
......@@ -136,7 +132,6 @@ run-make/return-non-c-like-enum-from-c/Makefile
136132run-make/rlib-format-packed-bundled-libs-2/Makefile
137133run-make/rlib-format-packed-bundled-libs-3/Makefile
138134run-make/rlib-format-packed-bundled-libs/Makefile
139run-make/rmeta-preferred/Makefile
140135run-make/rustc-macro-dep-files/Makefile
141136run-make/sanitizer-cdylib-link/Makefile
142137run-make/sanitizer-dylib-link/Makefile
tests/run-make/include-bytes-deps/input.bin created+1
......@@ -0,0 +1 @@
1Hello world!
tests/run-make/include-bytes-deps/input.md created+1
......@@ -0,0 +1 @@
1# Hello, world!
tests/run-make/include-bytes-deps/input.txt created+1
......@@ -0,0 +1 @@
1Hello world!
tests/run-make/include-bytes-deps/main.rs created+10
......@@ -0,0 +1,10 @@
1#[doc = include_str!("input.md")]
2pub struct SomeStruct;
3
4pub fn main() {
5 const INPUT_TXT: &'static str = include_str!("input.txt");
6 const INPUT_BIN: &'static [u8] = include_bytes!("input.bin");
7
8 println!("{}", INPUT_TXT);
9 println!("{:?}", INPUT_BIN);
10}
tests/run-make/include-bytes-deps/rmake.rs created+13
......@@ -0,0 +1,13 @@
1// include_bytes! and include_str! in `main.rs`
2// should register the included file as of #24423,
3// and this test checks that this is still the case.
4// See https://github.com/rust-lang/rust/pull/24423
5
6use run_make_support::{invalid_utf8_contains, rustc};
7
8fn main() {
9 rustc().emit("dep-info").input("main.rs").run();
10 invalid_utf8_contains("main.d", "input.txt");
11 invalid_utf8_contains("main.d", "input.bin");
12 invalid_utf8_contains("main.d", "input.md");
13}
tests/run-make/include_bytes_deps/Makefile deleted-7
......@@ -1,7 +0,0 @@
1include ../tools.mk
2
3# ignore-freebsd
4
5all:
6 $(RUSTC) --emit dep-info main.rs
7 $(CGREP) "input.txt" "input.bin" "input.md" < $(TMPDIR)/main.d
tests/run-make/include_bytes_deps/input.bin deleted-1
......@@ -1 +0,0 @@
1Hello world!
tests/run-make/include_bytes_deps/input.md deleted-1
......@@ -1 +0,0 @@
1# Hello, world!
tests/run-make/include_bytes_deps/input.txt deleted-1
......@@ -1 +0,0 @@
1Hello world!
tests/run-make/include_bytes_deps/main.rs deleted-10
......@@ -1,10 +0,0 @@
1#[doc = include_str!("input.md")]
2pub struct SomeStruct;
3
4pub fn main() {
5 const INPUT_TXT: &'static str = include_str!("input.txt");
6 const INPUT_BIN: &'static [u8] = include_bytes!("input.bin");
7
8 println!("{}", INPUT_TXT);
9 println!("{:?}", INPUT_BIN);
10}
tests/run-make/issue-40535/Makefile deleted-13
......@@ -1,13 +0,0 @@
1include ../tools.mk
2
3# The ICE occurred in the following situation:
4# * `foo` declares `extern crate bar, baz`, depends only on `bar` (forgetting `baz` in `Cargo.toml`)
5# * `bar` declares and depends on `extern crate baz`
6# * All crates built in metadata-only mode (`cargo check`)
7all:
8 # cc https://github.com/rust-lang/rust/issues/40623
9 $(RUSTC) baz.rs --emit=metadata
10 $(RUSTC) bar.rs --emit=metadata --extern baz=$(TMPDIR)/libbaz.rmeta
11 $(RUSTC) foo.rs --emit=metadata --extern bar=$(TMPDIR)/libbar.rmeta 2>&1 | \
12 $(CGREP) -v "unexpectedly panicked"
13 # ^ Succeeds if it doesn't find the ICE message
tests/run-make/issue-40535/bar.rs deleted-3
......@@ -1,3 +0,0 @@
1#![crate_type = "lib"]
2
3extern crate baz;
tests/run-make/issue-40535/baz.rs deleted-1
......@@ -1 +0,0 @@
1#![crate_type = "lib"]
tests/run-make/issue-40535/foo.rs deleted-4
......@@ -1,4 +0,0 @@
1#![crate_type = "lib"]
2
3extern crate bar;
4extern crate baz;
tests/run-make/llvm-ident/rmake.rs+1-1
......@@ -28,7 +28,7 @@ fn main() {
2828 files.push(path.to_path_buf());
2929 }
3030 });
31 cmd(llvm_bin_dir().join("llvm-dis")).args(&files).run();
31 cmd(llvm_bin_dir().join("llvm-dis")).args(files).run();
3232
3333 // Check LLVM IR files (including temporary outputs) have `!llvm.ident`
3434 // named metadata, reusing the related codegen test.
tests/run-make/metadata-only-crate-no-ice/bar.rs created+3
......@@ -0,0 +1,3 @@
1#![crate_type = "lib"]
2
3extern crate baz;
tests/run-make/metadata-only-crate-no-ice/baz.rs created+1
......@@ -0,0 +1 @@
1#![crate_type = "lib"]
tests/run-make/metadata-only-crate-no-ice/foo.rs created+4
......@@ -0,0 +1,4 @@
1#![crate_type = "lib"]
2
3extern crate bar;
4extern crate baz;
tests/run-make/metadata-only-crate-no-ice/rmake.rs created+14
......@@ -0,0 +1,14 @@
1// In a dependency hierarchy, metadata-only crates could cause an Internal
2// Compiler Error (ICE) due to a compiler bug - not correctly fetching sources for
3// metadata-only crates. This test is a minimal reproduction of a program that triggered
4// this bug, and checks that no ICE occurs.
5// See https://github.com/rust-lang/rust/issues/40535
6
7use run_make_support::rustc;
8
9fn main() {
10 rustc().input("baz.rs").emit("metadata").run();
11 rustc().input("bar.rs").emit("metadata").extern_("baz", "libbaz.rmeta").run();
12 // There should be no internal compiler error.
13 rustc().input("foo.rs").emit("metadata").extern_("bar", "libbaz.rmeta").run();
14}
tests/run-make/optimization-remarks-dir-pgo/Makefile deleted-17
......@@ -1,17 +0,0 @@
1# needs-profiler-support
2# ignore-cross-compile
3
4include ../tools.mk
5
6PROFILE_DIR=$(TMPDIR)/profiles
7
8check_hotness:
9 $(RUSTC) -Cprofile-generate="$(TMPDIR)"/profdata -O foo.rs -o$(TMPDIR)/foo
10 $(TMPDIR)/foo
11 "$(LLVM_BIN_DIR)"/llvm-profdata merge \
12 -o "$(TMPDIR)"/merged.profdata \
13 "$(TMPDIR)"/profdata/*.profraw
14 $(RUSTC) -Cprofile-use=$(TMPDIR)/merged.profdata -O foo.rs -Cremark=all -Zremark-dir=$(PROFILE_DIR)
15
16 # Check that PGO hotness is included in the remark files
17 cat $(PROFILE_DIR)/*.opt.yaml | $(CGREP) -e "Hotness"
tests/run-make/optimization-remarks-dir-pgo/rmake.rs created+41
......@@ -0,0 +1,41 @@
1// This test checks the -Zremark-dir flag, which writes LLVM
2// optimization remarks to the YAML format. When using PGO (Profile
3// Guided Optimization), the Hotness attribute should be included in
4// the output remark files.
5// See https://github.com/rust-lang/rust/pull/114439
6
7//@ needs-profiler-support
8//@ ignore-cross-compile
9
10use run_make_support::{
11 has_extension, has_prefix, invalid_utf8_contains, llvm_profdata, run, rustc, shallow_find_files,
12};
13
14fn main() {
15 rustc().profile_generate("profdata").opt().input("foo.rs").output("foo").run();
16 run("foo");
17 // The profdata filename is a long sequence of numbers, fetch it by prefix and extension
18 // to keep the test working even if the filename changes.
19 let profdata_files = shallow_find_files("profdata", |path| {
20 has_prefix(path, "default") && has_extension(path, "profraw")
21 });
22 let profdata_file = profdata_files.get(0).unwrap();
23 llvm_profdata().merge().output("merged.profdata").input(profdata_file).run();
24 rustc()
25 .profile_use("merged.profdata")
26 .opt()
27 .input("foo.rs")
28 .arg("-Cremark=all")
29 .arg("-Zremark-dir=profiles")
30 .run();
31 // Check that PGO hotness is included in the remark files
32 let remark_files = shallow_find_files("profiles", |path| {
33 has_prefix(path, "foo") && has_extension(path, "yaml")
34 });
35 assert!(!remark_files.is_empty());
36 for file in remark_files {
37 if !file.to_str().unwrap().contains("codegen") {
38 invalid_utf8_contains(file, "Hotness")
39 };
40 }
41}
tests/run-make/optimization-remarks-dir/Makefile deleted-12
......@@ -1,12 +0,0 @@
1include ../tools.mk
2
3PROFILE_DIR=$(TMPDIR)/profiles
4
5all: check_inline check_filter
6
7check_inline:
8 $(RUSTC) -O foo.rs --crate-type=lib -Cremark=all -Zremark-dir=$(PROFILE_DIR)
9 cat $(PROFILE_DIR)/*.opt.yaml | $(CGREP) -e "inline"
10check_filter:
11 $(RUSTC) -O foo.rs --crate-type=lib -Cremark=foo -Zremark-dir=$(PROFILE_DIR)
12 cat $(PROFILE_DIR)/*.opt.yaml | $(CGREP) -e -v "inline"
tests/run-make/optimization-remarks-dir/rmake.rs created+39
......@@ -0,0 +1,39 @@
1// In this test, the function `bar` has #[inline(never)] and the function `foo`
2// does not. This test outputs LLVM optimization remarks twice - first for all
3// functions (including `bar`, and the `inline` mention), and then for only `foo`
4// (should not have the `inline` mention).
5// See https://github.com/rust-lang/rust/pull/113040
6
7use run_make_support::{
8 has_extension, has_prefix, invalid_utf8_contains, invalid_utf8_not_contains, not_contains,
9 rustc, shallow_find_files,
10};
11
12fn main() {
13 rustc()
14 .opt()
15 .input("foo.rs")
16 .crate_type("lib")
17 .arg("-Cremark=all")
18 .arg("-Zremark-dir=profiles_all")
19 .run();
20 let all_remark_files = shallow_find_files("profiles_all", |path| {
21 has_prefix(path, "foo") && has_extension(path, "yaml") && not_contains(path, "codegen")
22 });
23 for file in all_remark_files {
24 invalid_utf8_contains(file, "inline")
25 }
26 rustc()
27 .opt()
28 .input("foo.rs")
29 .crate_type("lib")
30 .arg("-Cremark=foo")
31 .arg("-Zremark-dir=profiles_foo")
32 .run();
33 let foo_remark_files = shallow_find_files("profiles_foo", |path| {
34 has_prefix(path, "foo") && has_extension(path, "yaml")
35 });
36 for file in foo_remark_files {
37 invalid_utf8_not_contains(file, "inline")
38 }
39}
tests/run-make/rmeta-preferred/Makefile deleted-16
......@@ -1,16 +0,0 @@
1# ignore-cross-compile
2include ../tools.mk
3
4# Test that using rlibs and rmeta dep crates work together. Specifically, that
5# there can be both an rmeta and an rlib file and rustc will prefer the rmeta
6# file.
7#
8# This behavior is simply making sure this doesn't accidentally change; in this
9# case we want to make sure that the rlib isn't being used as that would cause
10# bugs in -Zbinary-dep-depinfo (see #68298).
11
12all:
13 $(RUSTC) rmeta_aux.rs --crate-type=rlib --emit link,metadata
14 $(RUSTC) lib.rs --crate-type=rlib --emit dep-info -Zbinary-dep-depinfo
15 $(CGREP) "librmeta_aux.rmeta" < $(TMPDIR)/lib.d
16 $(CGREP) -v "librmeta_aux.rlib" < $(TMPDIR)/lib.d
tests/run-make/rmeta-preferred/rmake.rs created+18
......@@ -0,0 +1,18 @@
1// This test compiles `lib.rs`'s dependency, `rmeta_aux.rs`, as both an rlib
2// and an rmeta crate. By default, rustc should give the metadata crate (rmeta)
3// precedence over the rust-lib (rlib). This test inspects the contents of the binary
4// and that the correct (rmeta) crate was used.
5// rlibs being preferred could indicate a resurgence of the -Zbinary-dep-depinfo bug
6// seen in #68298.
7// See https://github.com/rust-lang/rust/pull/37681
8
9//@ ignore-cross-compile
10
11use run_make_support::{invalid_utf8_contains, invalid_utf8_not_contains, rustc};
12
13fn main() {
14 rustc().input("rmeta_aux.rs").crate_type("rlib").emit("link,metadata").run();
15 rustc().input("lib.rs").crate_type("rlib").emit("dep-info").arg("-Zbinary-dep-depinfo").run();
16 invalid_utf8_contains("lib.d", "librmeta_aux.rmeta");
17 invalid_utf8_not_contains("lib.d", "librmeta_aux.rlib");
18}
tests/ui/feature-gates/feature-gate-negate-unsigned.stderr+5-4
......@@ -2,12 +2,13 @@ error[E0600]: cannot apply unary operator `-` to type `usize`
22 --> $DIR/feature-gate-negate-unsigned.rs:10:23
33 |
44LL | let _max: usize = -1;
5 | ^^
6 | |
7 | cannot apply unary operator `-`
8 | help: you may have meant the maximum value of `usize`: `usize::MAX`
5 | ^^ cannot apply unary operator `-`
96 |
107 = note: unsigned values cannot be negated
8help: you may have meant the maximum value of `usize`
9 |
10LL | let _max: usize = usize::MAX;
11 | ~~~~~~~~~~
1112
1213error[E0600]: cannot apply unary operator `-` to type `u8`
1314 --> $DIR/feature-gate-negate-unsigned.rs:14:14
tests/ui/unsigned-literal-negation.stderr+15-12
......@@ -2,34 +2,37 @@ error[E0600]: cannot apply unary operator `-` to type `usize`
22 --> $DIR/unsigned-literal-negation.rs:2:13
33 |
44LL | let x = -1 as usize;
5 | ^^
6 | |
7 | cannot apply unary operator `-`
8 | help: you may have meant the maximum value of `usize`: `usize::MAX`
5 | ^^ cannot apply unary operator `-`
96 |
107 = note: unsigned values cannot be negated
8help: you may have meant the maximum value of `usize`
9 |
10LL | let x = usize::MAX;
11 | ~~~~~~~~~~
1112
1213error[E0600]: cannot apply unary operator `-` to type `usize`
1314 --> $DIR/unsigned-literal-negation.rs:3:13
1415 |
1516LL | let x = (-1) as usize;
16 | ^^^^
17 | |
18 | cannot apply unary operator `-`
19 | help: you may have meant the maximum value of `usize`: `usize::MAX`
17 | ^^^^ cannot apply unary operator `-`
2018 |
2119 = note: unsigned values cannot be negated
20help: you may have meant the maximum value of `usize`
21 |
22LL | let x = usize::MAX;
23 | ~~~~~~~~~~
2224
2325error[E0600]: cannot apply unary operator `-` to type `u32`
2426 --> $DIR/unsigned-literal-negation.rs:4:18
2527 |
2628LL | let x: u32 = -1;
27 | ^^
28 | |
29 | cannot apply unary operator `-`
30 | help: you may have meant the maximum value of `u32`: `u32::MAX`
29 | ^^ cannot apply unary operator `-`
3130 |
3231 = note: unsigned values cannot be negated
32help: you may have meant the maximum value of `u32`
33 |
34LL | let x: u32 = u32::MAX;
35 | ~~~~~~~~
3336
3437error: aborting due to 3 previous errors
3538