]> git.proxmox.com Git - rustc.git/blame - src/test/run-make-fulldeps/atomic-lock-free/atomic_lock_free.rs
New upstream version 1.32.0~beta.2+dfsg1
[rustc.git] / src / test / run-make-fulldeps / atomic-lock-free / atomic_lock_free.rs
CommitLineData
a7813a04
XL
1// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2// file at the top-level directory of this distribution and at
3// http://rust-lang.org/COPYRIGHT.
4//
5// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8// option. This file may not be copied, modified, or distributed
9// except according to those terms.
10
11#![feature(cfg_target_has_atomic, no_core, intrinsics, lang_items)]
12#![crate_type="rlib"]
13#![no_core]
14
15extern "rust-intrinsic" {
16 fn atomic_xadd<T>(dst: *mut T, src: T) -> T;
17}
18
19#[lang = "sized"]
20trait Sized {}
3157f602
XL
21#[lang = "copy"]
22trait Copy {}
7cac9316
XL
23#[lang = "freeze"]
24trait Freeze {}
a7813a04 25
83c7162d
XL
26impl<T: ?Sized> Copy for *mut T {}
27
a7813a04
XL
28#[cfg(target_has_atomic = "8")]
29pub unsafe fn atomic_u8(x: *mut u8) {
30 atomic_xadd(x, 1);
31 atomic_xadd(x, 1);
32}
33#[cfg(target_has_atomic = "8")]
34pub unsafe fn atomic_i8(x: *mut i8) {
35 atomic_xadd(x, 1);
36}
37#[cfg(target_has_atomic = "16")]
38pub unsafe fn atomic_u16(x: *mut u16) {
39 atomic_xadd(x, 1);
40}
41#[cfg(target_has_atomic = "16")]
42pub unsafe fn atomic_i16(x: *mut i16) {
43 atomic_xadd(x, 1);
44}
45#[cfg(target_has_atomic = "32")]
46pub unsafe fn atomic_u32(x: *mut u32) {
47 atomic_xadd(x, 1);
48}
49#[cfg(target_has_atomic = "32")]
50pub unsafe fn atomic_i32(x: *mut i32) {
51 atomic_xadd(x, 1);
52}
53#[cfg(target_has_atomic = "64")]
54pub unsafe fn atomic_u64(x: *mut u64) {
55 atomic_xadd(x, 1);
56}
57#[cfg(target_has_atomic = "64")]
58pub unsafe fn atomic_i64(x: *mut i64) {
59 atomic_xadd(x, 1);
60}
a1dfa0c6
XL
61#[cfg(target_has_atomic = "128")]
62pub unsafe fn atomic_u128(x: *mut u128) {
63 atomic_xadd(x, 1);
64}
65#[cfg(target_has_atomic = "128")]
66pub unsafe fn atomic_i128(x: *mut i128) {
67 atomic_xadd(x, 1);
68}
a7813a04
XL
69#[cfg(target_has_atomic = "ptr")]
70pub unsafe fn atomic_usize(x: *mut usize) {
71 atomic_xadd(x, 1);
72}
73#[cfg(target_has_atomic = "ptr")]
74pub unsafe fn atomic_isize(x: *mut isize) {
75 atomic_xadd(x, 1);
76}