Skip to content

Add add/sub/and/or/xor methods that do not return previous value#47

Merged
bors[bot] merged 1 commit intomainfrom
no-fetch
Dec 9, 2022
Merged

Add add/sub/and/or/xor methods that do not return previous value#47
bors[bot] merged 1 commit intomainfrom
no-fetch

Conversation

@taiki-e
Copy link
Copy Markdown
Owner

@taiki-e taiki-e commented Dec 4, 2022

This adds Atomic{I,U}*::{add,sub,and,or,xor} and AtomicBool::{and,or,xor} methods.

They are equivalent to the corresponding fetch_* methods, but do not return the previous value. They are intended for optimization on platforms that implement atomics using inline assembly, such as the MSP430.

Currently, optimizations by these methods (add,sub,and,or,xor) are only guaranteed for MSP430; on x86, LLVM can optimize in most cases, so cases, where this would improve things, should be rare.

See pftbest/msp430-atomic#7 for the context.
cc @cr1901 @YuhanLiin

@taiki-e taiki-e added the O-msp430 Target: MSP430 label Dec 4, 2022
@taiki-e taiki-e mentioned this pull request Dec 4, 2022
5 tasks
@cr1901
Copy link
Copy Markdown

cr1901 commented Dec 4, 2022

Look great to me. @YuhanLiin, if this works for you, I'll release msp430-atomic v0.1.5 with a deprecation notice (yea, sorry about that :P). With this commit, msp430-atomic should be a proper subset of portable-atomic.

}
}

doc_comment! {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use triple slashes for this comment?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we want to stringify a macro metavariable using stringify!, we need to use the #[doc] attribute and string literal instead of the usual doc comment. In recent compilers (1.54+), #[doc = concat!(...)] also works, but in older compilers, a macro like this needs to be used.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense

@YuhanLiin
Copy link
Copy Markdown

Yeah everything looks good to me.

@taiki-e
Copy link
Copy Markdown
Owner Author

taiki-e commented Dec 9, 2022

Thanks both of you for the review!

bors r+

bors bot added a commit that referenced this pull request Dec 9, 2022
47: Add add/sub/and/or/xor methods that do not return previous value r=taiki-e a=taiki-e

This adds `Atomic{I,U}*::{add,sub,and,or,xor}` and `AtomicBool::{and,or,xor}` methods.

They are equivalent to the corresponding `fetch_*` methods, but do not return the previous value. They are intended for optimization on platforms that implement atomics using inline assembly, such as the MSP430.

Currently, optimizations by these methods (add,sub,and,or,xor) are only guaranteed for MSP430; on x86, LLVM can optimize in most cases, so cases, where this would improve things, should be rare.

See pftbest/msp430-atomic#7 for the context.
cc `@cr1901` `@YuhanLiin` 

Co-authored-by: Taiki Endo <te316e89@gmail.com>
@bors
Copy link
Copy Markdown
Contributor

bors bot commented Dec 9, 2022

Timed out.

@taiki-e
Copy link
Copy Markdown
Owner Author

taiki-e commented Dec 9, 2022

bors retry

@bors
Copy link
Copy Markdown
Contributor

bors bot commented Dec 9, 2022

@bors bors bot merged commit 6eac1c5 into main Dec 9, 2022
@bors bors bot deleted the no-fetch branch December 9, 2022 15:51
@taiki-e
Copy link
Copy Markdown
Owner Author

taiki-e commented Dec 9, 2022

Published in 0.3.16.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

O-msp430 Target: MSP430

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants