Skip to content

Commit 4027a52

Browse files
committed
Sync from rust f9b1614
2 parents 5075386 + a2a949b commit 4027a52

File tree

3 files changed

+58
-24
lines changed

3 files changed

+58
-24
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
From 0d741cf82c3c908616abd39dc84ebf7d8702e0c3 Mon Sep 17 00:00:00 2001
2+
From: Chris Denton <chris@chrisdenton.dev>
3+
Date: Tue, 16 Apr 2024 15:51:34 +0000
4+
Subject: [PATCH] Revert use raw-dylib for Windows futex APIs
5+
6+
---
7+
library/std/src/sys/pal/windows/c.rs | 14 +-------------
8+
1 file changed, 1 insertion(+), 13 deletions(-)
9+
10+
diff --git a/library/std/src/sys/pal/windows/c.rs b/library/std/src/sys/pal/windows/c.rs
11+
index 9d58ce05f01..1c828bac4b6 100644
12+
--- a/library/std/src/sys/pal/windows/c.rs
13+
+++ b/library/std/src/sys/pal/windows/c.rs
14+
@@ -357,19 +357,7 @@ pub fn GetTempPath2W(bufferlength: u32, buffer: PWSTR) -> u32 {
15+
}
16+
17+
#[cfg(not(target_vendor = "win7"))]
18+
-// Use raw-dylib to import synchronization functions to workaround issues with the older mingw import library.
19+
-#[cfg_attr(
20+
- target_arch = "x86",
21+
- link(
22+
- name = "api-ms-win-core-synch-l1-2-0",
23+
- kind = "raw-dylib",
24+
- import_name_type = "undecorated"
25+
- )
26+
-)]
27+
-#[cfg_attr(
28+
- not(target_arch = "x86"),
29+
- link(name = "api-ms-win-core-synch-l1-2-0", kind = "raw-dylib")
30+
-)]
31+
+#[link(name = "synchronization")]
32+
extern "system" {
33+
pub fn WaitOnAddress(
34+
address: *const c_void,
35+
--
36+
2.42.0.windows.2
37+

src/constant.rs

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ pub(crate) fn codegen_const_value<'tcx>(
110110
if fx.clif_type(layout.ty).is_some() {
111111
return CValue::const_val(fx, layout, int);
112112
} else {
113-
let raw_val = int.size().truncate(int.to_bits(int.size()).unwrap());
113+
let raw_val = int.size().truncate(int.assert_bits(int.size()));
114114
let val = match int.size().bytes() {
115115
1 => fx.bcx.ins().iconst(types::I8, raw_val as i64),
116116
2 => fx.bcx.ins().iconst(types::I16, raw_val as i64),
@@ -491,27 +491,24 @@ pub(crate) fn mir_operand_get_const_val<'tcx>(
491491
return None;
492492
}
493493
let scalar_int = mir_operand_get_const_val(fx, operand)?;
494-
let scalar_int = match fx
495-
.layout_of(*ty)
496-
.size
497-
.cmp(&scalar_int.size())
498-
{
499-
Ordering::Equal => scalar_int,
500-
Ordering::Less => match ty.kind() {
501-
ty::Uint(_) => ScalarInt::try_from_uint(
502-
scalar_int.try_to_uint(scalar_int.size()).unwrap(),
503-
fx.layout_of(*ty).size,
504-
)
505-
.unwrap(),
506-
ty::Int(_) => ScalarInt::try_from_int(
507-
scalar_int.try_to_int(scalar_int.size()).unwrap(),
508-
fx.layout_of(*ty).size,
509-
)
510-
.unwrap(),
511-
_ => unreachable!(),
512-
},
513-
Ordering::Greater => return None,
514-
};
494+
let scalar_int =
495+
match fx.layout_of(*ty).size.cmp(&scalar_int.size()) {
496+
Ordering::Equal => scalar_int,
497+
Ordering::Less => match ty.kind() {
498+
ty::Uint(_) => ScalarInt::try_from_uint(
499+
scalar_int.assert_uint(scalar_int.size()),
500+
fx.layout_of(*ty).size,
501+
)
502+
.unwrap(),
503+
ty::Int(_) => ScalarInt::try_from_int(
504+
scalar_int.assert_int(scalar_int.size()),
505+
fx.layout_of(*ty).size,
506+
)
507+
.unwrap(),
508+
_ => unreachable!(),
509+
},
510+
Ordering::Greater => return None,
511+
};
515512
computed_scalar_int = Some(scalar_int);
516513
}
517514
Rvalue::Use(operand) => {

src/value_and_place.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ impl<'tcx> CValue<'tcx> {
326326

327327
let val = match layout.ty.kind() {
328328
ty::Uint(UintTy::U128) | ty::Int(IntTy::I128) => {
329-
let const_val = const_val.to_bits(layout.size).unwrap();
329+
let const_val = const_val.assert_bits(layout.size);
330330
let lsb = fx.bcx.ins().iconst(types::I64, const_val as u64 as i64);
331331
let msb = fx.bcx.ins().iconst(types::I64, (const_val >> 64) as u64 as i64);
332332
fx.bcx.ins().iconcat(lsb, msb)
@@ -338,7 +338,7 @@ impl<'tcx> CValue<'tcx> {
338338
| ty::Ref(..)
339339
| ty::RawPtr(..)
340340
| ty::FnPtr(..) => {
341-
let raw_val = const_val.size().truncate(const_val.to_bits(layout.size).unwrap());
341+
let raw_val = const_val.size().truncate(const_val.assert_bits(layout.size));
342342
fx.bcx.ins().iconst(clif_ty, raw_val as i64)
343343
}
344344
ty::Float(FloatTy::F32) => {

0 commit comments

Comments
 (0)