Commit 37763d38fbf5db932be8d6a0070255839e7719ca

Edward Thomson 2020-12-05T15:26:59

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`).

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
diff --git a/src/attr_file.c b/src/attr_file.c
index 0781c1d..adc56d5 100644
--- a/src/attr_file.c
+++ b/src/attr_file.c
@@ -960,7 +960,7 @@ int git_attr_session__init(git_attr_session *session, git_repository *repo)
 	GIT_ASSERT_ARG(repo);
 
 	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;
 }
diff --git a/src/cache.c b/src/cache.c
index a76da50..dbd4c31 100644
--- a/src/cache.c
+++ b/src/cache.c
@@ -235,7 +235,7 @@ void git_cached_obj_decref(void *_obj)
 {
 	git_cached_obj *obj = _obj;
 
-	if (git_atomic_dec(&obj->refcount) == 0) {
+	if (git_atomic32_dec(&obj->refcount) == 0) {
 		switch (obj->flags) {
 		case GIT_CACHE_STORE_RAW:
 			git_odb_object__free(_obj);
diff --git a/src/cache.h b/src/cache.h
index 1e61792..c43422d 100644
--- a/src/cache.h
+++ b/src/cache.h
@@ -23,11 +23,11 @@ enum {
 };
 
 typedef struct {
-	git_oid    oid;
-	int16_t    type;  /* git_object_t value */
-	uint16_t   flags; /* GIT_CACHE_STORE value */
-	size_t     size;
-	git_atomic refcount;
+	git_oid      oid;
+	int16_t      type;  /* git_object_t value */
+	uint16_t     flags; /* GIT_CACHE_STORE value */
+	size_t       size;
+	git_atomic32 refcount;
 } git_cached_obj;
 
 typedef struct {
@@ -61,7 +61,7 @@ GIT_INLINE(size_t) git_cache_size(git_cache *cache)
 GIT_INLINE(void) git_cached_obj_incref(void *_obj)
 {
 	git_cached_obj *obj = _obj;
-	git_atomic_inc(&obj->refcount);
+	git_atomic32_inc(&obj->refcount);
 }
 
 void git_cached_obj_decref(void *_obj);
diff --git a/src/index.c b/src/index.c
index d9116c4..942fcca 100644
--- a/src/index.c
+++ b/src/index.c
@@ -461,7 +461,7 @@ static void index_free(git_index *index)
 	/* index iterators increment the refcount of the index, so if we
 	 * get here then there should be no outstanding iterators.
 	 */
-	if (git_atomic_get(&index->readers))
+	if (git_atomic32_get(&index->readers))
 		return;
 
 	git_index_clear(index);
@@ -488,7 +488,7 @@ void git_index_free(git_index *index)
 /* call with locked 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;
 
 	if (readers > 0 || !index->deleted.length)
@@ -516,7 +516,7 @@ static int index_remove_entry(git_index *index, size_t pos)
 	error = git_vector_remove(&index->entries, pos);
 
 	if (!error) {
-		if (git_atomic_get(&index->readers) > 0) {
+		if (git_atomic32_get(&index->readers) > 0) {
 			error = git_vector_insert(&index->deleted, entry);
 		} else {
 			index_entry_free(entry);
@@ -3637,7 +3637,7 @@ int git_index_snapshot_new(git_vector *snap, git_index *index)
 
 	GIT_REFCOUNT_INC(index);
 
-	git_atomic_inc(&index->readers);
+	git_atomic32_inc(&index->readers);
 	git_vector_sort(&index->entries);
 
 	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)
 {
 	git_vector_free(snap);
 
-	git_atomic_dec(&index->readers);
+	git_atomic32_dec(&index->readers);
 
 	git_index_free(index);
 }
diff --git a/src/index.h b/src/index.h
index 54402f5..a365867 100644
--- a/src/index.h
+++ b/src/index.h
@@ -33,7 +33,7 @@ struct git_index {
 	git_idxmap *entries_map;
 
 	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 ignore_case:1;
diff --git a/src/mwindow.c b/src/mwindow.c
index 4f105e6..7832d9c 100644
--- a/src/mwindow.c
+++ b/src/mwindow.c
@@ -79,7 +79,7 @@ int git_mwindow_get_pack(struct git_pack_file **out, const char *path)
 	git__free(packname);
 
 	if (pack != NULL) {
-		git_atomic_inc(&pack->refcount);
+		git_atomic32_inc(&pack->refcount);
 		git_mutex_unlock(&git__mwindow_mutex);
 		*out = pack;
 		return 0;
@@ -91,7 +91,7 @@ int git_mwindow_get_pack(struct git_pack_file **out, const char *path)
 		return error;
 	}
 
-	git_atomic_inc(&pack->refcount);
+	git_atomic32_inc(&pack->refcount);
 
 	error = git_strmap_set(git__pack_cache, pack->pack_name, pack);
 	git_mutex_unlock(&git__mwindow_mutex);
@@ -118,7 +118,7 @@ int git_mwindow_put_pack(struct git_pack_file *pack)
 	/* if we cannot find it, the state is corrupted */
 	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) {
 		git_strmap_delete(git__pack_cache, pack->pack_name);
 		pack_to_delete = pack;
diff --git a/src/pack.c b/src/pack.c
index b88c52a..a9140c6 100644
--- a/src/pack.c
+++ b/src/pack.c
@@ -57,7 +57,7 @@ static git_pack_cache_entry *new_cache_object(git_rawobj *source)
 	if (!e)
 		return NULL;
 
-	git_atomic_inc(&e->refcount);
+	git_atomic32_inc(&e->refcount);
 	memcpy(&e->raw, source, sizeof(git_rawobj));
 
 	return e;
@@ -114,7 +114,7 @@ static git_pack_cache_entry *cache_get(git_pack_cache *cache, off64_t offset)
 		return 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++;
 	}
 	git_mutex_unlock(&cache->lock);
@@ -129,7 +129,7 @@ static void free_lowest_entry(git_pack_cache *cache)
 	git_pack_cache_entry *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;
 			git_offmap_delete(cache->entries, offset);
 			free_cache_object(entry);
@@ -759,7 +759,7 @@ int git_packfile_unpack(
 		GIT_ERROR_CHECK_ALLOC(obj->data);
 
 		memcpy(obj->data, data, obj->len + 1);
-		git_atomic_dec(&cached->refcount);
+		git_atomic32_dec(&cached->refcount);
 		goto cleanup;
 	}
 
@@ -807,7 +807,7 @@ int git_packfile_unpack(
 		}
 
 		if (cached) {
-			git_atomic_dec(&cached->refcount);
+			git_atomic32_dec(&cached->refcount);
 			cached = NULL;
 		}
 
@@ -821,7 +821,7 @@ cleanup:
 	if (error < 0) {
 		git__free(obj->data);
 		if (cached)
-			git_atomic_dec(&cached->refcount);
+			git_atomic32_dec(&cached->refcount);
 	}
 
 	if (elem)
diff --git a/src/pack.h b/src/pack.h
index 7c3be07..1d07724 100644
--- a/src/pack.h
+++ b/src/pack.h
@@ -58,7 +58,7 @@ struct git_pack_idx_header {
 
 typedef struct git_pack_cache_entry {
 	size_t last_usage; /* enough? */
-	git_atomic refcount;
+	git_atomic32 refcount;
 	git_rawobj raw;
 } git_pack_cache_entry;
 
@@ -86,7 +86,7 @@ struct git_pack_file {
 	git_mwindow_file mwf;
 	git_map index_map;
 	git_mutex lock; /* protect updates to index_map */
-	git_atomic refcount;
+	git_atomic32 refcount;
 
 	uint32_t num_objects;
 	uint32_t num_bad_objects;
diff --git a/src/repository.h b/src/repository.h
index de009ba..4b1222e 100644
--- a/src/repository.h
+++ b/src/repository.h
@@ -152,7 +152,7 @@ struct git_repository {
 
 	unsigned int lru_counter;
 
-	git_atomic attr_session_key;
+	git_atomic32 attr_session_key;
 
 	git_configmap_value configmap_cache[GIT_CONFIGMAP_CACHE_MAX];
 	git_strmap *submodule_cache;
diff --git a/src/runtime.c b/src/runtime.c
index a214b43..3fd0649 100644
--- a/src/runtime.c
+++ b/src/runtime.c
@@ -9,9 +9,9 @@
 #include "runtime.h"
 
 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)
 {
@@ -34,9 +34,9 @@ static void shutdown_common(void)
 	git_runtime_shutdown_fn cb;
 	int pos;
 
-	for (pos = git_atomic_get(&shutdown_callback_count);
+	for (pos = git_atomic32_get(&shutdown_callback_count);
 	     pos > 0;
-	     pos = git_atomic_dec(&shutdown_callback_count)) {
+	     pos = git_atomic32_dec(&shutdown_callback_count)) {
 		cb = git__swap(shutdown_callback[pos - 1], NULL);
 
 		if (cb != NULL)
@@ -46,12 +46,12 @@ static void shutdown_common(void)
 
 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) {
 		git_error_set(GIT_ERROR_INVALID,
 		              "too many shutdown callbacks registered");
-		git_atomic_dec(&shutdown_callback_count);
+		git_atomic32_dec(&shutdown_callback_count);
 		return -1;
 	}
 
@@ -116,7 +116,7 @@ int git_runtime_init(git_runtime_init_fn init_fns[], size_t cnt)
 		return -1;
 
 	/* 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)
 			ret = -1;
 	}
@@ -136,7 +136,7 @@ int git_runtime_shutdown(void)
 		return -1;
 
 	/* 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();
 
 	/* Exit the lock */
diff --git a/src/thread-utils.h b/src/thread-utils.h
index 1014347..31a4c09 100644
--- a/src/thread-utils.h
+++ b/src/thread-utils.h
@@ -38,7 +38,7 @@ typedef struct {
 #else
 	volatile int val;
 #endif
-} git_atomic;
+} git_atomic32;
 
 #ifdef GIT_ARCH_64
 
@@ -58,11 +58,11 @@ typedef git_atomic64 git_atomic_ssize;
 
 #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_add git_atomic_add
-#define git_atomic_ssize_get git_atomic_get
+#define git_atomic_ssize_set git_atomic32_set
+#define git_atomic_ssize_add git_atomic32_add
+#define git_atomic_ssize_get git_atomic32_get
 
 #endif
 
@@ -74,7 +74,7 @@ typedef git_atomic git_atomic_ssize;
 #   include "unix/pthread.h"
 #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)
 	InterlockedExchange(&a->val, (LONG)val);
@@ -87,7 +87,7 @@ GIT_INLINE(void) git_atomic_set(git_atomic *a, int val)
 #endif
 }
 
-GIT_INLINE(int) git_atomic_inc(git_atomic *a)
+GIT_INLINE(int) git_atomic32_inc(git_atomic32 *a)
 {
 #if defined(GIT_WIN32)
 	return InterlockedIncrement(&a->val);
@@ -100,7 +100,7 @@ GIT_INLINE(int) git_atomic_inc(git_atomic *a)
 #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)
 	return InterlockedExchangeAdd(&a->val, addend);
@@ -113,7 +113,7 @@ GIT_INLINE(int) git_atomic_add(git_atomic *a, int32_t addend)
 #endif
 }
 
-GIT_INLINE(int) git_atomic_dec(git_atomic *a)
+GIT_INLINE(int) git_atomic32_dec(git_atomic32 *a)
 {
 #if defined(GIT_WIN32)
 	return InterlockedDecrement(&a->val);
@@ -126,7 +126,7 @@ GIT_INLINE(int) git_atomic_dec(git_atomic *a)
 #endif
 }
 
-GIT_INLINE(int) git_atomic_get(git_atomic *a)
+GIT_INLINE(int) git_atomic32_get(git_atomic32 *a)
 {
 #if defined(GIT_WIN32)
 	return (int)InterlockedCompareExchange(&a->val, 0, 0);
@@ -268,28 +268,28 @@ GIT_INLINE(int64_t) git_atomic64_get(git_atomic64 *a)
 #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;
 }
 
-GIT_INLINE(int) git_atomic_inc(git_atomic *a)
+GIT_INLINE(int) git_atomic32_inc(git_atomic32 *a)
 {
 	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;
 	return a->val;
 }
 
-GIT_INLINE(int) git_atomic_dec(git_atomic *a)
+GIT_INLINE(int) git_atomic32_dec(git_atomic32 *a)
 {
 	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;
 }
diff --git a/src/transports/local.c b/src/transports/local.c
index 4af85db..bb31b13 100644
--- a/src/transports/local.c
+++ b/src/transports/local.c
@@ -36,7 +36,7 @@ typedef struct {
 	char *url;
 	int direction;
 	int flags;
-	git_atomic cancelled;
+	git_atomic32 cancelled;
 	git_repository *repo;
 	git_transport_message_cb progress_cb;
 	git_transport_message_cb error_cb;
@@ -671,7 +671,7 @@ static void local_cancel(git_transport *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)
diff --git a/src/transports/smart.c b/src/transports/smart.c
index 3b8a14a..da8fe8e 100644
--- a/src/transports/smart.c
+++ b/src/transports/smart.c
@@ -30,7 +30,7 @@ static int git_smart__recv_cb(gitno_buffer *buf)
 	if (t->packetsize_cb && !t->cancelled.val) {
 		error = t->packetsize_cb(bytes_read, t->packetsize_payload);
 		if (error) {
-			git_atomic_set(&t->cancelled, 1);
+			git_atomic32_set(&t->cancelled, 1);
 			return GIT_EUSER;
 		}
 	}
@@ -389,7 +389,7 @@ static void git_smart__cancel(git_transport *transport)
 {
 	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)
diff --git a/src/transports/smart.h b/src/transports/smart.h
index 18e0b7e..a05d4c9 100644
--- a/src/transports/smart.h
+++ b/src/transports/smart.h
@@ -153,7 +153,7 @@ typedef struct {
 	git_vector refs;
 	git_vector heads;
 	git_vector common;
-	git_atomic cancelled;
+	git_atomic32 cancelled;
 	packetsize_cb packetsize_cb;
 	void *packetsize_payload;
 	unsigned rpc : 1,
diff --git a/src/transports/smart_protocol.c b/src/transports/smart_protocol.c
index 18dcaa8..9482915 100644
--- a/src/transports/smart_protocol.c
+++ b/src/transports/smart_protocol.c
@@ -535,7 +535,7 @@ int git_smart__download_pack(
 		/* We might have something in the buffer already from negotiate_fetch */
 		if (t->buffer.offset > 0 && !t->cancelled.val)
 			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 ||
diff --git a/src/util.h b/src/util.h
index ef5e4eb..6c7c4c2 100644
--- a/src/util.h
+++ b/src/util.h
@@ -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);
 
 typedef struct {
-	git_atomic refcount;
+	git_atomic32 refcount;
 	void *owner;
 } git_refcount;
 
 typedef void (*git_refcount_freeptr)(void *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) { \
 	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); } \
 }
 
@@ -191,7 +191,7 @@ typedef void (*git_refcount_freeptr)(void *r);
 
 #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[] = {
diff --git a/tests/threads/diff.c b/tests/threads/diff.c
index 6996427..04c8cb9 100644
--- a/tests/threads/diff.c
+++ b/tests/threads/diff.c
@@ -17,7 +17,7 @@
 
 static git_repository *_repo;
 static git_tree *_a, *_b;
-static git_atomic _counts[4];
+static git_atomic32 _counts[4];
 static int _check_counts;
 #ifdef GIT_WIN32
 static int _retries;
@@ -66,10 +66,10 @@ static void free_trees(void)
 	git_tree_free(_b); _b = NULL;
 
 	if (_check_counts) {
-		cl_assert_equal_i(288, git_atomic_get(&_counts[0]));
-		cl_assert_equal_i(112, git_atomic_get(&_counts[1]));
-		cl_assert_equal_i( 80, git_atomic_get(&_counts[2]));
-		cl_assert_equal_i( 96, git_atomic_get(&_counts[3]));
+		cl_assert_equal_i(288, git_atomic32_get(&_counts[0]));
+		cl_assert_equal_i(112, git_atomic32_get(&_counts[1]));
+		cl_assert_equal_i( 80, git_atomic32_get(&_counts[2]));
+		cl_assert_equal_i( 96, git_atomic32_get(&_counts[3]));
 	}
 }
 
@@ -107,14 +107,14 @@ static void *run_index_diffs(void *arg)
 	/* keep some diff stats to make sure results are as expected */
 
 	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;
 
 	while (i > 0) {
 		switch (git_diff_get_delta(diff, --i)->status) {
-		case GIT_DELTA_MODIFIED: exp[1]++; git_atomic_inc(&_counts[1]); break;
-		case GIT_DELTA_ADDED:    exp[2]++; git_atomic_inc(&_counts[2]); break;
-		case GIT_DELTA_DELETED:  exp[3]++; git_atomic_inc(&_counts[3]); break;
+		case GIT_DELTA_MODIFIED: exp[1]++; git_atomic32_inc(&_counts[1]); break;
+		case GIT_DELTA_ADDED:    exp[2]++; git_atomic32_inc(&_counts[2]); break;
+		case GIT_DELTA_DELETED:  exp[3]++; git_atomic32_inc(&_counts[3]); break;
 		default: break;
 		}
 	}