Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use core atomic types instead of intrinsics on non-MSP430 targets #6

Merged
merged 1 commit into from
Aug 12, 2022

Conversation

taiki-e
Copy link
Contributor

@taiki-e taiki-e commented Aug 5, 2022

Since rust-lang/rust#97423, build on non-MSP430 targets is failing.

log
error[E0425]: cannot find function `atomic_load` in module `core::intrinsics`
   --> src/lib.rs:684:37
    |
684 |                   ::core::intrinsics::atomic_load(dst)
    |                                       ^^^^^^^^^^^ not found in `core::intrinsics`
...
720 | / atomic_int! {
721 | |     i8 AtomicI8 ATOMIC_I8_INIT ".b"
722 | | }
    | |_- in this macro invocation
    |
    = note: this error originates in the macro `atomic_int` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0425]: cannot find function `atomic_xadd` in module `core::intrinsics`
   --> src/lib.rs:689:37
    |
689 |                   ::core::intrinsics::atomic_xadd(dst, val);
    |                                       ^^^^^^^^^^^ not found in `core::intrinsics`
...
720 | / atomic_int! {
721 | |     i8 AtomicI8 ATOMIC_I8_INIT ".b"
722 | | }
    | |_- in this macro invocation
    |
    = note: this error originates in the macro `atomic_int` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0425]: cannot find function `atomic_xsub` in module `core::intrinsics`
   --> src/lib.rs:694:37
    |
694 |                   ::core::intrinsics::atomic_xsub(dst, val);
    |                                       ^^^^^^^^^^^ not found in `core::intrinsics`
...
720 | / atomic_int! {
721 | |     i8 AtomicI8 ATOMIC_I8_INIT ".b"
722 | | }
    | |_- in this macro invocation
    |
    = note: this error originates in the macro `atomic_int` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0425]: cannot find function `atomic_and` in module `core::intrinsics`
   --> src/lib.rs:699:37
    |
699 |                   ::core::intrinsics::atomic_and(dst, val);
    |                                       ^^^^^^^^^^ not found in `core::intrinsics`
...
720 | / atomic_int! {
721 | |     i8 AtomicI8 ATOMIC_I8_INIT ".b"
722 | | }
    | |_- in this macro invocation
    |
    = note: this error originates in the macro `atomic_int` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0425]: cannot find function `atomic_and` in module `core::intrinsics`
   --> src/lib.rs:704:37
    |
704 |                   ::core::intrinsics::atomic_and(dst, !val);
    |                                       ^^^^^^^^^^ not found in `core::intrinsics`
...
720 | / atomic_int! {
721 | |     i8 AtomicI8 ATOMIC_I8_INIT ".b"
722 | | }
    | |_- in this macro invocation
    |
    = note: this error originates in the macro `atomic_int` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0425]: cannot find function `atomic_or` in module `core::intrinsics`
   --> src/lib.rs:709:37
    |
709 |                   ::core::intrinsics::atomic_or(dst, val);
    |                                       ^^^^^^^^^ help: a function with a similar name exists: `atomic_store`
...
720 | / atomic_int! {
721 | |     i8 AtomicI8 ATOMIC_I8_INIT ".b"
722 | | }
    | |_- in this macro invocation
    |
   ::: /Users/taiki/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/intrinsics.rs:523:5
    |
523 |       pub fn atomic_store_seqcst<T: Copy>(dst: *mut T, val: T);
    |       -------------------------------------------------------- similarly named function `atomic_store` defined here
    |
    = note: this error originates in the macro `atomic_int` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0425]: cannot find function `atomic_xor` in module `core::intrinsics`
   --> src/lib.rs:714:37
    |
714 |                   ::core::intrinsics::atomic_xor(dst, val);
    |                                       ^^^^^^^^^^ help: a function with a similar name exists: `atomic_store`
...
720 | / atomic_int! {
721 | |     i8 AtomicI8 ATOMIC_I8_INIT ".b"
722 | | }
    | |_- in this macro invocation
    |
   ::: /Users/taiki/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/intrinsics.rs:523:5
    |
