diff options
Diffstat (limited to 'xdelta3/xdelta3-blkcache.h')
-rw-r--r-- | xdelta3/xdelta3-blkcache.h | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/xdelta3/xdelta3-blkcache.h b/xdelta3/xdelta3-blkcache.h index 1ae663e..8de5d13 100644 --- a/xdelta3/xdelta3-blkcache.h +++ b/xdelta3/xdelta3-blkcache.h | |||
@@ -26,6 +26,9 @@ | |||
26 | typedef struct _main_blklru main_blklru; | 26 | typedef struct _main_blklru main_blklru; |
27 | typedef struct _main_blklru_list main_blklru_list; | 27 | typedef struct _main_blklru_list main_blklru_list; |
28 | 28 | ||
29 | |||
30 | #define XD3_INVALID_OFFSET XOFF_T_MAX | ||
31 | |||
29 | struct _main_blklru_list | 32 | struct _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 | ||
@@ -255,7 +258,7 @@ main_set_source (xd3_stream *stream, xd3_cmd cmd, | |||
255 | 258 | ||
256 | if (option_verbose > 1) | 259 | if (option_verbose > 1) |
257 | { | 260 | { |
258 | short_sprintf (nbufs, " #bufs %u", lru_size); | 261 | short_sprintf (nbufs, " #bufs %"W"u", lru_size); |
259 | } | 262 | } |
260 | 263 | ||
261 | XPR(NT "source %s %s blksize %s window %s%s%s\n", | 264 | XPR(NT "source %s %s blksize %s window %s%s%s\n", |
@@ -290,7 +293,7 @@ main_getblk_lru (xd3_source *source, xoff_t blkno, | |||
290 | return 0; | 293 | return 0; |
291 | } | 294 | } |
292 | /* No going backwards in a sequential scan. */ | 295 | /* No going backwards in a sequential scan. */ |
293 | if (blru->blkno != (xoff_t) -1 && blru->blkno > blkno) | 296 | if (blru->blkno != XD3_INVALID_OFFSET && blru->blkno > blkno) |
294 | { | 297 | { |
295 | return XD3_TOOFARBACK; | 298 | return XD3_TOOFARBACK; |
296 | } | 299 | } |
@@ -326,7 +329,7 @@ main_getblk_lru (xd3_source *source, xoff_t blkno, | |||
326 | lru_filled += 1; | 329 | lru_filled += 1; |
327 | (*is_new) = 1; | 330 | (*is_new) = 1; |
328 | (*blrup) = blru; | 331 | (*blrup) = blru; |
329 | blru->blkno = -1; | 332 | blru->blkno = XD3_INVALID_OFFSET; |
330 | return 0; | 333 | return 0; |
331 | } | 334 | } |
332 | 335 | ||
@@ -436,7 +439,7 @@ main_read_seek_source (xd3_stream *stream, | |||
436 | sfile->source_position += nread; | 439 | sfile->source_position += nread; |
437 | blru->size = nread; | 440 | blru->size = nread; |
438 | 441 | ||
439 | IF_DEBUG1 (DP(RINT "[getblk] skip blkno %"Q"u size %u\n", | 442 | IF_DEBUG1 (DP(RINT "[getblk] skip blkno %"Q" size %u\n", |
440 | skip_blkno, blru->size)); | 443 | skip_blkno, blru->size)); |
441 | 444 | ||
442 | XD3_ASSERT (sfile->source_position <= pos); | 445 | XD3_ASSERT (sfile->source_position <= pos); |
@@ -528,7 +531,7 @@ main_getblk_func (xd3_stream *stream, | |||
528 | 531 | ||
529 | if (option_verbose > 3) | 532 | if (option_verbose > 3) |
530 | { | 533 | { |
531 | if (blru->blkno != (xoff_t)-1) | 534 | if (blru->blkno != XD3_INVALID_OFFSET) |
532 | { | 535 | { |
533 | if (blru->blkno != blkno) | 536 | if (blru->blkno != blkno) |
534 | { | 537 | { |