Skip to content

Commit ff17b38

Browse files
committed
---
yaml --- r: 83885 b: refs/heads/try c: b571039 h: refs/heads/master i: 83883: 74df6ab v: v3
1 parent e01857a commit ff17b38

36 files changed

+383
-309
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 0e4d1fc8cae42e15e00f71d9f439b01bb25a86ae
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 6c08cc2db4f98e9f07ae7d50338396c4123c2f0a
5-
refs/heads/try: 309ab958e6cf78caf188f6dcbf9ce35d9ba62468
5+
refs/heads/try: b571039021e031888cea4e0b53d8f9b4e81c6d31
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/doc/tutorial-ffi.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -415,18 +415,21 @@ fn main() {
415415

416416
Most foreign code exposes a C ABI, and Rust uses the platform's C calling convention by default when
417417
calling foreign functions. Some foreign functions, most notably the Windows API, use other calling
418-
conventions. Rust provides a way to tell the compiler which convention to use:
418+
conventions. Rust provides the `abi` attribute as a way to hint to the compiler which calling
419+
convention to use:
419420

420421
~~~~
421422
#[cfg(target_os = "win32")]
423+
#[abi = "stdcall"]
422424
#[link_name = "kernel32"]
423-
extern "stdcall" {
425+
extern {
424426
fn SetEnvironmentVariableA(n: *u8, v: *u8) -> int;
425427
}
426428
~~~~
427429

428-
This applies to the entire `extern` block, and must be either `"cdecl"` or
429-
`"stdcall"`. The compiler may eventually support other calling conventions.
430+
The `abi` attribute applies to a foreign module (it cannot be applied to a single function within a
431+
module), and must be either `"cdecl"` or `"stdcall"`. The compiler may eventually support other
432+
calling conventions.
430433

431434
# Interoperability with foreign code
432435

branches/try/src/libextra/time.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ static NSEC_PER_SEC: i32 = 1_000_000_000_i32;
1919
pub mod rustrt {
2020
use super::Tm;
2121

22+
#[abi = "cdecl"]
2223
extern {
2324
pub fn get_time(sec: &mut i64, nsec: &mut i32);
2425
pub fn precise_time_ns(ns: &mut u64);

branches/try/src/libextra/unicode.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ pub mod icu {
162162

163163
// #[link_name = "icuuc"]
164164
#[link_args = "-licuuc"]
165+
#[abi = "cdecl"]
165166
extern {
166167
pub fn u_hasBinaryProperty(c: UChar32, which: UProperty) -> UBool;
167168
pub fn u_isdigit(c: UChar32) -> UBool;

branches/try/src/librustc/lib/llvm.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ pub mod llvm {
300300

301301
#[link_args = "-Lrustllvm -lrustllvm"]
302302
#[link_name = "rustllvm"]
303+
#[abi = "cdecl"]
303304
extern {
304305
/* Create and destroy contexts. */
305306
pub fn LLVMContextCreate() -> ContextRef;

branches/try/src/libstd/io.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ pub type fd_t = c_int;
7676
pub mod rustrt {
7777
use libc;
7878

79+
#[abi = "cdecl"]
7980
#[link_name = "rustrt"]
8081
extern {
8182
pub fn rust_get_stdin() -> *libc::FILE;

branches/try/src/libstd/libc.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2663,6 +2663,7 @@ pub mod funcs {
26632663

26642664
pub mod c95 {
26652665
#[nolink]
2666+
#[abi = "cdecl"]
26662667
pub mod ctype {
26672668
use libc::types::os::arch::c95::{c_char, c_int};
26682669

@@ -2684,6 +2685,7 @@ pub mod funcs {
26842685
}
26852686

26862687
#[nolink]
2688+
#[abi = "cdecl"]
26872689
pub mod stdio {
26882690
use libc::types::common::c95::{FILE, c_void, fpos_t};
26892691
use libc::types::os::arch::c95::{c_char, c_int, c_long, size_t};
@@ -2740,6 +2742,7 @@ pub mod funcs {
27402742
}
27412743

27422744
#[nolink]
2745+
#[abi = "cdecl"]
27432746
pub mod stdlib {
27442747
use libc::types::common::c95::c_void;
27452748
use libc::types::os::arch::c95::{c_char, c_double, c_int};
@@ -2773,6 +2776,7 @@ pub mod funcs {
27732776
}
27742777

27752778
#[nolink]
2779+
#[abi = "cdecl"]
27762780
pub mod string {
27772781
use libc::types::common::c95::c_void;
27782782
use libc::types::os::arch::c95::{c_char, c_int, size_t};
@@ -2822,6 +2826,7 @@ pub mod funcs {
28222826
#[cfg(target_os = "win32")]
28232827
pub mod posix88 {
28242828
#[nolink]
2829+
#[abi = "cdecl"]
28252830
pub mod stat_ {
28262831
use libc::types::os::common::posix01::stat;
28272832
use libc::types::os::arch::c95::{c_int, c_char};
@@ -2839,6 +2844,7 @@ pub mod funcs {
28392844
}
28402845

28412846
#[nolink]
2847+
#[abi = "cdecl"]
28422848
pub mod stdio {
28432849
use libc::types::common::c95::FILE;
28442850
use libc::types::os::arch::c95::{c_int, c_char};
@@ -2856,6 +2862,7 @@ pub mod funcs {
28562862
}
28572863

28582864
#[nolink]
2865+
#[abi = "cdecl"]
28592866
pub mod fcntl {
28602867
use libc::types::os::arch::c95::{c_int, c_char};
28612868
extern {
@@ -2868,11 +2875,13 @@ pub mod funcs {
28682875
}
28692876

28702877
#[nolink]
2878+
#[abi = "cdecl"]
28712879
pub mod dirent {
28722880
// Not supplied at all.
28732881
}
28742882

28752883
#[nolink]
2884+
#[abi = "cdecl"]
28762885
pub mod unistd {
28772886
use libc::types::common::c95::c_void;
28782887
use libc::types::os::arch::c95::{c_int, c_uint, c_char,
@@ -2940,6 +2949,7 @@ pub mod funcs {
29402949
use libc::types::os::arch::posix88::mode_t;
29412950

29422951
#[nolink]
2952+
#[abi = "cdecl"]
29432953
extern {
29442954
pub fn chmod(path: *c_char, mode: mode_t) -> c_int;
29452955
pub fn fchmod(fd: c_int, mode: mode_t) -> c_int;
@@ -2968,6 +2978,7 @@ pub mod funcs {
29682978
}
29692979

29702980
#[nolink]
2981+
#[abi = "cdecl"]
29712982
pub mod stdio {
29722983
use libc::types::common::c95::FILE;
29732984
use libc::types::os::arch::c95::{c_char, c_int};
@@ -2981,6 +2992,7 @@ pub mod funcs {
29812992
}
29822993

29832994
#[nolink]
2995+
#[abi = "cdecl"]
29842996
pub mod fcntl {
29852997
use libc::types::os::arch::c95::{c_char, c_int};
29862998
use libc::types::os::arch::posix88::mode_t;
@@ -2994,6 +3006,7 @@ pub mod funcs {
29943006
}
29953007

29963008
#[nolink]
3009+
#[abi = "cdecl"]
29973010
pub mod dirent {
29983011
use libc::types::common::posix88::{DIR, dirent_t};
29993012
use libc::types::os::arch::c95::{c_char, c_int, c_long};
@@ -3027,6 +3040,7 @@ pub mod funcs {
30273040
}
30283041

30293042
#[nolink]
3043+
#[abi = "cdecl"]
30303044
pub mod unistd {
30313045
use libc::types::common::c95::c_void;
30323046
use libc::types::os::arch::c95::{c_char, c_int, c_long, c_uint};
@@ -3086,6 +3100,7 @@ pub mod funcs {
30863100
}
30873101

30883102
#[nolink]
3103+
#[abi = "cdecl"]
30893104
pub mod signal {
30903105
use libc::types::os::arch::c95::{c_int};
30913106
use libc::types::os::arch::posix88::{pid_t};
@@ -3096,6 +3111,7 @@ pub mod funcs {
30963111
}
30973112

30983113
#[nolink]
3114+
#[abi = "cdecl"]
30993115
pub mod mman {
31003116
use libc::types::common::c95::{c_void};
31013117
use libc::types::os::arch::c95::{size_t, c_int, c_char};
@@ -3134,6 +3150,7 @@ pub mod funcs {
31343150
#[cfg(target_os = "freebsd")]
31353151
pub mod posix01 {
31363152
#[nolink]
3153+
#[abi = "cdecl"]
31373154
pub mod stat_ {
31383155
use libc::types::os::arch::c95::{c_char, c_int};
31393156
use libc::types::os::arch::posix01::stat;
@@ -3151,6 +3168,7 @@ pub mod funcs {
31513168
}
31523169

31533170
#[nolink]
3171+
#[abi = "cdecl"]
31543172
pub mod unistd {
31553173
use libc::types::os::arch::c95::{c_char, c_int, size_t};
31563174
use libc::types::os::arch::posix88::{ssize_t};
@@ -3177,6 +3195,7 @@ pub mod funcs {
31773195
}
31783196

31793197
#[nolink]
3198+
#[abi = "cdecl"]
31803199
pub mod wait {
31813200
use libc::types::os::arch::c95::{c_int};
31823201
use libc::types::os::arch::posix88::{pid_t};
@@ -3188,6 +3207,7 @@ pub mod funcs {
31883207
}
31893208

31903209
#[nolink]
3210+
#[abi = "cdecl"]
31913211
pub mod glob {
31923212
use libc::types::os::arch::c95::{c_char, c_int};
31933213
use libc::types::os::common::posix01::{glob_t};
@@ -3203,6 +3223,7 @@ pub mod funcs {
32033223
}
32043224

32053225
#[nolink]
3226+
#[abi = "cdecl"]
32063227
pub mod mman {
32073228
use libc::types::common::c95::{c_void};
32083229
use libc::types::os::arch::c95::{c_int, size_t};
@@ -3250,6 +3271,7 @@ pub mod funcs {
32503271
use libc::types::os::arch::c95::{c_char, c_uchar, c_int, c_uint,
32513272
size_t};
32523273

3274+
#[abi = "cdecl"]
32533275
extern {
32543276
pub fn sysctl(name: *c_int,
32553277
namelen: c_uint,
@@ -3283,6 +3305,7 @@ pub mod funcs {
32833305
use libc::types::common::c95::{c_void};
32843306
use libc::types::os::arch::c95::{c_uchar, c_int, size_t};
32853307

3308+
#[abi = "cdecl"]
32863309
extern {
32873310
pub fn getdtablesize() -> c_int;
32883311
pub fn madvise(addr: *c_void, len: size_t, advice: c_int)
@@ -3302,6 +3325,7 @@ pub mod funcs {
33023325
pub mod extra {
33033326
use libc::types::os::arch::c95::{c_char, c_int};
33043327

3328+
#[abi = "cdecl"]
33053329
extern {
33063330
pub fn _NSGetExecutablePath(buf: *mut c_char, bufsize: *mut u32)
33073331
-> c_int;
@@ -3334,6 +3358,7 @@ pub mod funcs {
33343358
use libc::types::os::arch::extra::{HANDLE, LPHANDLE};
33353359

33363360
#[cfg(target_arch = "x86")]
3361+
#[abi = "stdcall"]
33373362
extern "stdcall" {
33383363
pub fn GetEnvironmentVariableW(n: LPCWSTR,
33393364
v: LPWSTR,
@@ -3547,6 +3572,7 @@ pub mod funcs {
35473572
pub mod msvcrt {
35483573
use libc::types::os::arch::c95::{c_int, c_long};
35493574

3575+
#[abi = "cdecl"]
35503576
#[nolink]
35513577
extern {
35523578
#[link_name = "_commit"]

branches/try/src/libstd/num/cmath.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ pub mod c_double_utils {
1818
use libc::{c_double, c_int};
1919

2020
#[link_name = "m"]
21+
#[abi = "cdecl"]
2122
extern {
2223
// Alpabetically sorted by link_name
2324

@@ -106,6 +107,7 @@ pub mod c_float_utils {
106107
use libc::{c_float, c_int};
107108

108109
#[link_name = "m"]
110+
#[abi = "cdecl"]
109111
extern {
110112
// Alpabetically sorted by link_name
111113

branches/try/src/libstd/os.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,6 +1039,7 @@ pub fn errno() -> uint {
10391039

10401040
#[cfg(target_arch = "x86")]
10411041
#[link_name = "kernel32"]
1042+
#[abi = "stdcall"]
10421043
extern "stdcall" {
10431044
fn GetLastError() -> DWORD;
10441045
}
@@ -1117,6 +1118,7 @@ pub fn last_os_error() -> ~str {
11171118

11181119
#[cfg(target_arch = "x86")]
11191120
#[link_name = "kernel32"]
1121+
#[abi = "stdcall"]
11201122
extern "stdcall" {
11211123
fn FormatMessageW(flags: DWORD,
11221124
lpSrc: LPVOID,

branches/try/src/libstd/rt/thread_local_storage.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ pub unsafe fn get(key: Key) -> *mut c_void {
8484
}
8585

8686
#[cfg(windows, target_arch = "x86")]
87+
#[abi = "stdcall"]
8788
extern "stdcall" {
8889
fn TlsAlloc() -> DWORD;
8990
fn TlsSetValue(dwTlsIndex: DWORD, lpTlsvalue: LPVOID) -> BOOL;

branches/try/src/libstd/unstable/intrinsics.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ pub trait TyVisitor {
170170
fn visit_closure_ptr(&mut self, ck: uint) -> bool;
171171
}
172172

173+
#[abi = "rust-intrinsic"]
173174
extern "rust-intrinsic" {
174175

175176
/// Atomic compare and exchange, sequentially consistent.

0 commit comments

Comments
 (0)