523 |       pub fn atomic_store_seqcst<T: Copy>(dst: *mut T, val: T);
    |       -------------------------------------------------------- similarly named function `atomic_store` defined here
    |
    = note: this error originates in the macro `atomic_int` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0425]: cannot find function `atomic_load` in module `core::intrinsics`
   --> src/lib.rs:684:37
    |
684 |                   ::core::intrinsics::atomic_load(dst)
    |                                       ^^^^^^^^^^^ not found in `core::intrinsics`
...
724 | / atomic_int! {
725 | |     u8 AtomicU8 ATOMIC_U8_INIT ".b"
726 | | }
    | |_- in this macro invocation
    |
    = note: this error originates in the macro `atomic_int` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0425]: cannot find function `atomic_xadd` in module `core::intrinsics`
   --> src/lib.rs:689:37
    |
689 |                   ::core::intrinsics::atomic_xadd(dst, val);
    |                                       ^^^^^^^^^^^ not found in `core::intrinsics`
...
724 | / atomic_int! {
725 | |     u8 AtomicU8 ATOMIC_U8_INIT ".b"
726 | | }
    | |_- in this macro invocation
    |
    = note: this error originates in the macro `atomic_int` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0425]: cannot find function `atomic_xsub` in module `core::intrinsics`
   --> src/lib.rs:694:37
    |
694 |                   ::core::intrinsics::atomic_xsub(dst, val);
    |                                       ^^^^^^^^^^^ not found in `core::intrinsics`
...
724 | / atomic_int! {
725 | |     u8 AtomicU8 ATOMIC_U8_INIT ".b"
726 | | }
    | |_- in this macro invocation
    |
    = note: this error originates in the macro `atomic_int` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0425]: cannot find function `atomic_and` in module `core::intrinsics`
   --> src/lib.rs:699:37
    |
699 |                   ::core::intrinsics::atomic_and(dst, val);
    |                                       ^^^^^^^^^^ not found in `core::intrinsics`
...
724 | / atomic_int! {
725 | |     u8 AtomicU8 ATOMIC_U8_INIT ".b"
726 | | }
    | |_- in this macro invocation
    |
    = note: this error originates in the macro `atomic_int` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0425]: cannot find function `atomic_and` in module `core::intrinsics`
   --> src/lib.rs:704:37
    |
704 |                   ::core::intrinsics::atomic_and(dst, !val);
    |                                       ^^^^^^^^^^ not found in `core::intrinsics`
...
724 | / atomic_int! {
725 | |     u8 AtomicU8 ATOMIC_U8_INIT ".b"
726 | | }
    | |_- in this macro invocation
    |
    = note: this error originates in the macro `atomic_int` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0425]: cannot find function `atomic_or` in module `core::intrinsics`
   --> src/lib.rs:709:37
    |
709 |                   ::core::intrinsics::atomic_or(dst, val);
    |                                       ^^^^^^^^^ help: a function with a similar name exists: `atomic_store`
...
724 | / atomic_int! {
725 | |     u8 AtomicU8 ATOMIC_U8_INIT ".b"
726 | | }
    | |_- in this macro invocation
    |
   ::: /Users/taiki/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/intrinsics.rs:523:5
    |
523 |       pub fn atomic_store_seqcst<T: Copy>(dst: *mut T, val: T);
    |       -------------------------------------------------------- similarly named function `atomic_store` defined here
    |
    = note: this error originates in the macro `atomic_int` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0425]: cannot find function `atomic_xor` in module `core::intrinsics`
   --> src/lib.rs:714:37
    |
714 |                   ::core::intrinsics::atomic_xor(dst, val);
    |                                       ^^^^^^^^^^ help: a function with a similar name exists: `atomic_store`
...
724 | / atomic_int! {
725 | |     u8 AtomicU8 ATOMIC_U8_INIT ".b"
726 | | }
    | |_- in this macro invocation
    |
   ::: /Users/taiki/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/intrinsics.rs:523:5
    |
523 |       pub fn atomic_store_seqcst<T: Copy>(dst: *mut T, val: T);
    |       -------------------------------------------------------- similarly named function `atomic_store` defined here
    |
    = note: this error originates in the macro `atomic_int` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0425]: cannot find function `atomic_load` in module `core::intrinsics`
   --> src/lib.rs:684:37
    |
