| author | bors <bors@rust-lang.org> 2024-07-05 11:32:40 UTC |
| committer | bors <bors@rust-lang.org> 2024-07-05 11:32:40 UTC |
| log | 11dd90f7613a4b160ed8398a3f1c7c129ad1a372 |
| tree | 81cfa92ddffd6bfd8e36eac442c62085216ee7aa |
| parent | 2ad66306738f8fb4b88f7ac19f3a80491ce28e29 |
| parent | 4fd3b123bc4c25833d2270a428c1ba05e807af09 |
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: rollup51 files changed, 532 insertions(+), 1079 deletions(-)
Cargo.lock+4-4| ... | ... | @@ -6356,9 +6356,9 @@ dependencies = [ |
| 6356 | 6356 | |
| 6357 | 6357 | [[package]] |
| 6358 | 6358 | name = "windows-bindgen" |
| 6359 | version = "0.57.0" | |
| 6359 | version = "0.58.0" | |
| 6360 | 6360 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 6361 | checksum = "1ccb96113d6277ba543c0f77e1c5494af8094bf9daf9b85acdc3f1b620e7c7b4" | |
| 6361 | checksum = "91cd28d93c692351f3a6e5615567c56756e330bee1c99c6bdd57bfc5ab15f589" | |
| 6362 | 6362 | dependencies = [ |
| 6363 | 6363 | "proc-macro2", |
| 6364 | 6364 | "rayon", |
| ... | ... | @@ -6379,9 +6379,9 @@ dependencies = [ |
| 6379 | 6379 | |
| 6380 | 6380 | [[package]] |
| 6381 | 6381 | name = "windows-metadata" |
| 6382 | version = "0.57.0" | |
| 6382 | version = "0.58.0" | |
| 6383 | 6383 | source = "registry+https://github.com/rust-lang/crates.io-index" |
| 6384 | checksum = "8308d076825b9d9e5abc64f8113e96d02b2aeeba869b20fdd65c7e70cda13dfc" | |
| 6384 | checksum = "2e837f3c3012cfe9e7086302a93f441a7999439be1ad4c530d55d2f6d2921809" | |
| 6385 | 6385 | |
| 6386 | 6386 | [[package]] |
| 6387 | 6387 | name = "windows-sys" |
compiler/rustc_hir_typeck/src/op.rs+11-2| ... | ... | @@ -838,8 +838,17 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { |
| 838 | 838 | }, |
| 839 | 839 | ) = ex.kind |
| 840 | 840 | { |
| 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, | |
| 843 | 852 | format!( |
| 844 | 853 | "you may have meant the maximum value of `{actual}`", |
| 845 | 854 | ), |
compiler/rustc_middle/src/middle/dependency_format.rs+3-3| ... | ... | @@ -4,15 +4,15 @@ |
| 4 | 4 | //! For all the gory details, see the provider of the `dependency_formats` |
| 5 | 5 | //! query. |
| 6 | 6 | |
| 7 | // FIXME: move this file to rustc_metadata::dependency_format, but | |
| 8 | // this will introduce circular dependency between rustc_metadata and rustc_middle | |
| 9 | ||
| 7 | 10 | use rustc_macros::{Decodable, Encodable, HashStable}; |
| 8 | 11 | use rustc_session::config::CrateType; |
| 9 | 12 | |
| 10 | 13 | /// A list of dependencies for a certain crate type. |
| 11 | 14 | /// |
| 12 | 15 | /// 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). | |
| 16 | 16 | pub type DependencyList = Vec<Linkage>; |
| 17 | 17 | |
| 18 | 18 | /// 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 { |
| 103 | 103 | SpanMarker, |
| 104 | 104 | |
| 105 | 105 | /// Marks its enclosing basic block with an ID that can be referred to by |
| 106 | /// side data in [`BranchInfo`]. | |
| 106 | /// side data in [`CoverageInfoHi`]. | |
| 107 | 107 | /// |
| 108 | 108 | /// Should be erased before codegen (at some point after `InstrumentCoverage`). |
| 109 | 109 | BlockMarker { id: BlockMarkerId }, |
| ... | ... | @@ -274,10 +274,15 @@ pub struct FunctionCoverageInfo { |
| 274 | 274 | pub mcdc_num_condition_bitmaps: usize, |
| 275 | 275 | } |
| 276 | 276 | |
| 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.) | |
| 278 | 283 | #[derive(Clone, Debug)] |
| 279 | 284 | #[derive(TyEncodable, TyDecodable, Hash, HashStable, TypeFoldable, TypeVisitable)] |
| 280 | pub struct BranchInfo { | |
| 285 | pub struct CoverageInfoHi { | |
| 281 | 286 | /// 1 more than the highest-numbered [`CoverageKind::BlockMarker`] that was |
| 282 | 287 | /// injected into the MIR body. This makes it possible to allocate per-ID |
| 283 | 288 | /// 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> { |
| 430 | 430 | |
| 431 | 431 | pub tainted_by_errors: Option<ErrorGuaranteed>, |
| 432 | 432 | |
| 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. | |
| 435 | 435 | /// |
| 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>>, | |
| 438 | 439 | |
| 439 | 440 | /// Per-function coverage information added by the `InstrumentCoverage` |
| 440 | 441 | /// pass, to be used in conjunction with the coverage statements injected |
| ... | ... | @@ -484,7 +485,7 @@ impl<'tcx> Body<'tcx> { |
| 484 | 485 | is_polymorphic: false, |
| 485 | 486 | injection_phase: None, |
| 486 | 487 | tainted_by_errors, |
| 487 | coverage_branch_info: None, | |
| 488 | coverage_info_hi: None, | |
| 488 | 489 | function_coverage_info: None, |
| 489 | 490 | }; |
| 490 | 491 | body.is_polymorphic = body.has_non_region_param(); |
| ... | ... | @@ -515,7 +516,7 @@ impl<'tcx> Body<'tcx> { |
| 515 | 516 | is_polymorphic: false, |
| 516 | 517 | injection_phase: None, |
| 517 | 518 | tainted_by_errors: None, |
| 518 | coverage_branch_info: None, | |
| 519 | coverage_info_hi: None, | |
| 519 | 520 | function_coverage_info: None, |
| 520 | 521 | }; |
| 521 | 522 | 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>( |
| 473 | 473 | // Add an empty line before the first block is printed. |
| 474 | 474 | writeln!(w)?; |
| 475 | 475 | |
| 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)?; | |
| 478 | 478 | } |
| 479 | 479 | if let Some(function_coverage_info) = &body.function_coverage_info { |
| 480 | 480 | write_function_coverage_info(function_coverage_info, w)?; |
| ... | ... | @@ -483,18 +483,26 @@ pub fn write_mir_intro<'tcx>( |
| 483 | 483 | Ok(()) |
| 484 | 484 | } |
| 485 | 485 | |
| 486 | fn write_coverage_branch_info( | |
| 487 | branch_info: &coverage::BranchInfo, | |
| 486 | fn write_coverage_info_hi( | |
| 487 | coverage_info_hi: &coverage::CoverageInfoHi, | |
| 488 | 488 | w: &mut dyn io::Write, |
| 489 | 489 | ) -> 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; | |
| 492 | 499 | |
| 493 | 500 | for coverage::BranchSpan { span, true_marker, false_marker } in branch_spans { |
| 494 | 501 | writeln!( |
| 495 | 502 | w, |
| 496 | 503 | "{INDENT}coverage branch {{ true: {true_marker:?}, false: {false_marker:?} }} => {span:?}", |
| 497 | 504 | )?; |
| 505 | did_print = true; | |
| 498 | 506 | } |
| 499 | 507 | |
| 500 | 508 | for coverage::MCDCBranchSpan { |
| ... | ... | @@ -510,6 +518,7 @@ fn write_coverage_branch_info( |
| 510 | 518 | "{INDENT}coverage mcdc branch {{ condition_id: {:?}, true: {true_marker:?}, false: {false_marker:?}, depth: {decision_depth:?} }} => {span:?}", |
| 511 | 519 | condition_info.map(|info| info.condition_id) |
| 512 | 520 | )?; |
| 521 | did_print = true; | |
| 513 | 522 | } |
| 514 | 523 | |
| 515 | 524 | for coverage::MCDCDecisionSpan { span, num_conditions, end_markers, decision_depth } in |
| ... | ... | @@ -519,10 +528,10 @@ fn write_coverage_branch_info( |
| 519 | 528 | w, |
| 520 | 529 | "{INDENT}coverage mcdc decision {{ num_conditions: {num_conditions:?}, end: {end_markers:?}, depth: {decision_depth:?} }} => {span:?}" |
| 521 | 530 | )?; |
| 531 | did_print = true; | |
| 522 | 532 | } |
| 523 | 533 | |
| 524 | if !branch_spans.is_empty() || !mcdc_branch_spans.is_empty() || !mcdc_decision_spans.is_empty() | |
| 525 | { | |
| 534 | if did_print { | |
| 526 | 535 | writeln!(w)?; |
| 527 | 536 | } |
| 528 | 537 |
compiler/rustc_mir_build/src/build/coverageinfo.rs+60-47| ... | ... | @@ -2,7 +2,7 @@ use std::assert_matches::assert_matches; |
| 2 | 2 | use std::collections::hash_map::Entry; |
| 3 | 3 | |
| 4 | 4 | use rustc_data_structures::fx::FxHashMap; |
| 5 | use rustc_middle::mir::coverage::{BlockMarkerId, BranchSpan, CoverageKind}; | |
| 5 | use rustc_middle::mir::coverage::{BlockMarkerId, BranchSpan, CoverageInfoHi, CoverageKind}; | |
| 6 | 6 | use rustc_middle::mir::{self, BasicBlock, SourceInfo, UnOp}; |
| 7 | 7 | use rustc_middle::thir::{ExprId, ExprKind, Pat, Thir}; |
| 8 | 8 | use rustc_middle::ty::TyCtxt; |
| ... | ... | @@ -13,16 +13,25 @@ use crate::build::{Builder, CFG}; |
| 13 | 13 | |
| 14 | 14 | mod mcdc; |
| 15 | 15 | |
| 16 | pub(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. | |
| 18 | pub(crate) struct CoverageInfoBuilder { | |
| 17 | 19 | /// Maps condition expressions to their enclosing `!`, for better instrumentation. |
| 18 | 20 | nots: FxHashMap<ExprId, NotInfo>, |
| 19 | 21 | |
| 20 | 22 | markers: BlockMarkerGen, |
| 21 | branch_spans: Vec<BranchSpan>, | |
| 22 | 23 | |
| 24 | /// Present if branch coverage is enabled. | |
| 25 | branch_info: Option<BranchInfo>, | |
| 26 | /// Present if MC/DC coverage is enabled. | |
| 23 | 27 | mcdc_info: Option<MCDCInfoBuilder>, |
| 24 | 28 | } |
| 25 | 29 | |
| 30 | #[derive(Default)] | |
| 31 | struct BranchInfo { | |
| 32 | branch_spans: Vec<BranchSpan>, | |
| 33 | } | |
| 34 | ||
| 26 | 35 | #[derive(Clone, Copy)] |
| 27 | 36 | struct NotInfo { |
| 28 | 37 | /// When visiting the associated expression as a branch condition, treat this |
| ... | ... | @@ -62,20 +71,20 @@ impl BlockMarkerGen { |
| 62 | 71 | } |
| 63 | 72 | } |
| 64 | 73 | |
| 65 | impl BranchInfoBuilder { | |
| 66 | /// Creates a new branch info builder, but only if branch coverage instrumentation | |
| 74 | impl CoverageInfoBuilder { | |
| 75 | /// Creates a new coverage info builder, but only if coverage instrumentation | |
| 67 | 76 | /// is enabled and `def_id` represents a function that is eligible for coverage. |
| 68 | 77 | 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; | |
| 78 | 80 | } |
| 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 | }) | |
| 79 | 88 | } |
| 80 | 89 | |
| 81 | 90 | /// Unary `!` expressions inside an `if` condition are lowered by lowering |
| ... | ... | @@ -88,6 +97,12 @@ impl BranchInfoBuilder { |
| 88 | 97 | pub(crate) fn visit_unary_not(&mut self, thir: &Thir<'_>, unary_not: ExprId) { |
| 89 | 98 | assert_matches!(thir[unary_not].kind, ExprKind::Unary { op: UnOp::Not, .. }); |
| 90 | 99 | |
| 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 | ||
| 91 | 106 | self.visit_with_not_info( |
| 92 | 107 | thir, |
| 93 | 108 | unary_not, |
| ... | ... | @@ -137,40 +152,40 @@ impl BranchInfoBuilder { |
| 137 | 152 | false_block, |
| 138 | 153 | inject_block_marker, |
| 139 | 154 | ); |
| 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; | |
| 149 | 156 | } |
| 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 | }); | |
| 150 | 169 | } |
| 151 | 170 | |
| 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; | |
| 159 | 174 | |
| 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(); | |
| 164 | 177 | |
| 165 | 178 | let (mcdc_decision_spans, mcdc_branch_spans) = |
| 166 | 179 | mcdc_info.map(MCDCInfoBuilder::into_done).unwrap_or_default(); |
| 167 | 180 | |
| 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 { | |
| 169 | 184 | num_block_markers, |
| 170 | 185 | branch_spans, |
| 171 | 186 | mcdc_branch_spans, |
| 172 | 187 | mcdc_decision_spans, |
| 173 | })) | |
| 188 | }) | |
| 174 | 189 | } |
| 175 | 190 | } |
| 176 | 191 | |
| ... | ... | @@ -184,7 +199,7 @@ impl<'tcx> Builder<'_, 'tcx> { |
| 184 | 199 | block: &mut BasicBlock, |
| 185 | 200 | ) { |
| 186 | 201 | // 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 }; | |
| 188 | 203 | if !self.tcx.sess.instrument_coverage_condition() { |
| 189 | 204 | return; |
| 190 | 205 | }; |
| ... | ... | @@ -224,7 +239,7 @@ impl<'tcx> Builder<'_, 'tcx> { |
| 224 | 239 | ); |
| 225 | 240 | |
| 226 | 241 | // Separate path for handling branches when MC/DC is enabled. |
| 227 | branch_info.register_two_way_branch( | |
| 242 | coverage_info.register_two_way_branch( | |
| 228 | 243 | self.tcx, |
| 229 | 244 | &mut self.cfg, |
| 230 | 245 | source_info, |
| ... | ... | @@ -247,12 +262,12 @@ impl<'tcx> Builder<'_, 'tcx> { |
| 247 | 262 | mut then_block: BasicBlock, |
| 248 | 263 | mut else_block: BasicBlock, |
| 249 | 264 | ) { |
| 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 }; | |
| 252 | 267 | |
| 253 | 268 | // If this condition expression is nested within one or more `!` expressions, |
| 254 | 269 | // 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) { | |
| 256 | 271 | expr_id = enclosing_not; |
| 257 | 272 | if is_flipped { |
| 258 | 273 | std::mem::swap(&mut then_block, &mut else_block); |
| ... | ... | @@ -261,7 +276,7 @@ impl<'tcx> Builder<'_, 'tcx> { |
| 261 | 276 | |
| 262 | 277 | let source_info = SourceInfo { span: self.thir[expr_id].span, scope: self.source_scope }; |
| 263 | 278 | |
| 264 | branch_info.register_two_way_branch( | |
| 279 | coverage_info.register_two_way_branch( | |
| 265 | 280 | self.tcx, |
| 266 | 281 | &mut self.cfg, |
| 267 | 282 | source_info, |
| ... | ... | @@ -280,13 +295,11 @@ impl<'tcx> Builder<'_, 'tcx> { |
| 280 | 295 | true_block: BasicBlock, |
| 281 | 296 | false_block: BasicBlock, |
| 282 | 297 | ) { |
| 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 }; | |
| 287 | 300 | |
| 288 | 301 | 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( | |
| 290 | 303 | self.tcx, |
| 291 | 304 | &mut self.cfg, |
| 292 | 305 | source_info, |
compiler/rustc_mir_build/src/build/coverageinfo/mcdc.rs+6-6| ... | ... | @@ -250,24 +250,24 @@ impl MCDCInfoBuilder { |
| 250 | 250 | |
| 251 | 251 | impl Builder<'_, '_> { |
| 252 | 252 | 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() | |
| 255 | 255 | { |
| 256 | 256 | mcdc_info.state.record_conditions(logical_op, span); |
| 257 | 257 | } |
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | 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() | |
| 263 | 263 | { |
| 264 | 264 | mcdc_info.state.decision_ctx_stack.push(MCDCDecisionCtx::default()); |
| 265 | 265 | }; |
| 266 | 266 | } |
| 267 | 267 | |
| 268 | 268 | 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() | |
| 271 | 271 | { |
| 272 | 272 | if mcdc_info.state.decision_ctx_stack.pop().is_none() { |
| 273 | 273 | 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>( |
| 62 | 62 | tainted_by_errors: None, |
| 63 | 63 | injection_phase: None, |
| 64 | 64 | pass_count: 0, |
| 65 | coverage_branch_info: None, | |
| 65 | coverage_info_hi: None, | |
| 66 | 66 | function_coverage_info: None, |
| 67 | 67 | }; |
| 68 | 68 |
compiler/rustc_mir_build/src/build/matches/mod.rs+2-2| ... | ... | @@ -160,8 +160,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { |
| 160 | 160 | // Improve branch coverage instrumentation by noting conditions |
| 161 | 161 | // nested within one or more `!` expressions. |
| 162 | 162 | // (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); | |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | let local_scope = this.local_scope(); |
compiler/rustc_mir_build/src/build/mod.rs+4-4| ... | ... | @@ -218,8 +218,8 @@ struct Builder<'a, 'tcx> { |
| 218 | 218 | lint_level_roots_cache: GrowableBitSet<hir::ItemLocalId>, |
| 219 | 219 | |
| 220 | 220 | /// 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>, | |
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | type CaptureMap<'tcx> = SortedIndexMultiMap<usize, HirId, Capture<'tcx>>; |
| ... | ... | @@ -773,7 +773,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { |
| 773 | 773 | unit_temp: None, |
| 774 | 774 | var_debug_info: vec![], |
| 775 | 775 | 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), | |
| 777 | 777 | }; |
| 778 | 778 | |
| 779 | 779 | assert_eq!(builder.cfg.start_new_block(), START_BLOCK); |
| ... | ... | @@ -802,7 +802,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { |
| 802 | 802 | self.coroutine, |
| 803 | 803 | None, |
| 804 | 804 | ); |
| 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()); | |
| 806 | 806 | body |
| 807 | 807 | } |
| 808 | 808 |
compiler/rustc_mir_transform/src/coverage/mappings.rs+12-10| ... | ... | @@ -3,7 +3,9 @@ use std::collections::BTreeSet; |
| 3 | 3 | use rustc_data_structures::graph::DirectedGraph; |
| 4 | 4 | use rustc_index::bit_set::BitSet; |
| 5 | 5 | use rustc_index::IndexVec; |
| 6 | use rustc_middle::mir::coverage::{BlockMarkerId, BranchSpan, ConditionInfo, CoverageKind}; | |
| 6 | use rustc_middle::mir::coverage::{ | |
| 7 | BlockMarkerId, BranchSpan, ConditionInfo, CoverageInfoHi, CoverageKind, | |
| 8 | }; | |
| 7 | 9 | use rustc_middle::mir::{self, BasicBlock, StatementKind}; |
| 8 | 10 | use rustc_middle::ty::TyCtxt; |
| 9 | 11 | use rustc_span::Span; |
| ... | ... | @@ -157,12 +159,12 @@ impl ExtractedMappings { |
| 157 | 159 | } |
| 158 | 160 | |
| 159 | 161 | fn resolve_block_markers( |
| 160 | branch_info: &mir::coverage::BranchInfo, | |
| 162 | coverage_info_hi: &CoverageInfoHi, | |
| 161 | 163 | mir_body: &mir::Body<'_>, |
| 162 | 164 | ) -> IndexVec<BlockMarkerId, Option<BasicBlock>> { |
| 163 | 165 | let mut block_markers = IndexVec::<BlockMarkerId, Option<BasicBlock>>::from_elem_n( |
| 164 | 166 | None, |
| 165 | branch_info.num_block_markers, | |
| 167 | coverage_info_hi.num_block_markers, | |
| 166 | 168 | ); |
| 167 | 169 | |
| 168 | 170 | // Fill out the mapping from block marker IDs to their enclosing blocks. |
| ... | ... | @@ -188,11 +190,11 @@ pub(super) fn extract_branch_pairs( |
| 188 | 190 | hir_info: &ExtractedHirInfo, |
| 189 | 191 | basic_coverage_blocks: &CoverageGraph, |
| 190 | 192 | ) -> 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![] }; | |
| 192 | 194 | |
| 193 | let block_markers = resolve_block_markers(branch_info, mir_body); | |
| 195 | let block_markers = resolve_block_markers(coverage_info_hi, mir_body); | |
| 194 | 196 | |
| 195 | branch_info | |
| 197 | coverage_info_hi | |
| 196 | 198 | .branch_spans |
| 197 | 199 | .iter() |
| 198 | 200 | .filter_map(|&BranchSpan { span: raw_span, true_marker, false_marker }| { |
| ... | ... | @@ -222,9 +224,9 @@ pub(super) fn extract_mcdc_mappings( |
| 222 | 224 | mcdc_branches: &mut impl Extend<MCDCBranch>, |
| 223 | 225 | mcdc_decisions: &mut impl Extend<MCDCDecision>, |
| 224 | 226 | ) { |
| 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 }; | |
| 226 | 228 | |
| 227 | let block_markers = resolve_block_markers(branch_info, mir_body); | |
| 229 | let block_markers = resolve_block_markers(coverage_info_hi, mir_body); | |
| 228 | 230 | |
| 229 | 231 | let bcb_from_marker = |
| 230 | 232 | |marker: BlockMarkerId| basic_coverage_blocks.bcb_from_bb(block_markers[marker]?); |
| ... | ... | @@ -243,7 +245,7 @@ pub(super) fn extract_mcdc_mappings( |
| 243 | 245 | Some((span, true_bcb, false_bcb)) |
| 244 | 246 | }; |
| 245 | 247 | |
| 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( | |
| 247 | 249 | |&mir::coverage::MCDCBranchSpan { |
| 248 | 250 | span: raw_span, |
| 249 | 251 | condition_info, |
| ... | ... | @@ -257,7 +259,7 @@ pub(super) fn extract_mcdc_mappings( |
| 257 | 259 | }, |
| 258 | 260 | )); |
| 259 | 261 | |
| 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( | |
| 261 | 263 | |decision: &mir::coverage::MCDCDecisionSpan| { |
| 262 | 264 | let span = unexpand_into_body_span(decision.span, body_span)?; |
| 263 | 265 |
library/panic_unwind/src/lib.rs+13-21| ... | ... | @@ -36,18 +36,14 @@ use core::panic::PanicPayload; |
| 36 | 36 | cfg_if::cfg_if! { |
| 37 | 37 | if #[cfg(target_os = "emscripten")] { |
| 38 | 38 | #[path = "emcc.rs"] |
| 39 | mod real_imp; | |
| 39 | mod imp; | |
| 40 | 40 | } else if #[cfg(target_os = "hermit")] { |
| 41 | 41 | #[path = "hermit.rs"] |
| 42 | mod real_imp; | |
| 42 | mod imp; | |
| 43 | 43 | } else if #[cfg(target_os = "l4re")] { |
| 44 | 44 | // L4Re is unix family but does not yet support unwinding. |
| 45 | 45 | #[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; | |
| 51 | 47 | } else if #[cfg(any( |
| 52 | 48 | all(target_family = "windows", target_env = "gnu"), |
| 53 | 49 | target_os = "psp", |
| ... | ... | @@ -58,7 +54,16 @@ cfg_if::cfg_if! { |
| 58 | 54 | target_family = "wasm", |
| 59 | 55 | ))] { |
| 60 | 56 | #[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; | |
| 62 | 67 | } else { |
| 63 | 68 | // Targets that don't support unwinding. |
| 64 | 69 | // - os=none ("bare metal" targets) |
| ... | ... | @@ -67,20 +72,7 @@ cfg_if::cfg_if! { |
| 67 | 72 | // - nvptx64-nvidia-cuda |
| 68 | 73 | // - arch=avr |
| 69 | 74 | #[path = "dummy.rs"] |
| 70 | mod real_imp; | |
| 71 | } | |
| 72 | } | |
| 73 | ||
| 74 | cfg_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"] | |
| 80 | 75 | mod imp; |
| 81 | } else { | |
| 82 | // Use the real runtime. | |
| 83 | use real_imp as imp; | |
| 84 | 76 | } |
| 85 | 77 | } |
| 86 | 78 |
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 |
| 13 | 13 | use crate::os::windows::io::{AsRawHandle, BorrowedHandle}; |
| 14 | 14 | use crate::ptr; |
| 15 | 15 | |
| 16 | mod windows_targets; | |
| 17 | ||
| 16 | 18 | mod windows_sys; |
| 17 | 19 | pub use windows_sys::*; |
| 18 | 20 | |
| ... | ... | @@ -504,11 +506,8 @@ if #[cfg(not(target_vendor = "uwp"))] { |
| 504 | 506 | #[cfg(target_arch = "arm")] |
| 505 | 507 | pub enum CONTEXT {} |
| 506 | 508 | }} |
| 507 | ||
| 508 | #[link(name = "ws2_32")] | |
| 509 | extern "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 | |
| 510 | windows_targets::link!("ws2_32.dll" "system" fn WSAStartup(wversionrequested: u16, lpwsadata: *mut WSADATA) -> i32); | |
| 512 | 511 | #[cfg(target_arch = "arm")] |
| 513 | 512 | #[repr(C)] |
| 514 | 513 | pub struct WSADATA { |
library/std/src/sys/pal/windows/c/bindings.txt+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | --out windows_sys.rs |
| 2 | --config flatten std | |
| 2 | --config flatten sys | |
| 3 | 3 | --filter |
| 4 | 4 | !Windows.Win32.Foundation.INVALID_HANDLE_VALUE |
| 5 | 5 | Windows.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 | |
| 2 | 2 | |
| 3 | 3 | #![allow(non_snake_case, non_upper_case_globals, non_camel_case_types, dead_code, clippy::all)] |
| 4 | #[link(name = "advapi32")] | |
| 5 | extern "system" { | |
| 6 | pub fn OpenProcessToken( | |
| 7 | processhandle: HANDLE, | |
| 8 | desiredaccess: TOKEN_ACCESS_MASK, | |
| 9 | tokenhandle: *mut HANDLE, | |
| 10 | ) -> BOOL; | |
| 11 | } | |
| 12 | #[link(name = "advapi32")] | |
| 13 | extern "system" { | |
| 14 | #[link_name = "SystemFunction036"] | |
| 15 | pub fn RtlGenRandom(randombuffer: *mut core::ffi::c_void, randombufferlength: u32) -> BOOLEAN; | |
| 16 | } | |
| 17 | #[link(name = "kernel32")] | |
| 18 | extern "system" { | |
| 19 | pub fn AcquireSRWLockExclusive(srwlock: *mut SRWLOCK); | |
| 20 | } | |
| 21 | #[link(name = "kernel32")] | |
| 22 | extern "system" { | |
| 23 | pub fn AcquireSRWLockShared(srwlock: *mut SRWLOCK); | |
| 24 | } | |
| 25 | #[link(name = "kernel32")] | |
| 26 | extern "system" { | |
| 27 | pub fn CancelIo(hfile: HANDLE) -> BOOL; | |
| 28 | } | |
| 29 | #[link(name = "kernel32")] | |
| 30 | extern "system" { | |
| 31 | pub fn CloseHandle(hobject: HANDLE) -> BOOL; | |
| 32 | } | |
| 33 | #[link(name = "kernel32")] | |
| 34 | extern "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")] | |
| 44 | extern "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")] | |
| 55 | extern "system" { | |
| 56 | pub fn CreateDirectoryW( | |
| 57 | lppathname: PCWSTR, | |
| 58 | lpsecurityattributes: *const SECURITY_ATTRIBUTES, | |
| 59 | ) -> BOOL; | |
| 60 | } | |
| 61 | #[link(name = "kernel32")] | |
| 62 | extern "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")] | |
| 71 | extern "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")] | |
| 83 | extern "system" { | |
| 84 | pub fn CreateHardLinkW( | |
| 85 | lpfilename: PCWSTR, | |
| 86 | lpexistingfilename: PCWSTR, | |
| 87 | lpsecurityattributes: *const SECURITY_ATTRIBUTES, | |
| 88 | ) -> BOOL; | |
| 89 | } | |
| 90 | #[link(name = "kernel32")] | |
| 91 | extern "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")] | |
| 104 | extern "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")] | |
| 119 | extern "system" { | |
| 120 | pub fn CreateSymbolicLinkW( | |
| 121 | lpsymlinkfilename: PCWSTR, | |
| 122 | lptargetfilename: PCWSTR, | |
| 123 | dwflags: SYMBOLIC_LINK_FLAGS, | |
| 124 | ) -> BOOLEAN; | |
| 125 | } | |
| 126 | #[link(name = "kernel32")] | |
| 127 | extern "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")] | |
| 138 | extern "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")] | |
| 147 | extern "system" { | |
| 148 | pub fn DeleteFileW(lpfilename: PCWSTR) -> BOOL; | |
| 149 | } | |
| 150 | #[link(name = "kernel32")] | |
| 151 | extern "system" { | |
| 152 | pub fn DeleteProcThreadAttributeList(lpattributelist: LPPROC_THREAD_ATTRIBUTE_LIST); | |
| 153 | } | |
| 154 | #[link(name = "kernel32")] | |
| 155 | extern "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")] | |
| 168 | extern "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")] | |
| 180 | extern "system" { | |
| 181 | pub fn ExitProcess(uexitcode: u32) -> !; | |
| 182 | } | |
| 183 | #[link(name = "kernel32")] | |
| 184 | extern "system" { | |
| 185 | pub fn FindClose(hfindfile: HANDLE) -> BOOL; | |
| 186 | } | |
| 187 | #[link(name = "kernel32")] | |
| 188 | extern "system" { | |
| 189 | pub fn FindFirstFileW(lpfilename: PCWSTR, lpfindfiledata: *mut WIN32_FIND_DATAW) -> HANDLE; | |
| 190 | } | |
| 191 | #[link(name = "kernel32")] | |
| 192 | extern "system" { | |
| 193 | pub fn FindNextFileW(hfindfile: HANDLE, lpfindfiledata: *mut WIN32_FIND_DATAW) -> BOOL; | |
| 194 | } | |
| 195 | #[link(name = "kernel32")] | |
| 196 | extern "system" { | |
| 197 | pub fn FlushFileBuffers(hfile: HANDLE) -> BOOL; | |
| 198 | } | |
| 199 | #[link(name = "kernel32")] | |
| 200 | extern "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")] | |
| 212 | extern "system" { | |
| 213 | pub fn FreeEnvironmentStringsW(penv: PCWSTR) -> BOOL; | |
| 214 | } | |
| 215 | #[link(name = "kernel32")] | |
| 216 | extern "system" { | |
| 217 | pub fn GetActiveProcessorCount(groupnumber: u16) -> u32; | |
| 218 | } | |
| 219 | #[link(name = "kernel32")] | |
| 220 | extern "system" { | |
| 221 | pub fn GetCommandLineW() -> PCWSTR; | |
| 222 | } | |
| 223 | #[link(name = "kernel32")] | |
| 224 | extern "system" { | |
| 225 | pub fn GetConsoleMode(hconsolehandle: HANDLE, lpmode: *mut CONSOLE_MODE) -> BOOL; | |
| 226 | } | |
| 227 | #[link(name = "kernel32")] | |
| 228 | extern "system" { | |
| 229 | pub fn GetCurrentDirectoryW(nbufferlength: u32, lpbuffer: PWSTR) -> u32; | |
| 230 | } | |
| 231 | #[link(name = "kernel32")] | |
| 232 | extern "system" { | |
| 233 | pub fn GetCurrentProcess() -> HANDLE; | |
| 234 | } | |
| 235 | #[link(name = "kernel32")] | |
| 236 | extern "system" { | |
| 237 | pub fn GetCurrentProcessId() -> u32; | |
| 238 | } | |
| 239 | #[link(name = "kernel32")] | |
| 240 | extern "system" { | |
| 241 | pub fn GetCurrentThread() -> HANDLE; | |
| 242 | } | |
| 243 | #[link(name = "kernel32")] | |
| 244 | extern "system" { | |
| 245 | pub fn GetEnvironmentStringsW() -> PWSTR; | |
| 246 | } | |
| 247 | #[link(name = "kernel32")] | |
| 248 | extern "system" { | |
| 249 | pub fn GetEnvironmentVariableW(lpname: PCWSTR, lpbuffer: PWSTR, nsize: u32) -> u32; | |
| 250 | } | |
| 251 | #[link(name = "kernel32")] | |
| 252 | extern "system" { | |
| 253 | pub fn GetExitCodeProcess(hprocess: HANDLE, lpexitcode: *mut u32) -> BOOL; | |
| 254 | } | |
| 255 | #[link(name = "kernel32")] | |
| 256 | extern "system" { | |
| 257 | pub fn GetFileAttributesW(lpfilename: PCWSTR) -> u32; | |
| 258 | } | |
| 259 | #[link(name = "kernel32")] | |
| 260 | extern "system" { | |
| 261 | pub fn GetFileInformationByHandle( | |
| 262 | hfile: HANDLE, | |
| 263 | lpfileinformation: *mut BY_HANDLE_FILE_INFORMATION, | |
| 264 | ) -> BOOL; | |
| 265 | } | |
| 266 | #[link(name = "kernel32")] | |
| 267 | extern "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")] | |
| 276 | extern "system" { | |
| 277 | pub fn GetFileType(hfile: HANDLE) -> FILE_TYPE; | |
| 278 | } | |
| 279 | #[link(name = "kernel32")] | |
| 280 | extern "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")] | |
| 289 | extern "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")] | |
| 298 | extern "system" { | |
| 299 | pub fn GetLastError() -> WIN32_ERROR; | |
| 300 | } | |
| 301 | #[link(name = "kernel32")] | |
| 302 | extern "system" { | |
| 303 | pub fn GetModuleFileNameW(hmodule: HMODULE, lpfilename: PWSTR, nsize: u32) -> u32; | |
| 304 | } | |
| 305 | #[link(name = "kernel32")] | |
| 306 | extern "system" { | |
| 307 | pub fn GetModuleHandleA(lpmodulename: PCSTR) -> HMODULE; | |
| 308 | } | |
| 309 | #[link(name = "kernel32")] | |
| 310 | extern "system" { | |
| 311 | pub fn GetModuleHandleW(lpmodulename: PCWSTR) -> HMODULE; | |
| 312 | } | |
| 313 | #[link(name = "kernel32")] | |
| 314 | extern "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")] | |
| 323 | extern "system" { | |
| 324 | pub fn GetProcAddress(hmodule: HMODULE, lpprocname: PCSTR) -> FARPROC; | |
| 325 | } | |
| 326 | #[link(name = "kernel32")] | |
| 327 | extern "system" { | |
| 328 | pub fn GetProcessId(process: HANDLE) -> u32; | |
| 329 | } | |
| 330 | #[link(name = "kernel32")] | |
| 331 | extern "system" { | |
| 332 | pub fn GetStdHandle(nstdhandle: STD_HANDLE) -> HANDLE; | |
| 333 | } | |
| 334 | #[link(name = "kernel32")] | |
| 335 | extern "system" { | |
| 336 | pub fn GetSystemDirectoryW(lpbuffer: PWSTR, usize: u32) -> u32; | |
| 337 | } | |
| 338 | #[link(name = "kernel32")] | |
| 339 | extern "system" { | |
| 340 | pub fn GetSystemInfo(lpsysteminfo: *mut SYSTEM_INFO); | |
| 341 | } | |
| 342 | #[link(name = "kernel32")] | |
| 343 | extern "system" { | |
| 344 | pub fn GetSystemTimeAsFileTime(lpsystemtimeasfiletime: *mut FILETIME); | |
| 345 | } | |
| 346 | #[link(name = "kernel32")] | |
| 347 | extern "system" { | |
| 348 | pub fn GetSystemTimePreciseAsFileTime(lpsystemtimeasfiletime: *mut FILETIME); | |
| 349 | } | |
| 350 | #[link(name = "kernel32")] | |
| 351 | extern "system" { | |
| 352 | pub fn GetTempPathW(nbufferlength: u32, lpbuffer: PWSTR) -> u32; | |
| 353 | } | |
| 354 | #[link(name = "kernel32")] | |
| 355 | extern "system" { | |
| 356 | pub fn GetWindowsDirectoryW(lpbuffer: PWSTR, usize: u32) -> u32; | |
| 357 | } | |
| 358 | #[link(name = "kernel32")] | |
| 359 | extern "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")] | |
| 368 | extern "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")] | |
| 376 | extern "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")] | |
| 385 | extern "system" { | |
| 386 | pub fn LocalFree(hmem: HLOCAL) -> HLOCAL; | |
| 387 | } | |
| 388 | #[link(name = "kernel32")] | |
| 389 | extern "system" { | |
| 390 | pub fn MoveFileExW( | |
| 391 | lpexistingfilename: PCWSTR, | |
| 392 | lpnewfilename: PCWSTR, | |
| 393 | dwflags: MOVE_FILE_FLAGS, | |
| 394 | ) -> BOOL; | |
| 395 | } | |
| 396 | #[link(name = "kernel32")] | |
| 397 | extern "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")] | |
| 408 | extern "system" { | |
| 409 | pub fn QueryPerformanceCounter(lpperformancecount: *mut i64) -> BOOL; | |
| 410 | } | |
| 411 | #[link(name = "kernel32")] | |
| 412 | extern "system" { | |
| 413 | pub fn QueryPerformanceFrequency(lpfrequency: *mut i64) -> BOOL; | |
| 414 | } | |
| 415 | #[link(name = "kernel32")] | |
| 416 | extern "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")] | |
| 426 | extern "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")] | |
| 436 | extern "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")] | |
| 446 | extern "system" { | |
| 447 | pub fn ReleaseSRWLockExclusive(srwlock: *mut SRWLOCK); | |
| 448 | } | |
| 449 | #[link(name = "kernel32")] | |
| 450 | extern "system" { | |
| 451 | pub fn ReleaseSRWLockShared(srwlock: *mut SRWLOCK); | |
| 452 | } | |
| 453 | #[link(name = "kernel32")] | |
| 454 | extern "system" { | |
| 455 | pub fn RemoveDirectoryW(lppathname: PCWSTR) -> BOOL; | |
| 456 | } | |
| 457 | #[link(name = "kernel32")] | |
| 458 | extern "system" { | |
| 459 | pub fn SetCurrentDirectoryW(lppathname: PCWSTR) -> BOOL; | |
| 460 | } | |
| 461 | #[link(name = "kernel32")] | |
| 462 | extern "system" { | |
| 463 | pub fn SetEnvironmentVariableW(lpname: PCWSTR, lpvalue: PCWSTR) -> BOOL; | |
| 464 | } | |
| 465 | #[link(name = "kernel32")] | |
| 466 | extern "system" { | |
| 467 | pub fn SetFileAttributesW( | |
| 468 | lpfilename: PCWSTR, | |
| 469 | dwfileattributes: FILE_FLAGS_AND_ATTRIBUTES, | |
| 470 | ) -> BOOL; | |
| 471 | } | |
| 472 | #[link(name = "kernel32")] | |
| 473 | extern "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")] | |
| 482 | extern "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")] | |
| 491 | extern "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")] | |
| 500 | extern "system" { | |
| 501 | pub fn SetHandleInformation(hobject: HANDLE, dwmask: u32, dwflags: HANDLE_FLAGS) -> BOOL; | |
| 502 | } | |
| 503 | #[link(name = "kernel32")] | |
| 504 | extern "system" { | |
| 505 | pub fn SetLastError(dwerrcode: WIN32_ERROR); | |
| 506 | } | |
| 507 | #[link(name = "kernel32")] | |
| 508 | extern "system" { | |
| 509 | pub fn SetThreadStackGuarantee(stacksizeinbytes: *mut u32) -> BOOL; | |
| 510 | } | |
| 511 | #[link(name = "kernel32")] | |
| 512 | extern "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")] | |
| 523 | extern "system" { | |
| 524 | pub fn Sleep(dwmilliseconds: u32); | |
| 525 | } | |
| 526 | #[link(name = "kernel32")] | |
| 527 | extern "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")] | |
| 536 | extern "system" { | |
| 537 | pub fn SleepEx(dwmilliseconds: u32, balertable: BOOL) -> u32; | |
| 538 | } | |
| 539 | #[link(name = "kernel32")] | |
| 540 | extern "system" { | |
| 541 | pub fn SwitchToThread() -> BOOL; | |
| 542 | } | |
| 543 | #[link(name = "kernel32")] | |
| 544 | extern "system" { | |
| 545 | pub fn TerminateProcess(hprocess: HANDLE, uexitcode: u32) -> BOOL; | |
| 546 | } | |
| 547 | #[link(name = "kernel32")] | |
| 548 | extern "system" { | |
| 549 | pub fn TlsAlloc() -> u32; | |
| 550 | } | |
| 551 | #[link(name = "kernel32")] | |
| 552 | extern "system" { | |
| 553 | pub fn TlsFree(dwtlsindex: u32) -> BOOL; | |
| 554 | } | |
| 555 | #[link(name = "kernel32")] | |
| 556 | extern "system" { | |
| 557 | pub fn TlsGetValue(dwtlsindex: u32) -> *mut core::ffi::c_void; | |
| 558 | } | |
| 559 | #[link(name = "kernel32")] | |
| 560 | extern "system" { | |
| 561 | pub fn TlsSetValue(dwtlsindex: u32, lptlsvalue: *const core::ffi::c_void) -> BOOL; | |
| 562 | } | |
| 563 | #[link(name = "kernel32")] | |
| 564 | extern "system" { | |
| 565 | pub fn TryAcquireSRWLockExclusive(srwlock: *mut SRWLOCK) -> BOOLEAN; | |
| 566 | } | |
| 567 | #[link(name = "kernel32")] | |
| 568 | extern "system" { | |
| 569 | pub fn TryAcquireSRWLockShared(srwlock: *mut SRWLOCK) -> BOOLEAN; | |
| 570 | } | |
| 571 | #[link(name = "kernel32")] | |
| 572 | extern "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")] | |
| 584 | extern "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")] | |
| 593 | extern "system" { | |
| 594 | pub fn WaitForSingleObject(hhandle: HANDLE, dwmilliseconds: u32) -> WAIT_EVENT; | |
| 595 | } | |
| 596 | #[link(name = "kernel32")] | |
| 597 | extern "system" { | |
| 598 | pub fn WakeAllConditionVariable(conditionvariable: *mut CONDITION_VARIABLE); | |
| 599 | } | |
| 600 | #[link(name = "kernel32")] | |
| 601 | extern "system" { | |
| 602 | pub fn WakeConditionVariable(conditionvariable: *mut CONDITION_VARIABLE); | |
| 603 | } | |
| 604 | #[link(name = "kernel32")] | |
| 605 | extern "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")] | |
| 618 | extern "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")] | |
| 628 | extern "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")] | |
| 638 | extern "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")] | |
| 654 | extern "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")] | |
| 668 | extern "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")] | |
| 682 | extern "system" { | |
| 683 | pub fn RtlNtStatusToDosError(status: NTSTATUS) -> u32; | |
| 684 | } | |
| 685 | #[link(name = "userenv")] | |
| 686 | extern "system" { | |
| 687 | pub fn GetUserProfileDirectoryW( | |
| 688 | htoken: HANDLE, | |
| 689 | lpprofiledir: PWSTR, | |
| 690 | lpcchsize: *mut u32, | |
| 691 | ) -> BOOL; | |
| 692 | } | |
| 693 | #[link(name = "ws2_32")] | |
| 694 | extern "system" { | |
| 695 | pub fn WSACleanup() -> i32; | |
| 696 | } | |
| 697 | #[link(name = "ws2_32")] | |
| 698 | extern "system" { | |
| 699 | pub fn WSADuplicateSocketW( | |
| 700 | s: SOCKET, | |
| 701 | dwprocessid: u32, | |
| 702 | lpprotocolinfo: *mut WSAPROTOCOL_INFOW, | |
| 703 | ) -> i32; | |
| 704 | } | |
| 705 | #[link(name = "ws2_32")] | |
| 706 | extern "system" { | |
| 707 | pub fn WSAGetLastError() -> WSA_ERROR; | |
| 708 | } | |
| 709 | #[link(name = "ws2_32")] | |
| 710 | extern "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")] | |
| 722 | extern "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")] | |
| 734 | extern "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")] | |
| 745 | extern "system" { | |
| 746 | pub fn accept(s: SOCKET, addr: *mut SOCKADDR, addrlen: *mut i32) -> SOCKET; | |
| 747 | } | |
| 748 | #[link(name = "ws2_32")] | |
| 749 | extern "system" { | |
| 750 | pub fn bind(s: SOCKET, name: *const SOCKADDR, namelen: i32) -> i32; | |
| 751 | } | |
| 752 | #[link(name = "ws2_32")] | |
| 753 | extern "system" { | |
| 754 | pub fn closesocket(s: SOCKET) -> i32; | |
| 755 | } | |
| 756 | #[link(name = "ws2_32")] | |
| 757 | extern "system" { | |
| 758 | pub fn connect(s: SOCKET, name: *const SOCKADDR, namelen: i32) -> i32; | |
| 759 | } | |
| 760 | #[link(name = "ws2_32")] | |
| 761 | extern "system" { | |
| 762 | pub fn freeaddrinfo(paddrinfo: *const ADDRINFOA); | |
| 763 | } | |
| 764 | #[link(name = "ws2_32")] | |
| 765 | extern "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")] | |
| 774 | extern "system" { | |
| 775 | pub fn getpeername(s: SOCKET, name: *mut SOCKADDR, namelen: *mut i32) -> i32; | |
| 776 | } | |
| 777 | #[link(name = "ws2_32")] | |
| 778 | extern "system" { | |
| 779 | pub fn getsockname(s: SOCKET, name: *mut SOCKADDR, namelen: *mut i32) -> i32; | |
| 780 | } | |
| 781 | #[link(name = "ws2_32")] | |
| 782 | extern "system" { | |
| 783 | pub fn getsockopt(s: SOCKET, level: i32, optname: i32, optval: PSTR, optlen: *mut i32) -> i32; | |
| 784 | } | |
| 785 | #[link(name = "ws2_32")] | |
| 786 | extern "system" { | |
| 787 | pub fn ioctlsocket(s: SOCKET, cmd: i32, argp: *mut u32) -> i32; | |
| 788 | } | |
| 789 | #[link(name = "ws2_32")] | |
| 790 | extern "system" { | |
| 791 | pub fn listen(s: SOCKET, backlog: i32) -> i32; | |
| 792 | } | |
| 793 | #[link(name = "ws2_32")] | |
| 794 | extern "system" { | |
| 795 | pub fn recv(s: SOCKET, buf: PSTR, len: i32, flags: SEND_RECV_FLAGS) -> i32; | |
| 796 | } | |
| 797 | #[link(name = "ws2_32")] | |
| 798 | extern "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")] | |
| 809 | extern "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")] | |
| 819 | extern "system" { | |
| 820 | pub fn send(s: SOCKET, buf: PCSTR, len: i32, flags: SEND_RECV_FLAGS) -> i32; | |
| 821 | } | |
| 822 | #[link(name = "ws2_32")] | |
| 823 | extern "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")] | |
| 834 | extern "system" { | |
| 835 | pub fn setsockopt(s: SOCKET, level: i32, optname: i32, optval: PCSTR, optlen: i32) -> i32; | |
| 836 | } | |
| 837 | #[link(name = "ws2_32")] | |
| 838 | extern "system" { | |
| 839 | pub fn shutdown(s: SOCKET, how: WINSOCK_SHUTDOWN_HOW) -> i32; | |
| 840 | } | |
| 4 | windows_targets::link!("advapi32.dll" "system" fn OpenProcessToken(processhandle : HANDLE, desiredaccess : TOKEN_ACCESS_MASK, tokenhandle : *mut HANDLE) -> BOOL); | |
| 5 | windows_targets::link!("advapi32.dll" "system" "SystemFunction036" fn RtlGenRandom(randombuffer : *mut core::ffi::c_void, randombufferlength : u32) -> BOOLEAN); | |
| 6 | windows_targets::link!("kernel32.dll" "system" fn AcquireSRWLockExclusive(srwlock : *mut SRWLOCK)); | |
| 7 | windows_targets::link!("kernel32.dll" "system" fn AcquireSRWLockShared(srwlock : *mut SRWLOCK)); | |
| 8 | windows_targets::link!("kernel32.dll" "system" fn CancelIo(hfile : HANDLE) -> BOOL); | |
| 9 | windows_targets::link!("kernel32.dll" "system" fn CloseHandle(hobject : HANDLE) -> BOOL); | |
| 10 | windows_targets::link!("kernel32.dll" "system" fn CompareStringOrdinal(lpstring1 : PCWSTR, cchcount1 : i32, lpstring2 : PCWSTR, cchcount2 : i32, bignorecase : BOOL) -> COMPARESTRING_RESULT); | |
| 11 | windows_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); | |
| 12 | windows_targets::link!("kernel32.dll" "system" fn CreateDirectoryW(lppathname : PCWSTR, lpsecurityattributes : *const SECURITY_ATTRIBUTES) -> BOOL); | |
| 13 | windows_targets::link!("kernel32.dll" "system" fn CreateEventW(lpeventattributes : *const SECURITY_ATTRIBUTES, bmanualreset : BOOL, binitialstate : BOOL, lpname : PCWSTR) -> HANDLE); | |
| 14 | windows_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); | |
| 15 | windows_targets::link!("kernel32.dll" "system" fn CreateHardLinkW(lpfilename : PCWSTR, lpexistingfilename : PCWSTR, lpsecurityattributes : *const SECURITY_ATTRIBUTES) -> BOOL); | |
| 16 | windows_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); | |
| 17 | windows_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); | |
| 18 | windows_targets::link!("kernel32.dll" "system" fn CreateSymbolicLinkW(lpsymlinkfilename : PCWSTR, lptargetfilename : PCWSTR, dwflags : SYMBOLIC_LINK_FLAGS) -> BOOLEAN); | |
| 19 | windows_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); | |
| 20 | windows_targets::link!("kernel32.dll" "system" fn CreateWaitableTimerExW(lptimerattributes : *const SECURITY_ATTRIBUTES, lptimername : PCWSTR, dwflags : u32, dwdesiredaccess : u32) -> HANDLE); | |
| 21 | windows_targets::link!("kernel32.dll" "system" fn DeleteFileW(lpfilename : PCWSTR) -> BOOL); | |
| 22 | windows_targets::link!("kernel32.dll" "system" fn DeleteProcThreadAttributeList(lpattributelist : LPPROC_THREAD_ATTRIBUTE_LIST)); | |
| 23 | windows_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); | |
| 24 | windows_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); | |
| 25 | windows_targets::link!("kernel32.dll" "system" fn ExitProcess(uexitcode : u32) -> !); | |
| 26 | windows_targets::link!("kernel32.dll" "system" fn FindClose(hfindfile : HANDLE) -> BOOL); | |
| 27 | windows_targets::link!("kernel32.dll" "system" fn FindFirstFileW(lpfilename : PCWSTR, lpfindfiledata : *mut WIN32_FIND_DATAW) -> HANDLE); | |
| 28 | windows_targets::link!("kernel32.dll" "system" fn FindNextFileW(hfindfile : HANDLE, lpfindfiledata : *mut WIN32_FIND_DATAW) -> BOOL); | |
| 29 | windows_targets::link!("kernel32.dll" "system" fn FlushFileBuffers(hfile : HANDLE) -> BOOL); | |
| 30 | windows_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); | |
| 31 | windows_targets::link!("kernel32.dll" "system" fn FreeEnvironmentStringsW(penv : PCWSTR) -> BOOL); | |
| 32 | windows_targets::link!("kernel32.dll" "system" fn GetActiveProcessorCount(groupnumber : u16) -> u32); | |
| 33 | windows_targets::link!("kernel32.dll" "system" fn GetCommandLineW() -> PCWSTR); | |
| 34 | windows_targets::link!("kernel32.dll" "system" fn GetConsoleMode(hconsolehandle : HANDLE, lpmode : *mut CONSOLE_MODE) -> BOOL); | |
| 35 | windows_targets::link!("kernel32.dll" "system" fn GetCurrentDirectoryW(nbufferlength : u32, lpbuffer : PWSTR) -> u32); | |
| 36 | windows_targets::link!("kernel32.dll" "system" fn GetCurrentProcess() -> HANDLE); | |
| 37 | windows_targets::link!("kernel32.dll" "system" fn GetCurrentProcessId() -> u32); | |
| 38 | windows_targets::link!("kernel32.dll" "system" fn GetCurrentThread() -> HANDLE); | |
| 39 | windows_targets::link!("kernel32.dll" "system" fn GetEnvironmentStringsW() -> PWSTR); | |
| 40 | windows_targets::link!("kernel32.dll" "system" fn GetEnvironmentVariableW(lpname : PCWSTR, lpbuffer : PWSTR, nsize : u32) -> u32); | |
| 41 | windows_targets::link!("kernel32.dll" "system" fn GetExitCodeProcess(hprocess : HANDLE, lpexitcode : *mut u32) -> BOOL); | |
| 42 | windows_targets::link!("kernel32.dll" "system" fn GetFileAttributesW(lpfilename : PCWSTR) -> u32); | |
| 43 | windows_targets::link!("kernel32.dll" "system" fn GetFileInformationByHandle(hfile : HANDLE, lpfileinformation : *mut BY_HANDLE_FILE_INFORMATION) -> BOOL); | |
| 44 | windows_targets::link!("kernel32.dll" "system" fn GetFileInformationByHandleEx(hfile : HANDLE, fileinformationclass : FILE_INFO_BY_HANDLE_CLASS, lpfileinformation : *mut core::ffi::c_void, dwbuffersize : u32) -> BOOL); | |
| 45 | windows_targets::link!("kernel32.dll" "system" fn GetFileType(hfile : HANDLE) -> FILE_TYPE); | |
| 46 | windows_targets::link!("kernel32.dll" "system" fn GetFinalPathNameByHandleW(hfile : HANDLE, lpszfilepath : PWSTR, cchfilepath : u32, dwflags : GETFINALPATHNAMEBYHANDLE_FLAGS) -> u32); | |
| 47 | windows_targets::link!("kernel32.dll" "system" fn GetFullPathNameW(lpfilename : PCWSTR, nbufferlength : u32, lpbuffer : PWSTR, lpfilepart : *mut PWSTR) -> u32); | |
| 48 | windows_targets::link!("kernel32.dll" "system" fn GetLastError() -> WIN32_ERROR); | |
| 49 | windows_targets::link!("kernel32.dll" "system" fn GetModuleFileNameW(hmodule : HMODULE, lpfilename : PWSTR, nsize : u32) -> u32); | |
| 50 | windows_targets::link!("kernel32.dll" "system" fn GetModuleHandleA(lpmodulename : PCSTR) -> HMODULE); | |
| 51 | windows_targets::link!("kernel32.dll" "system" fn GetModuleHandleW(lpmodulename : PCWSTR) -> HMODULE); | |
| 52 | windows_targets::link!("kernel32.dll" "system" fn GetOverlappedResult(hfile : HANDLE, lpoverlapped : *const OVERLAPPED, lpnumberofbytestransferred : *mut u32, bwait : BOOL) -> BOOL); | |
| 53 | windows_targets::link!("kernel32.dll" "system" fn GetProcAddress(hmodule : HMODULE, lpprocname : PCSTR) -> FARPROC); | |
| 54 | windows_targets::link!("kernel32.dll" "system" fn GetProcessId(process : HANDLE) -> u32); | |
| 55 | windows_targets::link!("kernel32.dll" "system" fn GetStdHandle(nstdhandle : STD_HANDLE) -> HANDLE); | |
| 56 | windows_targets::link!("kernel32.dll" "system" fn GetSystemDirectoryW(lpbuffer : PWSTR, usize : u32) -> u32); | |
| 57 | windows_targets::link!("kernel32.dll" "system" fn GetSystemInfo(lpsysteminfo : *mut SYSTEM_INFO)); | |
| 58 | windows_targets::link!("kernel32.dll" "system" fn GetSystemTimeAsFileTime(lpsystemtimeasfiletime : *mut FILETIME)); | |
| 59 | windows_targets::link!("kernel32.dll" "system" fn GetSystemTimePreciseAsFileTime(lpsystemtimeasfiletime : *mut FILETIME)); | |
| 60 | windows_targets::link!("kernel32.dll" "system" fn GetTempPathW(nbufferlength : u32, lpbuffer : PWSTR) -> u32); | |
| 61 | windows_targets::link!("kernel32.dll" "system" fn GetWindowsDirectoryW(lpbuffer : PWSTR, usize : u32) -> u32); | |
| 62 | windows_targets::link!("kernel32.dll" "system" fn InitOnceBeginInitialize(lpinitonce : *mut INIT_ONCE, dwflags : u32, fpending : *mut BOOL, lpcontext : *mut *mut core::ffi::c_void) -> BOOL); | |
| 63 | windows_targets::link!("kernel32.dll" "system" fn InitOnceComplete(lpinitonce : *mut INIT_ONCE, dwflags : u32, lpcontext : *const core::ffi::c_void) -> BOOL); | |
| 64 | windows_targets::link!("kernel32.dll" "system" fn InitializeProcThreadAttributeList(lpattributelist : LPPROC_THREAD_ATTRIBUTE_LIST, dwattributecount : u32, dwflags : u32, lpsize : *mut usize) -> BOOL); | |
| 65 | windows_targets::link!("kernel32.dll" "system" fn LocalFree(hmem : HLOCAL) -> HLOCAL); | |
| 66 | windows_targets::link!("kernel32.dll" "system" fn MoveFileExW(lpexistingfilename : PCWSTR, lpnewfilename : PCWSTR, dwflags : MOVE_FILE_FLAGS) -> BOOL); | |
| 67 | windows_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); | |
| 68 | windows_targets::link!("kernel32.dll" "system" fn QueryPerformanceCounter(lpperformancecount : *mut i64) -> BOOL); | |
| 69 | windows_targets::link!("kernel32.dll" "system" fn QueryPerformanceFrequency(lpfrequency : *mut i64) -> BOOL); | |
| 70 | windows_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); | |
| 71 | windows_targets::link!("kernel32.dll" "system" fn ReadFile(hfile : HANDLE, lpbuffer : *mut u8, nnumberofbytestoread : u32, lpnumberofbytesread : *mut u32, lpoverlapped : *mut OVERLAPPED) -> BOOL); | |
| 72 | windows_targets::link!("kernel32.dll" "system" fn ReadFileEx(hfile : HANDLE, lpbuffer : *mut u8, nnumberofbytestoread : u32, lpoverlapped : *mut OVERLAPPED, lpcompletionroutine : LPOVERLAPPED_COMPLETION_ROUTINE) -> BOOL); | |
| 73 | windows_targets::link!("kernel32.dll" "system" fn ReleaseSRWLockExclusive(srwlock : *mut SRWLOCK)); | |
| 74 | windows_targets::link!("kernel32.dll" "system" fn ReleaseSRWLockShared(srwlock : *mut SRWLOCK)); | |
| 75 | windows_targets::link!("kernel32.dll" "system" fn RemoveDirectoryW(lppathname : PCWSTR) -> BOOL); | |
| 76 | windows_targets::link!("kernel32.dll" "system" fn SetCurrentDirectoryW(lppathname : PCWSTR) -> BOOL); | |
| 77 | windows_targets::link!("kernel32.dll" "system" fn SetEnvironmentVariableW(lpname : PCWSTR, lpvalue : PCWSTR) -> BOOL); | |
| 78 | windows_targets::link!("kernel32.dll" "system" fn SetFileAttributesW(lpfilename : PCWSTR, dwfileattributes : FILE_FLAGS_AND_ATTRIBUTES) -> BOOL); | |
| 79 | windows_targets::link!("kernel32.dll" "system" fn SetFileInformationByHandle(hfile : HANDLE, fileinformationclass : FILE_INFO_BY_HANDLE_CLASS, lpfileinformation : *const core::ffi::c_void, dwbuffersize : u32) -> BOOL); | |
| 80 | windows_targets::link!("kernel32.dll" "system" fn SetFilePointerEx(hfile : HANDLE, lidistancetomove : i64, lpnewfilepointer : *mut i64, dwmovemethod : SET_FILE_POINTER_MOVE_METHOD) -> BOOL); | |
| 81 | windows_targets::link!("kernel32.dll" "system" fn SetFileTime(hfile : HANDLE, lpcreationtime : *const FILETIME, lplastaccesstime : *const FILETIME, lplastwritetime : *const FILETIME) -> BOOL); | |
| 82 | windows_targets::link!("kernel32.dll" "system" fn SetHandleInformation(hobject : HANDLE, dwmask : u32, dwflags : HANDLE_FLAGS) -> BOOL); | |
| 83 | windows_targets::link!("kernel32.dll" "system" fn SetLastError(dwerrcode : WIN32_ERROR)); | |
| 84 | windows_targets::link!("kernel32.dll" "system" fn SetThreadStackGuarantee(stacksizeinbytes : *mut u32) -> BOOL); | |
| 85 | windows_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); | |
| 86 | windows_targets::link!("kernel32.dll" "system" fn Sleep(dwmilliseconds : u32)); | |
| 87 | windows_targets::link!("kernel32.dll" "system" fn SleepConditionVariableSRW(conditionvariable : *mut CONDITION_VARIABLE, srwlock : *mut SRWLOCK, dwmilliseconds : u32, flags : u32) -> BOOL); | |
| 88 | windows_targets::link!("kernel32.dll" "system" fn SleepEx(dwmilliseconds : u32, balertable : BOOL) -> u32); | |
| 89 | windows_targets::link!("kernel32.dll" "system" fn SwitchToThread() -> BOOL); | |
| 90 | windows_targets::link!("kernel32.dll" "system" fn TerminateProcess(hprocess : HANDLE, uexitcode : u32) -> BOOL); | |
| 91 | windows_targets::link!("kernel32.dll" "system" fn TlsAlloc() -> u32); | |
| 92 | windows_targets::link!("kernel32.dll" "system" fn TlsFree(dwtlsindex : u32) -> BOOL); | |
| 93 | windows_targets::link!("kernel32.dll" "system" fn TlsGetValue(dwtlsindex : u32) -> *mut core::ffi::c_void); | |
| 94 | windows_targets::link!("kernel32.dll" "system" fn TlsSetValue(dwtlsindex : u32, lptlsvalue : *const core::ffi::c_void) -> BOOL); | |
| 95 | windows_targets::link!("kernel32.dll" "system" fn TryAcquireSRWLockExclusive(srwlock : *mut SRWLOCK) -> BOOLEAN); | |
| 96 | windows_targets::link!("kernel32.dll" "system" fn TryAcquireSRWLockShared(srwlock : *mut SRWLOCK) -> BOOLEAN); | |
| 97 | windows_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); | |
| 98 | windows_targets::link!("kernel32.dll" "system" fn WaitForMultipleObjects(ncount : u32, lphandles : *const HANDLE, bwaitall : BOOL, dwmilliseconds : u32) -> WAIT_EVENT); | |
| 99 | windows_targets::link!("kernel32.dll" "system" fn WaitForSingleObject(hhandle : HANDLE, dwmilliseconds : u32) -> WAIT_EVENT); | |
| 100 | windows_targets::link!("kernel32.dll" "system" fn WakeAllConditionVariable(conditionvariable : *mut CONDITION_VARIABLE)); | |
| 101 | windows_targets::link!("kernel32.dll" "system" fn WakeConditionVariable(conditionvariable : *mut CONDITION_VARIABLE)); | |
| 102 | windows_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); | |
| 103 | windows_targets::link!("kernel32.dll" "system" fn WriteConsoleW(hconsoleoutput : HANDLE, lpbuffer : PCWSTR, nnumberofcharstowrite : u32, lpnumberofcharswritten : *mut u32, lpreserved : *const core::ffi::c_void) -> BOOL); | |
| 104 | windows_targets::link!("kernel32.dll" "system" fn WriteFileEx(hfile : HANDLE, lpbuffer : *const u8, nnumberofbytestowrite : u32, lpoverlapped : *mut OVERLAPPED, lpcompletionroutine : LPOVERLAPPED_COMPLETION_ROUTINE) -> BOOL); | |
| 105 | windows_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); | |
| 106 | windows_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); | |
| 107 | windows_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); | |
| 108 | windows_targets::link!("ntdll.dll" "system" fn RtlNtStatusToDosError(status : NTSTATUS) -> u32); | |
| 109 | windows_targets::link!("userenv.dll" "system" fn GetUserProfileDirectoryW(htoken : HANDLE, lpprofiledir : PWSTR, lpcchsize : *mut u32) -> BOOL); | |
| 110 | windows_targets::link!("ws2_32.dll" "system" fn WSACleanup() -> i32); | |
| 111 | windows_targets::link!("ws2_32.dll" "system" fn WSADuplicateSocketW(s : SOCKET, dwprocessid : u32, lpprotocolinfo : *mut WSAPROTOCOL_INFOW) -> i32); | |
| 112 | windows_targets::link!("ws2_32.dll" "system" fn WSAGetLastError() -> WSA_ERROR); | |
| 113 | windows_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); | |
| 114 | windows_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); | |
| 115 | windows_targets::link!("ws2_32.dll" "system" fn WSASocketW(af : i32, r#type : i32, protocol : i32, lpprotocolinfo : *const WSAPROTOCOL_INFOW, g : u32, dwflags : u32) -> SOCKET); | |
| 116 | windows_targets::link!("ws2_32.dll" "system" fn accept(s : SOCKET, addr : *mut SOCKADDR, addrlen : *mut i32) -> SOCKET); | |
| 117 | windows_targets::link!("ws2_32.dll" "system" fn bind(s : SOCKET, name : *const SOCKADDR, namelen : i32) -> i32); | |
| 118 | windows_targets::link!("ws2_32.dll" "system" fn closesocket(s : SOCKET) -> i32); | |
| 119 | windows_targets::link!("ws2_32.dll" "system" fn connect(s : SOCKET, name : *const SOCKADDR, namelen : i32) -> i32); | |
| 120 | windows_targets::link!("ws2_32.dll" "system" fn freeaddrinfo(paddrinfo : *const ADDRINFOA)); | |
| 121 | windows_targets::link!("ws2_32.dll" "system" fn getaddrinfo(pnodename : PCSTR, pservicename : PCSTR, phints : *const ADDRINFOA, ppresult : *mut *mut ADDRINFOA) -> i32); | |
| 122 | windows_targets::link!("ws2_32.dll" "system" fn getpeername(s : SOCKET, name : *mut SOCKADDR, namelen : *mut i32) -> i32); | |
| 123 | windows_targets::link!("ws2_32.dll" "system" fn getsockname(s : SOCKET, name : *mut SOCKADDR, namelen : *mut i32) -> i32); | |
| 124 | windows_targets::link!("ws2_32.dll" "system" fn getsockopt(s : SOCKET, level : i32, optname : i32, optval : PSTR, optlen : *mut i32) -> i32); | |
| 125 | windows_targets::link!("ws2_32.dll" "system" fn ioctlsocket(s : SOCKET, cmd : i32, argp : *mut u32) -> i32); | |
| 126 | windows_targets::link!("ws2_32.dll" "system" fn listen(s : SOCKET, backlog : i32) -> i32); | |
| 127 | windows_targets::link!("ws2_32.dll" "system" fn recv(s : SOCKET, buf : PSTR, len : i32, flags : SEND_RECV_FLAGS) -> i32); | |
| 128 | windows_targets::link!("ws2_32.dll" "system" fn recvfrom(s : SOCKET, buf : PSTR, len : i32, flags : i32, from : *mut SOCKADDR, fromlen : *mut i32) -> i32); | |
| 129 | windows_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); | |
| 130 | windows_targets::link!("ws2_32.dll" "system" fn send(s : SOCKET, buf : PCSTR, len : i32, flags : SEND_RECV_FLAGS) -> i32); | |
| 131 | windows_targets::link!("ws2_32.dll" "system" fn sendto(s : SOCKET, buf : PCSTR, len : i32, flags : i32, to : *const SOCKADDR, tolen : i32) -> i32); | |
| 132 | windows_targets::link!("ws2_32.dll" "system" fn setsockopt(s : SOCKET, level : i32, optname : i32, optval : PCSTR, optlen : i32) -> i32); | |
| 133 | windows_targets::link!("ws2_32.dll" "system" fn shutdown(s : SOCKET, how : WINSOCK_SHUTDOWN_HOW) -> i32); | |
| 841 | 134 | pub const ABOVE_NORMAL_PRIORITY_CLASS: PROCESS_CREATION_FLAGS = 32768u32; |
| 842 | 135 | pub type ADDRESS_FAMILY = u16; |
| 843 | 136 | #[repr(C)] |
| ... | ... | @@ -3991,3 +3284,4 @@ pub struct XSAVE_FORMAT { |
| 3991 | 3284 | pub Reserved4: [u8; 224], |
| 3992 | 3285 | } |
| 3993 | 3286 | // ignore-tidy-filelength |
| 3287 | use 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 | ||
| 6 | pub 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")] | |
| 24 | extern "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> { |
| 232 | 232 | debug_assert!(data.len() < u32::MAX as usize); |
| 233 | 233 | let mut written = 0; |
| 234 | 234 | 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()) | |
| 242 | 236 | })?; |
| 243 | 237 | Ok(written as usize) |
| 244 | 238 | } |
src/tools/generate-windows-sys/Cargo.toml+1-1| ... | ... | @@ -4,4 +4,4 @@ version = "0.1.0" |
| 4 | 4 | edition = "2021" |
| 5 | 5 | |
| 6 | 6 | [dependencies.windows-bindgen] |
| 7 | version = "0.57.0" | |
| 7 | version = "0.58.0" |
src/tools/generate-windows-sys/src/main.rs+1| ... | ... | @@ -17,6 +17,7 @@ fn main() -> Result<(), Box<dyn Error>> { |
| 17 | 17 | |
| 18 | 18 | let mut f = std::fs::File::options().append(true).open("windows_sys.rs")?; |
| 19 | 19 | writeln!(&mut f, "// ignore-tidy-filelength")?; |
| 20 | writeln!(&mut f, "use super::windows_targets;")?; | |
| 20 | 21 | |
| 21 | 22 | Ok(()) |
| 22 | 23 | } |
src/tools/miri/src/shims/windows/foreign_items.rs+16| ... | ... | @@ -758,6 +758,22 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { |
| 758 | 758 | this.write_null(dest)?; |
| 759 | 759 | } |
| 760 | 760 | |
| 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 | ||
| 761 | 777 | _ => return Ok(EmulateItemResult::NotSupported), |
| 762 | 778 | } |
| 763 | 779 |
src/tools/run-make-support/src/command.rs+3-2| ... | ... | @@ -75,11 +75,12 @@ impl Command { |
| 75 | 75 | /// Generic command arguments provider. Prefer specific helper methods if possible. |
| 76 | 76 | /// Note that for some executables, arguments might be platform specific. For C/C++ |
| 77 | 77 | /// 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 | |
| 79 | 79 | where |
| 80 | 80 | S: AsRef<ffi::OsStr>, |
| 81 | V: AsRef<[S]>, | |
| 81 | 82 | { |
| 82 | self.cmd.args(args); | |
| 83 | self.cmd.args(args.as_ref()); | |
| 83 | 84 | self |
| 84 | 85 | } |
| 85 | 86 |
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> |
| 261 | 261 | success.unwrap(); |
| 262 | 262 | } |
| 263 | 263 | |
| 264 | /// Browse the directory `path` non-recursively and return all files which respect the parameters | |
| 265 | /// outlined by `closure`. | |
| 266 | #[track_caller] | |
| 267 | pub 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`. | |
| 284 | pub 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`. | |
| 289 | pub 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`. | |
| 294 | pub 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 | ||
| 264 | 298 | /// Use `cygpath -w` on a path to get a Windows path string back. This assumes that `cygpath` is |
| 265 | 299 | /// available on the platform! |
| 266 | 300 | #[track_caller] |
src/tools/tidy/src/allowed_run_make_makefiles.txt-5| ... | ... | @@ -46,7 +46,6 @@ run-make/fmt-write-bloat/Makefile |
| 46 | 46 | run-make/foreign-double-unwind/Makefile |
| 47 | 47 | run-make/foreign-exceptions/Makefile |
| 48 | 48 | run-make/foreign-rust-exceptions/Makefile |
| 49 | run-make/include_bytes_deps/Makefile | |
| 50 | 49 | run-make/incr-add-rust-src-component/Makefile |
| 51 | 50 | run-make/incr-foreign-head-span/Makefile |
| 52 | 51 | run-make/interdependent-c-libraries/Makefile |
| ... | ... | @@ -64,7 +63,6 @@ run-make/issue-33329/Makefile |
| 64 | 63 | run-make/issue-35164/Makefile |
| 65 | 64 | run-make/issue-36710/Makefile |
| 66 | 65 | run-make/issue-37839/Makefile |
| 67 | run-make/issue-40535/Makefile | |
| 68 | 66 | run-make/issue-47551/Makefile |
| 69 | 67 | run-make/issue-69368/Makefile |
| 70 | 68 | run-make/issue-83045/Makefile |
| ... | ... | @@ -102,8 +100,6 @@ run-make/no-alloc-shim/Makefile |
| 102 | 100 | run-make/no-builtins-attribute/Makefile |
| 103 | 101 | run-make/no-duplicate-libs/Makefile |
| 104 | 102 | run-make/obey-crate-type-flag/Makefile |
| 105 | run-make/optimization-remarks-dir-pgo/Makefile | |
| 106 | run-make/optimization-remarks-dir/Makefile | |
| 107 | 103 | run-make/output-type-permutations/Makefile |
| 108 | 104 | run-make/panic-abort-eh_frame/Makefile |
| 109 | 105 | run-make/pass-linker-flags-flavor/Makefile |
| ... | ... | @@ -136,7 +132,6 @@ run-make/return-non-c-like-enum-from-c/Makefile |
| 136 | 132 | run-make/rlib-format-packed-bundled-libs-2/Makefile |
| 137 | 133 | run-make/rlib-format-packed-bundled-libs-3/Makefile |
| 138 | 134 | run-make/rlib-format-packed-bundled-libs/Makefile |
| 139 | run-make/rmeta-preferred/Makefile | |
| 140 | 135 | run-make/rustc-macro-dep-files/Makefile |
| 141 | 136 | run-make/sanitizer-cdylib-link/Makefile |
| 142 | 137 | run-make/sanitizer-dylib-link/Makefile |
tests/run-make/include-bytes-deps/input.bin created+1| ... | ... | @@ -0,0 +1 @@ |
| 1 | Hello 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 @@ |
| 1 | Hello world! |
tests/run-make/include-bytes-deps/main.rs created+10| ... | ... | @@ -0,0 +1,10 @@ |
| 1 | #[doc = include_str!("input.md")] | |
| 2 | pub struct SomeStruct; | |
| 3 | ||
| 4 | pub 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 | ||
| 6 | use run_make_support::{invalid_utf8_contains, rustc}; | |
| 7 | ||
| 8 | fn 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 @@ |
| 1 | include ../tools.mk | |
| 2 | ||
| 3 | # ignore-freebsd | |
| 4 | ||
| 5 | all: | |
| 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 @@ |
| 1 | Hello 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 @@ |
| 1 | Hello world! |
tests/run-make/include_bytes_deps/main.rs deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | #[doc = include_str!("input.md")] | |
| 2 | pub struct SomeStruct; | |
| 3 | ||
| 4 | pub 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 @@ |
| 1 | include ../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`) | |
| 7 | all: | |
| 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 | ||
| 3 | extern 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 | ||
| 3 | extern crate bar; | |
| 4 | extern crate baz; |
tests/run-make/llvm-ident/rmake.rs+1-1| ... | ... | @@ -28,7 +28,7 @@ fn main() { |
| 28 | 28 | files.push(path.to_path_buf()); |
| 29 | 29 | } |
| 30 | 30 | }); |
| 31 | cmd(llvm_bin_dir().join("llvm-dis")).args(&files).run(); | |
| 31 | cmd(llvm_bin_dir().join("llvm-dis")).args(files).run(); | |
| 32 | 32 | |
| 33 | 33 | // Check LLVM IR files (including temporary outputs) have `!llvm.ident` |
| 34 | 34 | // 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 | ||
| 3 | extern 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 | ||
| 3 | extern crate bar; | |
| 4 | extern 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 | ||
| 7 | use run_make_support::rustc; | |
| 8 | ||
| 9 | fn 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 | ||
| 4 | include ../tools.mk | |
| 5 | ||
| 6 | PROFILE_DIR=$(TMPDIR)/profiles | |
| 7 | ||
| 8 | check_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 | ||
| 10 | use run_make_support::{ | |
| 11 | has_extension, has_prefix, invalid_utf8_contains, llvm_profdata, run, rustc, shallow_find_files, | |
| 12 | }; | |
| 13 | ||
| 14 | fn 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 @@ |
| 1 | include ../tools.mk | |
| 2 | ||
| 3 | PROFILE_DIR=$(TMPDIR)/profiles | |
| 4 | ||
| 5 | all: check_inline check_filter | |
| 6 | ||
| 7 | check_inline: | |
| 8 | 	$(RUSTC) -O foo.rs --crate-type=lib -Cremark=all -Zremark-dir=$(PROFILE_DIR) | |
| 9 | 	cat $(PROFILE_DIR)/*.opt.yaml | $(CGREP) -e "inline" | |
| 10 | check_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 | ||
| 7 | use run_make_support::{ | |
| 8 | has_extension, has_prefix, invalid_utf8_contains, invalid_utf8_not_contains, not_contains, | |
| 9 | rustc, shallow_find_files, | |
| 10 | }; | |
| 11 | ||
| 12 | fn 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 | |
| 2 | include ../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 | ||
| 12 | all: | |
| 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 | ||
| 11 | use run_make_support::{invalid_utf8_contains, invalid_utf8_not_contains, rustc}; | |
| 12 | ||
| 13 | fn 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` |
| 2 | 2 | --> $DIR/feature-gate-negate-unsigned.rs:10:23 |
| 3 | 3 | | |
| 4 | 4 | LL | 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 `-` | |
| 9 | 6 | | |
| 10 | 7 | = note: unsigned values cannot be negated |
| 8 | help: you may have meant the maximum value of `usize` | |
| 9 | | | |
| 10 | LL | let _max: usize = usize::MAX; | |
| 11 | | ~~~~~~~~~~ | |
| 11 | 12 | |
| 12 | 13 | error[E0600]: cannot apply unary operator `-` to type `u8` |
| 13 | 14 | --> $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` |
| 2 | 2 | --> $DIR/unsigned-literal-negation.rs:2:13 |
| 3 | 3 | | |
| 4 | 4 | LL | 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 `-` | |
| 9 | 6 | | |
| 10 | 7 | = note: unsigned values cannot be negated |
| 8 | help: you may have meant the maximum value of `usize` | |
| 9 | | | |
| 10 | LL | let x = usize::MAX; | |
| 11 | | ~~~~~~~~~~ | |
| 11 | 12 | |
| 12 | 13 | error[E0600]: cannot apply unary operator `-` to type `usize` |
| 13 | 14 | --> $DIR/unsigned-literal-negation.rs:3:13 |
| 14 | 15 | | |
| 15 | 16 | LL | 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 `-` | |
| 20 | 18 | | |
| 21 | 19 | = note: unsigned values cannot be negated |
| 20 | help: you may have meant the maximum value of `usize` | |
| 21 | | | |
| 22 | LL | let x = usize::MAX; | |
| 23 | | ~~~~~~~~~~ | |
| 22 | 24 | |
| 23 | 25 | error[E0600]: cannot apply unary operator `-` to type `u32` |
| 24 | 26 | --> $DIR/unsigned-literal-negation.rs:4:18 |
| 25 | 27 | | |
| 26 | 28 | LL | 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 `-` | |
| 31 | 30 | | |
| 32 | 31 | = note: unsigned values cannot be negated |
| 32 | help: you may have meant the maximum value of `u32` | |
| 33 | | | |
| 34 | LL | let x: u32 = u32::MAX; | |
| 35 | | ~~~~~~~~ | |
| 33 | 36 | |
| 34 | 37 | error: aborting due to 3 previous errors |
| 35 | 38 |