You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/abi.md
+7-4
Original file line number
Diff line number
Diff line change
@@ -16,7 +16,7 @@ Two types `T` and `U` are *abi compatible* if:
16
16
* There exists a type `V`, such that `T` is *abi compatible* with `V` an `V` is *abi compatible* with `U`,
17
17
18
18
> [!NOTE]
19
-
> These properties ensure that *abi compatibility* is an equivalence relation.
19
+
> These properties are respectively called "reflexivity", "symmetry", and "transitivity". They ensure that *abi compatibility* is an equivalence relation.
20
20
21
21
r[abi.compatibility.integer]
22
22
Two [integer types] are *abi compatible* if they have the same size and the same signedness
@@ -69,13 +69,13 @@ Two [pointer types], `*mut T` and `*const U`, are *abi compatible* if the *metad
69
69
> With transitivity, this applies regardless of the mutability of either pointer type
70
70
71
71
```rust
72
-
unsafefnfoo(x:*muti32){
72
+
unsafefnfoo(x:*mutu32){
73
73
unsafe{x.write(5);}
74
74
}
75
75
76
76
fnmain(){
77
77
letf:unsafefn(*mut ()) =unsafe{core::mem::transmute(fooasunsafefn(_))}; // Type Erase the function
78
-
letmutval=0;
78
+
letmutval:u32=0;
79
79
letptr=core::ptr::addr_of_mut!(val).cast::<()>(); // Get Opaque Userdata from somewhere
80
80
unsafe{f(ptr);}
81
81
assert_eq!(val, 5);
@@ -116,13 +116,16 @@ If `T` is a type listed in [layout.enum.option](https://doc.rust-lang.org/stable
116
116
117
117
118
118
r[abi.compatibility.fn-ptr]
119
-
An [`fn`-ptr type]`T` is compatible with an [`fn`-ptr type]`U` if `T` and `U` have *abi compatible* tags.
119
+
An [`fn`-ptr type]`T` is *abi compatible* with an [`fn`-ptr type]`U` if `T` and `U` have *abi compatible* tags.
120
120
121
121
r[abi.compatibility.extern-tag]
122
122
Two [abi tags][abi tag] are *abi compatible* if:
123
123
* They are the same string, or
124
124
* One tag is `"X"`, and the other is `"X-unwind"`
125
125
126
+
> [!NOTE]
127
+
> e.g. `extern "C"` and `extern "C-unwind"` are compatible with each other.
128
+
126
129
r[abi.compatibility.signature]
127
130
Two function signatures are compatible if:
128
131
* The [abi tags][abi tag] of both signatures are *abi compatible*,
0 commit comments