684 |                   ::core::intrinsics::atomic_load(dst)
    |                                       ^^^^^^^^^^^ not found in `core::intrinsics`
...
728 | / atomic_int! {
729 | |     i16 AtomicI16 ATOMIC_I16_INIT ".w"
730 | | }
    | |_- in this macro invocation
    |
    = note: this error originates in the macro `atomic_int` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0425]: cannot find function `atomic_xadd` in module `core::intrinsics`
   --> src/lib.rs:689:37
    |
689 |                   ::core::intrinsics::atomic_xadd(dst, val);
    |                                       ^^^^^^^^^^^ not found in `core::intrinsics`
...
728 | / atomic_int! {
729 | |     i16 AtomicI16 ATOMIC_I16_INIT ".w"
730 | | }
    | |_- in this macro invocation
    |
    = note: this error originates in the macro `atomic_int` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0425]: cannot find function `atomic_xsub` in module `core::intrinsics`
   --> src/lib.rs:694:37
    |
694 |                   ::core::intrinsics::atomic_xsub(dst, val);
    |                                       ^^^^^^^^^^^ not found in `core::intrinsics`
...
728 | / atomic_int! {
729 | |     i16 AtomicI16 ATOMIC_I16_INIT ".w"
730 | | }
    | |_- in this macro invocation
    |
    = note: this error originates in the macro `atomic_int` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0425]: cannot find function `atomic_and` in module `core::intrinsics`
   --> src/lib.rs:699:37
    |
699 |                   ::core::intrinsics::atomic_and(dst, val);
    |                                       ^^^^^^^^^^ not found in `core::intrinsics`
...
728 | / atomic_int! {
729 | |     i16 AtomicI16 ATOMIC_I16_INIT ".w"
730 | | }
    | |_- in this macro invocation
    |
    = note: this error originates in the macro `atomic_int` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0425]: cannot find function `atomic_and` in module `core::intrinsics`
   --> src/lib.rs:704:37
    |
704 |                   ::core::intrinsics::atomic_and(dst, !val);
    |                                       ^^^^^^^^^^ not found in `core::intrinsics`
...
728 | / atomic_int! {
729 | |     i16 AtomicI16 ATOMIC_I16_INIT ".w"
730 | | }
    | |_- in this macro invocation
    |
    = note: this error originates in the macro `atomic_int` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0425]: cannot find function `atomic_or` in module `core::intrinsics`
   --> src/lib.rs:709:37
    |
709 |                   ::core::intrinsics::atomic_or(dst, val);
    |                                       ^^^^^^^^^ help: a function with a similar name exists: `atomic_store`
...
728 | / atomic_int! {
729 | |     i16 AtomicI16 ATOMIC_I16_INIT ".w"
730 | | }
    | |_- in this macro invocation
    |
   ::: /Users/taiki/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/intrinsics.rs:523:5
    |
523 |       pub fn atomic_store_seqcst<T: Copy>(dst: *mut T, val: T);
    |       -------------------------------------------------------- similarly named function `atomic_store` defined here
    |
    = note: this error originates in the macro `atomic_int` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0425]: cannot find function `atomic_xor` in module `core::intrinsics`
   --> src/lib.rs:714:37
    |
714 |                   ::core::intrinsics::atomic_xor(dst, val);
    |                                       ^^^^^^^^^^ help: a function with a similar name exists: `atomic_store`
...
728 | / atomic_int! {
729 | |     i16 AtomicI16 ATOMIC_I16_INIT ".w"
730 | | }
    | |_- in this macro invocation
    |
   ::: /Users/taiki/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/intrinsics.rs:523:5
    |
523 |       pub fn atomic_store_seqcst<T: Copy>(dst: *mut T, val: T);
    |       -------------------------------------------------------- similarly named function `atomic_store` defined here
    |
    = note: this error originates in the macro `atomic_int` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0425]: cannot find function `atomic_load` in module `core::intrinsics`
   --> src/lib.rs:684:37
    |
