diff options
Diffstat (limited to 'xdelta3/xdelta3.h')
-rw-r--r-- | xdelta3/xdelta3.h | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/xdelta3/xdelta3.h b/xdelta3/xdelta3.h index af79839..9abddbf 100644 --- a/xdelta3/xdelta3.h +++ b/xdelta3/xdelta3.h | |||
@@ -677,8 +677,7 @@ struct _xd3_source | |||
677 | xoff_t blocks; /* the total number of blocks in | 677 | xoff_t blocks; /* the total number of blocks in |
678 | this source */ | 678 | this source */ |
679 | usize_t onlastblk; /* cached size info, avoid __udivdi3 */ | 679 | usize_t onlastblk; /* cached size info, avoid __udivdi3 */ |
680 | usize_t cpyoff_blocks; /* offset of copy window in | 680 | xoff_t cpyoff_blocks; /* offset of dec_cpyoff in blocks */ |
681 | blocks */ | ||
682 | usize_t cpyoff_blkoff; /* offset of copy window in | 681 | usize_t cpyoff_blkoff; /* offset of copy window in |
683 | blocks, remainder */ | 682 | blocks, remainder */ |
684 | xoff_t getblkno; /* request block number: xd3 sets | 683 | xoff_t getblkno; /* request block number: xd3 sets |
@@ -1164,6 +1163,18 @@ const char* xd3_errstring (xd3_stream *stream) | |||
1164 | return stream->msg ? stream->msg : ""; | 1163 | return stream->msg ? stream->msg : ""; |
1165 | } | 1164 | } |
1166 | 1165 | ||
1166 | |||
1167 | /* 64-bit divisions are expensive. on a 32bit platform, these show in | ||
1168 | * a profile as __udivdi3(). these are all the xoff_t divisions: */ | ||
1169 | static inline | ||
1170 | void xd3_blksize_div (const xoff_t offset, | ||
1171 | const xd3_source *source, | ||
1172 | xoff_t *blkno, | ||
1173 | usize_t *blkoff) { | ||
1174 | *blkno = offset / source->blksize; | ||
1175 | *blkoff = offset - (*blkno * source->blksize); | ||
1176 | } | ||
1177 | |||
1167 | /* This function tells the number of bytes expected to be set in | 1178 | /* This function tells the number of bytes expected to be set in |
1168 | * source->onblk after a getblk request. This is for convenience of | 1179 | * source->onblk after a getblk request. This is for convenience of |
1169 | * handling a partial last block. Note that this is a relatively | 1180 | * handling a partial last block. Note that this is a relatively |
@@ -1173,14 +1184,16 @@ const char* xd3_errstring (xd3_stream *stream) | |||
1173 | static inline | 1184 | static inline |
1174 | usize_t xd3_bytes_on_srcblk (xd3_source *source, xoff_t blkno) | 1185 | usize_t xd3_bytes_on_srcblk (xd3_source *source, xoff_t blkno) |
1175 | { | 1186 | { |
1187 | xoff_t s_1_div; | ||
1188 | usize_t s_1_rem; | ||
1176 | XD3_ASSERT (blkno < source->blocks); | 1189 | XD3_ASSERT (blkno < source->blocks); |
1177 | 1190 | ||
1178 | if (blkno != source->blocks - 1) | 1191 | if (blkno != source->blocks - 1) |
1179 | { | 1192 | { |
1180 | return source->blksize; | 1193 | return source->blksize; |
1181 | } | 1194 | } |
1182 | 1195 | xd3_blksize_div(source->size - 1, source, &s_1_div, &s_1_rem); | |
1183 | return (usize_t)((source->size - 1) % source->blksize) + 1; | 1196 | return s_1_rem + 1; |
1184 | } | 1197 | } |
1185 | 1198 | ||
1186 | static inline | 1199 | static inline |