Commit 6460e8abcfda7692af9bd267bddf6e11a78f8130

Edward Thomson 2019-06-23T18:13:29

internal: use off64_t instead of git_off_t Prefer `off64_t` internally.

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
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
diff --git a/src/indexer.c b/src/indexer.c
index 84b950d..717549f 100644
--- a/src/indexer.c
+++ b/src/indexer.c
@@ -47,8 +47,8 @@ struct git_indexer {
 	struct git_pack_header hdr;
 	struct git_pack_file *pack;
 	unsigned int mode;
-	git_off_t off;
-	git_off_t entry_start;
+	off64_t off;
+	off64_t entry_start;
 	git_object_t entry_type;
 	git_buf entry_data;
 	git_packfile_stream stream;
@@ -75,7 +75,7 @@ struct git_indexer {
 };
 
 struct delta_info {
-	git_off_t delta_off;
+	off64_t delta_off;
 };
 
 const git_oid *git_indexer_hash(const git_indexer *idx)
@@ -220,7 +220,7 @@ static int store_delta(git_indexer *idx)
 	return 0;
 }
 
-static int hash_header(git_hash_ctx *ctx, git_off_t len, git_object_t type)
+static int hash_header(git_hash_ctx *ctx, off64_t len, git_object_t type)
 {
 	char buffer[64];
 	size_t hdrlen;
@@ -265,7 +265,7 @@ static int advance_delta_offset(git_indexer *idx, git_object_t type)
 	if (type == GIT_OBJECT_REF_DELTA) {
 		idx->off += GIT_OID_RAWSZ;
 	} else {
-		git_off_t base_off = get_delta_base(idx->pack, &w, &idx->off, type, idx->entry_start);
+		off64_t base_off = get_delta_base(idx->pack, &w, &idx->off, type, idx->entry_start);
 		git_mwindow_close(&w);
 		if (base_off < 0)
 			return (int)base_off;
@@ -291,7 +291,7 @@ static int read_object_stream(git_indexer *idx, git_packfile_stream *stream)
 	return 0;
 }
 
-static int crc_object(uint32_t *crc_out, git_mwindow_file *mwf, git_off_t start, git_off_t size)
+static int crc_object(uint32_t *crc_out, git_mwindow_file *mwf, off64_t start, off64_t size)
 {
 	void *ptr;
 	uint32_t crc;
@@ -414,9 +414,9 @@ static int store_object(git_indexer *idx)
 	int i, error;
 	git_oid oid;
 	struct entry *entry;
-	git_off_t entry_size;
+	off64_t entry_size;
 	struct git_pack_entry *pentry;
-	git_off_t entry_start = idx->entry_start;
+	off64_t entry_start = idx->entry_start;
 
 	entry = git__calloc(1, sizeof(*entry));
 	GIT_ERROR_CHECK_ALLOC(entry);
@@ -485,7 +485,7 @@ GIT_INLINE(bool) has_entry(git_indexer *idx, git_oid *id)
 	return git_oidmap_exists(idx->pack->idx_cache, id);
 }
 
-static int save_entry(git_indexer *idx, struct entry *entry, struct git_pack_entry *pentry, git_off_t entry_start)
+static int save_entry(git_indexer *idx, struct entry *entry, struct git_pack_entry *pentry, off64_t entry_start)
 {
 	int i;
 
@@ -515,7 +515,7 @@ static int save_entry(git_indexer *idx, struct entry *entry, struct git_pack_ent
 	return 0;
 }
 
-static int hash_and_save(git_indexer *idx, git_rawobj *obj, git_off_t entry_start)
+static int hash_and_save(git_indexer *idx, git_rawobj *obj, off64_t entry_start)
 {
 	git_oid oid;
 	size_t entry_size;
@@ -596,12 +596,12 @@ static void hash_partially(git_indexer *idx, const uint8_t *data, size_t size)
 	idx->inbuf_len += size - to_expell;
 }
 
-static int write_at(git_indexer *idx, const void *data, git_off_t offset, size_t size)
+static int write_at(git_indexer *idx, const void *data, off64_t offset, size_t size)
 {
 	git_file fd = idx->pack->mwf.fd;
 	size_t mmap_alignment;
 	size_t page_offset;
-	git_off_t page_start;
+	off64_t page_start;
 	unsigned char *map_data;
 	git_map map;
 	int error;
@@ -627,11 +627,11 @@ static int write_at(git_indexer *idx, const void *data, git_off_t offset, size_t
 
 static int append_to_pack(git_indexer *idx, const void *data, size_t size)
 {
-	git_off_t new_size;
+	off64_t new_size;
 	size_t mmap_alignment;
 	size_t page_offset;
-	git_off_t page_start;
-	git_off_t current_size = idx->pack->mwf.size;
+	off64_t page_start;
+	off64_t current_size = idx->pack->mwf.size;
 	int fd = idx->pack->mwf.fd;
 	int error;
 
@@ -661,7 +661,7 @@ static int append_to_pack(git_indexer *idx, const void *data, size_t size)
 static int read_stream_object(git_indexer *idx, git_indexer_progress *stats)
 {
 	git_packfile_stream *stream = &idx->stream;
-	git_off_t entry_start = idx->off;
+	off64_t entry_start = idx->off;
 	size_t entry_size;
 	git_object_t type;
 	git_mwindow *w = NULL;
@@ -865,7 +865,7 @@ static int inject_object(git_indexer *idx, git_oid *id)
 	git_oid foo = {{0}};
 	unsigned char hdr[64];
 	git_buf buf = GIT_BUF_INIT;
-	git_off_t entry_start;
+	off64_t entry_start;
 	const void *data;
 	size_t len, hdr_len;
 	int error;
@@ -939,7 +939,7 @@ static int fix_thin_pack(git_indexer *idx, git_indexer_progress *stats)
 	size_t size;
 	git_object_t type;
 	git_mwindow *w = NULL;
-	git_off_t curpos = 0;
+	off64_t curpos = 0;
 	unsigned char *base_info;
 	unsigned int left = 0;
 	git_oid base;
@@ -1054,7 +1054,7 @@ static int update_header_and_rehash(git_indexer *idx, git_indexer_progress *stat
 {
 	void *ptr;
 	size_t chunk = 1024*1024;
-	git_off_t hashed = 0;
+	off64_t hashed = 0;
 	git_mwindow *w = NULL;
 	git_mwindow_file *mwf;
 	unsigned int left;
diff --git a/src/mwindow.c b/src/mwindow.c
index e834f76..262786a 100644
--- a/src/mwindow.c
+++ b/src/mwindow.c
@@ -167,11 +167,11 @@ void git_mwindow_free_all_locked(git_mwindow_file *mwf)
 /*
  * Check if a window 'win' contains the address 'offset'
  */
-int git_mwindow_contains(git_mwindow *win, git_off_t offset)
+int git_mwindow_contains(git_mwindow *win, off64_t offset)
 {
-	git_off_t win_off = win->offset;
+	off64_t win_off = win->offset;
 	return win_off <= offset
-		&& offset <= (git_off_t)(win_off + win->window_map.len);
+		&& offset <= (off64_t)(win_off + win->window_map.len);
 }
 
 /*
@@ -246,12 +246,12 @@ static int git_mwindow_close_lru(git_mwindow_file *mwf)
 static git_mwindow *new_window(
 	git_mwindow_file *mwf,
 	git_file fd,
-	git_off_t size,
-	git_off_t offset)
+	off64_t size,
+	off64_t offset)
 {
 	git_mwindow_ctl *ctl = &mem_ctl;
 	size_t walign = git_mwindow__window_size / 2;
-	git_off_t len;
+	off64_t len;
 	git_mwindow *w;
 
 	w = git__malloc(sizeof(*w));
@@ -263,8 +263,8 @@ static git_mwindow *new_window(
 	w->offset = (offset / walign) * walign;
 
 	len = size - w->offset;
-	if (len > (git_off_t)git_mwindow__window_size)
-		len = (git_off_t)git_mwindow__window_size;
+	if (len > (off64_t)git_mwindow__window_size)
+		len = (off64_t)git_mwindow__window_size;
 
 	ctl->mapped += (size_t)len;
 
@@ -311,7 +311,7 @@ static git_mwindow *new_window(
 unsigned char *git_mwindow_open(
 	git_mwindow_file *mwf,
 	git_mwindow **cursor,
-	git_off_t offset,
+	off64_t offset,
 	size_t extra,
 	unsigned int *left)
 {
diff --git a/src/mwindow.h b/src/mwindow.h
index ea962d1..1a391b0 100644
--- a/src/mwindow.h
+++ b/src/mwindow.h
@@ -16,7 +16,7 @@
 typedef struct git_mwindow {
 	struct git_mwindow *next;
 	git_map window_map;
-	git_off_t offset;
+	off64_t offset;
 	size_t last_used;
 	size_t inuse_cnt;
 } git_mwindow;
@@ -24,7 +24,7 @@ typedef struct git_mwindow {
 typedef struct git_mwindow_file {
 	git_mwindow *windows;
 	int fd;
-	git_off_t size;
+	off64_t size;
 } git_mwindow_file;
 
 typedef struct git_mwindow_ctl {
@@ -37,10 +37,10 @@ typedef struct git_mwindow_ctl {
 	git_vector windowfiles;
 } git_mwindow_ctl;
 
-int git_mwindow_contains(git_mwindow *win, git_off_t offset);
+int git_mwindow_contains(git_mwindow *win, off64_t offset);
 void git_mwindow_free_all(git_mwindow_file *mwf); /* locks */
 void git_mwindow_free_all_locked(git_mwindow_file *mwf); /* run under lock */
-unsigned char *git_mwindow_open(git_mwindow_file *mwf, git_mwindow **cursor, git_off_t offset, size_t extra, unsigned int *left);
+unsigned char *git_mwindow_open(git_mwindow_file *mwf, git_mwindow **cursor, off64_t offset, size_t extra, unsigned int *left);
 int git_mwindow_file_register(git_mwindow_file *mwf);
 void git_mwindow_file_deregister(git_mwindow_file *mwf);
 void git_mwindow_close(git_mwindow **w_cursor);
diff --git a/src/pack-objects.h b/src/pack-objects.h
index 53684a1..04514da 100644
--- a/src/pack-objects.h
+++ b/src/pack-objects.h
@@ -30,7 +30,7 @@
 typedef struct git_pobject {
 	git_oid id;
 	git_object_t type;
-	git_off_t offset;
+	off64_t offset;
 
 	size_t size;
 
diff --git a/src/pack.c b/src/pack.c
index 68eeb7b..4c4eb9b 100644
--- a/src/pack.c
+++ b/src/pack.c
@@ -20,12 +20,12 @@
 bool git_disable_pack_keep_file_checks = false;
 
 static int packfile_open(struct git_pack_file *p);
-static git_off_t nth_packed_object_offset(const struct git_pack_file *p, uint32_t n);
+static off64_t nth_packed_object_offset(const struct git_pack_file *p, uint32_t n);
 static int packfile_unpack_compressed(
 		git_rawobj *obj,
 		struct git_pack_file *p,
 		git_mwindow **w_curs,
-		git_off_t *curpos,
+		off64_t *curpos,
 		size_t size,
 		git_object_t type);
 
@@ -37,7 +37,7 @@ static int packfile_unpack_compressed(
  * GIT_OID_MINPREFIXLEN and GIT_OID_HEXSZ.
  */
 static int pack_entry_find_offset(
-		git_off_t *offset_out,
+		off64_t *offset_out,
 		git_oid *found_oid,
 		struct git_pack_file *p,
 		const git_oid *short_oid,
@@ -109,7 +109,7 @@ static int cache_init(git_pack_cache *cache)
 	return 0;
 }
 
-static git_pack_cache_entry *cache_get(git_pack_cache *cache, git_off_t offset)
+static git_pack_cache_entry *cache_get(git_pack_cache *cache, off64_t offset)
 {
 	git_pack_cache_entry *entry;
 
@@ -128,7 +128,7 @@ static git_pack_cache_entry *cache_get(git_pack_cache *cache, git_off_t offset)
 /* Run with the cache lock held */
 static void free_lowest_entry(git_pack_cache *cache)
 {
-	git_off_t offset;
+	off64_t offset;
 	git_pack_cache_entry *entry;
 
 	git_offmap_foreach(cache->entries, offset, entry, {
@@ -144,7 +144,7 @@ static int cache_add(
 		git_pack_cache_entry **cached_out,
 		git_pack_cache *cache,
 		git_rawobj *base,
-		git_off_t offset)
+		off64_t offset)
 {
 	git_pack_cache_entry *entry;
 	int exists;
@@ -345,7 +345,7 @@ static int pack_index_open(struct git_pack_file *p)
 static unsigned char *pack_window_open(
 		struct git_pack_file *p,
 		git_mwindow **w_cursor,
-		git_off_t offset,
+		off64_t offset,
 		unsigned int *left)
 {
 	if (p->mwf.fd == -1 && packfile_open(p) < 0)
@@ -441,7 +441,7 @@ int git_packfile_unpack_header(
 		git_object_t *type_p,
 		git_mwindow_file *mwf,
 		git_mwindow **w_curs,
-		git_off_t *curpos)
+		off64_t *curpos)
 {
 	unsigned char *base;
 	unsigned int left;
@@ -474,13 +474,13 @@ int git_packfile_resolve_header(
 		size_t *size_p,
 		git_object_t *type_p,
 		struct git_pack_file *p,
-		git_off_t offset)
+		off64_t offset)
 {
 	git_mwindow *w_curs = NULL;
-	git_off_t curpos = offset;
+	off64_t curpos = offset;
 	size_t size;
 	git_object_t type;
-	git_off_t base_offset;
+	off64_t base_offset;
 	int error;
 
 	error = git_packfile_unpack_header(&size, &type, &p->mwf, &w_curs, &curpos);
@@ -528,13 +528,13 @@ int git_packfile_resolve_header(
  * cache, we stop calculating there.
  */
 static int pack_dependency_chain(git_dependency_chain *chain_out,
-				 git_pack_cache_entry **cached_out, git_off_t *cached_off,
+				 git_pack_cache_entry **cached_out, off64_t *cached_off,
 				 struct pack_chain_elem *small_stack, size_t *stack_sz,
-				 struct git_pack_file *p, git_off_t obj_offset)
+				 struct git_pack_file *p, off64_t obj_offset)
 {
 	git_dependency_chain chain = GIT_ARRAY_INIT;
 	git_mwindow *w_curs = NULL;
-	git_off_t curpos = obj_offset, base_offset;
+	off64_t curpos = obj_offset, base_offset;
 	int error = 0, use_heap = 0;
 	size_t size, elem_pos;
 	git_object_t type;
@@ -619,10 +619,10 @@ on_error:
 int git_packfile_unpack(
 	git_rawobj *obj,
 	struct git_pack_file *p,
-	git_off_t *obj_offset)
+	off64_t *obj_offset)
 {
 	git_mwindow *w_curs = NULL;
-	git_off_t curpos = *obj_offset;
+	off64_t curpos = *obj_offset;
 	int error, free_base = 0;
 	git_dependency_chain chain = GIT_ARRAY_INIT;
 	struct pack_chain_elem *elem = NULL, *stack;
@@ -777,7 +777,7 @@ static void use_git_free(void *opaq, void *ptr)
 	git__free(ptr);
 }
 
-int git_packfile_stream_open(git_packfile_stream *obj, struct git_pack_file *p, git_off_t curpos)
+int git_packfile_stream_open(git_packfile_stream *obj, struct git_pack_file *p, off64_t curpos)
 {
 	int st;
 
@@ -846,7 +846,7 @@ static int packfile_unpack_compressed(
 	git_rawobj *obj,
 	struct git_pack_file *p,
 	git_mwindow **w_curs,
-	git_off_t *curpos,
+	off64_t *curpos,
 	size_t size,
 	git_object_t type)
 {
@@ -909,16 +909,16 @@ static int packfile_unpack_compressed(
  * curpos is where the data starts, delta_obj_offset is the where the
  * header starts
  */
-git_off_t get_delta_base(
+off64_t get_delta_base(
 	struct git_pack_file *p,
 	git_mwindow **w_curs,
-	git_off_t *curpos,
+	off64_t *curpos,
 	git_object_t type,
-	git_off_t delta_obj_offset)
+	off64_t delta_obj_offset)
 {
 	unsigned int left = 0;
 	unsigned char *base_info;
-	git_off_t base_offset;
+	off64_t base_offset;
 	git_oid unused;
 
 	base_info = pack_window_open(p, w_curs, *curpos, &left);
@@ -1045,7 +1045,7 @@ static int packfile_open(struct git_pack_file *p)
 	if (!p->mwf.size) {
 		if (!S_ISREG(st.st_mode))
 			goto cleanup;
-		p->mwf.size = (git_off_t)st.st_size;
+		p->mwf.size = (off64_t)st.st_size;
 	} else if (p->mwf.size != st.st_size)
 		goto cleanup;
 
@@ -1182,7 +1182,7 @@ int git_packfile_alloc(struct git_pack_file **pack_out, const char *path)
  *
  ***********************************************************/
 
-static git_off_t nth_packed_object_offset(const struct git_pack_file *p, uint32_t n)
+static off64_t nth_packed_object_offset(const struct git_pack_file *p, uint32_t n)
 {
 	const unsigned char *index = p->index_map.data;
 	const unsigned char *end = index + p->index_map.len;
@@ -1270,7 +1270,7 @@ int git_pack_foreach_entry(
 }
 
 static int pack_entry_find_offset(
-	git_off_t *offset_out,
+	off64_t *offset_out,
 	git_oid *found_oid,
 	struct git_pack_file *p,
 	const git_oid *short_oid,
@@ -1280,7 +1280,7 @@ static int pack_entry_find_offset(
 	const unsigned char *index;
 	unsigned hi, lo, stride;
 	int pos, found = 0;
-	git_off_t offset;
+	off64_t offset;
 	const unsigned char *current = 0;
 
 	*offset_out = 0;
@@ -1375,7 +1375,7 @@ int git_pack_entry_find(
 		const git_oid *short_oid,
 		size_t len)
 {
-	git_off_t offset;
+	off64_t offset;
 	git_oid found_oid;
 	int error;
 
diff --git a/src/pack.h b/src/pack.h
index 483c4e8..a294ecd 100644
--- a/src/pack.h
+++ b/src/pack.h
@@ -64,8 +64,8 @@ typedef struct git_pack_cache_entry {
 } git_pack_cache_entry;
 
 struct pack_chain_elem {
-	git_off_t base_key;
-	git_off_t offset;
+	off64_t base_key;
+	off64_t offset;
 	size_t size;
 	git_object_t type;
 };
@@ -108,13 +108,13 @@ struct git_pack_file {
 };
 
 struct git_pack_entry {
-	git_off_t offset;
+	off64_t offset;
 	git_oid sha1;
 	struct git_pack_file *p;
 };
 
 typedef struct git_packfile_stream {
-	git_off_t curpos;
+	off64_t curpos;
 	int done;
 	z_stream zstream;
 	struct git_pack_file *p;
@@ -130,23 +130,23 @@ int git_packfile_unpack_header(
 		git_object_t *type_p,
 		git_mwindow_file *mwf,
 		git_mwindow **w_curs,
-		git_off_t *curpos);
+		off64_t *curpos);
 
 int git_packfile_resolve_header(
 		size_t *size_p,
 		git_object_t *type_p,
 		struct git_pack_file *p,
-		git_off_t offset);
+		off64_t offset);
 
-int git_packfile_unpack(git_rawobj *obj, struct git_pack_file *p, git_off_t *obj_offset);
+int git_packfile_unpack(git_rawobj *obj, struct git_pack_file *p, off64_t *obj_offset);
 
-int git_packfile_stream_open(git_packfile_stream *obj, struct git_pack_file *p, git_off_t curpos);
+int git_packfile_stream_open(git_packfile_stream *obj, struct git_pack_file *p, off64_t curpos);
 ssize_t git_packfile_stream_read(git_packfile_stream *obj, void *buffer, size_t len);
 void git_packfile_stream_dispose(git_packfile_stream *obj);
 
-git_off_t get_delta_base(struct git_pack_file *p, git_mwindow **w_curs,
-		git_off_t *curpos, git_object_t type,
-		git_off_t delta_obj_offset);
+off64_t get_delta_base(struct git_pack_file *p, git_mwindow **w_curs,
+		off64_t *curpos, git_object_t type,
+		off64_t delta_obj_offset);
 
 void git_packfile_close(struct git_pack_file *p, bool unlink_packfile);
 void git_packfile_free(struct git_pack_file *p);
diff --git a/src/unix/map.c b/src/unix/map.c
index 1ebbced..7f9076e 100644
--- a/src/unix/map.c
+++ b/src/unix/map.c
@@ -32,7 +32,7 @@ int git__mmap_alignment(size_t *alignment)
   return git__page_size(alignment);
 }
 
-int p_mmap(git_map *out, size_t len, int prot, int flags, int fd, git_off_t offset)
+int p_mmap(git_map *out, size_t len, int prot, int flags, int fd, off64_t offset)
 {
 	int mprot = PROT_READ;
 	int mflag = 0;
diff --git a/src/win32/posix.h b/src/win32/posix.h
index e427d64..f115088 100644
--- a/src/win32/posix.h
+++ b/src/win32/posix.h
@@ -47,7 +47,7 @@ extern int p_chdir(const char* path);
 extern int p_chmod(const char* path, mode_t mode);
 extern int p_rmdir(const char* path);
 extern int p_access(const char* path, mode_t mode);
-extern int p_ftruncate(int fd, git_off_t size);
+extern int p_ftruncate(int fd, off64_t size);
 
 /* p_lstat is almost but not quite POSIX correct.  Specifically, the use of
  * ENOTDIR is wrong, in that it does not mean precisely that a non-directory
diff --git a/src/win32/posix_w32.c b/src/win32/posix_w32.c
index 078b509..2bc93a3 100644
--- a/src/win32/posix_w32.c
+++ b/src/win32/posix_w32.c
@@ -210,7 +210,7 @@ on_error:
  * We now take a "git_off_t" rather than "long" because
  * files may be longer than 2Gb.
  */
-int p_ftruncate(int fd, git_off_t size)
+int p_ftruncate(int fd, off64_t size)
 {
 	if (size < 0) {
 		errno = EINVAL;
diff --git a/src/win32/w32_util.h b/src/win32/w32_util.h
index ac19115..d7f9d3d 100644
--- a/src/win32/w32_util.h
+++ b/src/win32/w32_util.h
@@ -120,7 +120,7 @@ GIT_INLINE(void) git_win32__stat_init(
 	st->st_uid = 0;
 	st->st_nlink = 1;
 	st->st_mode = mode;
-	st->st_size = ((git_off_t)nFileSizeHigh << 32) + nFileSizeLow;
+	st->st_size = ((int64_t)nFileSizeHigh << 32) + nFileSizeLow;
 	st->st_dev = _getdrive() - 1;
 	st->st_rdev = st->st_dev;
 	git_win32__filetime_to_timespec(&ftLastAccessTime, &(st->st_atim));
diff --git a/tests/core/ftruncate.c b/tests/core/ftruncate.c
index 2f4729f..0c731cb 100644
--- a/tests/core/ftruncate.c
+++ b/tests/core/ftruncate.c
@@ -27,7 +27,7 @@ void test_core_ftruncate__cleanup(void)
 	p_unlink(filename);
 }
 
-static void _extend(git_off_t i64len)
+static void _extend(off64_t i64len)
 {
 	struct stat st;
 	int error;
diff --git a/tests/index/tests.c b/tests/index/tests.c
index 2d2744d..1164cba 100644
--- a/tests/index/tests.c
+++ b/tests/index/tests.c
@@ -13,7 +13,7 @@ static const size_t index_entry_count_2 = 1437;
 struct test_entry {
    size_t index;
    char path[128];
-   git_off_t file_size;
+   off64_t file_size;
    git_time_t mtime;
 };
 
diff --git a/tests/object/blob/filter.c b/tests/object/blob/filter.c
index 45dbc92..0f0f484 100644
--- a/tests/object/blob/filter.c
+++ b/tests/object/blob/filter.c
@@ -19,7 +19,7 @@ static const char *g_crlf_raw[CRLF_NUM_TEST_OBJECTS] = {
 	"\xFE\xFF\x00T\x00h\x00i\x00s\x00!"
 };
 
-static git_off_t g_crlf_raw_len[CRLF_NUM_TEST_OBJECTS] = {
+static off64_t g_crlf_raw_len[CRLF_NUM_TEST_OBJECTS] = {
 	-1, -1, -1, -1, -1, 17, -1, -1, 12
 };