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

generic atomicops: promote Acquire_Store() and Release_Load() to use SEQ_CST fence #30

Merged
merged 1 commit into from
Sep 19, 2014
Merged

generic atomicops: promote Acquire_Store() and Release_Load() to use SEQ_CST fence #30

merged 1 commit into from
Sep 19, 2014

Conversation

edmonds
Copy link
Contributor

@edmonds edmonds commented Sep 19, 2014

__atomic_store_n() cannot take a memory model argument of
__ATOMIC_ACQUIRE, and __atomic_load_n() cannot take a memory model
argument of __ATOMIC_RELEASE, per the GCC documentation:

https://gcc.gnu.org/onlinedocs/gcc-4.9.1/gcc/_005f_005fatomic-Builtins.html

On Clang this generates a -Watomic-memory-ordering warning.

Promote the fences in Acquire_Store() and Release_Load() to the stronger
__ATOMIC_SEQ_CST memory model, which ought to be safe.

Note that there are no actual uses of Acquire_Store() or Release_Load()
in protobuf, though.

This follows the TSAN atomicops implementation, which also uses SEQ_CST
fences for these functions.

(Fixes #25.)

…SEQ_CST fence

__atomic_store_n() cannot take a memory model argument of
__ATOMIC_ACQUIRE, and __atomic_load_n() cannot take a memory model
argument of __ATOMIC_RELEASE, per the GCC documentation:

    https://gcc.gnu.org/onlinedocs/gcc-4.9.1/gcc/_005f_005fatomic-Builtins.html

On Clang this generates a -Watomic-memory-ordering warning.

Promote the fences in Acquire_Store() and Release_Load() to the stronger
__ATOMIC_SEQ_CST memory model, which ought to be safe.

Note that there are no actual uses of Acquire_Store() or Release_Load()
in protobuf, though.

This follows the TSAN atomicops implementation, which also uses SEQ_CST
fences for these functions.

(Fixes #25.)
@edmonds
Copy link
Contributor Author

edmonds commented Sep 19, 2014

Note that if you merge this instead, it obsoletes PR #28.

xfxyjwf added a commit that referenced this pull request Sep 19, 2014
…mory_models

generic atomicops: promote Acquire_Store() and Release_Load() to use SEQ_CST fence
@xfxyjwf xfxyjwf merged commit 7d50120 into protocolbuffers:master Sep 19, 2014
@edmonds edmonds deleted the branches/fix_generic_atomicops_memory_models branch September 19, 2014 19:05
TeBoring pushed a commit to TeBoring/protobuf that referenced this pull request Jan 19, 2019
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.

Clang generates atomic memory ordering warnings when compiling atomicops_internals_generic_gcc.h
2 participants