about summary refs log tree commit diff
path: root/doc
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2013-11-08 11:06:57 -0800
committerAlex Crichton <alex@alexcrichton.com>2013-11-09 11:16:09 -0800
commit2fcc70ec9d2f73b61285283aeb4abce4a4e84901 (patch)
treef5b239596c35f1936d3bd6f9e0f579ef665091a1 /doc
parent9d8dc004a021af5807120ae9ef2854ab99350cbf (diff)
downloadrust-2fcc70ec9d2f73b61285283aeb4abce4a4e84901.tar.gz
rust-2fcc70ec9d2f73b61285283aeb4abce4a4e84901.zip
Add a "system" ABI
This adds an other ABI option which allows a custom selection over the target
architecture and OS. The only current candidate for this change is that kernel32
on win32 uses stdcall, but on win64 it uses the cdecl calling convention.
Otherwise everywhere else this is defined as using the Cdecl calling convention.

cc #10049
Closes #8774
Diffstat (limited to 'doc')
-rw-r--r--doc/tutorial-ffi.md23
1 files changed, 20 insertions, 3 deletions
diff --git a/doc/tutorial-ffi.md b/doc/tutorial-ffi.md
index 57dc926dfa9..7d975d0ef62 100644
--- a/doc/tutorial-ffi.md
+++ b/doc/tutorial-ffi.md
@@ -418,15 +418,32 @@ calling foreign functions. Some foreign functions, most notably the Windows API,
 conventions. Rust provides a way to tell the compiler which convention to use:
 
 ~~~~
-#[cfg(target_os = "win32")]
+#[cfg(target_os = "win32", target_arch = "x86")]
 #[link_name = "kernel32"]
 extern "stdcall" {
     fn SetEnvironmentVariableA(n: *u8, v: *u8) -> int;
 }
 ~~~~
 
-This applies to the entire `extern` block, and must be either `"cdecl"` or
-`"stdcall"`. The compiler may eventually support other calling conventions.
+This applies to the entire `extern` block. The list of supported ABI constraints
+are:
+
+* `stdcall`
+* `aapcs`
+* `cdecl`
+* `fastcall`
+* `Rust`
+* `rust-intrinsic`
+* `system`
+* `C`
+
+Most of the abis in this list are self-explanatory, but the `system` abi may
+seem a little odd. This constraint selects whatever the appropriate ABI is for
+interoperating with the target's libraries. For example, on win32 with a x86
+architecture, this means that the abi used would be `stdcall`. On x86_64,
+however, windows uses the `C` calling convention, so `C` would be used. This
+means that in our previous example, we could have used `extern "system" { ... }`
+to define a block for all windows systems, not just x86 ones.
 
 # Interoperability with foreign code