Skip to content

Commit 37e99ae

Browse files
committed
std: Add Win64 types
1 parent e41a81b commit 37e99ae

File tree

1 file changed

+166
-0
lines changed

1 file changed

+166
-0
lines changed

src/libstd/libc.rs

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,172 @@ pub mod types {
764764
pub type LPMEMORY_BASIC_INFORMATION = *mut MEMORY_BASIC_INFORMATION;
765765
}
766766
}
767+
768+
#[cfg(target_arch = "x86_64")]
769+
pub mod arch {
770+
pub mod c95 {
771+
pub type c_char = i8;
772+
pub type c_schar = i8;
773+
pub type c_uchar = u8;
774+
pub type c_short = i16;
775+
pub type c_ushort = u16;
776+
pub type c_int = i32;
777+
pub type c_uint = u32;
778+
pub type c_long = i32;
779+
pub type c_ulong = u32;
780+
pub type c_float = f32;
781+
pub type c_double = f64;
782+
pub type size_t = u64;
783+
pub type ptrdiff_t = i64;
784+
pub type clock_t = i32;
785+
pub type time_t = i64;
786+
pub type wchar_t = u16;
787+
}
788+
pub mod c99 {
789+
pub type c_longlong = i64;
790+
pub type c_ulonglong = u64;
791+
pub type intptr_t = int;
792+
pub type uintptr_t = uint;
793+
}
794+
pub mod posix88 {
795+
pub type off_t = i32; // XXX unless _FILE_OFFSET_BITS == 64
796+
pub type dev_t = u32;
797+
pub type ino_t = i16;
798+
pub type pid_t = i64;
799+
pub type useconds_t = u32;
800+
pub type mode_t = u16;
801+
pub type ssize_t = i64;
802+
}
803+
pub mod posix01 {
804+
}
805+
pub mod posix08 {
806+
}
807+
pub mod bsd44 {
808+
}
809+
pub mod extra {
810+
use ptr;
811+
use libc::types::common::c95::c_void;
812+
use libc::types::os::arch::c95::{c_char, c_int, c_uint, size_t};
813+
use libc::types::os::arch::c95::{c_ulong};
814+
use libc::types::os::arch::c95::{wchar_t};
815+
use libc::types::os::arch::c99::{c_ulonglong};
816+
817+
pub type BOOL = c_int;
818+
pub type BYTE = u8;
819+
pub type CCHAR = c_char;
820+
pub type CHAR = c_char;
821+
822+
pub type DWORD = c_ulong;
823+
pub type DWORDLONG = c_ulonglong;
824+
825+
pub type HANDLE = LPVOID;
826+
pub type HMODULE = c_uint;
827+
828+
pub type LONG_PTR = i64; // changed
829+
830+
pub type LPCWSTR = *WCHAR;
831+
pub type LPCSTR = *CHAR;
832+
pub type LPCTSTR = *CHAR;
833+
pub type LPTCH = *CHAR;
834+
835+
pub type LPWSTR = *mut WCHAR;
836+
pub type LPSTR = *mut CHAR;
837+
pub type LPTSTR = *mut CHAR;
838+
839+
// Not really, but opaque to us.
840+
pub type LPSECURITY_ATTRIBUTES = LPVOID;
841+
842+
pub type LPVOID = *mut c_void;
843+
pub type LPCVOID = *c_void;
844+
pub type LPBYTE = *mut BYTE;
845+
pub type LPWORD = *mut WORD;
846+
pub type LPDWORD = *mut DWORD;
847+
pub type LPHANDLE = *mut HANDLE;
848+
849+
pub type LRESULT = LONG_PTR;
850+
pub type PBOOL = *mut BOOL;
851+
pub type WCHAR = wchar_t;
852+
pub type WORD = u16;
853+
pub type SIZE_T = size_t;
854+
855+
pub type time64_t = i64;
856+
pub type int64 = i64;
857+
858+
pub struct STARTUPINFO {
859+
cb: DWORD,
860+
lpReserved: LPTSTR,
861+
lpDesktop: LPTSTR,
862+
lpTitle: LPTSTR,
863+
dwX: DWORD,
864+
dwY: DWORD,
865+
dwXSize: DWORD,
866+
dwYSize: DWORD,
867+
dwXCountChars: DWORD,
868+
dwYCountCharts: DWORD,
869+
dwFillAttribute: DWORD,
870+
dwFlags: DWORD,
871+
wShowWindow: WORD,
872+
cbReserved2: WORD,
873+
lpReserved2: LPBYTE,
874+
hStdInput: HANDLE,
875+
hStdOutput: HANDLE,
876+
hStdError: HANDLE
877+
}
878+
pub type LPSTARTUPINFO = *mut STARTUPINFO;
879+
880+
pub struct PROCESS_INFORMATION {
881+
hProcess: HANDLE,
882+
hThread: HANDLE,
883+
dwProcessId: DWORD,
884+
dwThreadId: DWORD
885+
}
886+
pub type LPPROCESS_INFORMATION = *mut PROCESS_INFORMATION;
887+
888+
pub struct SYSTEM_INFO {
889+
wProcessorArchitecture: WORD,
890+
wReserved: WORD,
891+
dwPageSize: DWORD,
892+
lpMinimumApplicationAddress: LPVOID,
893+
lpMaximumApplicationAddress: LPVOID,
894+
dwActiveProcessorMask: DWORD,
895+
dwNumberOfProcessors: DWORD,
896+
dwProcessorType: DWORD,
897+
dwAllocationGranularity: DWORD,
898+
wProcessorLevel: WORD,
899+
wProcessorRevision: WORD
900+
}
901+
pub type LPSYSTEM_INFO = *mut SYSTEM_INFO;
902+
903+
impl SYSTEM_INFO {
904+
pub fn new() -> SYSTEM_INFO {
905+
SYSTEM_INFO {
906+
wProcessorArchitecture: 0,
907+
wReserved: 0,
908+
dwPageSize: 0,
909+
lpMinimumApplicationAddress: ptr::mut_null(),
910+
lpMaximumApplicationAddress: ptr::mut_null(),
911+
dwActiveProcessorMask: 0,
912+
dwNumberOfProcessors: 0,
913+
dwProcessorType: 0,
914+
dwAllocationGranularity: 0,
915+
wProcessorLevel: 0,
916+
wProcessorRevision: 0
917+
}
918+
}
919+
}
920+
921+
pub struct MEMORY_BASIC_INFORMATION {
922+
BaseAddress: LPVOID,
923+
AllocationBase: LPVOID,
924+
AllocationProtect: DWORD,
925+
RegionSize: SIZE_T,
926+
State: DWORD,
927+
Protect: DWORD,
928+
Type: DWORD
929+
}
930+
pub type LPMEMORY_BASIC_INFORMATION = *mut MEMORY_BASIC_INFORMATION;
931+
}
932+
}
767933
}
768934

769935
#[cfg(target_os = "macos")]

0 commit comments

Comments
 (0)