Skip to content

Commit 4c05e3a

Browse files
committed
Use raw-dylib in the std
1 parent 57ee5cf commit 4c05e3a

File tree

1 file changed

+52
-3
lines changed
  • library/std/src/sys/windows

1 file changed

+52
-3
lines changed

library/std/src/sys/windows/c.rs

+52-3
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ pub const STATUS_INVALID_PARAMETER: NTSTATUS = 0xc000000d_u32 as _;
278278

279279
pub const STATUS_PENDING: NTSTATUS = 0x103 as _;
280280
pub const STATUS_END_OF_FILE: NTSTATUS = 0xC0000011_u32 as _;
281+
#[cfg(target_arch = "x86")]
281282
pub const STATUS_NOT_IMPLEMENTED: NTSTATUS = 0xC0000002_u32 as _;
282283

283284
// Equivalent to the `NT_SUCCESS` C preprocessor macro.
@@ -825,7 +826,8 @@ if #[cfg(not(target_vendor = "uwp"))] {
825826
) -> BOOL;
826827
}
827828

828-
#[link(name = "userenv")]
829+
#[cfg_attr(not(target_arch = "x86"), link(name = "userenv", kind = "raw-dylib"))]
830+
#[cfg_attr(target_arch = "x86", link(name = "userenv"))]
829831
extern "system" {
830832
// Allowed but unused by UWP
831833
pub fn GetUserProfileDirectoryW(
@@ -1130,7 +1132,8 @@ extern "system" {
11301132
pub fn GetFileAttributesW(lpFileName: LPCWSTR) -> DWORD;
11311133
}
11321134

1133-
#[link(name = "ws2_32")]
1135+
#[cfg_attr(not(target_arch = "x86"), link(name = "ws2_32", kind = "raw-dylib"))]
1136+
#[cfg_attr(target_arch = "x86", link(name = "ws2_32"))]
11341137
extern "system" {
11351138
pub fn WSAStartup(wVersionRequested: WORD, lpWSAData: LPWSADATA) -> c_int;
11361139
pub fn WSACleanup() -> c_int;
@@ -1223,7 +1226,8 @@ extern "system" {
12231226
) -> c_int;
12241227
}
12251228

1226-
#[link(name = "bcrypt")]
1229+
#[cfg_attr(not(target_arch = "x86"), link(name = "bcrypt", kind = "raw-dylib"))]
1230+
#[cfg_attr(target_arch = "x86", link(name = "bcrypt"))]
12271231
extern "system" {
12281232
// >= Vista / Server 2008
12291233
// https://docs.microsoft.com/en-us/windows/win32/api/bcrypt/nf-bcrypt-bcryptgenrandom
@@ -1242,6 +1246,47 @@ extern "system" {
12421246
pub fn BCryptCloseAlgorithmProvider(hAlgorithm: BCRYPT_ALG_HANDLE, dwFlags: ULONG) -> NTSTATUS;
12431247
}
12441248

1249+
#[cfg(not(target_arch = "x86"))]
1250+
#[link(name = "ntdll", kind = "raw-dylib")]
1251+
extern "system" {
1252+
pub fn NtCreateFile(
1253+
FileHandle: *mut HANDLE,
1254+
DesiredAccess: ACCESS_MASK,
1255+
ObjectAttributes: *const OBJECT_ATTRIBUTES,
1256+
IoStatusBlock: *mut IO_STATUS_BLOCK,
1257+
AllocationSize: *mut i64,
1258+
FileAttributes: ULONG,
1259+
ShareAccess: ULONG,
1260+
CreateDisposition: ULONG,
1261+
CreateOptions: ULONG,
1262+
EaBuffer: *mut c_void,
1263+
EaLength: ULONG,
1264+
) -> NTSTATUS;
1265+
pub fn NtReadFile(
1266+
FileHandle: BorrowedHandle<'_>,
1267+
Event: HANDLE,
1268+
ApcRoutine: Option<IO_APC_ROUTINE>,
1269+
ApcContext: *mut c_void,
1270+
IoStatusBlock: &mut IO_STATUS_BLOCK,
1271+
Buffer: *mut crate::mem::MaybeUninit<u8>,
1272+
Length: ULONG,
1273+
ByteOffset: Option<&LARGE_INTEGER>,
1274+
Key: Option<&ULONG>,
1275+
) -> NTSTATUS;
1276+
pub fn NtWriteFile(
1277+
FileHandle: BorrowedHandle<'_>,
1278+
Event: HANDLE,
1279+
ApcRoutine: Option<IO_APC_ROUTINE>,
1280+
ApcContext: *mut c_void,
1281+
IoStatusBlock: &mut IO_STATUS_BLOCK,
1282+
Buffer: *const u8,
1283+
Length: ULONG,
1284+
ByteOffset: Option<&LARGE_INTEGER>,
1285+
Key: Option<&ULONG>,
1286+
) -> NTSTATUS;
1287+
pub fn RtlNtStatusToDosError(Status: NTSTATUS) -> ULONG;
1288+
}
1289+
12451290
// Functions that aren't available on every version of Windows that we support,
12461291
// but we still use them and just provide some form of a fallback implementation.
12471292
compat_fn_with_fallback! {
@@ -1282,6 +1327,7 @@ compat_fn_optional! {
12821327
compat_fn_with_fallback! {
12831328
pub static NTDLL: &CStr = ansi_str!("ntdll");
12841329

1330+
#[cfg(target_arch = "x86")]
12851331
pub fn NtCreateFile(
12861332
FileHandle: *mut HANDLE,
12871333
DesiredAccess: ACCESS_MASK,
@@ -1297,6 +1343,7 @@ compat_fn_with_fallback! {
12971343
) -> NTSTATUS {
12981344
STATUS_NOT_IMPLEMENTED
12991345
}
1346+
#[cfg(target_arch = "x86")]
13001347
pub fn NtReadFile(
13011348
FileHandle: BorrowedHandle<'_>,
13021349
Event: HANDLE,
@@ -1310,6 +1357,7 @@ compat_fn_with_fallback! {
13101357
) -> NTSTATUS {
13111358
STATUS_NOT_IMPLEMENTED
13121359
}
1360+
#[cfg(target_arch = "x86")]
13131361
pub fn NtWriteFile(
13141362
FileHandle: BorrowedHandle<'_>,
13151363
Event: HANDLE,
@@ -1323,6 +1371,7 @@ compat_fn_with_fallback! {
13231371
) -> NTSTATUS {
13241372
STATUS_NOT_IMPLEMENTED
13251373
}
1374+
#[cfg(target_arch = "x86")]
13261375
pub fn RtlNtStatusToDosError(
13271376
Status: NTSTATUS
13281377
) -> ULONG {

0 commit comments

Comments
 (0)