mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-30 18:53:39 +00:00
auto merge of #10408 : alexcrichton/rust/snapshots, r=huonw
Mostly just using the `system` abi where possible.
This commit is contained in:
commit
46100c0622
@ -3387,8 +3387,7 @@ pub mod funcs {
|
||||
LPSYSTEM_INFO};
|
||||
use libc::types::os::arch::extra::{HANDLE, LPHANDLE};
|
||||
|
||||
#[cfg(target_arch = "x86")]
|
||||
extern "stdcall" {
|
||||
extern "system" {
|
||||
pub fn GetEnvironmentVariableW(n: LPCWSTR,
|
||||
v: LPWSTR,
|
||||
nsize: DWORD)
|
||||
@ -3494,114 +3493,6 @@ pub mod funcs {
|
||||
-> LPVOID;
|
||||
pub fn UnmapViewOfFile(lpBaseAddress: LPCVOID) -> BOOL;
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
extern {
|
||||
pub fn GetEnvironmentVariableW(n: LPCWSTR,
|
||||
v: LPWSTR,
|
||||
nsize: DWORD)
|
||||
-> DWORD;
|
||||
pub fn SetEnvironmentVariableW(n: LPCWSTR, v: LPCWSTR)
|
||||
-> BOOL;
|
||||
pub fn GetEnvironmentStringsA() -> LPTCH;
|
||||
pub fn FreeEnvironmentStringsA(env_ptr: LPTCH) -> BOOL;
|
||||
pub fn GetModuleFileNameW(hModule: HMODULE,
|
||||
lpFilename: LPWSTR,
|
||||
nSize: DWORD)
|
||||
-> DWORD;
|
||||
pub fn CreateDirectoryW(lpPathName: LPCWSTR,
|
||||
lpSecurityAttributes:
|
||||
LPSECURITY_ATTRIBUTES)
|
||||
-> BOOL;
|
||||
pub fn CopyFileW(lpExistingFileName: LPCWSTR,
|
||||
lpNewFileName: LPCWSTR,
|
||||
bFailIfExists: BOOL)
|
||||
-> BOOL;
|
||||
pub fn DeleteFileW(lpPathName: LPCWSTR) -> BOOL;
|
||||
pub fn RemoveDirectoryW(lpPathName: LPCWSTR) -> BOOL;
|
||||
pub fn GetCurrentDirectoryW(nBufferLength: DWORD,
|
||||
lpBuffer: LPWSTR)
|
||||
-> DWORD;
|
||||
pub fn SetCurrentDirectoryW(lpPathName: LPCWSTR) -> BOOL;
|
||||
pub fn GetLastError() -> DWORD;
|
||||
pub fn FindFirstFileW(fileName: *u16, findFileData: HANDLE)
|
||||
-> HANDLE;
|
||||
pub fn FindNextFileW(findFile: HANDLE, findFileData: HANDLE)
|
||||
-> BOOL;
|
||||
pub fn FindClose(findFile: HANDLE) -> BOOL;
|
||||
pub fn DuplicateHandle(hSourceProcessHandle: HANDLE,
|
||||
hSourceHandle: HANDLE,
|
||||
hTargetProcessHandle: HANDLE,
|
||||
lpTargetHandle: LPHANDLE,
|
||||
dwDesiredAccess: DWORD,
|
||||
bInheritHandle: BOOL,
|
||||
dwOptions: DWORD)
|
||||
-> BOOL;
|
||||
pub fn CloseHandle(hObject: HANDLE) -> BOOL;
|
||||
pub fn OpenProcess(dwDesiredAccess: DWORD,
|
||||
bInheritHandle: BOOL,
|
||||
dwProcessId: DWORD)
|
||||
-> HANDLE;
|
||||
pub fn GetCurrentProcess() -> HANDLE;
|
||||
pub fn CreateProcessA(lpApplicationName: LPCTSTR,
|
||||
lpCommandLine: LPTSTR,
|
||||
lpProcessAttributes:
|
||||
LPSECURITY_ATTRIBUTES,
|
||||
lpThreadAttributes:
|
||||
LPSECURITY_ATTRIBUTES,
|
||||
bInheritHandles: BOOL,
|
||||
dwCreationFlags: DWORD,
|
||||
lpEnvironment: LPVOID,
|
||||
lpCurrentDirectory: LPCTSTR,
|
||||
lpStartupInfo: LPSTARTUPINFO,
|
||||
lpProcessInformation:
|
||||
LPPROCESS_INFORMATION)
|
||||
-> BOOL;
|
||||
pub fn WaitForSingleObject(hHandle: HANDLE,
|
||||
dwMilliseconds: DWORD)
|
||||
-> DWORD;
|
||||
pub fn TerminateProcess(hProcess: HANDLE, uExitCode: c_uint)
|
||||
-> BOOL;
|
||||
pub fn GetExitCodeProcess(hProcess: HANDLE,
|
||||
lpExitCode: LPDWORD)
|
||||
-> BOOL;
|
||||
pub fn GetSystemInfo(lpSystemInfo: LPSYSTEM_INFO);
|
||||
pub fn VirtualAlloc(lpAddress: LPVOID,
|
||||
dwSize: SIZE_T,
|
||||
flAllocationType: DWORD,
|
||||
flProtect: DWORD)
|
||||
-> LPVOID;
|
||||
pub fn VirtualFree(lpAddress: LPVOID,
|
||||
dwSize: SIZE_T,
|
||||
dwFreeType: DWORD)
|
||||
-> BOOL;
|
||||
pub fn VirtualLock(lpAddress: LPVOID, dwSize: SIZE_T) -> BOOL;
|
||||
pub fn VirtualUnlock(lpAddress: LPVOID, dwSize: SIZE_T)
|
||||
-> BOOL;
|
||||
pub fn VirtualProtect(lpAddress: LPVOID,
|
||||
dwSize: SIZE_T,
|
||||
flNewProtect: DWORD,
|
||||
lpflOldProtect: LPDWORD)
|
||||
-> BOOL;
|
||||
pub fn VirtualQuery(lpAddress: LPCVOID,
|
||||
lpBuffer: LPMEMORY_BASIC_INFORMATION,
|
||||
dwLength: SIZE_T)
|
||||
-> SIZE_T;
|
||||
pub fn CreateFileMappingW(hFile: HANDLE,
|
||||
lpAttributes: LPSECURITY_ATTRIBUTES,
|
||||
flProtect: DWORD,
|
||||
dwMaximumSizeHigh: DWORD,
|
||||
dwMaximumSizeLow: DWORD,
|
||||
lpName: LPCTSTR)
|
||||
-> HANDLE;
|
||||
pub fn MapViewOfFile(hFileMappingObject: HANDLE,
|
||||
dwDesiredAccess: DWORD,
|
||||
dwFileOffsetHigh: DWORD,
|
||||
dwFileOffsetLow: DWORD,
|
||||
dwNumberOfBytesToMap: SIZE_T)
|
||||
-> LPVOID;
|
||||
pub fn UnmapViewOfFile(lpBaseAddress: LPCVOID) -> BOOL;
|
||||
}
|
||||
}
|
||||
|
||||
pub mod msvcrt {
|
||||
|
@ -615,15 +615,8 @@ pub fn errno() -> uint {
|
||||
#[fixed_stack_segment]; #[inline(never)];
|
||||
use libc::types::os::arch::extra::DWORD;
|
||||
|
||||
#[cfg(target_arch = "x86")]
|
||||
#[link_name = "kernel32"]
|
||||
extern "stdcall" {
|
||||
fn GetLastError() -> DWORD;
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
#[link_name = "kernel32"]
|
||||
extern {
|
||||
extern "system" {
|
||||
fn GetLastError() -> DWORD;
|
||||
}
|
||||
|
||||
@ -693,22 +686,8 @@ pub fn last_os_error() -> ~str {
|
||||
use libc::types::os::arch::extra::LPVOID;
|
||||
use libc::types::os::arch::extra::WCHAR;
|
||||
|
||||
#[cfg(target_arch = "x86")]
|
||||
#[link_name = "kernel32"]
|
||||
extern "stdcall" {
|
||||
fn FormatMessageW(flags: DWORD,
|
||||
lpSrc: LPVOID,
|
||||
msgId: DWORD,
|
||||
langId: DWORD,
|
||||
buf: LPWSTR,
|
||||
nsize: DWORD,
|
||||
args: *c_void)
|
||||
-> DWORD;
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
#[link_name = "kernel32"]
|
||||
extern {
|
||||
extern "system" {
|
||||
fn FormatMessageW(flags: DWORD,
|
||||
lpSrc: LPVOID,
|
||||
msgId: DWORD,
|
||||
@ -833,31 +812,16 @@ fn real_args() -> ~[~str] {
|
||||
|
||||
type LPCWSTR = *u16;
|
||||
|
||||
#[cfg(windows, target_arch = "x86")]
|
||||
#[cfg(windows)]
|
||||
#[link_name="kernel32"]
|
||||
#[abi="stdcall"]
|
||||
extern "stdcall" {
|
||||
extern "system" {
|
||||
fn GetCommandLineW() -> LPCWSTR;
|
||||
fn LocalFree(ptr: *c_void);
|
||||
}
|
||||
|
||||
#[cfg(windows, target_arch = "x86_64")]
|
||||
#[link_name="kernel32"]
|
||||
extern {
|
||||
fn GetCommandLineW() -> LPCWSTR;
|
||||
fn LocalFree(ptr: *c_void);
|
||||
}
|
||||
|
||||
#[cfg(windows, target_arch = "x86")]
|
||||
#[cfg(windows)]
|
||||
#[link_name="shell32"]
|
||||
#[abi="stdcall"]
|
||||
extern "stdcall" {
|
||||
fn CommandLineToArgvW(lpCmdLine: LPCWSTR, pNumArgs: *mut c_int) -> **u16;
|
||||
}
|
||||
|
||||
#[cfg(windows, target_arch = "x86_64")]
|
||||
#[link_name="shell32"]
|
||||
extern {
|
||||
extern "system" {
|
||||
fn CommandLineToArgvW(lpCmdLine: LPCWSTR, pNumArgs: *mut c_int) -> **u16;
|
||||
}
|
||||
|
||||
|
@ -118,16 +118,8 @@ impl Drop for Thread {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows, target_arch = "x86")]
|
||||
extern "stdcall" {
|
||||
fn CreateThread(lpThreadAttributes: LPSECURITY_ATTRIBUTES, dwStackSize: SIZE_T,
|
||||
lpStartAddress: extern "C" fn(*libc::c_void) -> rust_thread_return,
|
||||
lpParameter: LPVOID, dwCreationFlags: DWORD, lpThreadId: LPDWORD) -> HANDLE;
|
||||
fn WaitForSingleObject(hHandle: HANDLE, dwMilliseconds: DWORD) -> DWORD;
|
||||
}
|
||||
|
||||
#[cfg(windows, target_arch = "x86_64")]
|
||||
extern {
|
||||
#[cfg(windows)]
|
||||
extern "system" {
|
||||
fn CreateThread(lpThreadAttributes: LPSECURITY_ATTRIBUTES, dwStackSize: SIZE_T,
|
||||
lpStartAddress: extern "C" fn(*libc::c_void) -> rust_thread_return,
|
||||
lpParameter: LPVOID, dwCreationFlags: DWORD, lpThreadId: LPDWORD) -> HANDLE;
|
||||
|
@ -88,8 +88,8 @@ pub unsafe fn get(key: Key) -> *mut c_void {
|
||||
TlsGetValue(key)
|
||||
}
|
||||
|
||||
#[cfg(windows, target_arch = "x86")]
|
||||
extern "stdcall" {
|
||||
#[cfg(windows)]
|
||||
extern "system" {
|
||||
fn TlsAlloc() -> DWORD;
|
||||
|
||||
// See the reasoning in pthread_getspecific as to why this has the
|
||||
@ -101,17 +101,6 @@ extern "stdcall" {
|
||||
fn TlsSetValue(dwTlsIndex: DWORD, lpTlsvalue: LPVOID) -> BOOL;
|
||||
}
|
||||
|
||||
#[cfg(windows, target_arch = "x86_64")]
|
||||
extern {
|
||||
fn TlsAlloc() -> DWORD;
|
||||
|
||||
// See above.
|
||||
#[rust_stack]
|
||||
fn TlsGetValue(dwTlsIndex: DWORD) -> LPVOID;
|
||||
#[rust_stack]
|
||||
fn TlsSetValue(dwTlsIndex: DWORD, lpTlsvalue: LPVOID) -> BOOL;
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn tls_smoke_test() {
|
||||
use cast::transmute;
|
||||
|
@ -264,20 +264,8 @@ pub mod dl {
|
||||
FreeLibrary(handle); ()
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "x86")]
|
||||
#[link_name = "kernel32"]
|
||||
extern "stdcall" {
|
||||
fn SetLastError(error: u32);
|
||||
fn LoadLibraryW(name: *u16) -> *libc::c_void;
|
||||
fn GetModuleHandleExW(dwFlags: libc::DWORD, name: *u16,
|
||||
handle: **libc::c_void) -> *libc::c_void;
|
||||
fn GetProcAddress(handle: *libc::c_void, name: *libc::c_char) -> *libc::c_void;
|
||||
fn FreeLibrary(handle: *libc::c_void);
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
#[link_name = "kernel32"]
|
||||
extern {
|
||||
extern "system" {
|
||||
fn SetLastError(error: u32);
|
||||
fn LoadLibraryW(name: *u16) -> *libc::c_void;
|
||||
fn GetModuleHandleExW(dwFlags: libc::DWORD, name: *u16,
|
||||
|
@ -1,3 +1,11 @@
|
||||
S 2013-11-10 b5e602a
|
||||
freebsd-x86_64 bdcfcfa63216559765b83fe4056abb953da25da0
|
||||
linux-i386 0fb5cdff8a46e9a02bcdba100803bb5504b6f332
|
||||
linux-x86_64 fe861214208cacef085bfc13c22ce655c207facc
|
||||
macos-i386 83d7853554e5d5404227924cc3cbf86c673f4626
|
||||
macos-x86_64 27a71031d9030057746199a3c82efac8f8607093
|
||||
winnt-i386 d1a0e2a3cfbc09e360aa0ac4f47b3e8a638b39f7
|
||||
|
||||
S 2013-11-06 fdc830d
|
||||
freebsd-x86_64 ef38f3acf8d05eda3c9f21e75c2bbd2f90a614a3
|
||||
linux-i386 6ad20f6722c15a71fe7654d187dc431e26c1da6f
|
||||
|
@ -14,11 +14,11 @@ pub type SIZE_T = u32;
|
||||
pub type LPVOID = uint;
|
||||
pub type BOOL = u8;
|
||||
|
||||
#[cfg(target_os = "win32")]
|
||||
#[cfg(windows)]
|
||||
mod kernel32 {
|
||||
use super::{HANDLE, DWORD, SIZE_T, LPVOID, BOOL};
|
||||
|
||||
extern "stdcall" {
|
||||
extern "system" {
|
||||
pub fn GetProcessHeap() -> HANDLE;
|
||||
pub fn HeapAlloc(hHeap: HANDLE, dwFlags: DWORD, dwBytes: SIZE_T)
|
||||
-> LPVOID;
|
||||
@ -27,7 +27,7 @@ mod kernel32 {
|
||||
}
|
||||
|
||||
|
||||
#[cfg(target_os = "win32")]
|
||||
#[cfg(windows)]
|
||||
#[fixed_stack_segment]
|
||||
pub fn main() {
|
||||
let heap = unsafe { kernel32::GetProcessHeap() };
|
||||
@ -37,8 +37,5 @@ pub fn main() {
|
||||
assert!(res != 0u8);
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
#[cfg(target_os = "linux")]
|
||||
#[cfg(target_os = "freebsd")]
|
||||
#[cfg(target_os = "android")]
|
||||
#[cfg(not(windows))]
|
||||
pub fn main() { }
|
||||
|
Loading…
Reference in New Issue
Block a user