Add a Windows version of foreign2.rs

This commit is contained in:
Ben Kimock 2024-04-18 17:30:07 -04:00
parent 18b0a07d49
commit 281178de42

View File

@ -1,9 +1,8 @@
//@ run-pass
#![allow(dead_code)]
//@ pretty-expanded FIXME #23616
#![feature(rustc_private)]
extern crate libc;
#![allow(dead_code)]
#![feature(rustc_private)]
mod bar {
extern "C" {}
@ -13,7 +12,9 @@ mod zed {
extern "C" {}
}
#[cfg(not(windows))]
mod mlibc {
extern crate libc;
use libc::{c_int, c_void, size_t, ssize_t};
extern "C" {
@ -21,6 +22,27 @@ mod mlibc {
}
}
#[cfg(windows)]
mod mlibc {
#![allow(non_snake_case)]
use std::ffi::c_void;
pub type BOOL = i32;
pub type HANDLE = *mut c_void;
#[link(name = "ntdll")]
extern "system" {
pub fn WriteFile(
hfile: HANDLE,
lpbuffer: *const u8,
nnumberofbytestowrite: u32,
lpnumberofbyteswritten: *mut u32,
lpoverlapped: *mut c_void,
) -> BOOL;
}
}
mod baz {
extern "C" {}
}