From dbe6a09a8b8ab8c2c2b422df1e10db8306b1a481 Mon Sep 17 00:00:00 2001 From: ubsan Date: Fri, 24 Jun 2016 15:27:22 -0700 Subject: [PATCH 1/2] First commit, fix ABI string docs in reference.md --- src/doc/reference.md | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/src/doc/reference.md b/src/doc/reference.md index fb8ea0f5661d3..d564b19e1001c 100644 --- a/src/doc/reference.md +++ b/src/doc/reference.md @@ -1631,14 +1631,41 @@ the Rust ABI and the foreign ABI. A number of [attributes](#ffi-attributes) control the behavior of external blocks. By default external blocks assume that the library they are calling uses the -standard C "cdecl" ABI. Other ABIs may be specified using an `abi` string, as -shown here: +standard C ABI on the specific platform. Other ABIs may be specified using an +`abi` string, as shown here: ```ignore // Interface to the Windows API extern "stdcall" { } ``` +There are three ABI strings which are cross-platform, and which all compilers +are guaranteed to support: + +* `extern "Rust"` -- The default ABI when you write a normal `fn foo()` in any + Rust code. +* `extern "C"` -- This is the same as `extern fn foo()`; whatever the default + your C compiler supports. +* `extern "system"` -- Usually the same as `extern "C"`, except on Win32, in + which case it's `"stdcall"`, or what you should use to link to the Windows API + itself + +There are also some platform-specific ABI strings: + +* `extern "cdecl"` -- The default for x86\_32 C code. +* `extern "stdcall"` -- The default for the Win32 API on x86\_32. +* `extern "win64"` -- The default for C code on x86\_64 Windows. +* `extern "aapcs"` -- The default for ARM. +* `extern "fastcall"` +* `extern "vectorcall"` + +Finally, there are some rustc-specific ABI strings: + +* `extern "rust-intrinsic"` -- The ABI of rustc intrinsics. +* `extern "rust-call"` -- The ABI of the Fn::call trait functions. +* `extern "platform-intrinsic"` -- Specific platform intrinsics -- like, for + example, `sqrt` -- have this ABI. You should never have to deal with it. + The `link` attribute allows the name of the library to be specified. When specified the compiler will attempt to link against the native library of the specified name. From 1e899fde015c29f53642b6b8e582a8547b6e3b1d Mon Sep 17 00:00:00 2001 From: ubsan Date: Sat, 25 Jun 2016 11:53:46 -0700 Subject: [PATCH 2/2] Add vectorcall and fastcall explanation --- src/doc/reference.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/doc/reference.md b/src/doc/reference.md index d564b19e1001c..fa6014a3d6cee 100644 --- a/src/doc/reference.md +++ b/src/doc/reference.md @@ -1656,8 +1656,10 @@ There are also some platform-specific ABI strings: * `extern "stdcall"` -- The default for the Win32 API on x86\_32. * `extern "win64"` -- The default for C code on x86\_64 Windows. * `extern "aapcs"` -- The default for ARM. -* `extern "fastcall"` -* `extern "vectorcall"` +* `extern "fastcall"` -- The `fastcall` ABI -- corresponds to MSVC's + `__fastcall` and GCC and clang's `__attribute__((fastcall))` +* `extern "vectorcall"` -- The `vectorcall` ABI -- corresponds to MSVC's + `__vectorcall` and clang's `__attribute__((vectorcall))` Finally, there are some rustc-specific ABI strings: