Skip to content

zelang-dev/c-atomics

Repository files navigation

c-atomics

An C89 compatible interface to C11 like atomic

This library aims to implement an equivalent to the C11 atomics library. It's intended to be used as a way to enable the use of atomics in a mostly consistent manner to modern C, while still enabling compatibility with older compilers.

This initially started out as a fork of c89atomic for an drop-in replacement to C11 atomics. But after adding thread tests and macros equivalents for C11 API's, it failed to pass a more adavance stress from concurrent-programs, example mpsc and spmc both are used here for testing.

For general usage on how to use, see Chapter 40 Atomics in Beej's Guide to C Programming, An Introduction to Lock-Free Programming, and Microsoft Windows: Atomic ops and memory barriers


Usage

This is a header-only library. Just add catomics.h to your source tree and include it:

#include "catomics.h"

To simplify cross-platform atomic typedef creation, use macro make_atomic(/*current*/ type, /*new*/ atomic_type).

About

C89 compatible C11 Atomics.

Resources

License

Stars

Watchers

Forks

Packages

No packages published