summaryrefslogtreecommitdiff
path: root/src/odb.c
diff options
context:
space:
mode:
authorlhchavez <lhchavez@lhchavez.com>2020-08-01 17:47:20 -0700
committerlhchavez <lhchavez@lhchavez.com>2020-10-08 05:31:30 -0700
commitcc1d7f5ceb31985b69ac5aef0828109814c68d2e (patch)
tree7e8bb9f5c4368c287c47a93181961db5e283f28f /src/odb.c
parent2307a2256a658d5988f2eab1d367b3971918d527 (diff)
downloadlibgit2-cc1d7f5ceb31985b69ac5aef0828109814c68d2e.tar.gz
Improve the support of atomics
This change: * Starts using GCC's and clang's `__atomic_*` intrinsics instead of the `__sync_*` ones, since the former supercede the latter (and can be safely replaced by their equivalent `__atomic_*` version with the sequentially consistent model). * Makes `git_atomic64`'s value `volatile`. Otherwise, this will make ThreadSanitizer complain. * Adds ways to load the values from atomics. As it turns out, unsynchronized read are okay only in some architectures, but if we want to be correct (and make ThreadSanitizer happy), those loads should also be performed with the atomic builtins. * Fixes two ThreadSanitizer warnings, as a proof-of-concept that this works: - Avoid directly accessing `git_refcount`'s `owner` directly, and instead makes all callers go through the `GIT_REFCOUNT_*()` macros, which also use the atomic utilities. - Makes `pool_system_page_size()` race-free. Part of: #5592
Diffstat (limited to 'src/odb.c')
-rw-r--r--src/odb.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/odb.c b/src/odb.c
index 9d9530250..129a63255 100644
--- a/src/odb.c
+++ b/src/odb.c
@@ -44,8 +44,8 @@ typedef struct
static git_cache *odb_cache(git_odb *odb)
{
- if (odb->rc.owner != NULL) {
- git_repository *owner = odb->rc.owner;
+ git_repository *owner = GIT_REFCOUNT_OWNER(odb);
+ if (owner != NULL) {
return &owner->objects;
}
@@ -664,7 +664,7 @@ int git_odb_open(git_odb **out, const char *objects_dir)
int git_odb__set_caps(git_odb *odb, int caps)
{
if (caps == GIT_ODB_CAP_FROM_OWNER) {
- git_repository *repo = odb->rc.owner;
+ git_repository *repo = GIT_REFCOUNT_OWNER(odb);
int val;
if (!repo) {