684 |                   ::core::intrinsics::atomic_load(dst)
    |                                       ^^^^^^^^^^^ not found in `core::intrinsics`
...
732 | / atomic_int! {
733 | |     u16 AtomicU16 ATOMIC_U16_INIT ".w"
734 | | }
    | |_- in this macro invocation
    |
    = note: this error originates in the macro `atomic_int` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0425]: cannot find function `atomic_xadd` in module `core::intrinsics`
   --> src/lib.rs:689:37
    |
689 |                   ::core::intrinsics::atomic_xadd(dst, val);
    |                                       ^^^^^^^^^^^ not found in `core::intrinsics`
...
732 | / atomic_int! {
733 | |     u16 AtomicU16 ATOMIC_U16_INIT ".w"
734 | | }
    | |_- in this macro invocation
    |
    = note: this error originates in the macro `atomic_int` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0425]: cannot find function `atomic_xsub` in module `core::intrinsics`
   --> src/lib.rs:694:37
    |
694 |                   ::core::intrinsics::atomic_xsub(dst, val);
    |                                       ^^^^^^^^^^^ not found in `core::intrinsics`
...
732 | / atomic_int! {
733 | |     u16 AtomicU16 ATOMIC_U16_INIT ".w"
734 | | }
    | |_- in this macro invocation
    |
    = note: this error originates in the macro `atomic_int` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0425]: cannot find function `atomic_and` in module `core::intrinsics`
   --> src/lib.rs:699:37
    |
699 |                   ::core::intrinsics::atomic_and(dst, val);
    |                                       ^^^^^^^^^^ not found in `core::intrinsics`
...
732 | / atomic_int! {
733 | |     u16 AtomicU16 ATOMIC_U16_INIT ".w"
734 | | }
    | |_- in this macro invocation
    |
    = note: this error originates in the macro `atomic_int` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0425]: cannot find function `atomic_and` in module `core::intrinsics`
   --> src/lib.rs:704:37
    |
704 |                   ::core::intrinsics::atomic_and(dst, !val);
    |                                       ^^^^^^^^^^ not found in `core::intrinsics`
...
732 | / atomic_int! {
733 | |     u16 AtomicU16 ATOMIC_U16_INIT ".w"
734 | | }
    | |_- in this macro invocation
    |
    = note: this error originates in the macro `atomic_int` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0425]: cannot find function `atomic_or` in module `core::intrinsics`
   --> src/lib.rs:709:37
    |
709 |                   ::core::intrinsics::atomic_or(dst, val);
    |                                       ^^^^^^^^^ help: a function with a similar name exists: `atomic_store`
...
732 | / atomic_int! {
733 | |     u16 AtomicU16 ATOMIC_U16_INIT ".w"
734 | | }
    | |_- in this macro invocation
    |
   ::: /Users/taiki/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/intrinsics.rs:523:5
    |
523 |       pub fn atomic_store_seqcst<T: Copy>(dst: *mut T, val: T);
    |       -------------------------------------------------------- similarly named function `atomic_store` defined here
    |
    = note: this error originates in the macro `atomic_int` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0425]: cannot find function `atomic_xor` in module `core::intrinsics`
   --> src/lib.rs:714:37
    |
714 |                   ::core::intrinsics::atomic_xor(dst, val);
    |                                       ^^^^^^^^^^ help: a function with a similar name exists: `atomic_store`
...
732 | / atomic_int! {
733 | |     u16 AtomicU16 ATOMIC_U16_INIT ".w"
734 | | }
    | |_- in this macro invocation
    |
   ::: /Users/taiki/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/intrinsics.rs:523:5
    |
523 |       pub fn atomic_store_seqcst<T: Copy>(dst: *mut T, val: T);
    |       -------------------------------------------------------- similarly named function `atomic_store` defined here
    |
    = note: this error originates in the macro `atomic_int` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0425]: cannot find function `atomic_load` in module `core::intrinsics`
   --> src/lib.rs:684:37
    |
684 |                   ::core::intrinsics::atomic_load(dst)
    |                                       ^^^^^^^^^^^ not found in `core::intrinsics`
