Skip to content

Commit 7c274a3

Browse files
committed
Add a Windows version of foreign2.rs
1 parent df9dd1c commit 7c274a3

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

tests/ui/foreign/foreign2.rs

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
//@ run-pass
2-
#![allow(dead_code)]
32
//@ pretty-expanded FIXME #23616
4-
#![feature(rustc_private)]
53

6-
extern crate libc;
4+
#![allow(dead_code)]
5+
#![feature(rustc_private)]
76

87
mod bar {
98
extern "C" {}
@@ -13,14 +12,37 @@ mod zed {
1312
extern "C" {}
1413
}
1514

15+
#[cfg(not(windows))]
1616
mod mlibc {
17+
extern crate libc;
1718
use libc::{c_int, c_void, size_t, ssize_t};
1819

1920
extern "C" {
2021
pub fn write(fd: c_int, buf: *const c_void, count: size_t) -> ssize_t;
2122
}
2223
}
2324

25+
#[cfg(windows)]
26+
mod mlibc {
27+
#![allow(non_snake_case)]
28+
29+
use std::ffi::c_void;
30+
31+
pub type BOOL = i32;
32+
pub type HANDLE = *mut c_void;
33+
34+
#[link(name = "ntdll")]
35+
extern "system" {
36+
pub fn WriteFile(
37+
hfile: HANDLE,
38+
lpbuffer: *const u8,
39+
nnumberofbytestowrite: u32,
40+
lpnumberofbyteswritten: *mut u32,
41+
lpoverlapped: *mut c_void,
42+
) -> BOOL;
43+
}
44+
}
45+
2446
mod baz {
2547
extern "C" {}
2648
}

0 commit comments

Comments
 (0)