concurrent-programs icon indicating copy to clipboard operation
concurrent-programs copied to clipboard

seqlock: Enforce C11 Atomics

Open scc-tw opened this issue 2 years ago • 1 comments

Pull Request Summary

This pull request aims to enhance the existing seqlock implementation by making it more portable, improving code readability, and adhering to coding standards. The changes involve modifications to both the Makefile and the seqlock code itself.

Changes Made

Makefile Enhancements

  • Added compilation flags to improve code quality and compliance:
    • -Wextra: This flag enables additional warnings beyond -Wall, helping catch potential issues in the code.
    • -pedantic: Enforced strict adherence to the C standard, promoting standardized and portable code.

Code Improvements

  • Transitioned to using <stdatomic.h> for atomic operations, which enhances synchronization and makes the code more standardized.
  • Employed atomic_thread_fence for memory barriers, enhancing portability across different architectures.
  • Replaced architecture-dependent inline assembly instructions with standardized atomic operations. This improves cross-architecture compatibility and maintainability.
  • Revised the ATOMIC_COPY macro to utilize atomic load and store operations for atomic data copying.

Data Types and Typedefs

  • Redefined the seqlock_t type using _Atomic(uint32_t) to ensure atomic access to the variable, further improving synchronization.

Motivation

These enhancements were motivated by the goal of creating a more reliable and maintainable seqlock implementation. The changes aim to address portability concerns across various architectures while improving the overall readability and standardization of the codebase.

Request for Review

Kindly review the changes made in this pull request. Your feedback is highly valuable, and any suggestions for further improvements are welcome.

Thank you for considering this pull request.

Best regards, scc Feel free to customize the context further to suit the specifics of your project and the details you'd like to emphasize.

scc-tw avatar Aug 27 '23 13:08 scc-tw

Remove seqlock/tests, which was generated.

I'm sorry for that commit. I fixed it.

scc-tw avatar Sep 02 '23 06:09 scc-tw