Skip to content

Provide more atomic ops #48

@taiki-e

Description

@taiki-e

The following are the atomic operations supported by the x86 lock prefix.

ADD, ADC, AND, BTC, BTR, BTS, CMPXCHG, CMPXCH8B, CMPXCHG16B, DEC, INC, NEG, NOT, OR, SBB, SUB, XOR, XADD, and XCHG.

We currently do not provide corresponding operations for BTC, BTR, BTS, NEG, and NOT. 1 2

NEG and NOT don't return the previous value, but can be provided in a way like #47.

Footnotes

  1. To be exact, BTC, BTR, and BTS are available via other operations on Rust 1.65+, but LLVM only generates lock bt{s,r,c} for immediate bit offsets (as of LLVM 15). EDIT: see https://github.com/taiki-e/portable-atomic/issues/48#issuecomment-1453473831

  2. As for NOT, an equivalent is available via fetch_xor(-1i*)/fetch_xor(u*::MAX), though, LLVM does not lower it to lock not.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-enhancementCategory: A new feature or an improvement for an existing one

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions