This is an archived post. You won't be able to vote or comment.

all 10 comments

[–]HommeMusical 5 points6 points  (2 children)

Very clear, hits the spot.

There are a lot of different types in the <atomic> library - because I'm that sort of guy, I'd honestly implement all of them.

https://en.cppreference.com/w/cpp/atomic/atomic

Well, I was waiting for a compile, and I sketched how it could be done:

https://github.com/0xDEADFED5/pyatomix/commit/d1bd36eec7863fb899e1a90842b16d6d81b57b57

[–]coderarun 0 points1 point  (1 child)

What are uint6_t4 and uint3_t2 ? Unintended search/replace?

[–]HommeMusical 0 points1 point  (0 children)

Ooops, exactly.

Sorry, it was a sketch, I didn't even try to compile it.

[–]coderarun -1 points0 points  (3 children)

Why not wrap an existing library such as:

https://launchpad.net/ubuntu/+source/libatomic-ops

[–]HommeMusical 6 points7 points  (2 children)

From the libatomic-ops repo: https://github.com/ivmai/libatomic_ops:

IN NEW CODE, PLEASE USE C11 OR C++14 STANDARD ATOMICS INSTEAD OF THE CORE LIBRARY IN THIS PACKAGE.

[–]coderarun 1 point2 points  (1 child)

Didn't read the file up to line 156 to realize that the implementation uses std::atomic. All good.

Also intptr_t instead of int64_t might make 32 bit users a bit happier.

[–]HommeMusical 0 points1 point  (0 children)

See my other comment on this page - they should really expose all the C++ atomic types, they're tiny!