...
736 | / atomic_int! {
737 | |     isize AtomicIsize ATOMIC_ISIZE_INIT ".w"
738 | | }
    | |_- in this macro invocation
    |
    = note: this error originates in the macro `atomic_int` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0425]: cannot find function `atomic_xadd` in module `core::intrinsics`
   --> src/lib.rs:689:37
    |
689 |                   ::core::intrinsics::atomic_xadd(dst, val);
    |                                       ^^^^^^^^^^^ not found in `core::intrinsics`
...
736 | / atomic_int! {
737 | |     isize AtomicIsize ATOMIC_ISIZE_INIT ".w"
738 | | }
    | |_- in this macro invocation
    |
    = note: this error originates in the macro `atomic_int` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0425]: cannot find function `atomic_xsub` in module `core::intrinsics`
   --> src/lib.rs:694:37
    |
694 |                   ::core::intrinsics::atomic_xsub(dst, val);
    |                                       ^^^^^^^^^^^ not found in `core::intrinsics`
...
736 | / atomic_int! {
737 | |     isize AtomicIsize ATOMIC_ISIZE_INIT ".w"
738 | | }
    | |_- in this macro invocation
    |
    = note: this error originates in the macro `atomic_int` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0425]: cannot find function `atomic_and` in module `core::intrinsics`
   --> src/lib.rs:699:37
    |
699 |                   ::core::intrinsics::atomic_and(dst, val);
    |                                       ^^^^^^^^^^ not found in `core::intrinsics`
...
736 | / atomic_int! {
737 | |     isize AtomicIsize ATOMIC_ISIZE_INIT ".w"
738 | | }
    | |_- in this macro invocation
    |
    = note: this error originates in the macro `atomic_int` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0425]: cannot find function `atomic_and` in module `core::intrinsics`
   --> src/lib.rs:704:37
    |
704 |                   ::core::intrinsics::atomic_and(dst, !val);
    |                                       ^^^^^^^^^^ not found in `core::intrinsics`
...
736 | / atomic_int! {
737 | |     isize AtomicIsize ATOMIC_ISIZE_INIT ".w"
738 | | }
    | |_- in this macro invocation
    |
    = note: this error originates in the macro `atomic_int` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0425]: cannot find function `atomic_or` in module `core::intrinsics`
   --> src/lib.rs:709:37
    |
709 |                   ::core::intrinsics::atomic_or(dst, val);
    |                                       ^^^^^^^^^ help: a function with a similar name exists: `atomic_store`
...
736 | / atomic_int! {
737 | |     isize AtomicIsize ATOMIC_ISIZE_INIT ".w"
738 | | }
    | |_- in this macro invocation
    |
   ::: /Users/taiki/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/intrinsics.rs:523:5
    |
523 |       pub fn atomic_store_seqcst<T: Copy>(dst: *mut T, val: T);
    |       -------------------------------------------------------- similarly named function `atomic_store` defined here
    |
    = note: this error originates in the macro `atomic_int` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0425]: cannot find function `atomic_xor` in module `core::intrinsics`
   --> src/lib.rs:714:37
    |
714 |                   ::core::intrinsics::atomic_xor(dst, val);
    |                                       ^^^^^^^^^^ help: a function with a similar name exists: `atomic_store`
...
736 | / atomic_int! {
737 | |     isize AtomicIsize ATOMIC_ISIZE_INIT ".w"
738 | | }
    | |_- in this macro invocation
    |
   ::: /Users/taiki/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/intrinsics.rs:523:5
    |
523 |       pub fn atomic_store_seqcst<T: Copy>(dst: *mut T, val: T);
    |       -------------------------------------------------------- similarly named function `atomic_store` defined here
    |
    = note: this error originates in the macro `atomic_int` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0425]: cannot find function `atomic_load` in module `core::intrinsics`
   --> src/lib.rs:684:37
    |
684 |                   ::core::intrinsics::atomic_load(dst)
    |                                       ^^^^^^^^^^^ not found in `core::intrinsics`
