]> git.lizzy.rs Git - rust.git/blob - library/core/src/intrinsics.rs
Fix font color for help button in ayu and dark themes
[rust.git] / library / core / src / intrinsics.rs
1 //! Compiler intrinsics.
2 //!
3 //! The corresponding definitions are in `librustc_codegen_llvm/intrinsic.rs`.
4 //! The corresponding const implementations are in `librustc_mir/interpret/intrinsics.rs`
5 //!
6 //! # Const intrinsics
7 //!
8 //! Note: any changes to the constness of intrinsics should be discussed with the language team.
9 //! This includes changes in the stability of the constness.
10 //!
11 //! In order to make an intrinsic usable at compile-time, one needs to copy the implementation
12 //! from https://github.com/rust-lang/miri/blob/master/src/shims/intrinsics.rs to
13 //! `librustc_mir/interpret/intrinsics.rs` and add a
14 //! `#[rustc_const_unstable(feature = "foo", issue = "01234")]` to the intrinsic.
15 //!
16 //! If an intrinsic is supposed to be used from a `const fn` with a `rustc_const_stable` attribute,
17 //! the intrinsic's attribute must be `rustc_const_stable`, too. Such a change should not be done
18 //! without T-lang consultation, because it bakes a feature into the language that cannot be
19 //! replicated in user code without compiler support.
20 //!
21 //! # Volatiles
22 //!
23 //! The volatile intrinsics provide operations intended to act on I/O
24 //! memory, which are guaranteed to not be reordered by the compiler
25 //! across other volatile intrinsics. See the LLVM documentation on
26 //! [[volatile]].
27 //!
28 //! [volatile]: http://llvm.org/docs/LangRef.html#volatile-memory-accesses
29 //!
30 //! # Atomics
31 //!
32 //! The atomic intrinsics provide common atomic operations on machine
33 //! words, with multiple possible memory orderings. They obey the same
34 //! semantics as C++11. See the LLVM documentation on [[atomics]].
35 //!
36 //! [atomics]: http://llvm.org/docs/Atomics.html
37 //!
38 //! A quick refresher on memory ordering:
39 //!
40 //! * Acquire - a barrier for acquiring a lock. Subsequent reads and writes
41 //!   take place after the barrier.
42 //! * Release - a barrier for releasing a lock. Preceding reads and writes
43 //!   take place before the barrier.
44 //! * Sequentially consistent - sequentially consistent operations are
45 //!   guaranteed to happen in order. This is the standard mode for working
46 //!   with atomic types and is equivalent to Java's `volatile`.
47
48 #![unstable(
49     feature = "core_intrinsics",
50     reason = "intrinsics are unlikely to ever be stabilized, instead \
51                       they should be used through stabilized interfaces \
52                       in the rest of the standard library",
53     issue = "none"
54 )]
55 #![allow(missing_docs)]
56
57 use crate::marker::DiscriminantKind;
58 use crate::mem;
59
60 #[stable(feature = "drop_in_place", since = "1.8.0")]
61 #[rustc_deprecated(
62     reason = "no longer an intrinsic - use `ptr::drop_in_place` directly",
63     since = "1.18.0"
64 )]
65 pub use crate::ptr::drop_in_place;
66
67 extern "rust-intrinsic" {
68     // N.B., these intrinsics take raw pointers because they mutate aliased
69     // memory, which is not valid for either `&` or `&mut`.
70
71     /// Stores a value if the current value is the same as the `old` value.
72     ///
73     /// The stabilized version of this intrinsic is available on the
74     /// `std::sync::atomic` types via the `compare_exchange` method by passing
75     /// [`Ordering::SeqCst`](../../std/sync/atomic/enum.Ordering.html)
76     /// as both the `success` and `failure` parameters. For example,
77     /// [`AtomicBool::compare_exchange`][compare_exchange].
78     ///
79     /// [compare_exchange]: ../../std/sync/atomic/struct.AtomicBool.html#method.compare_exchange
80     pub fn atomic_cxchg<T: Copy>(dst: *mut T, old: T, src: T) -> (T, bool);
81     /// Stores a value if the current value is the same as the `old` value.
82     ///
83     /// The stabilized version of this intrinsic is available on the
84     /// `std::sync::atomic` types via the `compare_exchange` method by passing
85     /// [`Ordering::Acquire`](../../std/sync/atomic/enum.Ordering.html)
86     /// as both the `success` and `failure` parameters. For example,
87     /// [`AtomicBool::compare_exchange`][compare_exchange].
88     ///
89     /// [compare_exchange]: ../../std/sync/atomic/struct.AtomicBool.html#method.compare_exchange
90     pub fn atomic_cxchg_acq<T: Copy>(dst: *mut T, old: T, src: T) -> (T, bool);
91     /// Stores a value if the current value is the same as the `old` value.
92     ///
93     /// The stabilized version of this intrinsic is available on the
94     /// `std::sync::atomic` types via the `compare_exchange` method by passing
95     /// [`Ordering::Release`](../../std/sync/atomic/enum.Ordering.html)
96     /// as the `success` and
97     /// [`Ordering::Relaxed`](../../std/sync/atomic/enum.Ordering.html)
98     /// as the `failure` parameters. For example,
99     /// [`AtomicBool::compare_exchange`][compare_exchange].
100     ///
101     /// [compare_exchange]: ../../std/sync/atomic/struct.AtomicBool.html#method.compare_exchange
102     pub fn atomic_cxchg_rel<T: Copy>(dst: *mut T, old: T, src: T) -> (T, bool);
103     /// Stores a value if the current value is the same as the `old` value.
104     ///
105     /// The stabilized version of this intrinsic is available on the
106     /// `std::sync::atomic` types via the `compare_exchange` method by passing
107     /// [`Ordering::AcqRel`](../../std/sync/atomic/enum.Ordering.html)
108     /// as the `success` and
109     /// [`Ordering::Acquire`](../../std/sync/atomic/enum.Ordering.html)
110     /// as the `failure` parameters. For example,
111     /// [`AtomicBool::compare_exchange`][compare_exchange].
112     ///
113     /// [compare_exchange]: ../../std/sync/atomic/struct.AtomicBool.html#method.compare_exchange
114     pub fn atomic_cxchg_acqrel<T: Copy>(dst: *mut T, old: T, src: T) -> (T, bool);
115     /// Stores a value if the current value is the same as the `old` value.
116     ///
117     /// The stabilized version of this intrinsic is available on the
118     /// `std::sync::atomic` types via the `compare_exchange` method by passing
119     /// [`Ordering::Relaxed`](../../std/sync/atomic/enum.Ordering.html)
120     /// as both the `success` and `failure` parameters. For example,
121     /// [`AtomicBool::compare_exchange`][compare_exchange].
122     ///
123     /// [compare_exchange]: ../../std/sync/atomic/struct.AtomicBool.html#method.compare_exchange
124     pub fn atomic_cxchg_relaxed<T: Copy>(dst: *mut T, old: T, src: T) -> (T, bool);
125     /// Stores a value if the current value is the same as the `old` value.
126     ///
127     /// The stabilized version of this intrinsic is available on the
128     /// `std::sync::atomic` types via the `compare_exchange` method by passing
129     /// [`Ordering::SeqCst`](../../std/sync/atomic/enum.Ordering.html)
130     /// as the `success` and
131     /// [`Ordering::Relaxed`](../../std/sync/atomic/enum.Ordering.html)
132     /// as the `failure` parameters. For example,
133     /// [`AtomicBool::compare_exchange`][compare_exchange].
134     ///
135     /// [compare_exchange]: ../../std/sync/atomic/struct.AtomicBool.html#method.compare_exchange
136     pub fn atomic_cxchg_failrelaxed<T: Copy>(dst: *mut T, old: T, src: T) -> (T, bool);
137     /// Stores a value if the current value is the same as the `old` value.
138     ///
139     /// The stabilized version of this intrinsic is available on the
140     /// `std::sync::atomic` types via the `compare_exchange` method by passing
141     /// [`Ordering::SeqCst`](../../std/sync/atomic/enum.Ordering.html)
142     /// as the `success` and
143     /// [`Ordering::Acquire`](../../std/sync/atomic/enum.Ordering.html)
144     /// as the `failure` parameters. For example,
145     /// [`AtomicBool::compare_exchange`][compare_exchange].
146     ///
147     /// [compare_exchange]: ../../std/sync/atomic/struct.AtomicBool.html#method.compare_exchange
148     pub fn atomic_cxchg_failacq<T: Copy>(dst: *mut T, old: T, src: T) -> (T, bool);
149     /// Stores a value if the current value is the same as the `old` value.
150     ///
151     /// The stabilized version of this intrinsic is available on the
152     /// `std::sync::atomic` types via the `compare_exchange` method by passing
153     /// [`Ordering::Acquire`](../../std/sync/atomic/enum.Ordering.html)
154     /// as the `success` and
155     /// [`Ordering::Relaxed`](../../std/sync/atomic/enum.Ordering.html)
156     /// as the `failure` parameters. For example,
157     /// [`AtomicBool::compare_exchange`][compare_exchange].
158     ///
159     /// [compare_exchange]: ../../std/sync/atomic/struct.AtomicBool.html#method.compare_exchange
160     pub fn atomic_cxchg_acq_failrelaxed<T: Copy>(dst: *mut T, old: T, src: T) -> (T, bool);
161     /// Stores a value if the current value is the same as the `old` value.
162     ///
163     /// The stabilized version of this intrinsic is available on the
164     /// `std::sync::atomic` types via the `compare_exchange` method by passing
165     /// [`Ordering::AcqRel`](../../std/sync/atomic/enum.Ordering.html)
166     /// as the `success` and
167     /// [`Ordering::Relaxed`](../../std/sync/atomic/enum.Ordering.html)
168     /// as the `failure` parameters. For example,
169     /// [`AtomicBool::compare_exchange`][compare_exchange].
170     ///
171     /// [compare_exchange]: ../../std/sync/atomic/struct.AtomicBool.html#method.compare_exchange
172     pub fn atomic_cxchg_acqrel_failrelaxed<T: Copy>(dst: *mut T, old: T, src: T) -> (T, bool);
173
174     /// Stores a value if the current value is the same as the `old` value.
175     ///
176     /// The stabilized version of this intrinsic is available on the
177     /// `std::sync::atomic` types via the `compare_exchange_weak` method by passing
178     /// [`Ordering::SeqCst`](../../std/sync/atomic/enum.Ordering.html)
179     /// as both the `success` and `failure` parameters. For example,
180     /// [`AtomicBool::compare_exchange_weak`][cew].
181     ///
182     /// [cew]: ../../std/sync/atomic/struct.AtomicBool.html#method.compare_exchange_weak
183     pub fn atomic_cxchgweak<T: Copy>(dst: *mut T, old: T, src: T) -> (T, bool);
184     /// Stores a value if the current value is the same as the `old` value.
185     ///
186     /// The stabilized version of this intrinsic is available on the
187     /// `std::sync::atomic` types via the `compare_exchange_weak` method by passing
188     /// [`Ordering::Acquire`](../../std/sync/atomic/enum.Ordering.html)
189     /// as both the `success` and `failure` parameters. For example,
190     /// [`AtomicBool::compare_exchange_weak`][cew].
191     ///
192     /// [cew]: ../../std/sync/atomic/struct.AtomicBool.html#method.compare_exchange_weak
193     pub fn atomic_cxchgweak_acq<T: Copy>(dst: *mut T, old: T, src: T) -> (T, bool);
194     /// Stores a value if the current value is the same as the `old` value.
195     ///
196     /// The stabilized version of this intrinsic is available on the
197     /// `std::sync::atomic` types via the `compare_exchange_weak` method by passing
198     /// [`Ordering::Release`](../../std/sync/atomic/enum.Ordering.html)
199     /// as the `success` and
200     /// [`Ordering::Relaxed`](../../std/sync/atomic/enum.Ordering.html)
201     /// as the `failure` parameters. For example,
202     /// [`AtomicBool::compare_exchange_weak`][cew].
203     ///
204     /// [cew]: ../../std/sync/atomic/struct.AtomicBool.html#method.compare_exchange_weak
205     pub fn atomic_cxchgweak_rel<T: Copy>(dst: *mut T, old: T, src: T) -> (T, bool);
206     /// Stores a value if the current value is the same as the `old` value.
207     ///
208     /// The stabilized version of this intrinsic is available on the
209     /// `std::sync::atomic` types via the `compare_exchange_weak` method by passing
210     /// [`Ordering::AcqRel`](../../std/sync/atomic/enum.Ordering.html)
211     /// as the `success` and
212     /// [`Ordering::Acquire`](../../std/sync/atomic/enum.Ordering.html)
213     /// as the `failure` parameters. For example,
214     /// [`AtomicBool::compare_exchange_weak`][cew].
215     ///
216     /// [cew]: ../../std/sync/atomic/struct.AtomicBool.html#method.compare_exchange_weak
217     pub fn atomic_cxchgweak_acqrel<T: Copy>(dst: *mut T, old: T, src: T) -> (T, bool);
218     /// Stores a value if the current value is the same as the `old` value.
219     ///
220     /// The stabilized version of this intrinsic is available on the
221     /// `std::sync::atomic` types via the `compare_exchange_weak` method by passing
222     /// [`Ordering::Relaxed`](../../std/sync/atomic/enum.Ordering.html)
223     /// as both the `success` and `failure` parameters. For example,
224     /// [`AtomicBool::compare_exchange_weak`][cew].
225     ///
226     /// [cew]: ../../std/sync/atomic/struct.AtomicBool.html#method.compare_exchange_weak
227     pub fn atomic_cxchgweak_relaxed<T: Copy>(dst: *mut T, old: T, src: T) -> (T, bool);
228     /// Stores a value if the current value is the same as the `old` value.
229     ///
230     /// The stabilized version of this intrinsic is available on the
231     /// `std::sync::atomic` types via the `compare_exchange_weak` method by passing
232     /// [`Ordering::SeqCst`](../../std/sync/atomic/enum.Ordering.html)
233     /// as the `success` and
234     /// [`Ordering::Relaxed`](../../std/sync/atomic/enum.Ordering.html)
235     /// as the `failure` parameters. For example,
236     /// [`AtomicBool::compare_exchange_weak`][cew].
237     ///
238     /// [cew]: ../../std/sync/atomic/struct.AtomicBool.html#method.compare_exchange_weak
239     pub fn atomic_cxchgweak_failrelaxed<T: Copy>(dst: *mut T, old: T, src: T) -> (T, bool);
240     /// Stores a value if the current value is the same as the `old` value.
241     ///
242     /// The stabilized version of this intrinsic is available on the
243     /// `std::sync::atomic` types via the `compare_exchange_weak` method by passing
244     /// [`Ordering::SeqCst`](../../std/sync/atomic/enum.Ordering.html)
245     /// as the `success` and
246     /// [`Ordering::Acquire`](../../std/sync/atomic/enum.Ordering.html)
247     /// as the `failure` parameters. For example,
248     /// [`AtomicBool::compare_exchange_weak`][cew].
249     ///
250     /// [cew]: ../../std/sync/atomic/struct.AtomicBool.html#method.compare_exchange_weak
251     pub fn atomic_cxchgweak_failacq<T: Copy>(dst: *mut T, old: T, src: T) -> (T, bool);
252     /// Stores a value if the current value is the same as the `old` value.
253     ///
254     /// The stabilized version of this intrinsic is available on the
255     /// `std::sync::atomic` types via the `compare_exchange_weak` method by passing
256     /// [`Ordering::Acquire`](../../std/sync/atomic/enum.Ordering.html)
257     /// as the `success` and
258     /// [`Ordering::Relaxed`](../../std/sync/atomic/enum.Ordering.html)
259     /// as the `failure` parameters. For example,
260     /// [`AtomicBool::compare_exchange_weak`][cew].
261     ///
262     /// [cew]: ../../std/sync/atomic/struct.AtomicBool.html#method.compare_exchange_weak
263     pub fn atomic_cxchgweak_acq_failrelaxed<T: Copy>(dst: *mut T, old: T, src: T) -> (T, bool);
264     /// Stores a value if the current value is the same as the `old` value.
265     ///
266     /// The stabilized version of this intrinsic is available on the
267     /// `std::sync::atomic` types via the `compare_exchange_weak` method by passing
268     /// [`Ordering::AcqRel`](../../std/sync/atomic/enum.Ordering.html)
269     /// as the `success` and
270     /// [`Ordering::Relaxed`](../../std/sync/atomic/enum.Ordering.html)
271     /// as the `failure` parameters. For example,
272     /// [`AtomicBool::compare_exchange_weak`][cew].
273     ///
274     /// [cew]: ../../std/sync/atomic/struct.AtomicBool.html#method.compare_exchange_weak
275     pub fn atomic_cxchgweak_acqrel_failrelaxed<T: Copy>(dst: *mut T, old: T, src: T) -> (T, bool);
276
277     /// Loads the current value of the pointer.
278     ///
279     /// The stabilized version of this intrinsic is available on the
280     /// `std::sync::atomic` types via the `load` method by passing
281     /// [`Ordering::SeqCst`](../../std/sync/atomic/enum.Ordering.html)
282     /// as the `order`. For example,
283     /// [`AtomicBool::load`](../../std/sync/atomic/struct.AtomicBool.html#method.load).
284     pub fn atomic_load<T: Copy>(src: *const T) -> T;
285     /// Loads the current value of the pointer.
286     ///
287     /// The stabilized version of this intrinsic is available on the
288     /// `std::sync::atomic` types via the `load` method by passing
289     /// [`Ordering::Acquire`](../../std/sync/atomic/enum.Ordering.html)
290     /// as the `order`. For example,
291     /// [`AtomicBool::load`](../../std/sync/atomic/struct.AtomicBool.html#method.load).
292     pub fn atomic_load_acq<T: Copy>(src: *const T) -> T;
293     /// Loads the current value of the pointer.
294     ///
295     /// The stabilized version of this intrinsic is available on the
296     /// `std::sync::atomic` types via the `load` method by passing
297     /// [`Ordering::Relaxed`](../../std/sync/atomic/enum.Ordering.html)
298     /// as the `order`. For example,
299     /// [`AtomicBool::load`](../../std/sync/atomic/struct.AtomicBool.html#method.load).
300     pub fn atomic_load_relaxed<T: Copy>(src: *const T) -> T;
301     pub fn atomic_load_unordered<T: Copy>(src: *const T) -> T;
302
303     /// Stores the value at the specified memory location.
304     ///
305     /// The stabilized version of this intrinsic is available on the
306     /// `std::sync::atomic` types via the `store` method by passing
307     /// [`Ordering::SeqCst`](../../std/sync/atomic/enum.Ordering.html)
308     /// as the `order`. For example,
309     /// [`AtomicBool::store`](../../std/sync/atomic/struct.AtomicBool.html#method.store).
310     pub fn atomic_store<T: Copy>(dst: *mut T, val: T);
311     /// Stores the value at the specified memory location.
312     ///
313     /// The stabilized version of this intrinsic is available on the
314     /// `std::sync::atomic` types via the `store` method by passing
315     /// [`Ordering::Release`](../../std/sync/atomic/enum.Ordering.html)
316     /// as the `order`. For example,
317     /// [`AtomicBool::store`](../../std/sync/atomic/struct.AtomicBool.html#method.store).
318     pub fn atomic_store_rel<T: Copy>(dst: *mut T, val: T);
319     /// Stores the value at the specified memory location.
320     ///
321     /// The stabilized version of this intrinsic is available on the
322     /// `std::sync::atomic` types via the `store` method by passing
323     /// [`Ordering::Relaxed`](../../std/sync/atomic/enum.Ordering.html)
324     /// as the `order`. For example,
325     /// [`AtomicBool::store`](../../std/sync/atomic/struct.AtomicBool.html#method.store).
326     pub fn atomic_store_relaxed<T: Copy>(dst: *mut T, val: T);
327     pub fn atomic_store_unordered<T: Copy>(dst: *mut T, val: T);
328
329     /// Stores the value at the specified memory location, returning the old value.
330     ///
331     /// The stabilized version of this intrinsic is available on the
332     /// `std::sync::atomic` types via the `swap` method by passing
333     /// [`Ordering::SeqCst`](../../std/sync/atomic/enum.Ordering.html)
334     /// as the `order`. For example,
335     /// [`AtomicBool::swap`](../../std/sync/atomic/struct.AtomicBool.html#method.swap).
336     pub fn atomic_xchg<T: Copy>(dst: *mut T, src: T) -> T;
337     /// Stores the value at the specified memory location, returning the old value.
338     ///
339     /// The stabilized version of this intrinsic is available on the
340     /// `std::sync::atomic` types via the `swap` method by passing
341     /// [`Ordering::Acquire`](../../std/sync/atomic/enum.Ordering.html)
342     /// as the `order`. For example,
343     /// [`AtomicBool::swap`](../../std/sync/atomic/struct.AtomicBool.html#method.swap).
344     pub fn atomic_xchg_acq<T: Copy>(dst: *mut T, src: T) -> T;
345     /// Stores the value at the specified memory location, returning the old value.
346     ///
347     /// The stabilized version of this intrinsic is available on the
348     /// `std::sync::atomic` types via the `swap` method by passing
349     /// [`Ordering::Release`](../../std/sync/atomic/enum.Ordering.html)
350     /// as the `order`. For example,
351     /// [`AtomicBool::swap`](../../std/sync/atomic/struct.AtomicBool.html#method.swap).
352     pub fn atomic_xchg_rel<T: Copy>(dst: *mut T, src: T) -> T;
353     /// Stores the value at the specified memory location, returning the old value.
354     ///
355     /// The stabilized version of this intrinsic is available on the
356     /// `std::sync::atomic` types via the `swap` method by passing
357     /// [`Ordering::AcqRel`](../../std/sync/atomic/enum.Ordering.html)
358     /// as the `order`. For example,
359     /// [`AtomicBool::swap`](../../std/sync/atomic/struct.AtomicBool.html#method.swap).
360     pub fn atomic_xchg_acqrel<T: Copy>(dst: *mut T, src: T) -> T;
361     /// Stores the value at the specified memory location, returning the old value.
362     ///
363     /// The stabilized version of this intrinsic is available on the
364     /// `std::sync::atomic` types via the `swap` method by passing
365     /// [`Ordering::Relaxed`](../../std/sync/atomic/enum.Ordering.html)
366     /// as the `order`. For example,
367     /// [`AtomicBool::swap`](../../std/sync/atomic/struct.AtomicBool.html#method.swap).
368     pub fn atomic_xchg_relaxed<T: Copy>(dst: *mut T, src: T) -> T;
369
370     /// Adds to the current value, returning the previous value.
371     ///
372     /// The stabilized version of this intrinsic is available on the
373     /// `std::sync::atomic` types via the `fetch_add` method by passing
374     /// [`Ordering::SeqCst`](../../std/sync/atomic/enum.Ordering.html)
375     /// as the `order`. For example,
376     /// [`AtomicIsize::fetch_add`](../../std/sync/atomic/struct.AtomicIsize.html#method.fetch_add).
377     pub fn atomic_xadd<T: Copy>(dst: *mut T, src: T) -> T;
378     /// Adds to the current value, returning the previous value.
379     ///
380     /// The stabilized version of this intrinsic is available on the
381     /// `std::sync::atomic` types via the `fetch_add` method by passing
382     /// [`Ordering::Acquire`](../../std/sync/atomic/enum.Ordering.html)
383     /// as the `order`. For example,
384     /// [`AtomicIsize::fetch_add`](../../std/sync/atomic/struct.AtomicIsize.html#method.fetch_add).
385     pub fn atomic_xadd_acq<T: Copy>(dst: *mut T, src: T) -> T;
386     /// Adds to the current value, returning the previous value.
387     ///
388     /// The stabilized version of this intrinsic is available on the
389     /// `std::sync::atomic` types via the `fetch_add` method by passing
390     /// [`Ordering::Release`](../../std/sync/atomic/enum.Ordering.html)
391     /// as the `order`. For example,
392     /// [`AtomicIsize::fetch_add`](../../std/sync/atomic/struct.AtomicIsize.html#method.fetch_add).
393     pub fn atomic_xadd_rel<T: Copy>(dst: *mut T, src: T) -> T;
394     /// Adds to the current value, returning the previous value.
395     ///
396     /// The stabilized version of this intrinsic is available on the
397     /// `std::sync::atomic` types via the `fetch_add` method by passing
398     /// [`Ordering::AcqRel`](../../std/sync/atomic/enum.Ordering.html)
399     /// as the `order`. For example,
400     /// [`AtomicIsize::fetch_add`](../../std/sync/atomic/struct.AtomicIsize.html#method.fetch_add).
401     pub fn atomic_xadd_acqrel<T: Copy>(dst: *mut T, src: T) -> T;
402     /// Adds to the current value, returning the previous value.
403     ///
404     /// The stabilized version of this intrinsic is available on the
405     /// `std::sync::atomic` types via the `fetch_add` method by passing
406     /// [`Ordering::Relaxed`](../../std/sync/atomic/enum.Ordering.html)
407     /// as the `order`. For example,
408     /// [`AtomicIsize::fetch_add`](../../std/sync/atomic/struct.AtomicIsize.html#method.fetch_add).
409     pub fn atomic_xadd_relaxed<T: Copy>(dst: *mut T, src: T) -> T;
410
411     /// Subtract from the current value, returning the previous value.
412     ///
413     /// The stabilized version of this intrinsic is available on the
414     /// `std::sync::atomic` types via the `fetch_sub` method by passing
415     /// [`Ordering::SeqCst`](../../std/sync/atomic/enum.Ordering.html)
416     /// as the `order`. For example,
417     /// [`AtomicIsize::fetch_sub`](../../std/sync/atomic/struct.AtomicIsize.html#method.fetch_sub).
418     pub fn atomic_xsub<T: Copy>(dst: *mut T, src: T) -> T;
419     /// Subtract from the current value, returning the previous value.
420     ///
421     /// The stabilized version of this intrinsic is available on the
422     /// `std::sync::atomic` types via the `fetch_sub` method by passing
423     /// [`Ordering::Acquire`](../../std/sync/atomic/enum.Ordering.html)
424     /// as the `order`. For example,
425     /// [`AtomicIsize::fetch_sub`](../../std/sync/atomic/struct.AtomicIsize.html#method.fetch_sub).
426     pub fn atomic_xsub_acq<T: Copy>(dst: *mut T, src: T) -> T;
427     /// Subtract from the current value, returning the previous value.
428     ///
429     /// The stabilized version of this intrinsic is available on the
430     /// `std::sync::atomic` types via the `fetch_sub` method by passing
431     /// [`Ordering::Release`](../../std/sync/atomic/enum.Ordering.html)
432     /// as the `order`. For example,
433     /// [`AtomicIsize::fetch_sub`](../../std/sync/atomic/struct.AtomicIsize.html#method.fetch_sub).
434     pub fn atomic_xsub_rel<T: Copy>(dst: *mut T, src: T) -> T;
435     /// Subtract from the current value, returning the previous value.
436     ///
437     /// The stabilized version of this intrinsic is available on the
438     /// `std::sync::atomic` types via the `fetch_sub` method by passing
439     /// [`Ordering::AcqRel`](../../std/sync/atomic/enum.Ordering.html)
440     /// as the `order`. For example,
441     /// [`AtomicIsize::fetch_sub`](../../std/sync/atomic/struct.AtomicIsize.html#method.fetch_sub).
442     pub fn atomic_xsub_acqrel<T: Copy>(dst: *mut T, src: T) -> T;
443     /// Subtract from the current value, returning the previous value.
444     ///
445     /// The stabilized version of this intrinsic is available on the
446     /// `std::sync::atomic` types via the `fetch_sub` method by passing
447     /// [`Ordering::Relaxed`](../../std/sync/atomic/enum.Ordering.html)
448     /// as the `order`. For example,
449     /// [`AtomicIsize::fetch_sub`](../../std/sync/atomic/struct.AtomicIsize.html#method.fetch_sub).
450     pub fn atomic_xsub_relaxed<T: Copy>(dst: *mut T, src: T) -> T;
451
452     /// Bitwise and with the current value, returning the previous value.
453     ///
454     /// The stabilized version of this intrinsic is available on the
455     /// `std::sync::atomic` types via the `fetch_and` method by passing
456     /// [`Ordering::SeqCst`](../../std/sync/atomic/enum.Ordering.html)
457     /// as the `order`. For example,
458     /// [`AtomicBool::fetch_and`](../../std/sync/atomic/struct.AtomicBool.html#method.fetch_and).
459     pub fn atomic_and<T: Copy>(dst: *mut T, src: T) -> T;
460     /// Bitwise and with the current value, returning the previous value.
461     ///
462     /// The stabilized version of this intrinsic is available on the
463     /// `std::sync::atomic` types via the `fetch_and` method by passing
464     /// [`Ordering::Acquire`](../../std/sync/atomic/enum.Ordering.html)
465     /// as the `order`. For example,
466     /// [`AtomicBool::fetch_and`](../../std/sync/atomic/struct.AtomicBool.html#method.fetch_and).
467     pub fn atomic_and_acq<T: Copy>(dst: *mut T, src: T) -> T;
468     /// Bitwise and with the current value, returning the previous value.
469     ///
470     /// The stabilized version of this intrinsic is available on the
471     /// `std::sync::atomic` types via the `fetch_and` method by passing
472     /// [`Ordering::Release`](../../std/sync/atomic/enum.Ordering.html)
473     /// as the `order`. For example,
474     /// [`AtomicBool::fetch_and`](../../std/sync/atomic/struct.AtomicBool.html#method.fetch_and).
475     pub fn atomic_and_rel<T: Copy>(dst: *mut T, src: T) -> T;
476     /// Bitwise and with the current value, returning the previous value.
477     ///
478     /// The stabilized version of this intrinsic is available on the
479     /// `std::sync::atomic` types via the `fetch_and` method by passing
480     /// [`Ordering::AcqRel`](../../std/sync/atomic/enum.Ordering.html)
481     /// as the `order`. For example,
482     /// [`AtomicBool::fetch_and`](../../std/sync/atomic/struct.AtomicBool.html#method.fetch_and).
483     pub fn atomic_and_acqrel<T: Copy>(dst: *mut T, src: T) -> T;
484     /// Bitwise and with the current value, returning the previous value.
485     ///
486     /// The stabilized version of this intrinsic is available on the
487     /// `std::sync::atomic` types via the `fetch_and` method by passing
488     /// [`Ordering::Relaxed`](../../std/sync/atomic/enum.Ordering.html)
489     /// as the `order`. For example,
490     /// [`AtomicBool::fetch_and`](../../std/sync/atomic/struct.AtomicBool.html#method.fetch_and).
491     pub fn atomic_and_relaxed<T: Copy>(dst: *mut T, src: T) -> T;
492
493     /// Bitwise nand with the current value, returning the previous value.
494     ///
495     /// The stabilized version of this intrinsic is available on the
496     /// `std::sync::atomic::AtomicBool` type via the `fetch_nand` method by passing
497     /// [`Ordering::SeqCst`](../../std/sync/atomic/enum.Ordering.html)
498     /// as the `order`. For example,
499     /// [`AtomicBool::fetch_nand`](../../std/sync/atomic/struct.AtomicBool.html#method.fetch_nand).
500     pub fn atomic_nand<T: Copy>(dst: *mut T, src: T) -> T;
501     /// Bitwise nand with the current value, returning the previous value.
502     ///
503     /// The stabilized version of this intrinsic is available on the
504     /// `std::sync::atomic::AtomicBool` type via the `fetch_nand` method by passing
505     /// [`Ordering::Acquire`](../../std/sync/atomic/enum.Ordering.html)
506     /// as the `order`. For example,
507     /// [`AtomicBool::fetch_nand`](../../std/sync/atomic/struct.AtomicBool.html#method.fetch_nand).
508     pub fn atomic_nand_acq<T: Copy>(dst: *mut T, src: T) -> T;
509     /// Bitwise nand with the current value, returning the previous value.
510     ///
511     /// The stabilized version of this intrinsic is available on the
512     /// `std::sync::atomic::AtomicBool` type via the `fetch_nand` method by passing
513     /// [`Ordering::Release`](../../std/sync/atomic/enum.Ordering.html)
514     /// as the `order`. For example,
515     /// [`AtomicBool::fetch_nand`](../../std/sync/atomic/struct.AtomicBool.html#method.fetch_nand).
516     pub fn atomic_nand_rel<T: Copy>(dst: *mut T, src: T) -> T;
517     /// Bitwise nand with the current value, returning the previous value.
518     ///
519     /// The stabilized version of this intrinsic is available on the
520     /// `std::sync::atomic::AtomicBool` type via the `fetch_nand` method by passing
521     /// [`Ordering::AcqRel`](../../std/sync/atomic/enum.Ordering.html)
522     /// as the `order`. For example,
523     /// [`AtomicBool::fetch_nand`](../../std/sync/atomic/struct.AtomicBool.html#method.fetch_nand).
524     pub fn atomic_nand_acqrel<T: Copy>(dst: *mut T, src: T) -> T;
525     /// Bitwise nand with the current value, returning the previous value.
526     ///
527     /// The stabilized version of this intrinsic is available on the
528     /// `std::sync::atomic::AtomicBool` type via the `fetch_nand` method by passing
529     /// [`Ordering::Relaxed`](../../std/sync/atomic/enum.Ordering.html)
530     /// as the `order`. For example,
531     /// [`AtomicBool::fetch_nand`](../../std/sync/atomic/struct.AtomicBool.html#method.fetch_nand).
532     pub fn atomic_nand_relaxed<T: Copy>(dst: *mut T, src: T) -> T;
533
534     /// Bitwise or with the current value, returning the previous value.
535     ///
536     /// The stabilized version of this intrinsic is available on the
537     /// `std::sync::atomic` types via the `fetch_or` method by passing
538     /// [`Ordering::SeqCst`](../../std/sync/atomic/enum.Ordering.html)
539     /// as the `order`. For example,
540     /// [`AtomicBool::fetch_or`](../../std/sync/atomic/struct.AtomicBool.html#method.fetch_or).
541     pub fn atomic_or<T: Copy>(dst: *mut T, src: T) -> T;
542     /// Bitwise or with the current value, returning the previous value.
543     ///
544     /// The stabilized version of this intrinsic is available on the
545     /// `std::sync::atomic` types via the `fetch_or` method by passing
546     /// [`Ordering::Acquire`](../../std/sync/atomic/enum.Ordering.html)
547     /// as the `order`. For example,
548     /// [`AtomicBool::fetch_or`](../../std/sync/atomic/struct.AtomicBool.html#method.fetch_or).
549     pub fn atomic_or_acq<T: Copy>(dst: *mut T, src: T) -> T;
550     /// Bitwise or with the current value, returning the previous value.
551     ///
552     /// The stabilized version of this intrinsic is available on the
553     /// `std::sync::atomic` types via the `fetch_or` method by passing
554     /// [`Ordering::Release`](../../std/sync/atomic/enum.Ordering.html)
555     /// as the `order`. For example,
556     /// [`AtomicBool::fetch_or`](../../std/sync/atomic/struct.AtomicBool.html#method.fetch_or).
557     pub fn atomic_or_rel<T: Copy>(dst: *mut T, src: T) -> T;
558     /// Bitwise or with the current value, returning the previous value.
559     ///
560     /// The stabilized version of this intrinsic is available on the
561     /// `std::sync::atomic` types via the `fetch_or` method by passing
562     /// [`Ordering::AcqRel`](../../std/sync/atomic/enum.Ordering.html)
563     /// as the `order`. For example,
564     /// [`AtomicBool::fetch_or`](../../std/sync/atomic/struct.AtomicBool.html#method.fetch_or).
565     pub fn atomic_or_acqrel<T: Copy>(dst: *mut T, src: T) -> T;
566     /// Bitwise or with the current value, returning the previous value.
567     ///
568     /// The stabilized version of this intrinsic is available on the
569     /// `std::sync::atomic` types via the `fetch_or` method by passing
570     /// [`Ordering::Relaxed`](../../std/sync/atomic/enum.Ordering.html)
571     /// as the `order`. For example,
572     /// [`AtomicBool::fetch_or`](../../std/sync/atomic/struct.AtomicBool.html#method.fetch_or).
573     pub fn atomic_or_relaxed<T: Copy>(dst: *mut T, src: T) -> T;
574
575     /// Bitwise xor with the current value, returning the previous value.
576     ///
577     /// The stabilized version of this intrinsic is available on the
578     /// `std::sync::atomic` types via the `fetch_xor` method by passing
579     /// [`Ordering::SeqCst`](../../std/sync/atomic/enum.Ordering.html)
580     /// as the `order`. For example,
581     /// [`AtomicBool::fetch_xor`](../../std/sync/atomic/struct.AtomicBool.html#method.fetch_xor).
582     pub fn atomic_xor<T: Copy>(dst: *mut T, src: T) -> T;
583     /// Bitwise xor with the current value, returning the previous value.
584     ///
585     /// The stabilized version of this intrinsic is available on the
586     /// `std::sync::atomic` types via the `fetch_xor` method by passing
587     /// [`Ordering::Acquire`](../../std/sync/atomic/enum.Ordering.html)
588     /// as the `order`. For example,
589     /// [`AtomicBool::fetch_xor`](../../std/sync/atomic/struct.AtomicBool.html#method.fetch_xor).
590     pub fn atomic_xor_acq<T: Copy>(dst: *mut T, src: T) -> T;
591     /// Bitwise xor with the current value, returning the previous value.
592     ///
593     /// The stabilized version of this intrinsic is available on the
594     /// `std::sync::atomic` types via the `fetch_xor` method by passing
595     /// [`Ordering::Release`](../../std/sync/atomic/enum.Ordering.html)
596     /// as the `order`. For example,
597     /// [`AtomicBool::fetch_xor`](../../std/sync/atomic/struct.AtomicBool.html#method.fetch_xor).
598     pub fn atomic_xor_rel<T: Copy>(dst: *mut T, src: T) -> T;
599     /// Bitwise xor with the current value, returning the previous value.
600     ///
601     /// The stabilized version of this intrinsic is available on the
602     /// `std::sync::atomic` types via the `fetch_xor` method by passing
603     /// [`Ordering::AcqRel`](../../std/sync/atomic/enum.Ordering.html)
604     /// as the `order`. For example,
605     /// [`AtomicBool::fetch_xor`](../../std/sync/atomic/struct.AtomicBool.html#method.fetch_xor).
606     pub fn atomic_xor_acqrel<T: Copy>(dst: *mut T, src: T) -> T;
607     /// Bitwise xor with the current value, returning the previous value.
608     ///
609     /// The stabilized version of this intrinsic is available on the
610     /// `std::sync::atomic` types via the `fetch_xor` method by passing
611     /// [`Ordering::Relaxed`](../../std/sync/atomic/enum.Ordering.html)
612     /// as the `order`. For example,
613     /// [`AtomicBool::fetch_xor`](../../std/sync/atomic/struct.AtomicBool.html#method.fetch_xor).
614     pub fn atomic_xor_relaxed<T: Copy>(dst: *mut T, src: T) -> T;
615
616     /// Maximum with the current value using a signed comparison.
617     ///
618     /// The stabilized version of this intrinsic is available on the
619     /// `std::sync::atomic` signed integer types via the `fetch_max` method by passing
620     /// [`Ordering::SeqCst`](../../std/sync/atomic/enum.Ordering.html#variant.SeqCst)
621     /// as the `order`. For example,
622     /// [`AtomicI32::fetch_max`](../../std/sync/atomic/struct.AtomicI32.html#method.fetch_max).
623     pub fn atomic_max<T: Copy>(dst: *mut T, src: T) -> T;
624     /// Maximum with the current value using a signed comparison.
625     ///
626     /// The stabilized version of this intrinsic is available on the
627     /// `std::sync::atomic` signed integer types via the `fetch_max` method by passing
628     /// [`Ordering::Acquire`](../../std/sync/atomic/enum.Ordering.html#variant.Acquire)
629     /// as the `order`. For example,
630     /// [`AtomicI32::fetch_max`](../../std/sync/atomic/struct.AtomicI32.html#method.fetch_max).
631     pub fn atomic_max_acq<T: Copy>(dst: *mut T, src: T) -> T;
632     /// Maximum with the current value using a signed comparison.
633     ///
634     /// The stabilized version of this intrinsic is available on the
635     /// `std::sync::atomic` signed integer types via the `fetch_max` method by passing
636     /// [`Ordering::Release`](../../std/sync/atomic/enum.Ordering.html#variant.Release)
637     /// as the `order`. For example,
638     /// [`AtomicI32::fetch_max`](../../std/sync/atomic/struct.AtomicI32.html#method.fetch_max).
639     pub fn atomic_max_rel<T: Copy>(dst: *mut T, src: T) -> T;
640     /// Maximum with the current value using a signed comparison.
641     ///
642     /// The stabilized version of this intrinsic is available on the
643     /// `std::sync::atomic` signed integer types via the `fetch_max` method by passing
644     /// [`Ordering::AcqRel`](../../std/sync/atomic/enum.Ordering.html#variant.AcqRel)
645     /// as the `order`. For example,
646     /// [`AtomicI32::fetch_max`](../../std/sync/atomic/struct.AtomicI32.html#method.fetch_max).
647     pub fn atomic_max_acqrel<T: Copy>(dst: *mut T, src: T) -> T;
648     /// Maximum with the current value.
649     ///
650     /// The stabilized version of this intrinsic is available on the
651     /// `std::sync::atomic` signed integer types via the `fetch_max` method by passing
652     /// [`Ordering::Relaxed`](../../std/sync/atomic/enum.Ordering.html#variant.Relaxed)
653     /// as the `order`. For example,
654     /// [`AtomicI32::fetch_max`](../../std/sync/atomic/struct.AtomicI32.html#method.fetch_max).
655     pub fn atomic_max_relaxed<T: Copy>(dst: *mut T, src: T) -> T;
656
657     /// Minimum with the current value using a signed comparison.
658     ///
659     /// The stabilized version of this intrinsic is available on the
660     /// `std::sync::atomic` signed integer types via the `fetch_min` method by passing
661     /// [`Ordering::SeqCst`](../../std/sync/atomic/enum.Ordering.html#variant.SeqCst)
662     /// as the `order`. For example,
663     /// [`AtomicI32::fetch_min`](../../std/sync/atomic/struct.AtomicI32.html#method.fetch_min).
664     pub fn atomic_min<T: Copy>(dst: *mut T, src: T) -> T;
665     /// Minimum with the current value using a signed comparison.
666     ///
667     /// The stabilized version of this intrinsic is available on the
668     /// `std::sync::atomic` signed integer types via the `fetch_min` method by passing
669     /// [`Ordering::Acquire`](../../std/sync/atomic/enum.Ordering.html#variant.Acquire)
670     /// as the `order`. For example,
671     /// [`AtomicI32::fetch_min`](../../std/sync/atomic/struct.AtomicI32.html#method.fetch_min).
672     pub fn atomic_min_acq<T: Copy>(dst: *mut T, src: T) -> T;
673     /// Minimum with the current value using a signed comparison.
674     ///
675     /// The stabilized version of this intrinsic is available on the
676     /// `std::sync::atomic` signed integer types via the `fetch_min` method by passing
677     /// [`Ordering::Release`](../../std/sync/atomic/enum.Ordering.html#variant.Release)
678     /// as the `order`. For example,
679     /// [`AtomicI32::fetch_min`](../../std/sync/atomic/struct.AtomicI32.html#method.fetch_min).
680     pub fn atomic_min_rel<T: Copy>(dst: *mut T, src: T) -> T;
681     /// Minimum with the current value using a signed comparison.
682     ///
683     /// The stabilized version of this intrinsic is available on the
684     /// `std::sync::atomic` signed integer types via the `fetch_min` method by passing
685     /// [`Ordering::AcqRel`](../../std/sync/atomic/enum.Ordering.html#variant.AcqRel)
686     /// as the `order`. For example,
687     /// [`AtomicI32::fetch_min`](../../std/sync/atomic/struct.AtomicI32.html#method.fetch_min).
688     pub fn atomic_min_acqrel<T: Copy>(dst: *mut T, src: T) -> T;
689     /// Minimum with the current value using a signed comparison.
690     ///
691     /// The stabilized version of this intrinsic is available on the
692     /// `std::sync::atomic` signed integer types via the `fetch_min` method by passing
693     /// [`Ordering::Relaxed`](../../std/sync/atomic/enum.Ordering.html#variant.Relaxed)
694     /// as the `order`. For example,
695     /// [`AtomicI32::fetch_min`](../../std/sync/atomic/struct.AtomicI32.html#method.fetch_min).
696     pub fn atomic_min_relaxed<T: Copy>(dst: *mut T, src: T) -> T;
697
698     /// Minimum with the current value using an unsigned comparison.
699     ///
700     /// The stabilized version of this intrinsic is available on the
701     /// `std::sync::atomic` unsigned integer types via the `fetch_min` method by passing
702     /// [`Ordering::SeqCst`](../../std/sync/atomic/enum.Ordering.html#variant.SeqCst)
703     /// as the `order`. For example,
704     /// [`AtomicU32::fetch_min`](../../std/sync/atomic/struct.AtomicU32.html#method.fetch_min).
705     pub fn atomic_umin<T: Copy>(dst: *mut T, src: T) -> T;
706     /// Minimum with the current value using an unsigned comparison.
707     ///
708     /// The stabilized version of this intrinsic is available on the
709     /// `std::sync::atomic` unsigned integer types via the `fetch_min` method by passing
710     /// [`Ordering::Acquire`](../../std/sync/atomic/enum.Ordering.html#variant.Acquire)
711     /// as the `order`. For example,
712     /// [`AtomicU32::fetch_min`](../../std/sync/atomic/struct.AtomicU32.html#method.fetch_min).
713     pub fn atomic_umin_acq<T: Copy>(dst: *mut T, src: T) -> T;
714     /// Minimum with the current value using an unsigned comparison.
715     ///
716     /// The stabilized version of this intrinsic is available on the
717     /// `std::sync::atomic` unsigned integer types via the `fetch_min` method by passing
718     /// [`Ordering::Release`](../../std/sync/atomic/enum.Ordering.html#variant.Release)
719     /// as the `order`. For example,
720     /// [`AtomicU32::fetch_min`](../../std/sync/atomic/struct.AtomicU32.html#method.fetch_min).
721     pub fn atomic_umin_rel<T: Copy>(dst: *mut T, src: T) -> T;
722     /// Minimum with the current value using an unsigned comparison.
723     ///
724     /// The stabilized version of this intrinsic is available on the
725     /// `std::sync::atomic` unsigned integer types via the `fetch_min` method by passing
726     /// [`Ordering::AcqRel`](../../std/sync/atomic/enum.Ordering.html#variant.AcqRel)
727     /// as the `order`. For example,
728     /// [`AtomicU32::fetch_min`](../../std/sync/atomic/struct.AtomicU32.html#method.fetch_min).
729     pub fn atomic_umin_acqrel<T: Copy>(dst: *mut T, src: T) -> T;
730     /// Minimum with the current value using an unsigned comparison.
731     ///
732     /// The stabilized version of this intrinsic is available on the
733     /// `std::sync::atomic` unsigned integer types via the `fetch_min` method by passing
734     /// [`Ordering::Relaxed`](../../std/sync/atomic/enum.Ordering.html#variant.Relaxed)
735     /// as the `order`. For example,
736     /// [`AtomicU32::fetch_min`](../../std/sync/atomic/struct.AtomicU32.html#method.fetch_min).
737     pub fn atomic_umin_relaxed<T: Copy>(dst: *mut T, src: T) -> T;
738
739     /// Maximum with the current value using an unsigned comparison.
740     ///
741     /// The stabilized version of this intrinsic is available on the
742     /// `std::sync::atomic` unsigned integer types via the `fetch_max` method by passing
743     /// [`Ordering::SeqCst`](../../std/sync/atomic/enum.Ordering.html#variant.SeqCst)
744     /// as the `order`. For example,
745     /// [`AtomicU32::fetch_max`](../../std/sync/atomic/struct.AtomicU32.html#method.fetch_max).
746     pub fn atomic_umax<T: Copy>(dst: *mut T, src: T) -> T;
747     /// Maximum with the current value using an unsigned comparison.
748     ///
749     /// The stabilized version of this intrinsic is available on the
750     /// `std::sync::atomic` unsigned integer types via the `fetch_max` method by passing
751     /// [`Ordering::Acquire`](../../std/sync/atomic/enum.Ordering.html#variant.Acquire)
752     /// as the `order`. For example,
753     /// [`AtomicU32::fetch_max`](../../std/sync/atomic/struct.AtomicU32.html#method.fetch_max).
754     pub fn atomic_umax_acq<T: Copy>(dst: *mut T, src: T) -> T;
755     /// Maximum with the current value using an unsigned comparison.
756     ///
757     /// The stabilized version of this intrinsic is available on the
758     /// `std::sync::atomic` unsigned integer types via the `fetch_max` method by passing
759     /// [`Ordering::Release`](../../std/sync/atomic/enum.Ordering.html#variant.Release)
760     /// as the `order`. For example,
761     /// [`AtomicU32::fetch_max`](../../std/sync/atomic/struct.AtomicU32.html#method.fetch_max).
762     pub fn atomic_umax_rel<T: Copy>(dst: *mut T, src: T) -> T;
763     /// Maximum with the current value using an unsigned comparison.
764     ///
765     /// The stabilized version of this intrinsic is available on the
766     /// `std::sync::atomic` unsigned integer types via the `fetch_max` method by passing
767     /// [`Ordering::AcqRel`](../../std/sync/atomic/enum.Ordering.html#variant.AcqRel)
768     /// as the `order`. For example,
769     /// [`AtomicU32::fetch_max`](../../std/sync/atomic/struct.AtomicU32.html#method.fetch_max).
770     pub fn atomic_umax_acqrel<T: Copy>(dst: *mut T, src: T) -> T;
771     /// Maximum with the current value using an unsigned comparison.
772     ///
773     /// The stabilized version of this intrinsic is available on the
774     /// `std::sync::atomic` unsigned integer types via the `fetch_max` method by passing
775     /// [`Ordering::Relaxed`](../../std/sync/atomic/enum.Ordering.html#variant.Relaxed)
776     /// as the `order`. For example,
777     /// [`AtomicU32::fetch_max`](../../std/sync/atomic/struct.AtomicU32.html#method.fetch_max).
778     pub fn atomic_umax_relaxed<T: Copy>(dst: *mut T, src: T) -> T;
779
780     /// The `prefetch` intrinsic is a hint to the code generator to insert a prefetch instruction
781     /// if supported; otherwise, it is a no-op.
782     /// Prefetches have no effect on the behavior of the program but can change its performance
783     /// characteristics.
784     ///
785     /// The `locality` argument must be a constant integer and is a temporal locality specifier
786     /// ranging from (0) - no locality, to (3) - extremely local keep in cache.
787     ///
788     /// This intrinsic does not have a stable counterpart.
789     pub fn prefetch_read_data<T>(data: *const T, locality: i32);
790     /// The `prefetch` intrinsic is a hint to the code generator to insert a prefetch instruction
791     /// if supported; otherwise, it is a no-op.
792     /// Prefetches have no effect on the behavior of the program but can change its performance
793     /// characteristics.
794     ///
795     /// The `locality` argument must be a constant integer and is a temporal locality specifier
796     /// ranging from (0) - no locality, to (3) - extremely local keep in cache.
797     ///
798     /// This intrinsic does not have a stable counterpart.
799     pub fn prefetch_write_data<T>(data: *const T, locality: i32);
800     /// The `prefetch` intrinsic is a hint to the code generator to insert a prefetch instruction
801     /// if supported; otherwise, it is a no-op.
802     /// Prefetches have no effect on the behavior of the program but can change its performance
803     /// characteristics.
804     ///
805     /// The `locality` argument must be a constant integer and is a temporal locality specifier
806     /// ranging from (0) - no locality, to (3) - extremely local keep in cache.
807     ///
808     /// This intrinsic does not have a stable counterpart.
809     pub fn prefetch_read_instruction<T>(data: *const T, locality: i32);
810     /// The `prefetch` intrinsic is a hint to the code generator to insert a prefetch instruction
811     /// if supported; otherwise, it is a no-op.
812     /// Prefetches have no effect on the behavior of the program but can change its performance
813     /// characteristics.
814     ///
815     /// The `locality` argument must be a constant integer and is a temporal locality specifier
816     /// ranging from (0) - no locality, to (3) - extremely local keep in cache.
817     ///
818     /// This intrinsic does not have a stable counterpart.
819     pub fn prefetch_write_instruction<T>(data: *const T, locality: i32);
820 }
821
822 extern "rust-intrinsic" {
823     /// An atomic fence.
824     ///
825     /// The stabilized version of this intrinsic is available in
826     /// [`std::sync::atomic::fence`](../../std/sync/atomic/fn.fence.html)
827     /// by passing
828     /// [`Ordering::SeqCst`](../../std/sync/atomic/enum.Ordering.html#variant.SeqCst)
829     /// as the `order`.
830     pub fn atomic_fence();
831     /// An atomic fence.
832     ///
833     /// The stabilized version of this intrinsic is available in
834     /// [`std::sync::atomic::fence`](../../std/sync/atomic/fn.fence.html)
835     /// by passing
836     /// [`Ordering::Acquire`](../../std/sync/atomic/enum.Ordering.html#variant.Acquire)
837     /// as the `order`.
838     pub fn atomic_fence_acq();
839     /// An atomic fence.
840     ///
841     /// The stabilized version of this intrinsic is available in
842     /// [`std::sync::atomic::fence`](../../std/sync/atomic/fn.fence.html)
843     /// by passing
844     /// [`Ordering::Release`](../../std/sync/atomic/enum.Ordering.html#variant.Release)
845     /// as the `order`.
846     pub fn atomic_fence_rel();
847     /// An atomic fence.
848     ///
849     /// The stabilized version of this intrinsic is available in
850     /// [`std::sync::atomic::fence`](../../std/sync/atomic/fn.fence.html)
851     /// by passing
852     /// [`Ordering::AcqRel`](../../std/sync/atomic/enum.Ordering.html#variant.AcqRel)
853     /// as the `order`.
854     pub fn atomic_fence_acqrel();
855
856     /// A compiler-only memory barrier.
857     ///
858     /// Memory accesses will never be reordered across this barrier by the
859     /// compiler, but no instructions will be emitted for it. This is
860     /// appropriate for operations on the same thread that may be preempted,
861     /// such as when interacting with signal handlers.
862     ///
863     /// The stabilized version of this intrinsic is available in
864     /// [`std::sync::atomic::compiler_fence`](../../std/sync/atomic/fn.compiler_fence.html)
865     /// by passing
866     /// [`Ordering::SeqCst`](../../std/sync/atomic/enum.Ordering.html#variant.SeqCst)
867     /// as the `order`.
868     pub fn atomic_singlethreadfence();
869     /// A compiler-only memory barrier.
870     ///
871     /// Memory accesses will never be reordered across this barrier by the
872     /// compiler, but no instructions will be emitted for it. This is
873     /// appropriate for operations on the same thread that may be preempted,
874     /// such as when interacting with signal handlers.
875     ///
876     /// The stabilized version of this intrinsic is available in
877     /// [`std::sync::atomic::compiler_fence`](../../std/sync/atomic/fn.compiler_fence.html)
878     /// by passing
879     /// [`Ordering::Acquire`](../../std/sync/atomic/enum.Ordering.html#variant.Acquire)
880     /// as the `order`.
881     pub fn atomic_singlethreadfence_acq();
882     /// A compiler-only memory barrier.
883     ///
884     /// Memory accesses will never be reordered across this barrier by the
885     /// compiler, but no instructions will be emitted for it. This is
886     /// appropriate for operations on the same thread that may be preempted,
887     /// such as when interacting with signal handlers.
888     ///
889     /// The stabilized version of this intrinsic is available in
890     /// [`std::sync::atomic::compiler_fence`](../../std/sync/atomic/fn.compiler_fence.html)
891     /// by passing
892     /// [`Ordering::Release`](../../std/sync/atomic/enum.Ordering.html#variant.Release)
893     /// as the `order`.
894     pub fn atomic_singlethreadfence_rel();
895     /// A compiler-only memory barrier.
896     ///
897     /// Memory accesses will never be reordered across this barrier by the
898     /// compiler, but no instructions will be emitted for it. This is
899     /// appropriate for operations on the same thread that may be preempted,
900     /// such as when interacting with signal handlers.
901     ///
902     /// The stabilized version of this intrinsic is available in
903     /// [`std::sync::atomic::compiler_fence`](../../std/sync/atomic/fn.compiler_fence.html)
904     /// by passing
905     /// [`Ordering::AcqRel`](../../std/sync/atomic/enum.Ordering.html#variant.AcqRel)
906     /// as the `order`.
907     pub fn atomic_singlethreadfence_acqrel();
908
909     /// Magic intrinsic that derives its meaning from attributes
910     /// attached to the function.
911     ///
912     /// For example, dataflow uses this to inject static assertions so
913     /// that `rustc_peek(potentially_uninitialized)` would actually
914     /// double-check that dataflow did indeed compute that it is
915     /// uninitialized at that point in the control flow.
916     ///
917     /// This intrinsic should not be used outside of the compiler.
918     pub fn rustc_peek<T>(_: T) -> T;
919
920     /// Aborts the execution of the process.
921     ///
922     /// A more user-friendly and stable version of this operation is
923     /// [`std::process::abort`](../../std/process/fn.abort.html).
924     pub fn abort() -> !;
925
926     /// Tells LLVM that this point in the code is not reachable, enabling
927     /// further optimizations.
928     ///
929     /// N.B., this is very different from the `unreachable!()` macro: Unlike the
930     /// macro, which panics when it is executed, it is *undefined behavior* to
931     /// reach code marked with this function.
932     ///
933     /// The stabilized version of this intrinsic is
934     /// [`std::hint::unreachable_unchecked`](../../std/hint/fn.unreachable_unchecked.html).
935     #[rustc_const_unstable(feature = "const_unreachable_unchecked", issue = "53188")]
936     pub fn unreachable() -> !;
937
938     /// Informs the optimizer that a condition is always true.
939     /// If the condition is false, the behavior is undefined.
940     ///
941     /// No code is generated for this intrinsic, but the optimizer will try
942     /// to preserve it (and its condition) between passes, which may interfere
943     /// with optimization of surrounding code and reduce performance. It should
944     /// not be used if the invariant can be discovered by the optimizer on its
945     /// own, or if it does not enable any significant optimizations.
946     ///
947     /// This intrinsic does not have a stable counterpart.
948     pub fn assume(b: bool);
949
950     /// Hints to the compiler that branch condition is likely to be true.
951     /// Returns the value passed to it.
952     ///
953     /// Any use other than with `if` statements will probably not have an effect.
954     ///
955     /// This intrinsic does not have a stable counterpart.
956     #[rustc_const_unstable(feature = "const_likely", issue = "none")]
957     pub fn likely(b: bool) -> bool;
958
959     /// Hints to the compiler that branch condition is likely to be false.
960     /// Returns the value passed to it.
961     ///
962     /// Any use other than with `if` statements will probably not have an effect.
963     ///
964     /// This intrinsic does not have a stable counterpart.
965     #[rustc_const_unstable(feature = "const_likely", issue = "none")]
966     pub fn unlikely(b: bool) -> bool;
967
968     /// Executes a breakpoint trap, for inspection by a debugger.
969     ///
970     /// This intrinsic does not have a stable counterpart.
971     pub fn breakpoint();
972
973     /// The size of a type in bytes.
974     ///
975     /// More specifically, this is the offset in bytes between successive
976     /// items of the same type, including alignment padding.
977     ///
978     /// The stabilized version of this intrinsic is
979     /// [`std::mem::size_of`](../../std/mem/fn.size_of.html).
980     #[rustc_const_stable(feature = "const_size_of", since = "1.40.0")]
981     pub fn size_of<T>() -> usize;
982
983     /// Moves a value to an uninitialized memory location.
984     ///
985     /// Drop glue is not run on the destination.
986     ///
987     /// The stabilized version of this intrinsic is
988     /// [`std::ptr::write`](../../std/ptr/fn.write.html).
989     pub fn move_val_init<T>(dst: *mut T, src: T);
990
991     /// The minimum alignment of a type.
992     ///
993     /// The stabilized version of this intrinsic is
994     /// [`std::mem::align_of`](../../std/mem/fn.align_of.html).
995     #[rustc_const_stable(feature = "const_min_align_of", since = "1.40.0")]
996     pub fn min_align_of<T>() -> usize;
997     /// The preferred alignment of a type.
998     ///
999     /// This intrinsic does not have a stable counterpart.
1000     #[rustc_const_unstable(feature = "const_pref_align_of", issue = "none")]
1001     pub fn pref_align_of<T>() -> usize;
1002
1003     /// The size of the referenced value in bytes.
1004     ///
1005     /// The stabilized version of this intrinsic is
1006     /// [`std::mem::size_of_val`](../../std/mem/fn.size_of_val.html).
1007     #[rustc_const_unstable(feature = "const_size_of_val", issue = "46571")]
1008     pub fn size_of_val<T: ?Sized>(_: *const T) -> usize;
1009     /// The required alignment of the referenced value.
1010     ///
1011     /// The stabilized version of this intrinsic is
1012     /// [`std::mem::align_of_val`](../../std/mem/fn.align_of_val.html).
1013     #[rustc_const_unstable(feature = "const_align_of_val", issue = "46571")]
1014     pub fn min_align_of_val<T: ?Sized>(_: *const T) -> usize;
1015
1016     /// Gets a static string slice containing the name of a type.
1017     ///
1018     /// The stabilized version of this intrinsic is
1019     /// [`std::any::type_name`](../../std/any/fn.type_name.html)
1020     #[rustc_const_unstable(feature = "const_type_name", issue = "63084")]
1021     pub fn type_name<T: ?Sized>() -> &'static str;
1022
1023     /// Gets an identifier which is globally unique to the specified type. This
1024     /// function will return the same value for a type regardless of whichever
1025     /// crate it is invoked in.
1026     ///
1027     /// The stabilized version of this intrinsic is
1028     /// [`std::any::TypeId::of`](../../std/any/struct.TypeId.html#method.of)
1029     #[rustc_const_stable(feature = "const_type_id", since = "1.46.0")]
1030     pub fn type_id<T: ?Sized + 'static>() -> u64;
1031
1032     /// A guard for unsafe functions that cannot ever be executed if `T` is uninhabited:
1033     /// This will statically either panic, or do nothing.
1034     ///
1035     /// This intrinsic does not have a stable counterpart.
1036     pub fn assert_inhabited<T>();
1037
1038     /// A guard for unsafe functions that cannot ever be executed if `T` does not permit
1039     /// zero-initialization: This will statically either panic, or do nothing.
1040     ///
1041     /// This intrinsic does not have a stable counterpart.
1042     pub fn assert_zero_valid<T>();
1043
1044     /// A guard for unsafe functions that cannot ever be executed if `T` has invalid
1045     /// bit patterns: This will statically either panic, or do nothing.
1046     ///
1047     /// This intrinsic does not have a stable counterpart.
1048     pub fn assert_uninit_valid<T>();
1049
1050     /// Gets a reference to a static `Location` indicating where it was called.
1051     ///
1052     /// Consider using [`std::panic::Location::caller`](../../std/panic/struct.Location.html#method.caller)
1053     /// instead.
1054     #[rustc_const_unstable(feature = "const_caller_location", issue = "47809")]
1055     pub fn caller_location() -> &'static crate::panic::Location<'static>;
1056
1057     /// Moves a value out of scope without running drop glue.
1058     ///
1059     /// This exists solely for [`mem::forget_unsized`](../../std/mem/fn.forget_unsized.html);
1060     /// normal `forget` uses `ManuallyDrop` instead.
1061     pub fn forget<T: ?Sized>(_: T);
1062
1063     /// Reinterprets the bits of a value of one type as another type.
1064     ///
1065     /// Both types must have the same size. Neither the original, nor the result,
1066     /// may be an [invalid value](../../nomicon/what-unsafe-does.html).
1067     ///
1068     /// `transmute` is semantically equivalent to a bitwise move of one type
1069     /// into another. It copies the bits from the source value into the
1070     /// destination value, then forgets the original. It's equivalent to C's
1071     /// `memcpy` under the hood, just like `transmute_copy`.
1072     ///
1073     /// `transmute` is **incredibly** unsafe. There are a vast number of ways to
1074     /// cause [undefined behavior][ub] with this function. `transmute` should be
1075     /// the absolute last resort.
1076     ///
1077     /// The [nomicon](../../nomicon/transmutes.html) has additional
1078     /// documentation.
1079     ///
1080     /// [ub]: ../../reference/behavior-considered-undefined.html
1081     ///
1082     /// # Examples
1083     ///
1084     /// There are a few things that `transmute` is really useful for.
1085     ///
1086     /// Turning a pointer into a function pointer. This is *not* portable to
1087     /// machines where function pointers and data pointers have different sizes.
1088     ///
1089     /// ```
1090     /// fn foo() -> i32 {
1091     ///     0
1092     /// }
1093     /// let pointer = foo as *const ();
1094     /// let function = unsafe {
1095     ///     std::mem::transmute::<*const (), fn() -> i32>(pointer)
1096     /// };
1097     /// assert_eq!(function(), 0);
1098     /// ```
1099     ///
1100     /// Extending a lifetime, or shortening an invariant lifetime. This is
1101     /// advanced, very unsafe Rust!
1102     ///
1103     /// ```
1104     /// struct R<'a>(&'a i32);
1105     /// unsafe fn extend_lifetime<'b>(r: R<'b>) -> R<'static> {
1106     ///     std::mem::transmute::<R<'b>, R<'static>>(r)
1107     /// }
1108     ///
1109     /// unsafe fn shorten_invariant_lifetime<'b, 'c>(r: &'b mut R<'static>)
1110     ///                                              -> &'b mut R<'c> {
1111     ///     std::mem::transmute::<&'b mut R<'static>, &'b mut R<'c>>(r)
1112     /// }
1113     /// ```
1114     ///
1115     /// # Alternatives
1116     ///
1117     /// Don't despair: many uses of `transmute` can be achieved through other means.
1118     /// Below are common applications of `transmute` which can be replaced with safer
1119     /// constructs.
1120     ///
1121     /// Turning raw bytes(`&[u8]`) to `u32`, `f64`, etc.:
1122     ///
1123     /// ```
1124     /// let raw_bytes = [0x78, 0x56, 0x34, 0x12];
1125     ///
1126     /// let num = unsafe {
1127     ///     std::mem::transmute::<[u8; 4], u32>(raw_bytes);
1128     /// };
1129     ///
1130     /// // use `u32::from_ne_bytes` instead
1131     /// let num = u32::from_ne_bytes(raw_bytes);
1132     /// // or use `u32::from_le_bytes` or `u32::from_be_bytes` to specify the endianness
1133     /// let num = u32::from_le_bytes(raw_bytes);
1134     /// assert_eq!(num, 0x12345678);
1135     /// let num = u32::from_be_bytes(raw_bytes);
1136     /// assert_eq!(num, 0x78563412);
1137     /// ```
1138     ///
1139     /// Turning a pointer into a `usize`:
1140     ///
1141     /// ```
1142     /// let ptr = &0;
1143     /// let ptr_num_transmute = unsafe {
1144     ///     std::mem::transmute::<&i32, usize>(ptr)
1145     /// };
1146     ///
1147     /// // Use an `as` cast instead
1148     /// let ptr_num_cast = ptr as *const i32 as usize;
1149     /// ```
1150     ///
1151     /// Turning a `*mut T` into an `&mut T`:
1152     ///
1153     /// ```
1154     /// let ptr: *mut i32 = &mut 0;
1155     /// let ref_transmuted = unsafe {
1156     ///     std::mem::transmute::<*mut i32, &mut i32>(ptr)
1157     /// };
1158     ///
1159     /// // Use a reborrow instead
1160     /// let ref_casted = unsafe { &mut *ptr };
1161     /// ```
1162     ///
1163     /// Turning an `&mut T` into an `&mut U`:
1164     ///
1165     /// ```
1166     /// let ptr = &mut 0;
1167     /// let val_transmuted = unsafe {
1168     ///     std::mem::transmute::<&mut i32, &mut u32>(ptr)
1169     /// };
1170     ///
1171     /// // Now, put together `as` and reborrowing - note the chaining of `as`
1172     /// // `as` is not transitive
1173     /// let val_casts = unsafe { &mut *(ptr as *mut i32 as *mut u32) };
1174     /// ```
1175     ///
1176     /// Turning an `&str` into an `&[u8]`:
1177     ///
1178     /// ```
1179     /// // this is not a good way to do this.
1180     /// let slice = unsafe { std::mem::transmute::<&str, &[u8]>("Rust") };
1181     /// assert_eq!(slice, &[82, 117, 115, 116]);
1182     ///
1183     /// // You could use `str::as_bytes`
1184     /// let slice = "Rust".as_bytes();
1185     /// assert_eq!(slice, &[82, 117, 115, 116]);
1186     ///
1187     /// // Or, just use a byte string, if you have control over the string
1188     /// // literal
1189     /// assert_eq!(b"Rust", &[82, 117, 115, 116]);
1190     /// ```
1191     ///
1192     /// Turning a `Vec<&T>` into a `Vec<Option<&T>>`:
1193     ///
1194     /// ```
1195     /// let store = [0, 1, 2, 3];
1196     /// let v_orig = store.iter().collect::<Vec<&i32>>();
1197     ///
1198     /// // clone the vector as we will reuse them later
1199     /// let v_clone = v_orig.clone();
1200     ///
1201     /// // Using transmute: this relies on the unspecified data layout of `Vec`, which is a
1202     /// // bad idea and could cause Undefined Behavior.
1203     /// // However, it is no-copy.
1204     /// let v_transmuted = unsafe {
1205     ///     std::mem::transmute::<Vec<&i32>, Vec<Option<&i32>>>(v_clone)
1206     /// };
1207     ///
1208     /// let v_clone = v_orig.clone();
1209     ///
1210     /// // This is the suggested, safe way.
1211     /// // It does copy the entire vector, though, into a new array.
1212     /// let v_collected = v_clone.into_iter()
1213     ///                          .map(Some)
1214     ///                          .collect::<Vec<Option<&i32>>>();
1215     ///
1216     /// let v_clone = v_orig.clone();
1217     ///
1218     /// // The no-copy, unsafe way, still using transmute, but not relying on the data layout.
1219     /// // Like the first approach, this reuses the `Vec` internals.
1220     /// // Therefore, the new inner type must have the
1221     /// // exact same size, *and the same alignment*, as the old type.
1222     /// // The same caveats exist for this method as transmute, for
1223     /// // the original inner type (`&i32`) to the converted inner type
1224     /// // (`Option<&i32>`), so read the nomicon pages linked above and also
1225     /// // consult the [`from_raw_parts`] documentation.
1226     /// let v_from_raw = unsafe {
1227     // FIXME Update this when vec_into_raw_parts is stabilized
1228     ///     // Ensure the original vector is not dropped.
1229     ///     let mut v_clone = std::mem::ManuallyDrop::new(v_clone);
1230     ///     Vec::from_raw_parts(v_clone.as_mut_ptr() as *mut Option<&i32>,
1231     ///                         v_clone.len(),
1232     ///                         v_clone.capacity())
1233     /// };
1234     /// ```
1235     ///
1236     /// [`from_raw_parts`]: ../../std/vec/struct.Vec.html#method.from_raw_parts
1237     ///
1238     /// Implementing `split_at_mut`:
1239     ///
1240     /// ```
1241     /// use std::{slice, mem};
1242     ///
1243     /// // There are multiple ways to do this, and there are multiple problems
1244     /// // with the following (transmute) way.
1245     /// fn split_at_mut_transmute<T>(slice: &mut [T], mid: usize)
1246     ///                              -> (&mut [T], &mut [T]) {
1247     ///     let len = slice.len();
1248     ///     assert!(mid <= len);
1249     ///     unsafe {
1250     ///         let slice2 = mem::transmute::<&mut [T], &mut [T]>(slice);
1251     ///         // first: transmute is not type safe; all it checks is that T and
1252     ///         // U are of the same size. Second, right here, you have two
1253     ///         // mutable references pointing to the same memory.
1254     ///         (&mut slice[0..mid], &mut slice2[mid..len])
1255     ///     }
1256     /// }
1257     ///
1258     /// // This gets rid of the type safety problems; `&mut *` will *only* give
1259     /// // you an `&mut T` from an `&mut T` or `*mut T`.
1260     /// fn split_at_mut_casts<T>(slice: &mut [T], mid: usize)
1261     ///                          -> (&mut [T], &mut [T]) {
1262     ///     let len = slice.len();
1263     ///     assert!(mid <= len);
1264     ///     unsafe {
1265     ///         let slice2 = &mut *(slice as *mut [T]);
1266     ///         // however, you still have two mutable references pointing to
1267     ///         // the same memory.
1268     ///         (&mut slice[0..mid], &mut slice2[mid..len])
1269     ///     }
1270     /// }
1271     ///
1272     /// // This is how the standard library does it. This is the best method, if
1273     /// // you need to do something like this
1274     /// fn split_at_stdlib<T>(slice: &mut [T], mid: usize)
1275     ///                       -> (&mut [T], &mut [T]) {
1276     ///     let len = slice.len();
1277     ///     assert!(mid <= len);
1278     ///     unsafe {
1279     ///         let ptr = slice.as_mut_ptr();
1280     ///         // This now has three mutable references pointing at the same
1281     ///         // memory. `slice`, the rvalue ret.0, and the rvalue ret.1.
1282     ///         // `slice` is never used after `let ptr = ...`, and so one can
1283     ///         // treat it as "dead", and therefore, you only have two real
1284     ///         // mutable slices.
1285     ///         (slice::from_raw_parts_mut(ptr, mid),
1286     ///          slice::from_raw_parts_mut(ptr.add(mid), len - mid))
1287     ///     }
1288     /// }
1289     /// ```
1290     #[stable(feature = "rust1", since = "1.0.0")]
1291     // NOTE: While this makes the intrinsic const stable, we have some custom code in const fn
1292     // checks that prevent its use within `const fn`.
1293     #[rustc_const_stable(feature = "const_transmute", since = "1.46.0")]
1294     pub fn transmute<T, U>(e: T) -> U;
1295
1296     /// Returns `true` if the actual type given as `T` requires drop
1297     /// glue; returns `false` if the actual type provided for `T`
1298     /// implements `Copy`.
1299     ///
1300     /// If the actual type neither requires drop glue nor implements
1301     /// `Copy`, then the return value of this function is unspecified.
1302     ///
1303     /// The stabilized version of this intrinsic is
1304     /// [`std::mem::needs_drop`](../../std/mem/fn.needs_drop.html).
1305     #[rustc_const_stable(feature = "const_needs_drop", since = "1.40.0")]
1306     pub fn needs_drop<T>() -> bool;
1307
1308     /// Calculates the offset from a pointer.
1309     ///
1310     /// This is implemented as an intrinsic to avoid converting to and from an
1311     /// integer, since the conversion would throw away aliasing information.
1312     ///
1313     /// # Safety
1314     ///
1315     /// Both the starting and resulting pointer must be either in bounds or one
1316     /// byte past the end of an allocated object. If either pointer is out of
1317     /// bounds or arithmetic overflow occurs then any further use of the
1318     /// returned value will result in undefined behavior.
1319     ///
1320     /// The stabilized version of this intrinsic is
1321     /// [`std::pointer::offset`](../../std/primitive.pointer.html#method.offset).
1322     #[must_use = "returns a new pointer rather than modifying its argument"]
1323     #[rustc_const_unstable(feature = "const_ptr_offset", issue = "71499")]
1324     pub fn offset<T>(dst: *const T, offset: isize) -> *const T;
1325
1326     /// Calculates the offset from a pointer, potentially wrapping.
1327     ///
1328     /// This is implemented as an intrinsic to avoid converting to and from an
1329     /// integer, since the conversion inhibits certain optimizations.
1330     ///
1331     /// # Safety
1332     ///
1333     /// Unlike the `offset` intrinsic, this intrinsic does not restrict the
1334     /// resulting pointer to point into or one byte past the end of an allocated
1335     /// object, and it wraps with two's complement arithmetic. The resulting
1336     /// value is not necessarily valid to be used to actually access memory.
1337     ///
1338     /// The stabilized version of this intrinsic is
1339     /// [`std::pointer::wrapping_offset`](../../std/primitive.pointer.html#method.wrapping_offset).
1340     #[must_use = "returns a new pointer rather than modifying its argument"]
1341     #[rustc_const_unstable(feature = "const_ptr_offset", issue = "71499")]
1342     pub fn arith_offset<T>(dst: *const T, offset: isize) -> *const T;
1343
1344     /// Equivalent to the appropriate `llvm.memcpy.p0i8.0i8.*` intrinsic, with
1345     /// a size of `count` * `size_of::<T>()` and an alignment of
1346     /// `min_align_of::<T>()`
1347     ///
1348     /// The volatile parameter is set to `true`, so it will not be optimized out
1349     /// unless size is equal to zero.
1350     ///
1351     /// This intrinsic does not have a stable counterpart.
1352     pub fn volatile_copy_nonoverlapping_memory<T>(dst: *mut T, src: *const T, count: usize);
1353     /// Equivalent to the appropriate `llvm.memmove.p0i8.0i8.*` intrinsic, with
1354     /// a size of `count` * `size_of::<T>()` and an alignment of
1355     /// `min_align_of::<T>()`
1356     ///
1357     /// The volatile parameter is set to `true`, so it will not be optimized out
1358     /// unless size is equal to zero.
1359     ///
1360     /// This intrinsic does not have a stable counterpart.
1361     pub fn volatile_copy_memory<T>(dst: *mut T, src: *const T, count: usize);
1362     /// Equivalent to the appropriate `llvm.memset.p0i8.*` intrinsic, with a
1363     /// size of `count` * `size_of::<T>()` and an alignment of
1364     /// `min_align_of::<T>()`.
1365     ///
1366     /// The volatile parameter is set to `true`, so it will not be optimized out
1367     /// unless size is equal to zero.
1368     ///
1369     /// This intrinsic does not have a stable counterpart.
1370     pub fn volatile_set_memory<T>(dst: *mut T, val: u8, count: usize);
1371
1372     /// Performs a volatile load from the `src` pointer.
1373     ///
1374     /// The stabilized version of this intrinsic is
1375     /// [`std::ptr::read_volatile`](../../std/ptr/fn.read_volatile.html).
1376     pub fn volatile_load<T>(src: *const T) -> T;
1377     /// Performs a volatile store to the `dst` pointer.
1378     ///
1379     /// The stabilized version of this intrinsic is
1380     /// [`std::ptr::write_volatile`](../../std/ptr/fn.write_volatile.html).
1381     pub fn volatile_store<T>(dst: *mut T, val: T);
1382
1383     /// Performs a volatile load from the `src` pointer
1384     /// The pointer is not required to be aligned.
1385     ///
1386     /// This intrinsic does not have a stable counterpart.
1387     pub fn unaligned_volatile_load<T>(src: *const T) -> T;
1388     /// Performs a volatile store to the `dst` pointer.
1389     /// The pointer is not required to be aligned.
1390     ///
1391     /// This intrinsic does not have a stable counterpart.
1392     pub fn unaligned_volatile_store<T>(dst: *mut T, val: T);
1393
1394     /// Returns the square root of an `f32`
1395     ///
1396     /// The stabilized version of this intrinsic is
1397     /// [`std::f32::sqrt`](../../std/primitive.f32.html#method.sqrt)
1398     pub fn sqrtf32(x: f32) -> f32;
1399     /// Returns the square root of an `f64`
1400     ///
1401     /// The stabilized version of this intrinsic is
1402     /// [`std::f64::sqrt`](../../std/primitive.f64.html#method.sqrt)
1403     pub fn sqrtf64(x: f64) -> f64;
1404
1405     /// Raises an `f32` to an integer power.
1406     ///
1407     /// The stabilized version of this intrinsic is
1408     /// [`std::f32::powi`](../../std/primitive.f32.html#method.powi)
1409     pub fn powif32(a: f32, x: i32) -> f32;
1410     /// Raises an `f64` to an integer power.
1411     ///
1412     /// The stabilized version of this intrinsic is
1413     /// [`std::f64::powi`](../../std/primitive.f64.html#method.powi)
1414     pub fn powif64(a: f64, x: i32) -> f64;
1415
1416     /// Returns the sine of an `f32`.
1417     ///
1418     /// The stabilized version of this intrinsic is
1419     /// [`std::f32::sin`](../../std/primitive.f32.html#method.sin)
1420     pub fn sinf32(x: f32) -> f32;
1421     /// Returns the sine of an `f64`.
1422     ///
1423     /// The stabilized version of this intrinsic is
1424     /// [`std::f64::sin`](../../std/primitive.f64.html#method.sin)
1425     pub fn sinf64(x: f64) -> f64;
1426
1427     /// Returns the cosine of an `f32`.
1428     ///
1429     /// The stabilized version of this intrinsic is
1430     /// [`std::f32::cos`](../../std/primitive.f32.html#method.cos)
1431     pub fn cosf32(x: f32) -> f32;
1432     /// Returns the cosine of an `f64`.
1433     ///
1434     /// The stabilized version of this intrinsic is
1435     /// [`std::f64::cos`](../../std/primitive.f64.html#method.cos)
1436     pub fn cosf64(x: f64) -> f64;
1437
1438     /// Raises an `f32` to an `f32` power.
1439     ///
1440     /// The stabilized version of this intrinsic is
1441     /// [`std::f32::powf`](../../std/primitive.f32.html#method.powf)
1442     pub fn powf32(a: f32, x: f32) -> f32;
1443     /// Raises an `f64` to an `f64` power.
1444     ///
1445     /// The stabilized version of this intrinsic is
1446     /// [`std::f64::powf`](../../std/primitive.f64.html#method.powf)
1447     pub fn powf64(a: f64, x: f64) -> f64;
1448
1449     /// Returns the exponential of an `f32`.
1450     ///
1451     /// The stabilized version of this intrinsic is
1452     /// [`std::f32::exp`](../../std/primitive.f32.html#method.exp)
1453     pub fn expf32(x: f32) -> f32;
1454     /// Returns the exponential of an `f64`.
1455     ///
1456     /// The stabilized version of this intrinsic is
1457     /// [`std::f64::exp`](../../std/primitive.f64.html#method.exp)
1458     pub fn expf64(x: f64) -> f64;
1459
1460     /// Returns 2 raised to the power of an `f32`.
1461     ///
1462     /// The stabilized version of this intrinsic is
1463     /// [`std::f32::exp2`](../../std/primitive.f32.html#method.exp2)
1464     pub fn exp2f32(x: f32) -> f32;
1465     /// Returns 2 raised to the power of an `f64`.
1466     ///
1467     /// The stabilized version of this intrinsic is
1468     /// [`std::f64::exp2`](../../std/primitive.f64.html#method.exp2)
1469     pub fn exp2f64(x: f64) -> f64;
1470
1471     /// Returns the natural logarithm of an `f32`.
1472     ///
1473     /// The stabilized version of this intrinsic is
1474     /// [`std::f32::ln`](../../std/primitive.f32.html#method.ln)
1475     pub fn logf32(x: f32) -> f32;
1476     /// Returns the natural logarithm of an `f64`.
1477     ///
1478     /// The stabilized version of this intrinsic is
1479     /// [`std::f64::ln`](../../std/primitive.f64.html#method.ln)
1480     pub fn logf64(x: f64) -> f64;
1481
1482     /// Returns the base 10 logarithm of an `f32`.
1483     ///
1484     /// The stabilized version of this intrinsic is
1485     /// [`std::f32::log10`](../../std/primitive.f32.html#method.log10)
1486     pub fn log10f32(x: f32) -> f32;
1487     /// Returns the base 10 logarithm of an `f64`.
1488     ///
1489     /// The stabilized version of this intrinsic is
1490     /// [`std::f64::log10`](../../std/primitive.f64.html#method.log10)
1491     pub fn log10f64(x: f64) -> f64;
1492
1493     /// Returns the base 2 logarithm of an `f32`.
1494     ///
1495     /// The stabilized version of this intrinsic is
1496     /// [`std::f32::log2`](../../std/primitive.f32.html#method.log2)
1497     pub fn log2f32(x: f32) -> f32;
1498     /// Returns the base 2 logarithm of an `f64`.
1499     ///
1500     /// The stabilized version of this intrinsic is
1501     /// [`std::f64::log2`](../../std/primitive.f64.html#method.log2)
1502     pub fn log2f64(x: f64) -> f64;
1503
1504     /// Returns `a * b + c` for `f32` values.
1505     ///
1506     /// The stabilized version of this intrinsic is
1507     /// [`std::f32::mul_add`](../../std/primitive.f32.html#method.mul_add)
1508     pub fn fmaf32(a: f32, b: f32, c: f32) -> f32;
1509     /// Returns `a * b + c` for `f64` values.
1510     ///
1511     /// The stabilized version of this intrinsic is
1512     /// [`std::f64::mul_add`](../../std/primitive.f64.html#method.mul_add)
1513     pub fn fmaf64(a: f64, b: f64, c: f64) -> f64;
1514
1515     /// Returns the absolute value of an `f32`.
1516     ///
1517     /// The stabilized version of this intrinsic is
1518     /// [`std::f32::abs`](../../std/primitive.f32.html#method.abs)
1519     pub fn fabsf32(x: f32) -> f32;
1520     /// Returns the absolute value of an `f64`.
1521     ///
1522     /// The stabilized version of this intrinsic is
1523     /// [`std::f64::abs`](../../std/primitive.f64.html#method.abs)
1524     pub fn fabsf64(x: f64) -> f64;
1525
1526     /// Returns the minimum of two `f32` values.
1527     ///
1528     /// The stabilized version of this intrinsic is
1529     /// [`std::f32::min`](../../std/primitive.f32.html#method.min)
1530     pub fn minnumf32(x: f32, y: f32) -> f32;
1531     /// Returns the minimum of two `f64` values.
1532     ///
1533     /// The stabilized version of this intrinsic is
1534     /// [`std::f64::min`](../../std/primitive.f64.html#method.min)
1535     pub fn minnumf64(x: f64, y: f64) -> f64;
1536     /// Returns the maximum of two `f32` values.
1537     ///
1538     /// The stabilized version of this intrinsic is
1539     /// [`std::f32::max`](../../std/primitive.f32.html#method.max)
1540     pub fn maxnumf32(x: f32, y: f32) -> f32;
1541     /// Returns the maximum of two `f64` values.
1542     ///
1543     /// The stabilized version of this intrinsic is
1544     /// [`std::f64::max`](../../std/primitive.f64.html#method.max)
1545     pub fn maxnumf64(x: f64, y: f64) -> f64;
1546
1547     /// Copies the sign from `y` to `x` for `f32` values.
1548     ///
1549     /// The stabilized version of this intrinsic is
1550     /// [`std::f32::copysign`](../../std/primitive.f32.html#method.copysign)
1551     pub fn copysignf32(x: f32, y: f32) -> f32;
1552     /// Copies the sign from `y` to `x` for `f64` values.
1553     ///
1554     /// The stabilized version of this intrinsic is
1555     /// [`std::f64::copysign`](../../std/primitive.f64.html#method.copysign)
1556     pub fn copysignf64(x: f64, y: f64) -> f64;
1557
1558     /// Returns the largest integer less than or equal to an `f32`.
1559     ///
1560     /// The stabilized version of this intrinsic is
1561     /// [`std::f32::floor`](../../std/primitive.f32.html#method.floor)
1562     pub fn floorf32(x: f32) -> f32;
1563     /// Returns the largest integer less than or equal to an `f64`.
1564     ///
1565     /// The stabilized version of this intrinsic is
1566     /// [`std::f64::floor`](../../std/primitive.f64.html#method.floor)
1567     pub fn floorf64(x: f64) -> f64;
1568
1569     /// Returns the smallest integer greater than or equal to an `f32`.
1570     ///
1571     /// The stabilized version of this intrinsic is
1572     /// [`std::f32::ceil`](../../std/primitive.f32.html#method.ceil)
1573     pub fn ceilf32(x: f32) -> f32;
1574     /// Returns the smallest integer greater than or equal to an `f64`.
1575     ///
1576     /// The stabilized version of this intrinsic is
1577     /// [`std::f64::ceil`](../../std/primitive.f64.html#method.ceil)
1578     pub fn ceilf64(x: f64) -> f64;
1579
1580     /// Returns the integer part of an `f32`.
1581     ///
1582     /// The stabilized version of this intrinsic is
1583     /// [`std::f32::trunc`](../../std/primitive.f32.html#method.trunc)
1584     pub fn truncf32(x: f32) -> f32;
1585     /// Returns the integer part of an `f64`.
1586     ///
1587     /// The stabilized version of this intrinsic is
1588     /// [`std::f64::trunc`](../../std/primitive.f64.html#method.trunc)
1589     pub fn truncf64(x: f64) -> f64;
1590
1591     /// Returns the nearest integer to an `f32`. May raise an inexact floating-point exception
1592     /// if the argument is not an integer.
1593     pub fn rintf32(x: f32) -> f32;
1594     /// Returns the nearest integer to an `f64`. May raise an inexact floating-point exception
1595     /// if the argument is not an integer.
1596     pub fn rintf64(x: f64) -> f64;
1597
1598     /// Returns the nearest integer to an `f32`.
1599     ///
1600     /// This intrinsic does not have a stable counterpart.
1601     pub fn nearbyintf32(x: f32) -> f32;
1602     /// Returns the nearest integer to an `f64`.
1603     ///
1604     /// This intrinsic does not have a stable counterpart.
1605     pub fn nearbyintf64(x: f64) -> f64;
1606
1607     /// Returns the nearest integer to an `f32`. Rounds half-way cases away from zero.
1608     ///
1609     /// The stabilized version of this intrinsic is
1610     /// [`std::f32::round`](../../std/primitive.f32.html#method.round)
1611     pub fn roundf32(x: f32) -> f32;
1612     /// Returns the nearest integer to an `f64`. Rounds half-way cases away from zero.
1613     ///
1614     /// The stabilized version of this intrinsic is
1615     /// [`std::f64::round`](../../std/primitive.f64.html#method.round)
1616     pub fn roundf64(x: f64) -> f64;
1617
1618     /// Float addition that allows optimizations based on algebraic rules.
1619     /// May assume inputs are finite.
1620     ///
1621     /// This intrinsic does not have a stable counterpart.
1622     pub fn fadd_fast<T: Copy>(a: T, b: T) -> T;
1623
1624     /// Float subtraction that allows optimizations based on algebraic rules.
1625     /// May assume inputs are finite.
1626     ///
1627     /// This intrinsic does not have a stable counterpart.
1628     pub fn fsub_fast<T: Copy>(a: T, b: T) -> T;
1629
1630     /// Float multiplication that allows optimizations based on algebraic rules.
1631     /// May assume inputs are finite.
1632     ///
1633     /// This intrinsic does not have a stable counterpart.
1634     pub fn fmul_fast<T: Copy>(a: T, b: T) -> T;
1635
1636     /// Float division that allows optimizations based on algebraic rules.
1637     /// May assume inputs are finite.
1638     ///
1639     /// This intrinsic does not have a stable counterpart.
1640     pub fn fdiv_fast<T: Copy>(a: T, b: T) -> T;
1641
1642     /// Float remainder that allows optimizations based on algebraic rules.
1643     /// May assume inputs are finite.
1644     ///
1645     /// This intrinsic does not have a stable counterpart.
1646     pub fn frem_fast<T: Copy>(a: T, b: T) -> T;
1647
1648     /// Convert with LLVM’s fptoui/fptosi, which may return undef for values out of range
1649     /// (<https://github.com/rust-lang/rust/issues/10184>)
1650     ///
1651     /// Stabilized as [`f32::to_int_unchecked`](../../std/primitive.f32.html#method.to_int_unchecked)
1652     /// and [`f64::to_int_unchecked`](../../std/primitive.f64.html#method.to_int_unchecked).
1653     pub fn float_to_int_unchecked<Float: Copy, Int: Copy>(value: Float) -> Int;
1654
1655     /// Returns the number of bits set in an integer type `T`
1656     ///
1657     /// The stabilized versions of this intrinsic are available on the integer
1658     /// primitives via the `count_ones` method. For example,
1659     /// [`std::u32::count_ones`](../../std/primitive.u32.html#method.count_ones)
1660     #[rustc_const_stable(feature = "const_ctpop", since = "1.40.0")]
1661     pub fn ctpop<T: Copy>(x: T) -> T;
1662
1663     /// Returns the number of leading unset bits (zeroes) in an integer type `T`.
1664     ///
1665     /// The stabilized versions of this intrinsic are available on the integer
1666     /// primitives via the `leading_zeros` method. For example,
1667     /// [`std::u32::leading_zeros`](../../std/primitive.u32.html#method.leading_zeros)
1668     ///
1669     /// # Examples
1670     ///
1671     /// ```
1672     /// #![feature(core_intrinsics)]
1673     ///
1674     /// use std::intrinsics::ctlz;
1675     ///
1676     /// let x = 0b0001_1100_u8;
1677     /// let num_leading = ctlz(x);
1678     /// assert_eq!(num_leading, 3);
1679     /// ```
1680     ///
1681     /// An `x` with value `0` will return the bit width of `T`.
1682     ///
1683     /// ```
1684     /// #![feature(core_intrinsics)]
1685     ///
1686     /// use std::intrinsics::ctlz;
1687     ///
1688     /// let x = 0u16;
1689     /// let num_leading = ctlz(x);
1690     /// assert_eq!(num_leading, 16);
1691     /// ```
1692     #[rustc_const_stable(feature = "const_ctlz", since = "1.40.0")]
1693     pub fn ctlz<T: Copy>(x: T) -> T;
1694
1695     /// Like `ctlz`, but extra-unsafe as it returns `undef` when
1696     /// given an `x` with value `0`.
1697     ///
1698     /// This intrinsic does not have a stable counterpart.
1699     ///
1700     /// # Examples
1701     ///
1702     /// ```
1703     /// #![feature(core_intrinsics)]
1704     ///
1705     /// use std::intrinsics::ctlz_nonzero;
1706     ///
1707     /// let x = 0b0001_1100_u8;
1708     /// let num_leading = unsafe { ctlz_nonzero(x) };
1709     /// assert_eq!(num_leading, 3);
1710     /// ```
1711     #[rustc_const_unstable(feature = "constctlz", issue = "none")]
1712     pub fn ctlz_nonzero<T: Copy>(x: T) -> T;
1713
1714     /// Returns the number of trailing unset bits (zeroes) in an integer type `T`.
1715     ///
1716     /// The stabilized versions of this intrinsic are available on the integer
1717     /// primitives via the `trailing_zeros` method. For example,
1718     /// [`std::u32::trailing_zeros`](../../std/primitive.u32.html#method.trailing_zeros)
1719     ///
1720     /// # Examples
1721     ///
1722     /// ```
1723     /// #![feature(core_intrinsics)]
1724     ///
1725     /// use std::intrinsics::cttz;
1726     ///
1727     /// let x = 0b0011_1000_u8;
1728     /// let num_trailing = cttz(x);
1729     /// assert_eq!(num_trailing, 3);
1730     /// ```
1731     ///
1732     /// An `x` with value `0` will return the bit width of `T`:
1733     ///
1734     /// ```
1735     /// #![feature(core_intrinsics)]
1736     ///
1737     /// use std::intrinsics::cttz;
1738     ///
1739     /// let x = 0u16;
1740     /// let num_trailing = cttz(x);
1741     /// assert_eq!(num_trailing, 16);
1742     /// ```
1743     #[rustc_const_stable(feature = "const_cttz", since = "1.40.0")]
1744     pub fn cttz<T: Copy>(x: T) -> T;
1745
1746     /// Like `cttz`, but extra-unsafe as it returns `undef` when
1747     /// given an `x` with value `0`.
1748     ///
1749     /// This intrinsic does not have a stable counterpart.
1750     ///
1751     /// # Examples
1752     ///
1753     /// ```
1754     /// #![feature(core_intrinsics)]
1755     ///
1756     /// use std::intrinsics::cttz_nonzero;
1757     ///
1758     /// let x = 0b0011_1000_u8;
1759     /// let num_trailing = unsafe { cttz_nonzero(x) };
1760     /// assert_eq!(num_trailing, 3);
1761     /// ```
1762     #[rustc_const_unstable(feature = "const_cttz", issue = "none")]
1763     pub fn cttz_nonzero<T: Copy>(x: T) -> T;
1764
1765     /// Reverses the bytes in an integer type `T`.
1766     ///
1767     /// The stabilized versions of this intrinsic are available on the integer
1768     /// primitives via the `swap_bytes` method. For example,
1769     /// [`std::u32::swap_bytes`](../../std/primitive.u32.html#method.swap_bytes)
1770     #[rustc_const_stable(feature = "const_bswap", since = "1.40.0")]
1771     pub fn bswap<T: Copy>(x: T) -> T;
1772
1773     /// Reverses the bits in an integer type `T`.
1774     ///
1775     /// The stabilized versions of this intrinsic are available on the integer
1776     /// primitives via the `reverse_bits` method. For example,
1777     /// [`std::u32::reverse_bits`](../../std/primitive.u32.html#method.reverse_bits)
1778     #[rustc_const_stable(feature = "const_bitreverse", since = "1.40.0")]
1779     pub fn bitreverse<T: Copy>(x: T) -> T;
1780
1781     /// Performs checked integer addition.
1782     ///
1783     /// The stabilized versions of this intrinsic are available on the integer
1784     /// primitives via the `overflowing_add` method. For example,
1785     /// [`std::u32::overflowing_add`](../../std/primitive.u32.html#method.overflowing_add)
1786     #[rustc_const_stable(feature = "const_int_overflow", since = "1.40.0")]
1787     pub fn add_with_overflow<T: Copy>(x: T, y: T) -> (T, bool);
1788
1789     /// Performs checked integer subtraction
1790     ///
1791     /// The stabilized versions of this intrinsic are available on the integer
1792     /// primitives via the `overflowing_sub` method. For example,
1793     /// [`std::u32::overflowing_sub`](../../std/primitive.u32.html#method.overflowing_sub)
1794     #[rustc_const_stable(feature = "const_int_overflow", since = "1.40.0")]
1795     pub fn sub_with_overflow<T: Copy>(x: T, y: T) -> (T, bool);
1796
1797     /// Performs checked integer multiplication
1798     ///
1799     /// The stabilized versions of this intrinsic are available on the integer
1800     /// primitives via the `overflowing_mul` method. For example,
1801     /// [`std::u32::overflowing_mul`](../../std/primitive.u32.html#method.overflowing_mul)
1802     #[rustc_const_stable(feature = "const_int_overflow", since = "1.40.0")]
1803     pub fn mul_with_overflow<T: Copy>(x: T, y: T) -> (T, bool);
1804
1805     /// Performs an exact division, resulting in undefined behavior where
1806     /// `x % y != 0` or `y == 0` or `x == T::MIN && y == -1`
1807     ///
1808     /// This intrinsic does not have a stable counterpart.
1809     pub fn exact_div<T: Copy>(x: T, y: T) -> T;
1810
1811     /// Performs an unchecked division, resulting in undefined behavior
1812     /// where y = 0 or x = `T::MIN` and y = -1
1813     ///
1814     /// Safe wrappers for this intrinsic are available on the integer
1815     /// primitives via the `checked_div` method. For example,
1816     /// [`std::u32::checked_div`](../../std/primitive.u32.html#method.checked_div)
1817     #[rustc_const_unstable(feature = "const_int_unchecked_arith", issue = "none")]
1818     pub fn unchecked_div<T: Copy>(x: T, y: T) -> T;
1819     /// Returns the remainder of an unchecked division, resulting in
1820     /// undefined behavior where y = 0 or x = `T::MIN` and y = -1
1821     ///
1822     /// Safe wrappers for this intrinsic are available on the integer
1823     /// primitives via the `checked_rem` method. For example,
1824     /// [`std::u32::checked_rem`](../../std/primitive.u32.html#method.checked_rem)
1825     #[rustc_const_unstable(feature = "const_int_unchecked_arith", issue = "none")]
1826     pub fn unchecked_rem<T: Copy>(x: T, y: T) -> T;
1827
1828     /// Performs an unchecked left shift, resulting in undefined behavior when
1829     /// y < 0 or y >= N, where N is the width of T in bits.
1830     ///
1831     /// Safe wrappers for this intrinsic are available on the integer
1832     /// primitives via the `checked_shl` method. For example,
1833     /// [`std::u32::checked_shl`](../../std/primitive.u32.html#method.checked_shl)
1834     #[rustc_const_stable(feature = "const_int_unchecked", since = "1.40.0")]
1835     pub fn unchecked_shl<T: Copy>(x: T, y: T) -> T;
1836     /// Performs an unchecked right shift, resulting in undefined behavior when
1837     /// y < 0 or y >= N, where N is the width of T in bits.
1838     ///
1839     /// Safe wrappers for this intrinsic are available on the integer
1840     /// primitives via the `checked_shr` method. For example,
1841     /// [`std::u32::checked_shr`](../../std/primitive.u32.html#method.checked_shr)
1842     #[rustc_const_stable(feature = "const_int_unchecked", since = "1.40.0")]
1843     pub fn unchecked_shr<T: Copy>(x: T, y: T) -> T;
1844
1845     /// Returns the result of an unchecked addition, resulting in
1846     /// undefined behavior when `x + y > T::MAX` or `x + y < T::MIN`.
1847     ///
1848     /// This intrinsic does not have a stable counterpart.
1849     #[rustc_const_unstable(feature = "const_int_unchecked_arith", issue = "none")]
1850     pub fn unchecked_add<T: Copy>(x: T, y: T) -> T;
1851
1852     /// Returns the result of an unchecked subtraction, resulting in
1853     /// undefined behavior when `x - y > T::MAX` or `x - y < T::MIN`.
1854     ///
1855     /// This intrinsic does not have a stable counterpart.
1856     #[rustc_const_unstable(feature = "const_int_unchecked_arith", issue = "none")]
1857     pub fn unchecked_sub<T: Copy>(x: T, y: T) -> T;
1858
1859     /// Returns the result of an unchecked multiplication, resulting in
1860     /// undefined behavior when `x * y > T::MAX` or `x * y < T::MIN`.
1861     ///
1862     /// This intrinsic does not have a stable counterpart.
1863     #[rustc_const_unstable(feature = "const_int_unchecked_arith", issue = "none")]
1864     pub fn unchecked_mul<T: Copy>(x: T, y: T) -> T;
1865
1866     /// Performs rotate left.
1867     ///
1868     /// The stabilized versions of this intrinsic are available on the integer
1869     /// primitives via the `rotate_left` method. For example,
1870     /// [`std::u32::rotate_left`](../../std/primitive.u32.html#method.rotate_left)
1871     #[rustc_const_stable(feature = "const_int_rotate", since = "1.40.0")]
1872     pub fn rotate_left<T: Copy>(x: T, y: T) -> T;
1873
1874     /// Performs rotate right.
1875     ///
1876     /// The stabilized versions of this intrinsic are available on the integer
1877     /// primitives via the `rotate_right` method. For example,
1878     /// [`std::u32::rotate_right`](../../std/primitive.u32.html#method.rotate_right)
1879     #[rustc_const_stable(feature = "const_int_rotate", since = "1.40.0")]
1880     pub fn rotate_right<T: Copy>(x: T, y: T) -> T;
1881
1882     /// Returns (a + b) mod 2<sup>N</sup>, where N is the width of T in bits.
1883     ///
1884     /// The stabilized versions of this intrinsic are available on the integer
1885     /// primitives via the `checked_add` method. For example,
1886     /// [`std::u32::checked_add`](../../std/primitive.u32.html#method.checked_add)
1887     #[rustc_const_stable(feature = "const_int_wrapping", since = "1.40.0")]
1888     pub fn wrapping_add<T: Copy>(a: T, b: T) -> T;
1889     /// Returns (a - b) mod 2<sup>N</sup>, where N is the width of T in bits.
1890     ///
1891     /// The stabilized versions of this intrinsic are available on the integer
1892     /// primitives via the `checked_sub` method. For example,
1893     /// [`std::u32::checked_sub`](../../std/primitive.u32.html#method.checked_sub)
1894     #[rustc_const_stable(feature = "const_int_wrapping", since = "1.40.0")]
1895     pub fn wrapping_sub<T: Copy>(a: T, b: T) -> T;
1896     /// Returns (a * b) mod 2<sup>N</sup>, where N is the width of T in bits.
1897     ///
1898     /// The stabilized versions of this intrinsic are available on the integer
1899     /// primitives via the `checked_mul` method. For example,
1900     /// [`std::u32::checked_mul`](../../std/primitive.u32.html#method.checked_mul)
1901     #[rustc_const_stable(feature = "const_int_wrapping", since = "1.40.0")]
1902     pub fn wrapping_mul<T: Copy>(a: T, b: T) -> T;
1903
1904     /// Computes `a + b`, while saturating at numeric bounds.
1905     ///
1906     /// The stabilized versions of this intrinsic are available on the integer
1907     /// primitives via the `saturating_add` method. For example,
1908     /// [`std::u32::saturating_add`](../../std/primitive.u32.html#method.saturating_add)
1909     #[rustc_const_stable(feature = "const_int_saturating", since = "1.40.0")]
1910     pub fn saturating_add<T: Copy>(a: T, b: T) -> T;
1911     /// Computes `a - b`, while saturating at numeric bounds.
1912     ///
1913     /// The stabilized versions of this intrinsic are available on the integer
1914     /// primitives via the `saturating_sub` method. For example,
1915     /// [`std::u32::saturating_sub`](../../std/primitive.u32.html#method.saturating_sub)
1916     #[rustc_const_stable(feature = "const_int_saturating", since = "1.40.0")]
1917     pub fn saturating_sub<T: Copy>(a: T, b: T) -> T;
1918
1919     /// Returns the value of the discriminant for the variant in 'v',
1920     /// cast to a `u64`; if `T` has no discriminant, returns 0.
1921     ///
1922     /// The stabilized version of this intrinsic is
1923     /// [`std::mem::discriminant`](../../std/mem/fn.discriminant.html)
1924     #[rustc_const_unstable(feature = "const_discriminant", issue = "69821")]
1925     pub fn discriminant_value<T>(v: &T) -> <T as DiscriminantKind>::Discriminant;
1926
1927     /// Returns the number of variants of the type `T` cast to a `usize`;
1928     /// if `T` has no variants, returns 0. Uninhabited variants will be counted.
1929     ///
1930     /// The to-be-stabilized version of this intrinsic is
1931     /// [`std::mem::variant_count`](../../std/mem/fn.variant_count.html)
1932     #[rustc_const_unstable(feature = "variant_count", issue = "73662")]
1933     pub fn variant_count<T>() -> usize;
1934
1935     /// Rust's "try catch" construct which invokes the function pointer `try_fn`
1936     /// with the data pointer `data`.
1937     ///
1938     /// The third argument is a function called if a panic occurs. This function
1939     /// takes the data pointer and a pointer to the target-specific exception
1940     /// object that was caught. For more information see the compiler's
1941     /// source as well as std's catch implementation.
1942     pub fn r#try(try_fn: fn(*mut u8), data: *mut u8, catch_fn: fn(*mut u8, *mut u8)) -> i32;
1943
1944     /// Emits a `!nontemporal` store according to LLVM (see their docs).
1945     /// Probably will never become stable.
1946     pub fn nontemporal_store<T>(ptr: *mut T, val: T);
1947
1948     /// See documentation of `<*const T>::offset_from` for details.
1949     #[rustc_const_unstable(feature = "const_ptr_offset_from", issue = "41079")]
1950     pub fn ptr_offset_from<T>(ptr: *const T, base: *const T) -> isize;
1951
1952     /// See documentation of `<*const T>::guaranteed_eq` for details.
1953     #[rustc_const_unstable(feature = "const_raw_ptr_comparison", issue = "53020")]
1954     pub fn ptr_guaranteed_eq<T>(ptr: *const T, other: *const T) -> bool;
1955
1956     /// See documentation of `<*const T>::guaranteed_ne` for details.
1957     #[rustc_const_unstable(feature = "const_raw_ptr_comparison", issue = "53020")]
1958     pub fn ptr_guaranteed_ne<T>(ptr: *const T, other: *const T) -> bool;
1959 }
1960
1961 // Some functions are defined here because they accidentally got made
1962 // available in this module on stable. See <https://github.com/rust-lang/rust/issues/15702>.
1963 // (`transmute` also falls into this category, but it cannot be wrapped due to the
1964 // check that `T` and `U` have the same size.)
1965
1966 /// Checks whether `ptr` is properly aligned with respect to
1967 /// `align_of::<T>()`.
1968 pub(crate) fn is_aligned_and_not_null<T>(ptr: *const T) -> bool {
1969     !ptr.is_null() && ptr as usize % mem::align_of::<T>() == 0
1970 }
1971
1972 /// Checks whether the regions of memory starting at `src` and `dst` of size
1973 /// `count * size_of::<T>()` do *not* overlap.
1974 pub(crate) fn is_nonoverlapping<T>(src: *const T, dst: *const T, count: usize) -> bool {
1975     let src_usize = src as usize;
1976     let dst_usize = dst as usize;
1977     let size = mem::size_of::<T>().checked_mul(count).unwrap();
1978     let diff = if src_usize > dst_usize { src_usize - dst_usize } else { dst_usize - src_usize };
1979     // If the absolute distance between the ptrs is at least as big as the size of the buffer,
1980     // they do not overlap.
1981     diff >= size
1982 }
1983
1984 /// Copies `count * size_of::<T>()` bytes from `src` to `dst`. The source
1985 /// and destination must *not* overlap.
1986 ///
1987 /// For regions of memory which might overlap, use [`copy`] instead.
1988 ///
1989 /// `copy_nonoverlapping` is semantically equivalent to C's [`memcpy`], but
1990 /// with the argument order swapped.
1991 ///
1992 /// [`copy`]: ./fn.copy.html
1993 /// [`memcpy`]: https://en.cppreference.com/w/c/string/byte/memcpy
1994 ///
1995 /// # Safety
1996 ///
1997 /// Behavior is undefined if any of the following conditions are violated:
1998 ///
1999 /// * `src` must be [valid] for reads of `count * size_of::<T>()` bytes.
2000 ///
2001 /// * `dst` must be [valid] for writes of `count * size_of::<T>()` bytes.
2002 ///
2003 /// * Both `src` and `dst` must be properly aligned.
2004 ///
2005 /// * The region of memory beginning at `src` with a size of `count *
2006 ///   size_of::<T>()` bytes must *not* overlap with the region of memory
2007 ///   beginning at `dst` with the same size.
2008 ///
2009 /// Like [`read`], `copy_nonoverlapping` creates a bitwise copy of `T`, regardless of
2010 /// whether `T` is [`Copy`]. If `T` is not [`Copy`], using *both* the values
2011 /// in the region beginning at `*src` and the region beginning at `*dst` can
2012 /// [violate memory safety][read-ownership].
2013 ///
2014 /// Note that even if the effectively copied size (`count * size_of::<T>()`) is
2015 /// `0`, the pointers must be non-NULL and properly aligned.
2016 ///
2017 /// [`Copy`]: ../marker/trait.Copy.html
2018 /// [`read`]: ../ptr/fn.read.html
2019 /// [read-ownership]: ../ptr/fn.read.html#ownership-of-the-returned-value
2020 /// [valid]: ../ptr/index.html#safety
2021 ///
2022 /// # Examples
2023 ///
2024 /// Manually implement [`Vec::append`]:
2025 ///
2026 /// ```
2027 /// use std::ptr;
2028 ///
2029 /// /// Moves all the elements of `src` into `dst`, leaving `src` empty.
2030 /// fn append<T>(dst: &mut Vec<T>, src: &mut Vec<T>) {
2031 ///     let src_len = src.len();
2032 ///     let dst_len = dst.len();
2033 ///
2034 ///     // Ensure that `dst` has enough capacity to hold all of `src`.
2035 ///     dst.reserve(src_len);
2036 ///
2037 ///     unsafe {
2038 ///         // The call to offset is always safe because `Vec` will never
2039 ///         // allocate more than `isize::MAX` bytes.
2040 ///         let dst_ptr = dst.as_mut_ptr().offset(dst_len as isize);
2041 ///         let src_ptr = src.as_ptr();
2042 ///
2043 ///         // Truncate `src` without dropping its contents. We do this first,
2044 ///         // to avoid problems in case something further down panics.
2045 ///         src.set_len(0);
2046 ///
2047 ///         // The two regions cannot overlap because mutable references do
2048 ///         // not alias, and two different vectors cannot own the same
2049 ///         // memory.
2050 ///         ptr::copy_nonoverlapping(src_ptr, dst_ptr, src_len);
2051 ///
2052 ///         // Notify `dst` that it now holds the contents of `src`.
2053 ///         dst.set_len(dst_len + src_len);
2054 ///     }
2055 /// }
2056 ///
2057 /// let mut a = vec!['r'];
2058 /// let mut b = vec!['u', 's', 't'];
2059 ///
2060 /// append(&mut a, &mut b);
2061 ///
2062 /// assert_eq!(a, &['r', 'u', 's', 't']);
2063 /// assert!(b.is_empty());
2064 /// ```
2065 ///
2066 /// [`Vec::append`]: ../../std/vec/struct.Vec.html#method.append
2067 #[doc(alias = "memcpy")]
2068 #[stable(feature = "rust1", since = "1.0.0")]
2069 #[inline]
2070 pub unsafe fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: usize) {
2071     extern "rust-intrinsic" {
2072         fn copy_nonoverlapping<T>(src: *const T, dst: *mut T, count: usize);
2073     }
2074
2075     if cfg!(debug_assertions)
2076         && !(is_aligned_and_not_null(src)
2077             && is_aligned_and_not_null(dst)
2078             && is_nonoverlapping(src, dst, count))
2079     {
2080         // Not panicking to keep codegen impact smaller.
2081         abort();
2082     }
2083
2084     // SAFETY: the safety contract for `copy_nonoverlapping` must be
2085     // upheld by the caller.
2086     unsafe { copy_nonoverlapping(src, dst, count) }
2087 }
2088
2089 /// Copies `count * size_of::<T>()` bytes from `src` to `dst`. The source
2090 /// and destination may overlap.
2091 ///
2092 /// If the source and destination will *never* overlap,
2093 /// [`copy_nonoverlapping`] can be used instead.
2094 ///
2095 /// `copy` is semantically equivalent to C's [`memmove`], but with the argument
2096 /// order swapped. Copying takes place as if the bytes were copied from `src`
2097 /// to a temporary array and then copied from the array to `dst`.
2098 ///
2099 /// [`copy_nonoverlapping`]: ./fn.copy_nonoverlapping.html
2100 /// [`memmove`]: https://en.cppreference.com/w/c/string/byte/memmove
2101 ///
2102 /// # Safety
2103 ///
2104 /// Behavior is undefined if any of the following conditions are violated:
2105 ///
2106 /// * `src` must be [valid] for reads of `count * size_of::<T>()` bytes.
2107 ///
2108 /// * `dst` must be [valid] for writes of `count * size_of::<T>()` bytes.
2109 ///
2110 /// * Both `src` and `dst` must be properly aligned.
2111 ///
2112 /// Like [`read`], `copy` creates a bitwise copy of `T`, regardless of
2113 /// whether `T` is [`Copy`]. If `T` is not [`Copy`], using both the values
2114 /// in the region beginning at `*src` and the region beginning at `*dst` can
2115 /// [violate memory safety][read-ownership].
2116 ///
2117 /// Note that even if the effectively copied size (`count * size_of::<T>()`) is
2118 /// `0`, the pointers must be non-NULL and properly aligned.
2119 ///
2120 /// [`Copy`]: ../marker/trait.Copy.html
2121 /// [`read`]: ../ptr/fn.read.html
2122 /// [read-ownership]: ../ptr/fn.read.html#ownership-of-the-returned-value
2123 /// [valid]: ../ptr/index.html#safety
2124 ///
2125 /// # Examples
2126 ///
2127 /// Efficiently create a Rust vector from an unsafe buffer:
2128 ///
2129 /// ```
2130 /// use std::ptr;
2131 ///
2132 /// # #[allow(dead_code)]
2133 /// unsafe fn from_buf_raw<T>(ptr: *const T, elts: usize) -> Vec<T> {
2134 ///     let mut dst = Vec::with_capacity(elts);
2135 ///     dst.set_len(elts);
2136 ///     ptr::copy(ptr, dst.as_mut_ptr(), elts);
2137 ///     dst
2138 /// }
2139 /// ```
2140 #[doc(alias = "memmove")]
2141 #[stable(feature = "rust1", since = "1.0.0")]
2142 #[inline]
2143 pub unsafe fn copy<T>(src: *const T, dst: *mut T, count: usize) {
2144     extern "rust-intrinsic" {
2145         fn copy<T>(src: *const T, dst: *mut T, count: usize);
2146     }
2147
2148     if cfg!(debug_assertions) && !(is_aligned_and_not_null(src) && is_aligned_and_not_null(dst)) {
2149         // Not panicking to keep codegen impact smaller.
2150         abort();
2151     }
2152
2153     // SAFETY: the safety contract for `copy` must be upheld by the caller.
2154     unsafe { copy(src, dst, count) }
2155 }
2156
2157 /// Sets `count * size_of::<T>()` bytes of memory starting at `dst` to
2158 /// `val`.
2159 ///
2160 /// `write_bytes` is similar to C's [`memset`], but sets `count *
2161 /// size_of::<T>()` bytes to `val`.
2162 ///
2163 /// [`memset`]: https://en.cppreference.com/w/c/string/byte/memset
2164 ///
2165 /// # Safety
2166 ///
2167 /// Behavior is undefined if any of the following conditions are violated:
2168 ///
2169 /// * `dst` must be [valid] for writes of `count * size_of::<T>()` bytes.
2170 ///
2171 /// * `dst` must be properly aligned.
2172 ///
2173 /// Additionally, the caller must ensure that writing `count *
2174 /// size_of::<T>()` bytes to the given region of memory results in a valid
2175 /// value of `T`. Using a region of memory typed as a `T` that contains an
2176 /// invalid value of `T` is undefined behavior.
2177 ///
2178 /// Note that even if the effectively copied size (`count * size_of::<T>()`) is
2179 /// `0`, the pointer must be non-NULL and properly aligned.
2180 ///
2181 /// [valid]: ../ptr/index.html#safety
2182 ///
2183 /// # Examples
2184 ///
2185 /// Basic usage:
2186 ///
2187 /// ```
2188 /// use std::ptr;
2189 ///
2190 /// let mut vec = vec![0u32; 4];
2191 /// unsafe {
2192 ///     let vec_ptr = vec.as_mut_ptr();
2193 ///     ptr::write_bytes(vec_ptr, 0xfe, 2);
2194 /// }
2195 /// assert_eq!(vec, [0xfefefefe, 0xfefefefe, 0, 0]);
2196 /// ```
2197 ///
2198 /// Creating an invalid value:
2199 ///
2200 /// ```
2201 /// use std::ptr;
2202 ///
2203 /// let mut v = Box::new(0i32);
2204 ///
2205 /// unsafe {
2206 ///     // Leaks the previously held value by overwriting the `Box<T>` with
2207 ///     // a null pointer.
2208 ///     ptr::write_bytes(&mut v as *mut Box<i32>, 0, 1);
2209 /// }
2210 ///
2211 /// // At this point, using or dropping `v` results in undefined behavior.
2212 /// // drop(v); // ERROR
2213 ///
2214 /// // Even leaking `v` "uses" it, and hence is undefined behavior.
2215 /// // mem::forget(v); // ERROR
2216 ///
2217 /// // In fact, `v` is invalid according to basic type layout invariants, so *any*
2218 /// // operation touching it is undefined behavior.
2219 /// // let v2 = v; // ERROR
2220 ///
2221 /// unsafe {
2222 ///     // Let us instead put in a valid value
2223 ///     ptr::write(&mut v as *mut Box<i32>, Box::new(42i32));
2224 /// }
2225 ///
2226 /// // Now the box is fine
2227 /// assert_eq!(*v, 42);
2228 /// ```
2229 #[stable(feature = "rust1", since = "1.0.0")]
2230 #[inline]
2231 pub unsafe fn write_bytes<T>(dst: *mut T, val: u8, count: usize) {
2232     extern "rust-intrinsic" {
2233         fn write_bytes<T>(dst: *mut T, val: u8, count: usize);
2234     }
2235
2236     debug_assert!(is_aligned_and_not_null(dst), "attempt to write to unaligned or null pointer");
2237
2238     // SAFETY: the safety contract for `write_bytes` must be upheld by the caller.
2239     unsafe { write_bytes(dst, val, count) }
2240 }