Commit 37763d38 by Edward Thomson

threads: rename git_atomic to git_atomic32

Clarify the `git_atomic` type and functions now that we have a 64 bit
version as well (`git_atomic64`).
parent 9800728a
...@@ -960,7 +960,7 @@ int git_attr_session__init(git_attr_session *session, git_repository *repo) ...@@ -960,7 +960,7 @@ int git_attr_session__init(git_attr_session *session, git_repository *repo)
GIT_ASSERT_ARG(repo); GIT_ASSERT_ARG(repo);
memset(session, 0, sizeof(*session)); memset(session, 0, sizeof(*session));
session->key = git_atomic_inc(&repo->attr_session_key); session->key = git_atomic32_inc(&repo->attr_session_key);
return 0; return 0;
} }
......
...@@ -235,7 +235,7 @@ void git_cached_obj_decref(void *_obj) ...@@ -235,7 +235,7 @@ void git_cached_obj_decref(void *_obj)
{ {
git_cached_obj *obj = _obj; git_cached_obj *obj = _obj;
if (git_atomic_dec(&obj->refcount) == 0) { if (git_atomic32_dec(&obj->refcount) == 0) {
switch (obj->flags) { switch (obj->flags) {
case GIT_CACHE_STORE_RAW: case GIT_CACHE_STORE_RAW:
git_odb_object__free(_obj); git_odb_object__free(_obj);
......
...@@ -27,7 +27,7 @@ typedef struct { ...@@ -27,7 +27,7 @@ typedef struct {
int16_t type; /* git_object_t value */ int16_t type; /* git_object_t value */
uint16_t flags; /* GIT_CACHE_STORE value */ uint16_t flags; /* GIT_CACHE_STORE value */
size_t size; size_t size;
git_atomic refcount; git_atomic32 refcount;
} git_cached_obj; } git_cached_obj;
typedef struct { typedef struct {
...@@ -61,7 +61,7 @@ GIT_INLINE(size_t) git_cache_size(git_cache *cache) ...@@ -61,7 +61,7 @@ GIT_INLINE(size_t) git_cache_size(git_cache *cache)
GIT_INLINE(void) git_cached_obj_incref(void *_obj) GIT_INLINE(void) git_cached_obj_incref(void *_obj)
{ {
git_cached_obj *obj = _obj; git_cached_obj *obj = _obj;
git_atomic_inc(&obj->refcount); git_atomic32_inc(&obj->refcount);
} }
void git_cached_obj_decref(void *_obj); void git_cached_obj_decref(void *_obj);
......
...@@ -461,7 +461,7 @@ static void index_free(git_index *index) ...@@ -461,7 +461,7 @@ static void index_free(git_index *index)
/* index iterators increment the refcount of the index, so if we /* index iterators increment the refcount of the index, so if we
* get here then there should be no outstanding iterators. * get here then there should be no outstanding iterators.
*/ */
if (git_atomic_get(&index->readers)) if (git_atomic32_get(&index->readers))
return; return;
git_index_clear(index); git_index_clear(index);
...@@ -488,7 +488,7 @@ void git_index_free(git_index *index) ...@@ -488,7 +488,7 @@ void git_index_free(git_index *index)
/* call with locked index */ /* call with locked index */
static void index_free_deleted(git_index *index) static void index_free_deleted(git_index *index)
{ {
int readers = (int)git_atomic_get(&index->readers); int readers = (int)git_atomic32_get(&index->readers);
size_t i; size_t i;
if (readers > 0 || !index->deleted.length) if (readers > 0 || !index->deleted.length)
...@@ -516,7 +516,7 @@ static int index_remove_entry(git_index *index, size_t pos) ...@@ -516,7 +516,7 @@ static int index_remove_entry(git_index *index, size_t pos)
error = git_vector_remove(&index->entries, pos); error = git_vector_remove(&index->entries, pos);
if (!error) { if (!error) {
if (git_atomic_get(&index->readers) > 0) { if (git_atomic32_get(&index->readers) > 0) {
error = git_vector_insert(&index->deleted, entry); error = git_vector_insert(&index->deleted, entry);
} else { } else {
index_entry_free(entry); index_entry_free(entry);
...@@ -3637,7 +3637,7 @@ int git_index_snapshot_new(git_vector *snap, git_index *index) ...@@ -3637,7 +3637,7 @@ int git_index_snapshot_new(git_vector *snap, git_index *index)
GIT_REFCOUNT_INC(index); GIT_REFCOUNT_INC(index);
git_atomic_inc(&index->readers); git_atomic32_inc(&index->readers);
git_vector_sort(&index->entries); git_vector_sort(&index->entries);
error = git_vector_dup(snap, &index->entries, index->entries._cmp); error = git_vector_dup(snap, &index->entries, index->entries._cmp);
...@@ -3652,7 +3652,7 @@ void git_index_snapshot_release(git_vector *snap, git_index *index) ...@@ -3652,7 +3652,7 @@ void git_index_snapshot_release(git_vector *snap, git_index *index)
{ {
git_vector_free(snap); git_vector_free(snap);
git_atomic_dec(&index->readers); git_atomic32_dec(&index->readers);
git_index_free(index); git_index_free(index);
} }
......
...@@ -33,7 +33,7 @@ struct git_index { ...@@ -33,7 +33,7 @@ struct git_index {
git_idxmap *entries_map; git_idxmap *entries_map;
git_vector deleted; /* deleted entries if readers > 0 */ git_vector deleted; /* deleted entries if readers > 0 */
git_atomic readers; /* number of active iterators */ git_atomic32 readers; /* number of active iterators */
unsigned int on_disk:1; unsigned int on_disk:1;
unsigned int ignore_case:1; unsigned int ignore_case:1;
......
...@@ -79,7 +79,7 @@ int git_mwindow_get_pack(struct git_pack_file **out, const char *path) ...@@ -79,7 +79,7 @@ int git_mwindow_get_pack(struct git_pack_file **out, const char *path)
git__free(packname); git__free(packname);
if (pack != NULL) { if (pack != NULL) {
git_atomic_inc(&pack->refcount); git_atomic32_inc(&pack->refcount);
git_mutex_unlock(&git__mwindow_mutex); git_mutex_unlock(&git__mwindow_mutex);
*out = pack; *out = pack;
return 0; return 0;
...@@ -91,7 +91,7 @@ int git_mwindow_get_pack(struct git_pack_file **out, const char *path) ...@@ -91,7 +91,7 @@ int git_mwindow_get_pack(struct git_pack_file **out, const char *path)
return error; return error;
} }
git_atomic_inc(&pack->refcount); git_atomic32_inc(&pack->refcount);
error = git_strmap_set(git__pack_cache, pack->pack_name, pack); error = git_strmap_set(git__pack_cache, pack->pack_name, pack);
git_mutex_unlock(&git__mwindow_mutex); git_mutex_unlock(&git__mwindow_mutex);
...@@ -118,7 +118,7 @@ int git_mwindow_put_pack(struct git_pack_file *pack) ...@@ -118,7 +118,7 @@ int git_mwindow_put_pack(struct git_pack_file *pack)
/* if we cannot find it, the state is corrupted */ /* if we cannot find it, the state is corrupted */
GIT_ASSERT(git_strmap_exists(git__pack_cache, pack->pack_name)); GIT_ASSERT(git_strmap_exists(git__pack_cache, pack->pack_name));
count = git_atomic_dec(&pack->refcount); count = git_atomic32_dec(&pack->refcount);
if (count == 0) { if (count == 0) {
git_strmap_delete(git__pack_cache, pack->pack_name); git_strmap_delete(git__pack_cache, pack->pack_name);
pack_to_delete = pack; pack_to_delete = pack;
......
...@@ -57,7 +57,7 @@ static git_pack_cache_entry *new_cache_object(git_rawobj *source) ...@@ -57,7 +57,7 @@ static git_pack_cache_entry *new_cache_object(git_rawobj *source)
if (!e) if (!e)
return NULL; return NULL;
git_atomic_inc(&e->refcount); git_atomic32_inc(&e->refcount);
memcpy(&e->raw, source, sizeof(git_rawobj)); memcpy(&e->raw, source, sizeof(git_rawobj));
return e; return e;
...@@ -114,7 +114,7 @@ static git_pack_cache_entry *cache_get(git_pack_cache *cache, off64_t offset) ...@@ -114,7 +114,7 @@ static git_pack_cache_entry *cache_get(git_pack_cache *cache, off64_t offset)
return NULL; return NULL;
if ((entry = git_offmap_get(cache->entries, offset)) != NULL) { if ((entry = git_offmap_get(cache->entries, offset)) != NULL) {
git_atomic_inc(&entry->refcount); git_atomic32_inc(&entry->refcount);
entry->last_usage = cache->use_ctr++; entry->last_usage = cache->use_ctr++;
} }
git_mutex_unlock(&cache->lock); git_mutex_unlock(&cache->lock);
...@@ -129,7 +129,7 @@ static void free_lowest_entry(git_pack_cache *cache) ...@@ -129,7 +129,7 @@ static void free_lowest_entry(git_pack_cache *cache)
git_pack_cache_entry *entry; git_pack_cache_entry *entry;
git_offmap_foreach(cache->entries, offset, entry, { git_offmap_foreach(cache->entries, offset, entry, {
if (entry && git_atomic_get(&entry->refcount) == 0) { if (entry && git_atomic32_get(&entry->refcount) == 0) {
cache->memory_used -= entry->raw.len; cache->memory_used -= entry->raw.len;
git_offmap_delete(cache->entries, offset); git_offmap_delete(cache->entries, offset);
free_cache_object(entry); free_cache_object(entry);
...@@ -759,7 +759,7 @@ int git_packfile_unpack( ...@@ -759,7 +759,7 @@ int git_packfile_unpack(
GIT_ERROR_CHECK_ALLOC(obj->data); GIT_ERROR_CHECK_ALLOC(obj->data);
memcpy(obj->data, data, obj->len + 1); memcpy(obj->data, data, obj->len + 1);
git_atomic_dec(&cached->refcount); git_atomic32_dec(&cached->refcount);
goto cleanup; goto cleanup;
} }
...@@ -807,7 +807,7 @@ int git_packfile_unpack( ...@@ -807,7 +807,7 @@ int git_packfile_unpack(
} }
if (cached) { if (cached) {
git_atomic_dec(&cached->refcount); git_atomic32_dec(&cached->refcount);
cached = NULL; cached = NULL;
} }
...@@ -821,7 +821,7 @@ cleanup: ...@@ -821,7 +821,7 @@ cleanup:
if (error < 0) { if (error < 0) {
git__free(obj->data); git__free(obj->data);
if (cached) if (cached)
git_atomic_dec(&cached->refcount); git_atomic32_dec(&cached->refcount);
} }
if (elem) if (elem)
......
...@@ -58,7 +58,7 @@ struct git_pack_idx_header { ...@@ -58,7 +58,7 @@ struct git_pack_idx_header {
typedef struct git_pack_cache_entry { typedef struct git_pack_cache_entry {
size_t last_usage; /* enough? */ size_t last_usage; /* enough? */
git_atomic refcount; git_atomic32 refcount;
git_rawobj raw; git_rawobj raw;
} git_pack_cache_entry; } git_pack_cache_entry;
...@@ -86,7 +86,7 @@ struct git_pack_file { ...@@ -86,7 +86,7 @@ struct git_pack_file {
git_mwindow_file mwf; git_mwindow_file mwf;
git_map index_map; git_map index_map;
git_mutex lock; /* protect updates to index_map */ git_mutex lock; /* protect updates to index_map */
git_atomic refcount; git_atomic32 refcount;
uint32_t num_objects; uint32_t num_objects;
uint32_t num_bad_objects; uint32_t num_bad_objects;
......
...@@ -152,7 +152,7 @@ struct git_repository { ...@@ -152,7 +152,7 @@ struct git_repository {
unsigned int lru_counter; unsigned int lru_counter;
git_atomic attr_session_key; git_atomic32 attr_session_key;
git_configmap_value configmap_cache[GIT_CONFIGMAP_CACHE_MAX]; git_configmap_value configmap_cache[GIT_CONFIGMAP_CACHE_MAX];
git_strmap *submodule_cache; git_strmap *submodule_cache;
......
...@@ -9,9 +9,9 @@ ...@@ -9,9 +9,9 @@
#include "runtime.h" #include "runtime.h"
static git_runtime_shutdown_fn shutdown_callback[32]; static git_runtime_shutdown_fn shutdown_callback[32];
static git_atomic shutdown_callback_count; static git_atomic32 shutdown_callback_count;
static git_atomic init_count; static git_atomic32 init_count;
static int init_common(git_runtime_init_fn init_fns[], size_t cnt) static int init_common(git_runtime_init_fn init_fns[], size_t cnt)
{ {
...@@ -34,9 +34,9 @@ static void shutdown_common(void) ...@@ -34,9 +34,9 @@ static void shutdown_common(void)
git_runtime_shutdown_fn cb; git_runtime_shutdown_fn cb;
int pos; int pos;
for (pos = git_atomic_get(&shutdown_callback_count); for (pos = git_atomic32_get(&shutdown_callback_count);
pos > 0; pos > 0;
pos = git_atomic_dec(&shutdown_callback_count)) { pos = git_atomic32_dec(&shutdown_callback_count)) {
cb = git__swap(shutdown_callback[pos - 1], NULL); cb = git__swap(shutdown_callback[pos - 1], NULL);
if (cb != NULL) if (cb != NULL)
...@@ -46,12 +46,12 @@ static void shutdown_common(void) ...@@ -46,12 +46,12 @@ static void shutdown_common(void)
int git_runtime_shutdown_register(git_runtime_shutdown_fn callback) int git_runtime_shutdown_register(git_runtime_shutdown_fn callback)
{ {
int count = git_atomic_inc(&shutdown_callback_count); int count = git_atomic32_inc(&shutdown_callback_count);
if (count > (int)ARRAY_SIZE(shutdown_callback) || count == 0) { if (count > (int)ARRAY_SIZE(shutdown_callback) || count == 0) {
git_error_set(GIT_ERROR_INVALID, git_error_set(GIT_ERROR_INVALID,
"too many shutdown callbacks registered"); "too many shutdown callbacks registered");
git_atomic_dec(&shutdown_callback_count); git_atomic32_dec(&shutdown_callback_count);
return -1; return -1;
} }
...@@ -116,7 +116,7 @@ int git_runtime_init(git_runtime_init_fn init_fns[], size_t cnt) ...@@ -116,7 +116,7 @@ int git_runtime_init(git_runtime_init_fn init_fns[], size_t cnt)
return -1; return -1;
/* Only do work on a 0 -> 1 transition of the refcount */ /* Only do work on a 0 -> 1 transition of the refcount */
if ((ret = git_atomic_inc(&init_count)) == 1) { if ((ret = git_atomic32_inc(&init_count)) == 1) {
if (init_common(init_fns, cnt) < 0) if (init_common(init_fns, cnt) < 0)
ret = -1; ret = -1;
} }
...@@ -136,7 +136,7 @@ int git_runtime_shutdown(void) ...@@ -136,7 +136,7 @@ int git_runtime_shutdown(void)
return -1; return -1;
/* Only do work on a 1 -> 0 transition of the refcount */ /* Only do work on a 1 -> 0 transition of the refcount */
if ((ret = git_atomic_dec(&init_count)) == 0) if ((ret = git_atomic32_dec(&init_count)) == 0)
shutdown_common(); shutdown_common();
/* Exit the lock */ /* Exit the lock */
......
...@@ -38,7 +38,7 @@ typedef struct { ...@@ -38,7 +38,7 @@ typedef struct {
#else #else
volatile int val; volatile int val;
#endif #endif
} git_atomic; } git_atomic32;
#ifdef GIT_ARCH_64 #ifdef GIT_ARCH_64
...@@ -58,11 +58,11 @@ typedef git_atomic64 git_atomic_ssize; ...@@ -58,11 +58,11 @@ typedef git_atomic64 git_atomic_ssize;
#else #else
typedef git_atomic git_atomic_ssize; typedef git_atomic32 git_atomic_ssize;
#define git_atomic_ssize_set git_atomic_set #define git_atomic_ssize_set git_atomic32_set
#define git_atomic_ssize_add git_atomic_add #define git_atomic_ssize_add git_atomic32_add
#define git_atomic_ssize_get git_atomic_get #define git_atomic_ssize_get git_atomic32_get
#endif #endif
...@@ -74,7 +74,7 @@ typedef git_atomic git_atomic_ssize; ...@@ -74,7 +74,7 @@ typedef git_atomic git_atomic_ssize;
# include "unix/pthread.h" # include "unix/pthread.h"
#endif #endif
GIT_INLINE(void) git_atomic_set(git_atomic *a, int val) GIT_INLINE(void) git_atomic32_set(git_atomic32 *a, int val)
{ {
#if defined(GIT_WIN32) #if defined(GIT_WIN32)
InterlockedExchange(&a->val, (LONG)val); InterlockedExchange(&a->val, (LONG)val);
...@@ -87,7 +87,7 @@ GIT_INLINE(void) git_atomic_set(git_atomic *a, int val) ...@@ -87,7 +87,7 @@ GIT_INLINE(void) git_atomic_set(git_atomic *a, int val)
#endif #endif
} }
GIT_INLINE(int) git_atomic_inc(git_atomic *a) GIT_INLINE(int) git_atomic32_inc(git_atomic32 *a)
{ {
#if defined(GIT_WIN32) #if defined(GIT_WIN32)
return InterlockedIncrement(&a->val); return InterlockedIncrement(&a->val);
...@@ -100,7 +100,7 @@ GIT_INLINE(int) git_atomic_inc(git_atomic *a) ...@@ -100,7 +100,7 @@ GIT_INLINE(int) git_atomic_inc(git_atomic *a)
#endif #endif
} }
GIT_INLINE(int) git_atomic_add(git_atomic *a, int32_t addend) GIT_INLINE(int) git_atomic32_add(git_atomic32 *a, int32_t addend)
{ {
#if defined(GIT_WIN32) #if defined(GIT_WIN32)
return InterlockedExchangeAdd(&a->val, addend); return InterlockedExchangeAdd(&a->val, addend);
...@@ -113,7 +113,7 @@ GIT_INLINE(int) git_atomic_add(git_atomic *a, int32_t addend) ...@@ -113,7 +113,7 @@ GIT_INLINE(int) git_atomic_add(git_atomic *a, int32_t addend)
#endif #endif
} }
GIT_INLINE(int) git_atomic_dec(git_atomic *a) GIT_INLINE(int) git_atomic32_dec(git_atomic32 *a)
{ {
#if defined(GIT_WIN32) #if defined(GIT_WIN32)
return InterlockedDecrement(&a->val); return InterlockedDecrement(&a->val);
...@@ -126,7 +126,7 @@ GIT_INLINE(int) git_atomic_dec(git_atomic *a) ...@@ -126,7 +126,7 @@ GIT_INLINE(int) git_atomic_dec(git_atomic *a)
#endif #endif
} }
GIT_INLINE(int) git_atomic_get(git_atomic *a) GIT_INLINE(int) git_atomic32_get(git_atomic32 *a)
{ {
#if defined(GIT_WIN32) #if defined(GIT_WIN32)
return (int)InterlockedCompareExchange(&a->val, 0, 0); return (int)InterlockedCompareExchange(&a->val, 0, 0);
...@@ -268,28 +268,28 @@ GIT_INLINE(int64_t) git_atomic64_get(git_atomic64 *a) ...@@ -268,28 +268,28 @@ GIT_INLINE(int64_t) git_atomic64_get(git_atomic64 *a)
#define GIT_RWLOCK_STATIC_INIT 0 #define GIT_RWLOCK_STATIC_INIT 0
GIT_INLINE(void) git_atomic_set(git_atomic *a, int val) GIT_INLINE(void) git_atomic32_set(git_atomic32 *a, int val)
{ {
a->val = val; a->val = val;
} }
GIT_INLINE(int) git_atomic_inc(git_atomic *a) GIT_INLINE(int) git_atomic32_inc(git_atomic32 *a)
{ {
return ++a->val; return ++a->val;
} }
GIT_INLINE(int) git_atomic_add(git_atomic *a, int32_t addend) GIT_INLINE(int) git_atomic32_add(git_atomic32 *a, int32_t addend)
{ {
a->val += addend; a->val += addend;
return a->val; return a->val;
} }
GIT_INLINE(int) git_atomic_dec(git_atomic *a) GIT_INLINE(int) git_atomic32_dec(git_atomic32 *a)
{ {
return --a->val; return --a->val;
} }
GIT_INLINE(int) git_atomic_get(git_atomic *a) GIT_INLINE(int) git_atomic32_get(git_atomic32 *a)
{ {
return (int)a->val; return (int)a->val;
} }
......
...@@ -36,7 +36,7 @@ typedef struct { ...@@ -36,7 +36,7 @@ typedef struct {
char *url; char *url;
int direction; int direction;
int flags; int flags;
git_atomic cancelled; git_atomic32 cancelled;
git_repository *repo; git_repository *repo;
git_transport_message_cb progress_cb; git_transport_message_cb progress_cb;
git_transport_message_cb error_cb; git_transport_message_cb error_cb;
...@@ -671,7 +671,7 @@ static void local_cancel(git_transport *transport) ...@@ -671,7 +671,7 @@ static void local_cancel(git_transport *transport)
{ {
transport_local *t = (transport_local *)transport; transport_local *t = (transport_local *)transport;
git_atomic_set(&t->cancelled, 1); git_atomic32_set(&t->cancelled, 1);
} }
static int local_close(git_transport *transport) static int local_close(git_transport *transport)
......
...@@ -30,7 +30,7 @@ static int git_smart__recv_cb(gitno_buffer *buf) ...@@ -30,7 +30,7 @@ static int git_smart__recv_cb(gitno_buffer *buf)
if (t->packetsize_cb && !t->cancelled.val) { if (t->packetsize_cb && !t->cancelled.val) {
error = t->packetsize_cb(bytes_read, t->packetsize_payload); error = t->packetsize_cb(bytes_read, t->packetsize_payload);
if (error) { if (error) {
git_atomic_set(&t->cancelled, 1); git_atomic32_set(&t->cancelled, 1);
return GIT_EUSER; return GIT_EUSER;
} }
} }
...@@ -389,7 +389,7 @@ static void git_smart__cancel(git_transport *transport) ...@@ -389,7 +389,7 @@ static void git_smart__cancel(git_transport *transport)
{ {
transport_smart *t = GIT_CONTAINER_OF(transport, transport_smart, parent); transport_smart *t = GIT_CONTAINER_OF(transport, transport_smart, parent);
git_atomic_set(&t->cancelled, 1); git_atomic32_set(&t->cancelled, 1);
} }
static int git_smart__is_connected(git_transport *transport) static int git_smart__is_connected(git_transport *transport)
......
...@@ -153,7 +153,7 @@ typedef struct { ...@@ -153,7 +153,7 @@ typedef struct {
git_vector refs; git_vector refs;
git_vector heads; git_vector heads;
git_vector common; git_vector common;
git_atomic cancelled; git_atomic32 cancelled;
packetsize_cb packetsize_cb; packetsize_cb packetsize_cb;
void *packetsize_payload; void *packetsize_payload;
unsigned rpc : 1, unsigned rpc : 1,
......
...@@ -535,7 +535,7 @@ int git_smart__download_pack( ...@@ -535,7 +535,7 @@ int git_smart__download_pack(
/* We might have something in the buffer already from negotiate_fetch */ /* We might have something in the buffer already from negotiate_fetch */
if (t->buffer.offset > 0 && !t->cancelled.val) if (t->buffer.offset > 0 && !t->cancelled.val)
if (t->packetsize_cb(t->buffer.offset, t->packetsize_payload)) if (t->packetsize_cb(t->buffer.offset, t->packetsize_payload))
git_atomic_set(&t->cancelled, 1); git_atomic32_set(&t->cancelled, 1);
} }
if ((error = git_repository_odb__weakptr(&odb, repo)) < 0 || if ((error = git_repository_odb__weakptr(&odb, repo)) < 0 ||
......
...@@ -169,19 +169,19 @@ extern int git__strncasecmp(const char *a, const char *b, size_t sz); ...@@ -169,19 +169,19 @@ extern int git__strncasecmp(const char *a, const char *b, size_t sz);
extern int git__strcasesort_cmp(const char *a, const char *b); extern int git__strcasesort_cmp(const char *a, const char *b);
typedef struct { typedef struct {
git_atomic refcount; git_atomic32 refcount;
void *owner; void *owner;
} git_refcount; } git_refcount;
typedef void (*git_refcount_freeptr)(void *r); typedef void (*git_refcount_freeptr)(void *r);
#define GIT_REFCOUNT_INC(r) { \ #define GIT_REFCOUNT_INC(r) { \
git_atomic_inc(&(r)->rc.refcount); \ git_atomic32_inc(&(r)->rc.refcount); \
} }
#define GIT_REFCOUNT_DEC(_r, do_free) { \ #define GIT_REFCOUNT_DEC(_r, do_free) { \
git_refcount *r = &(_r)->rc; \ git_refcount *r = &(_r)->rc; \
int val = git_atomic_dec(&r->refcount); \ int val = git_atomic32_dec(&r->refcount); \
if (val <= 0 && r->owner == NULL) { do_free(_r); } \ if (val <= 0 && r->owner == NULL) { do_free(_r); } \
} }
...@@ -191,7 +191,7 @@ typedef void (*git_refcount_freeptr)(void *r); ...@@ -191,7 +191,7 @@ typedef void (*git_refcount_freeptr)(void *r);
#define GIT_REFCOUNT_OWNER(r) git__load((r)->rc.owner) #define GIT_REFCOUNT_OWNER(r) git__load((r)->rc.owner)
#define GIT_REFCOUNT_VAL(r) git_atomic_get((r)->rc.refcount) #define GIT_REFCOUNT_VAL(r) git_atomic32_get((r)->rc.refcount)
static signed char from_hex[] = { static signed char from_hex[] = {
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
static git_repository *_repo; static git_repository *_repo;
static git_tree *_a, *_b; static git_tree *_a, *_b;
static git_atomic _counts[4]; static git_atomic32 _counts[4];
static int _check_counts; static int _check_counts;
#ifdef GIT_WIN32 #ifdef GIT_WIN32
static int _retries; static int _retries;
...@@ -66,10 +66,10 @@ static void free_trees(void) ...@@ -66,10 +66,10 @@ static void free_trees(void)
git_tree_free(_b); _b = NULL; git_tree_free(_b); _b = NULL;
if (_check_counts) { if (_check_counts) {
cl_assert_equal_i(288, git_atomic_get(&_counts[0])); cl_assert_equal_i(288, git_atomic32_get(&_counts[0]));
cl_assert_equal_i(112, git_atomic_get(&_counts[1])); cl_assert_equal_i(112, git_atomic32_get(&_counts[1]));
cl_assert_equal_i( 80, git_atomic_get(&_counts[2])); cl_assert_equal_i( 80, git_atomic32_get(&_counts[2]));
cl_assert_equal_i( 96, git_atomic_get(&_counts[3])); cl_assert_equal_i( 96, git_atomic32_get(&_counts[3]));
} }
} }
...@@ -107,14 +107,14 @@ static void *run_index_diffs(void *arg) ...@@ -107,14 +107,14 @@ static void *run_index_diffs(void *arg)
/* keep some diff stats to make sure results are as expected */ /* keep some diff stats to make sure results are as expected */
i = git_diff_num_deltas(diff); i = git_diff_num_deltas(diff);
git_atomic_add(&_counts[0], (int32_t)i); git_atomic32_add(&_counts[0], (int32_t)i);
exp[0] = (int)i; exp[0] = (int)i;
while (i > 0) { while (i > 0) {
switch (git_diff_get_delta(diff, --i)->status) { switch (git_diff_get_delta(diff, --i)->status) {
case GIT_DELTA_MODIFIED: exp[1]++; git_atomic_inc(&_counts[1]); break; case GIT_DELTA_MODIFIED: exp[1]++; git_atomic32_inc(&_counts[1]); break;
case GIT_DELTA_ADDED: exp[2]++; git_atomic_inc(&_counts[2]); break; case GIT_DELTA_ADDED: exp[2]++; git_atomic32_inc(&_counts[2]); break;
case GIT_DELTA_DELETED: exp[3]++; git_atomic_inc(&_counts[3]); break; case GIT_DELTA_DELETED: exp[3]++; git_atomic32_inc(&_counts[3]); break;
default: break; default: break;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment