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

Support _Atomic #394

Open
Gnimuc opened this issue Nov 4, 2022 · 2 comments
Open

Support _Atomic #394

Gnimuc opened this issue Nov 4, 2022 · 2 comments
Labels
C11 help wanted Extra attention is needed

Comments

@Gnimuc
Copy link
Member

Gnimuc commented Nov 4, 2022

It looks like _Atomic can be supported by simply using the @atomic macro: https://docs.julialang.org/en/v1/manual/multi-threading/#man-atomics

Need to study the memory model carefully to make sure both Julia's representation and C/C++'s representation are compatible.

@Gnimuc Gnimuc added C11 help wanted Extra attention is needed labels Nov 4, 2022
@emmt
Copy link

emmt commented Feb 7, 2023

If you use the @atomic macro for some structure member, the structure must be mutable.

@emmt
Copy link

emmt commented Feb 7, 2023

I have just checked that using @atomic x::T in a (mutable) Julia structure seems to be a more correct replacement for C member defined as _Atomic T x; than declaring them as x::Threads.Atomic{T}. With @atomic alignemnt and size seems to be preserved which is not the case with Threads.Atomic{T} because the latter yields a reference to a mutable Julia object.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C11 help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants