summaryrefslogtreecommitdiff
path: root/xdelta3/xdelta3-blkcache.h
diff options
context:
space:
mode:
Diffstat (limited to 'xdelta3/xdelta3-blkcache.h')
-rw-r--r--xdelta3/xdelta3-blkcache.h19
1 files changed, 11 insertions, 8 deletions
diff --git a/xdelta3/xdelta3-blkcache.h b/xdelta3/xdelta3-blkcache.h
index f8fa8e2..20a2a4a 100644
--- a/xdelta3/xdelta3-blkcache.h
+++ b/xdelta3/xdelta3-blkcache.h
@@ -26,6 +26,9 @@
26typedef struct _main_blklru main_blklru; 26typedef struct _main_blklru main_blklru;
27typedef struct _main_blklru_list main_blklru_list; 27typedef struct _main_blklru_list main_blklru_list;
28 28
29
30#define XD3_INVALID_OFFSET XOFF_T_MAX
31
29struct _main_blklru_list 32struct _main_blklru_list
30{ 33{
31 main_blklru_list *next; 34 main_blklru_list *next;
@@ -125,7 +128,7 @@ main_set_source (xd3_stream *stream, xd3_cmd cmd,
125 /* Note: The API requires a power-of-two blocksize and srcwinsz 128 /* Note: The API requires a power-of-two blocksize and srcwinsz
126 * (-B). The logic here will use a single block if the entire file 129 * (-B). The logic here will use a single block if the entire file
127 * is known to fit into srcwinsz. */ 130 * is known to fit into srcwinsz. */
128 option_srcwinsz = xd3_pow2_roundup (option_srcwinsz); 131 option_srcwinsz = xd3_xoff_roundup (option_srcwinsz);
129 132
130 /* Though called "lru", it is not LRU-specific. We always allocate 133 /* Though called "lru", it is not LRU-specific. We always allocate
131 * a maximum number of source block buffers. If the entire file 134 * a maximum number of source block buffers. If the entire file
@@ -153,7 +156,7 @@ main_set_source (xd3_stream *stream, xd3_cmd cmd,
153 * is the point at which external decompression may begin. Set the 156 * is the point at which external decompression may begin. Set the
154 * system for a single block. */ 157 * system for a single block. */
155 lru_size = 1; 158 lru_size = 1;
156 lru[0].blkno = (xoff_t) -1; 159 lru[0].blkno = XD3_INVALID_OFFSET;
157 blksize = option_srcwinsz; 160 blksize = option_srcwinsz;
158 main_blklru_list_push_back (& lru_list, & lru[0]); 161 main_blklru_list_push_back (& lru_list, & lru[0]);
159 XD3_ASSERT (blksize != 0); 162 XD3_ASSERT (blksize != 0);
@@ -162,7 +165,7 @@ main_set_source (xd3_stream *stream, xd3_cmd cmd,
162 source->blksize = blksize; 165 source->blksize = blksize;
163 source->name = sfile->filename; 166 source->name = sfile->filename;
164 source->ioh = sfile; 167 source->ioh = sfile;
165 source->curblkno = (xoff_t) -1; 168 source->curblkno = XD3_INVALID_OFFSET;
166 source->curblk = NULL; 169 source->curblk = NULL;
167 source->max_winsize = option_srcwinsz; 170 source->max_winsize = option_srcwinsz;
168 171
@@ -258,7 +261,7 @@ main_set_source (xd3_stream *stream, xd3_cmd cmd,
258 261
259 if (option_verbose > 1) 262 if (option_verbose > 1)
260 { 263 {
261 short_sprintf (nbufs, " #bufs %u", lru_size); 264 short_sprintf (nbufs, " #bufs %"W"u", lru_size);
262 } 265 }
263 266
264 XPR(NT "source %s %s blksize %s window %s%s%s\n", 267 XPR(NT "source %s %s blksize %s window %s%s%s\n",
@@ -293,7 +296,7 @@ main_getblk_lru (xd3_source *source, xoff_t blkno,
293 return 0; 296 return 0;
294 } 297 }
295 /* No going backwards in a sequential scan. */ 298 /* No going backwards in a sequential scan. */
296 if (blru->blkno != (xoff_t) -1 && blru->blkno > blkno) 299 if (blru->blkno != XD3_INVALID_OFFSET && blru->blkno > blkno)
297 { 300 {
298 return XD3_TOOFARBACK; 301 return XD3_TOOFARBACK;
299 } 302 }
@@ -333,7 +336,7 @@ main_getblk_lru (xd3_source *source, xoff_t blkno,
333 lru_filled += 1; 336 lru_filled += 1;
334 (*is_new) = 1; 337 (*is_new) = 1;
335 (*blrup) = blru; 338 (*blrup) = blru;
336 blru->blkno = -1; 339 blru->blkno = XD3_INVALID_OFFSET;
337 return 0; 340 return 0;
338} 341}
339 342
@@ -443,7 +446,7 @@ main_read_seek_source (xd3_stream *stream,
443 sfile->source_position += nread; 446 sfile->source_position += nread;
444 blru->size = nread; 447 blru->size = nread;
445 448
446 IF_DEBUG1 (DP(RINT "[getblk] skip blkno %"Q"u size %u\n", 449 IF_DEBUG1 (DP(RINT "[getblk] skip blkno %"Q" size %u\n",
447 skip_blkno, blru->size)); 450 skip_blkno, blru->size));
448 451
449 XD3_ASSERT (sfile->source_position <= pos); 452 XD3_ASSERT (sfile->source_position <= pos);
@@ -524,7 +527,7 @@ main_getblk_func (xd3_stream *stream,
524 527
525 if (option_verbose > 3) 528 if (option_verbose > 3)
526 { 529 {
527 if (blru->blkno != (xoff_t)-1) 530 if (blru->blkno != XD3_INVALID_OFFSET)
528 { 531 {
529 if (blru->blkno != blkno) 532 if (blru->blkno != blkno)
530 { 533 {