about summary refs log tree commit diff
path: root/src/libstd/os.rs
diff options
context:
space:
mode:
authorklutzy <klutzytheklutzy@gmail.com>2013-08-12 15:27:46 +0900
committerklutzy <klutzytheklutzy@gmail.com>2013-08-26 22:15:45 +0900
commit05b6a2f59c8efa0605db3f5d8f5ef554cb35ff74 (patch)
treebee06074fc13f9987282722381c8c241b38ba377 /src/libstd/os.rs
parent6aff4c67f607a38bc4d95e132fe40563e7422beb (diff)
downloadrust-05b6a2f59c8efa0605db3f5d8f5ef554cb35ff74.tar.gz
rust-05b6a2f59c8efa0605db3f5d8f5ef554cb35ff74.zip
std: Add Win64 support
Some extern blobs are duplicated without "stdcall" abi,
since Win64 does not use any calling convention.
(Giving any abi to them causes llvm producing wrong bytecode.)
Diffstat (limited to 'src/libstd/os.rs')
-rw-r--r--src/libstd/os.rs38
1 files changed, 36 insertions, 2 deletions
diff --git a/src/libstd/os.rs b/src/libstd/os.rs
index 0b5f53dbf19..e7caf3f23ab 100644
--- a/src/libstd/os.rs
+++ b/src/libstd/os.rs
@@ -1042,12 +1042,19 @@ pub fn errno() -> uint {
     #[fixed_stack_segment]; #[inline(never)];
     use libc::types::os::arch::extra::DWORD;
 
+    #[cfg(target_arch = "x86")]
     #[link_name = "kernel32"]
     #[abi = "stdcall"]
     extern "stdcall" {
         fn GetLastError() -> DWORD;
     }
 
+    #[cfg(target_arch = "x86_64")]
+    #[link_name = "kernel32"]
+    extern {
+        fn GetLastError() -> DWORD;
+    }
+
     unsafe {
         GetLastError() as uint
     }
@@ -1113,6 +1120,7 @@ pub fn last_os_error() -> ~str {
         use libc::types::os::arch::extra::LPSTR;
         use libc::types::os::arch::extra::LPVOID;
 
+        #[cfg(target_arch = "x86")]
         #[link_name = "kernel32"]
         #[abi = "stdcall"]
         extern "stdcall" {
@@ -1126,6 +1134,19 @@ pub fn last_os_error() -> ~str {
                               -> DWORD;
         }
 
+        #[cfg(target_arch = "x86_64")]
+        #[link_name = "kernel32"]
+        extern {
+            fn FormatMessageA(flags: DWORD,
+                              lpSrc: LPVOID,
+                              msgId: DWORD,
+                              langId: DWORD,
+                              buf: LPSTR,
+                              nsize: DWORD,
+                              args: *c_void)
+                              -> DWORD;
+        }
+
         static FORMAT_MESSAGE_FROM_SYSTEM: DWORD = 0x00001000;
         static FORMAT_MESSAGE_IGNORE_INSERTS: DWORD = 0x00000200;
 
@@ -1241,7 +1262,7 @@ fn real_args() -> ~[~str] {
 
 type LPCWSTR = *u16;
 
-#[cfg(windows)]
+#[cfg(windows, target_arch = "x86")]
 #[link_name="kernel32"]
 #[abi="stdcall"]
 extern "stdcall" {
@@ -1249,13 +1270,26 @@ extern "stdcall" {
     fn LocalFree(ptr: *c_void);
 }
 
-#[cfg(windows)]
+#[cfg(windows, target_arch = "x86_64")]
+#[link_name="kernel32"]
+extern {
+    fn GetCommandLineW() -> LPCWSTR;
+    fn LocalFree(ptr: *c_void);
+}
+
+#[cfg(windows, target_arch = "x86")]
 #[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 {
+    fn CommandLineToArgvW(lpCmdLine: LPCWSTR, pNumArgs: *mut c_int) -> **u16;
+}
+
 struct OverriddenArgs {
     val: ~[~str]
 }