...
740 | / atomic_int! {
741 | |     usize AtomicUsize ATOMIC_USIZE_INIT ".w"
742 | | }
    | |_- in this macro invocation
    |
    = note: this error originates in the macro `atomic_int` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0425]: cannot find function `atomic_xadd` in module `core::intrinsics`
   --> src/lib.rs:689:37
    |
689 |                   ::core::intrinsics::atomic_xadd(dst, val);
    |                                       ^^^^^^^^^^^ not found in `core::intrinsics`
...
740 | / atomic_int! {
741 | |     usize AtomicUsize ATOMIC_USIZE_INIT ".w"
742 | | }
    | |_- in this macro invocation
    |
    = note: this error originates in the macro `atomic_int` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0425]: cannot find function `atomic_xsub` in module `core::intrinsics`
   --> src/lib.rs:694:37
    |
694 |                   ::core::intrinsics::atomic_xsub(dst, val);
    |                                       ^^^^^^^^^^^ not found in `core::intrinsics`
...
740 | / atomic_int! {
741 | |     usize AtomicUsize ATOMIC_USIZE_INIT ".w"
742 | | }
    | |_- in this macro invocation
    |
    = note: this error originates in the macro `atomic_int` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0425]: cannot find function `atomic_and` in module `core::intrinsics`
   --> src/lib.rs:699:37
    |
699 |                   ::core::intrinsics::atomic_and(dst, val);
    |                                       ^^^^^^^^^^ not found in `core::intrinsics`
...
740 | / atomic_int! {
741 | |     usize AtomicUsize ATOMIC_USIZE_INIT ".w"
742 | | }
    | |_- in this macro invocation
    |
    = note: this error originates in the macro `atomic_int` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0425]: cannot find function `atomic_and` in module `core::intrinsics`
   --> src/lib.rs:704:37
    |
704 |                   ::core::intrinsics::atomic_and(dst, !val);
    |                                       ^^^^^^^^^^ not found in `core::intrinsics`
...
740 | / atomic_int! {
741 | |     usize AtomicUsize ATOMIC_USIZE_INIT ".w"
742 | | }
    | |_- in this macro invocation
    |
    = note: this error originates in the macro `atomic_int` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0425]: cannot find function `atomic_or` in module `core::intrinsics`
   --> src/lib.rs:709:37
    |
709 |                   ::core::intrinsics::atomic_or(dst, val);
    |                                       ^^^^^^^^^ help: a function with a similar name exists: `atomic_store`
...
740 | / atomic_int! {
741 | |     usize AtomicUsize ATOMIC_USIZE_INIT ".w"
742 | | }
    | |_- in this macro invocation
    |
   ::: /Users/taiki/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/intrinsics.rs:523:5
    |
523 |       pub fn atomic_store_seqcst<T: Copy>(dst: *mut T, val: T);
    |       -------------------------------------------------------- similarly named function `atomic_store` defined here
    |
    = note: this error originates in the macro `atomic_int` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0425]: cannot find function `atomic_xor` in module `core::intrinsics`
   --> src/lib.rs:714:37
    |
714 |                   ::core::intrinsics::atomic_xor(dst, val);
    |                                       ^^^^^^^^^^ help: a function with a similar name exists: `atomic_store`
...
740 | / atomic_int! {
741 | |     usize AtomicUsize ATOMIC_USIZE_INIT ".w"
742 | | }
    | |_- in this macro invocation
    |
   ::: /Users/taiki/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/intrinsics.rs:523:5
    |
523 |       pub fn atomic_store_seqcst<T: Copy>(dst: *mut T, val: T);
    |       -------------------------------------------------------- similarly named function `atomic_store` defined here
    |
    = note: this error originates in the macro `atomic_int` (in Nightly builds, run with -Z macro-backtrace for more info)

@taiki-e
Copy link
Contributor Author

taiki-e commented Aug 5, 2022

Btw, an alternative idea is using core atomic types instead of intrinsics on non-MSP430 targets: taiki-e@a5512a9

@cr1901
Copy link
Collaborator

cr1901 commented Aug 5, 2022

I don't remember the rationale for making the API function names reflect the intrinsics rather than "the API provided by core::sync::atomic.

cc: @pftbest Do you object if the API is updated (in a breaking change) to reflect core::sync::atomic function names rather than core::intrinsics functions?

@pftbest
Copy link
Owner

pftbest commented Aug 6, 2022

Hello @cr1901, The idea of this crate was to keep public API exactly the same as in std to simply porting code written for another platforms. The internal implementation (ie intrinsics, inline asm, atomic types, etc) doesn't really matter as long as public API behaves as expected. I am ok with any internal changes to that effect.

@cr1901
Copy link
Collaborator

cr1901 commented Aug 9, 2022

@pftbest

The idea of this crate was to keep public API exactly the same as in std to simply porting code written for another platforms

I'm a little bit confused. Right now, the names in the public API of this crate reflect core::instrinics, not core::sync::atomic. I'm not sure if core::intrinsics is ever meant to be stabilized. Was this intentional at the time?

Additionally, msp430 RMW insns are not sufficient for implementing the return value part of the functions provided by core::sync::atomic, only the actual atomic operation. Actually returning the value in a register would require a second memory access. So this crate already didn't have the same API as core::sync::atomic or core::intrinsics.

@pftbest
Copy link
Owner

pftbest commented Aug 10, 2022

@cr1901 Sorry, I guess I did forget this part. You are right it's not possible to have a matching API. I'm not sure why I went with the intrinsics API at the time. Following intrinsics API doesn't really make sense because it's unstable by definition and it's not used in practice. Updating API to match core::sync::atomic looks like a better idea. Please go ahead.

@cr1901
Copy link
Collaborator

cr1901 commented Aug 12, 2022

Updating API to match core::sync::atomic looks like a better idea. Please go ahead.

@pftbest I will hold onto this as an alternate alternate idea. I think I want to deprecate this crate once fence/compiler_fence is actually working for MSP430 LLVM (it doesn't lower properly right now). EDIT: I don't think this is relevant to msp430 and we can deprecate whenever:

  • portable-atomic reuses the inline asm versions from this crate to provide msp430 1/8/16-bit load and store, and those implicitly introduce a SeqCst compiler fence (hardware fence is irrelevant for single core).
  • atomic-polyfill for everything- and portable-atomic for anything not in the previous bullet- uses critical sections, the beginning and end of which are implemented in inline asm and implicitly introduce SeqCst compiler fences around the closure that must run with interrupts disabled.

@taiki-e Do you mind if we use your alternate idea for this PR? I think short-to-medium term plans are to deprecate this crate and either use your portable-atomic crate (looks fine, although the scary --cfg option is not necessary for msp430- all msp430s are single-core) and/or add msp430 support to the atomic-polyfill crate (which rust-embedded seems to be using more).

bors bot added a commit to taiki-e/portable-atomic that referenced this pull request Aug 12, 2022
31: Always provide atomic CAS for MSP430 and AVR r=taiki-e a=taiki-e

This previously required unsafe cfg `portable_atomic_unsafe_assume_single_core`, but since all MSP430 and AVR are single-core, we can safely provide atomic CAS based on disabling interrupts.

Thanks `@cr1901` for pointing out this in pftbest/msp430-atomic#6 (comment).

Co-authored-by: Taiki Endo <te316e89@gmail.com>
@taiki-e
Copy link
Contributor Author

taiki-e commented Aug 12, 2022

@cr1901

Do you mind if we use your alternate idea for this PR?

Updated to use it.

I think short-to-medium term plans are to deprecate this crate and either use your portable-atomic crate (looks fine, although the scary --cfg option is not necessary for msp430- all msp430s are single-core) and/or add msp430 support to the atomic-polyfill crate (which rust-embedded seems to be using more).

Sounds good to me. For portable-atomic, I've updated it to remove the need for the unsafe cfg for msp430. (taiki-e/portable-atomic#31)

@taiki-e taiki-e changed the title Update to new atomic intrinsics names Use core atomic types instead of intrinsics on non-MSP430 targets Aug 12, 2022
@cr1901 cr1901 merged commit 73fce89 into pftbest:master Aug 12, 2022
@taiki-e taiki-e deleted the intrinsics branch August 12, 2022 15:45
@cr1901 cr1901 mentioned this pull request Oct 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants