src/lib: Use tabs instead of spaces
Fix the following errors and warnings detected by checkpatch.pl: ERROR: code indent should use tabs where possible ERROR: switch and case should be at the same indent WARNING: Statements should start on a tabstop WARNING: please, no spaces at the start of a line WARNING: please, no space before tabs WARNING: suspect code indent for conditional statements WARNING: labels should not be indented TEST=Build and run on Galileo Gen2 Change-Id: Iebcff26ad41ab6eb0027b871a1c06f3b52dd207c Signed-off-by: Lee Leahy <Leroy.P.Leahy@intel.com> Reviewed-on: https://review.coreboot.org/18732 Tested-by: build bot (Jenkins) Reviewed-by: Martin Roth <martinroth@google.com>
This commit is contained in:
@ -875,11 +875,9 @@ parse_cea(struct edid *out, unsigned char *x, struct edid_context *c)
|
||||
if (offset < 4)
|
||||
break;
|
||||
|
||||
if (version < 3) {
|
||||
if (version < 3)
|
||||
printk(BIOS_SPEW, "%d 8-byte timing descriptors\n", (offset - 4) / 8);
|
||||
if (offset - 4 > 0)
|
||||
/* do stuff */ ;
|
||||
} else if (version == 3) {
|
||||
else if (version == 3) {
|
||||
int i;
|
||||
printk(BIOS_SPEW, "%d bytes of CEA data\n", offset - 4);
|
||||
for (i = 4; i < offset; i += (x[i] & 0x1f) + 1)
|
||||
|
@ -36,8 +36,7 @@ static void gcov_allocate(unsigned int);
|
||||
static inline gcov_unsigned_t from_file(gcov_unsigned_t value)
|
||||
{
|
||||
#if !IN_LIBGCOV
|
||||
if (gcov_var.endian)
|
||||
{
|
||||
if (gcov_var.endian) {
|
||||
value = (value >> 16) | (value << 16);
|
||||
value = ((value & 0xff00ff) << 8) | ((value >> 8) & 0xff00ff);
|
||||
}
|
||||
@ -84,14 +83,11 @@ gcov_open(const char *name, int mode)
|
||||
gcov_var.endian = 0;
|
||||
#endif
|
||||
#if GCOV_LOCKED
|
||||
if (mode > 0)
|
||||
{
|
||||
if (mode > 0) {
|
||||
/* Read-only mode - acquire a read-lock. */
|
||||
s_flock.l_type = F_RDLCK;
|
||||
fd = open(name, O_RDONLY);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
/* Write mode - acquire a write-lock. */
|
||||
s_flock.l_type = F_WRLCK;
|
||||
fd = open(name, O_RDWR | O_CREAT, 0666);
|
||||
@ -104,20 +100,17 @@ gcov_open(const char *name, int mode)
|
||||
|
||||
gcov_var.file = fdopen(fd, (mode > 0) ? "rb" : "r+b");
|
||||
|
||||
if (!gcov_var.file)
|
||||
{
|
||||
if (!gcov_var.file) {
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (mode > 0)
|
||||
gcov_var.mode = 1;
|
||||
else if (mode == 0)
|
||||
{
|
||||
else if (mode == 0) {
|
||||
struct stat st;
|
||||
|
||||
if (fstat(fd, &st) < 0)
|
||||
{
|
||||
if (fstat(fd, &st) < 0) {
|
||||
fclose(gcov_var.file);
|
||||
gcov_var.file = 0;
|
||||
return 0;
|
||||
@ -126,8 +119,7 @@ gcov_open(const char *name, int mode)
|
||||
gcov_var.mode = 1;
|
||||
else
|
||||
gcov_var.mode = mode * 2 + 1;
|
||||
}
|
||||
else
|
||||
} else
|
||||
gcov_var.mode = mode * 2 + 1;
|
||||
#else
|
||||
if (mode >= 0)
|
||||
@ -135,8 +127,7 @@ gcov_open(const char *name, int mode)
|
||||
|
||||
if (gcov_var.file)
|
||||
gcov_var.mode = 1;
|
||||
else if (mode <= 0)
|
||||
{
|
||||
else if (mode <= 0) {
|
||||
gcov_var.file = fopen(name, "w+b");
|
||||
if (gcov_var.file)
|
||||
gcov_var.mode = mode * 2 + 1;
|
||||
@ -156,8 +147,7 @@ gcov_open(const char *name, int mode)
|
||||
GCOV_LINKAGE int
|
||||
gcov_close(void)
|
||||
{
|
||||
if (gcov_var.file)
|
||||
{
|
||||
if (gcov_var.file) {
|
||||
#if !IN_GCOV
|
||||
if (gcov_var.offset && gcov_var.mode < 0)
|
||||
gcov_write_block(gcov_var.offset);
|
||||
@ -187,8 +177,7 @@ gcov_magic(gcov_unsigned_t magic, gcov_unsigned_t expected)
|
||||
return 1;
|
||||
magic = (magic >> 16) | (magic << 16);
|
||||
magic = ((magic & 0xff00ff) << 8) | ((magic >> 8) & 0xff00ff);
|
||||
if (magic == expected)
|
||||
{
|
||||
if (magic == expected) {
|
||||
gcov_var.endian = 1;
|
||||
return -1;
|
||||
}
|
||||
@ -208,7 +197,8 @@ gcov_allocate(unsigned int length)
|
||||
new_size *= 2;
|
||||
|
||||
gcov_var.alloc = new_size;
|
||||
gcov_var.buffer = XRESIZEVAR(gcov_unsigned_t, gcov_var.buffer, new_size << 2);
|
||||
gcov_var.buffer = XRESIZEVAR(gcov_unsigned_t, gcov_var.buffer,
|
||||
new_size << 2);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -234,13 +224,12 @@ gcov_write_words(unsigned int words)
|
||||
|
||||
gcc_assert(gcov_var.mode < 0);
|
||||
#if IN_LIBGCOV
|
||||
if (gcov_var.offset >= GCOV_BLOCK_SIZE)
|
||||
{
|
||||
if (gcov_var.offset >= GCOV_BLOCK_SIZE) {
|
||||
gcov_write_block(GCOV_BLOCK_SIZE);
|
||||
if (gcov_var.offset)
|
||||
{
|
||||
if (gcov_var.offset) {
|
||||
gcc_assert(gcov_var.offset == 1);
|
||||
memcpy(gcov_var.buffer, gcov_var.buffer + GCOV_BLOCK_SIZE, 4);
|
||||
memcpy(gcov_var.buffer, gcov_var.buffer
|
||||
+ GCOV_BLOCK_SIZE, 4);
|
||||
}
|
||||
}
|
||||
#else
|
||||
@ -292,8 +281,7 @@ gcov_write_string(const char *string)
|
||||
unsigned int alloc = 0;
|
||||
gcov_unsigned_t *buffer;
|
||||
|
||||
if (string)
|
||||
{
|
||||
if (string) {
|
||||
length = strlen(string);
|
||||
alloc = (length + 4) >> 2;
|
||||
}
|
||||
@ -369,8 +357,7 @@ gcov_write_summary(gcov_unsigned_t tag, const struct gcov_summary *summary)
|
||||
|
||||
gcov_write_tag_length(tag, GCOV_TAG_SUMMARY_LENGTH);
|
||||
gcov_write_unsigned(summary->checksum);
|
||||
for (csum = summary->ctrs, ix = GCOV_COUNTERS_SUMMABLE; ix--; csum++)
|
||||
{
|
||||
for (csum = summary->ctrs, ix = GCOV_COUNTERS_SUMMABLE; ix--; csum++) {
|
||||
gcov_write_unsigned(csum->num);
|
||||
gcov_write_unsigned(csum->runs);
|
||||
gcov_write_counter(csum->sum_all);
|
||||
@ -392,17 +379,17 @@ gcov_read_words(unsigned int words)
|
||||
unsigned int excess = gcov_var.length - gcov_var.offset;
|
||||
|
||||
gcc_assert(gcov_var.mode > 0);
|
||||
if (excess < words)
|
||||
{
|
||||
if (excess < words) {
|
||||
gcov_var.start += gcov_var.offset;
|
||||
#if IN_LIBGCOV
|
||||
if (excess)
|
||||
{
|
||||
if (excess) {
|
||||
gcc_assert(excess == 1);
|
||||
memcpy(gcov_var.buffer, gcov_var.buffer + gcov_var.offset, 4);
|
||||
memcpy(gcov_var.buffer, gcov_var.buffer
|
||||
+ gcov_var.offset, 4);
|
||||
}
|
||||
#else
|
||||
memmove(gcov_var.buffer, gcov_var.buffer + gcov_var.offset, excess * 4);
|
||||
memmove(gcov_var.buffer, gcov_var.buffer
|
||||
+ gcov_var.offset, excess * 4);
|
||||
#endif
|
||||
gcov_var.offset = 0;
|
||||
gcov_var.length = excess;
|
||||
@ -417,8 +404,7 @@ gcov_read_words(unsigned int words)
|
||||
excess = fread(gcov_var.buffer + gcov_var.length,
|
||||
1, excess << 2, gcov_var.file) >> 2;
|
||||
gcov_var.length += excess;
|
||||
if (gcov_var.length < words)
|
||||
{
|
||||
if (gcov_var.length < words) {
|
||||
gcov_var.overread += words - gcov_var.length;
|
||||
gcov_var.length = 0;
|
||||
return 0;
|
||||
@ -488,8 +474,7 @@ gcov_read_summary(struct gcov_summary *summary)
|
||||
struct gcov_ctr_summary *csum;
|
||||
|
||||
summary->checksum = gcov_read_unsigned();
|
||||
for (csum = summary->ctrs, ix = GCOV_COUNTERS_SUMMABLE; ix--; csum++)
|
||||
{
|
||||
for (csum = summary->ctrs, ix = GCOV_COUNTERS_SUMMABLE; ix--; csum++) {
|
||||
csum->num = gcov_read_unsigned();
|
||||
csum->runs = gcov_read_unsigned();
|
||||
csum->sum_all = gcov_read_counter();
|
||||
@ -509,8 +494,7 @@ gcov_sync(gcov_position_t base, gcov_unsigned_t length)
|
||||
base += length;
|
||||
if (base - gcov_var.start <= gcov_var.length)
|
||||
gcov_var.offset = base - gcov_var.start;
|
||||
else
|
||||
{
|
||||
else {
|
||||
gcov_var.offset = gcov_var.length = 0;
|
||||
fseek(gcov_var.file, base << 2, SEEK_SET);
|
||||
gcov_var.start = ftell(gcov_var.file) >> 2;
|
||||
|
@ -464,8 +464,8 @@ struct gcov_info
|
||||
unused) */
|
||||
|
||||
unsigned int n_functions; /* number of functions */
|
||||
const struct gcov_fn_info *const *functions; /* pointer to pointers
|
||||
to function information */
|
||||
const struct gcov_fn_info *const *functions; /* pointer to pointers to
|
||||
function information */
|
||||
};
|
||||
|
||||
/* Register a new object file module. */
|
||||
@ -527,14 +527,16 @@ GCOV_LINKAGE struct gcov_var
|
||||
int mode; /* < 0 writing, > 0 reading */
|
||||
#if IN_LIBGCOV
|
||||
/* Holds one block plus 4 bytes, thus all coverage reads & writes
|
||||
fit within this buffer and we always can transfer GCOV_BLOCK_SIZE
|
||||
to and from the disk. libgcov never backtracks and only writes 4
|
||||
or 8 byte objects. */
|
||||
* fit within this buffer and we always can transfer GCOV_BLOCK_SIZE
|
||||
* to and from the disk. libgcov never backtracks and only writes 4
|
||||
* or 8 byte objects.
|
||||
*/
|
||||
gcov_unsigned_t buffer[GCOV_BLOCK_SIZE + 1];
|
||||
#else
|
||||
int endian; /* Swap endianness. */
|
||||
/* Holds a variable length block, as the compiler can write
|
||||
strings and needs to backtrack. */
|
||||
* strings and needs to backtrack.
|
||||
*/
|
||||
size_t alloc;
|
||||
gcov_unsigned_t *buffer;
|
||||
#endif
|
||||
|
@ -147,8 +147,7 @@ create_file_directory(char *filename)
|
||||
if (IS_DIR_SEPARATOR(*s))
|
||||
++s;
|
||||
for (; *s != '\0'; s++)
|
||||
if (IS_DIR_SEPARATOR(*s))
|
||||
{
|
||||
if (IS_DIR_SEPARATOR(*s)) {
|
||||
char sep = *s;
|
||||
*s = '\0';
|
||||
|
||||
@ -159,10 +158,12 @@ create_file_directory(char *filename)
|
||||
#else
|
||||
&& mkdir(filename) == -1
|
||||
#endif
|
||||
/* The directory might have been made by another process. */
|
||||
&& errno != EEXIST)
|
||||
{
|
||||
fprintf(stderr, "profiling:%s:Cannot create directory\n",
|
||||
/* The directory might have been made by another
|
||||
* process.
|
||||
*/
|
||||
&& errno != EEXIST) {
|
||||
fprintf(stderr,
|
||||
"profiling:%s:Cannot create directory\n",
|
||||
filename);
|
||||
*s = sep;
|
||||
return -1;
|
||||
@ -217,16 +218,14 @@ buffer_fn_data(const char *filename, const struct gcov_info *gi_ptr,
|
||||
fn_buffer->info.lineno_checksum = gcov_read_unsigned();
|
||||
fn_buffer->info.cfg_checksum = gcov_read_unsigned();
|
||||
|
||||
for (n_ctrs = ix = 0; ix != GCOV_COUNTERS; ix++)
|
||||
{
|
||||
for (n_ctrs = ix = 0; ix != GCOV_COUNTERS; ix++) {
|
||||
gcov_unsigned_t length;
|
||||
gcov_type *values;
|
||||
|
||||
if (!gi_ptr->merge[ix])
|
||||
continue;
|
||||
|
||||
if (gcov_read_unsigned() != GCOV_TAG_FOR_COUNTER(ix))
|
||||
{
|
||||
if (gcov_read_unsigned() != GCOV_TAG_FOR_COUNTER(ix)) {
|
||||
len = 0;
|
||||
goto fail;
|
||||
}
|
||||
@ -262,8 +261,7 @@ crc32_unsigned(gcov_unsigned_t crc32, gcov_unsigned_t value)
|
||||
{
|
||||
unsigned int ix;
|
||||
|
||||
for (ix = 32; ix--; value <<= 1)
|
||||
{
|
||||
for (ix = 32; ix--; value <<= 1) {
|
||||
unsigned int feedback;
|
||||
|
||||
feedback = (value ^ crc32) & 0x80000000 ? 0x04c11db7 : 0;
|
||||
@ -283,8 +281,7 @@ static int
|
||||
gcov_version(struct gcov_info *ptr, gcov_unsigned_t version,
|
||||
const char *filename)
|
||||
{
|
||||
if (version != GCOV_VERSION)
|
||||
{
|
||||
if (version != GCOV_VERSION) {
|
||||
char v[4], e[4];
|
||||
|
||||
GCOV_UNSIGNED2STRING(v, version);
|
||||
@ -326,27 +323,26 @@ gcov_exit(void)
|
||||
memset(&all_prg, 0, sizeof(all_prg));
|
||||
/* Find the totals for this execution. */
|
||||
memset(&this_prg, 0, sizeof(this_prg));
|
||||
for (gi_ptr = gcov_list; gi_ptr; gi_ptr = gi_ptr->next)
|
||||
{
|
||||
for (gi_ptr = gcov_list; gi_ptr; gi_ptr = gi_ptr->next) {
|
||||
crc32 = crc32_unsigned(crc32, gi_ptr->stamp);
|
||||
crc32 = crc32_unsigned(crc32, gi_ptr->n_functions);
|
||||
|
||||
for (f_ix = 0; (unsigned int)f_ix != gi_ptr->n_functions; f_ix++)
|
||||
{
|
||||
for (f_ix = 0; (unsigned int)f_ix != gi_ptr->n_functions;
|
||||
f_ix++) {
|
||||
gfi_ptr = gi_ptr->functions[f_ix];
|
||||
|
||||
if (gfi_ptr && gfi_ptr->key != gi_ptr)
|
||||
gfi_ptr = 0;
|
||||
|
||||
crc32 = crc32_unsigned(crc32, gfi_ptr ? gfi_ptr->cfg_checksum : 0);
|
||||
crc32 = crc32_unsigned(crc32, gfi_ptr
|
||||
? gfi_ptr->cfg_checksum : 0);
|
||||
crc32 = crc32_unsigned(crc32,
|
||||
gfi_ptr ? gfi_ptr->lineno_checksum : 0);
|
||||
if (!gfi_ptr)
|
||||
continue;
|
||||
|
||||
ci_ptr = gfi_ptr->ctrs;
|
||||
for (t_ix = 0; t_ix != GCOV_COUNTERS_SUMMABLE; t_ix++)
|
||||
{
|
||||
for (t_ix = 0; t_ix != GCOV_COUNTERS_SUMMABLE; t_ix++) {
|
||||
if (!gi_ptr->merge[t_ix])
|
||||
continue;
|
||||
|
||||
@ -354,11 +350,13 @@ gcov_exit(void)
|
||||
cs_ptr->num += ci_ptr->num;
|
||||
crc32 = crc32_unsigned(crc32, ci_ptr->num);
|
||||
|
||||
for (c_num = 0; c_num < ci_ptr->num; c_num++)
|
||||
{
|
||||
cs_ptr->sum_all += ci_ptr->values[c_num];
|
||||
if (cs_ptr->run_max < ci_ptr->values[c_num])
|
||||
cs_ptr->run_max = ci_ptr->values[c_num];
|
||||
for (c_num = 0; c_num < ci_ptr->num; c_num++) {
|
||||
cs_ptr->sum_all +=
|
||||
ci_ptr->values[c_num];
|
||||
if (cs_ptr->run_max
|
||||
< ci_ptr->values[c_num])
|
||||
cs_ptr->run_max =
|
||||
ci_ptr->values[c_num];
|
||||
}
|
||||
ci_ptr++;
|
||||
}
|
||||
@ -369,8 +367,7 @@ gcov_exit(void)
|
||||
{
|
||||
/* Check if the level of dirs to strip off specified. */
|
||||
char *tmp = getenv("GCOV_PREFIX_STRIP");
|
||||
if (tmp)
|
||||
{
|
||||
if (tmp) {
|
||||
gcov_prefix_strip = atoi(tmp);
|
||||
/* Do not consider negative values. */
|
||||
if (gcov_prefix_strip < 0)
|
||||
@ -380,22 +377,19 @@ gcov_exit(void)
|
||||
|
||||
/* Get file name relocation prefix. Non-absolute values are ignored. */
|
||||
gcov_prefix = getenv("GCOV_PREFIX");
|
||||
if (gcov_prefix)
|
||||
{
|
||||
if (gcov_prefix) {
|
||||
prefix_length = strlen(gcov_prefix);
|
||||
|
||||
/* Remove an unnecessary trailing '/' */
|
||||
if (IS_DIR_SEPARATOR(gcov_prefix[prefix_length - 1]))
|
||||
prefix_length--;
|
||||
}
|
||||
else
|
||||
} else
|
||||
#endif
|
||||
prefix_length = 0;
|
||||
|
||||
/* If no prefix was specified and a prefix strip, then we assume
|
||||
relative. */
|
||||
if (gcov_prefix_strip != 0 && prefix_length == 0)
|
||||
{
|
||||
if (gcov_prefix_strip != 0 && prefix_length == 0) {
|
||||
gcov_prefix = ".";
|
||||
prefix_length = 1;
|
||||
}
|
||||
@ -406,8 +400,7 @@ gcov_exit(void)
|
||||
gi_filename_up = gi_filename + prefix_length;
|
||||
|
||||
/* Now merge each file. */
|
||||
for (gi_ptr = gcov_list; gi_ptr; gi_ptr = gi_ptr->next)
|
||||
{
|
||||
for (gi_ptr = gcov_list; gi_ptr; gi_ptr = gi_ptr->next) {
|
||||
unsigned int n_counts;
|
||||
struct gcov_summary prg; /* summary for this object over all
|
||||
program. */
|
||||
@ -427,56 +420,55 @@ gcov_exit(void)
|
||||
fname += 2;
|
||||
|
||||
/* Build relocated filename, stripping off leading
|
||||
directories from the initial filename if requested. */
|
||||
if (gcov_prefix_strip > 0)
|
||||
{
|
||||
* directories from the initial filename if requested.
|
||||
*/
|
||||
if (gcov_prefix_strip > 0) {
|
||||
int level = 0;
|
||||
|
||||
s = fname;
|
||||
if (IS_DIR_SEPARATOR(*s))
|
||||
++s;
|
||||
|
||||
/* Skip selected directory levels. */
|
||||
for (; (*s != '\0') && (level < gcov_prefix_strip); s++)
|
||||
if (IS_DIR_SEPARATOR(*s))
|
||||
{
|
||||
if (IS_DIR_SEPARATOR(*s)) {
|
||||
fname = s;
|
||||
level++;
|
||||
}
|
||||
}
|
||||
|
||||
/* Update complete filename with stripped original. */
|
||||
if (prefix_length != 0 && !IS_DIR_SEPARATOR(*fname))
|
||||
{
|
||||
/* If prefix is given, add directory separator. */
|
||||
if (prefix_length != 0 && !IS_DIR_SEPARATOR(*fname)) {
|
||||
/* If prefix is given, add directory separator.
|
||||
*/
|
||||
strcpy(gi_filename_up, "/");
|
||||
strcpy(gi_filename_up + 1, fname);
|
||||
}
|
||||
else
|
||||
} else
|
||||
strcpy(gi_filename_up, fname);
|
||||
|
||||
if (!gcov_open(gi_filename))
|
||||
{
|
||||
if (!gcov_open(gi_filename)) {
|
||||
/* Open failed likely due to missed directory.
|
||||
Create directory and retry to open file. */
|
||||
if (create_file_directory(gi_filename))
|
||||
{
|
||||
fprintf(stderr, "profiling:%s:Skip\n", gi_filename);
|
||||
* Create directory and retry to open file.
|
||||
*/
|
||||
if (create_file_directory(gi_filename)) {
|
||||
fprintf(stderr, "profiling:%s:Skip\n",
|
||||
gi_filename);
|
||||
continue;
|
||||
}
|
||||
if (!gcov_open(gi_filename))
|
||||
{
|
||||
fprintf(stderr, "profiling:%s:Cannot open\n", gi_filename);
|
||||
if (!gcov_open(gi_filename)) {
|
||||
fprintf(stderr,
|
||||
"profiling:%s:Cannot open\n",
|
||||
gi_filename);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
tag = gcov_read_unsigned();
|
||||
if (tag)
|
||||
{
|
||||
if (tag) {
|
||||
/* Merge data from file. */
|
||||
if (tag != GCOV_DATA_MAGIC)
|
||||
{
|
||||
fprintf(stderr, "profiling:%s:Not a gcov data file\n",
|
||||
if (tag != GCOV_DATA_MAGIC) {
|
||||
fprintf(stderr,
|
||||
"profiling:%s:Not a gcov data file\n",
|
||||
gi_filename);
|
||||
goto read_fatal;
|
||||
}
|
||||
@ -486,12 +478,13 @@ gcov_exit(void)
|
||||
|
||||
length = gcov_read_unsigned();
|
||||
if (length != gi_ptr->stamp)
|
||||
/* Read from a different compilation. Overwrite the file. */
|
||||
/* Read from a different compilation.
|
||||
* Overwrite the file.
|
||||
*/
|
||||
goto rewrite;
|
||||
|
||||
/* Look for program summary. */
|
||||
for (f_ix = 0;;)
|
||||
{
|
||||
for (f_ix = 0;;) {
|
||||
struct gcov_summary tmp;
|
||||
|
||||
eof_pos = gcov_position();
|
||||
@ -506,11 +499,14 @@ gcov_exit(void)
|
||||
gcov_read_summary(&tmp);
|
||||
if ((error = gcov_is_error()))
|
||||
goto read_error;
|
||||
if (summary_pos || tmp.checksum != crc32)
|
||||
if (summary_pos
|
||||
|| tmp.checksum != crc32)
|
||||
goto next_summary;
|
||||
|
||||
for (t_ix = 0; t_ix != GCOV_COUNTERS_SUMMABLE; t_ix++)
|
||||
if (tmp.ctrs[t_ix].num != this_prg.ctrs[t_ix].num)
|
||||
for (t_ix = 0; t_ix !=
|
||||
GCOV_COUNTERS_SUMMABLE; t_ix++)
|
||||
if (tmp.ctrs[t_ix].num !=
|
||||
this_prg.ctrs[t_ix].num)
|
||||
goto next_summary;
|
||||
prg = tmp;
|
||||
summary_pos = eof_pos;
|
||||
@ -519,9 +515,9 @@ gcov_exit(void)
|
||||
}
|
||||
|
||||
/* Merge execution counts for each function. */
|
||||
for (f_ix = 0; (unsigned int)f_ix != gi_ptr->n_functions;
|
||||
f_ix++, tag = gcov_read_unsigned())
|
||||
{
|
||||
for (f_ix = 0; (unsigned int)f_ix !=
|
||||
gi_ptr->n_functions;
|
||||
f_ix++, tag = gcov_read_unsigned()) {
|
||||
gfi_ptr = gi_ptr->functions[f_ix];
|
||||
|
||||
if (tag != GCOV_TAG_FUNCTION)
|
||||
@ -529,22 +525,29 @@ gcov_exit(void)
|
||||
|
||||
length = gcov_read_unsigned();
|
||||
if (!length)
|
||||
/* This function did not appear in the other program.
|
||||
We have nothing to merge. */
|
||||
/* This function did not appear
|
||||
* in the other program. We
|
||||
* have nothing to merge.
|
||||
*/
|
||||
continue;
|
||||
|
||||
if (length != GCOV_TAG_FUNCTION_LENGTH)
|
||||
goto read_mismatch;
|
||||
|
||||
if (!gfi_ptr || gfi_ptr->key != gi_ptr)
|
||||
{
|
||||
/* This function appears in the other program. We
|
||||
need to buffer the information in order to write
|
||||
it back out -- we'll be inserting data before
|
||||
this point, so cannot simply keep the data in the
|
||||
file. */
|
||||
fn_tail = buffer_fn_data(gi_filename,
|
||||
gi_ptr, fn_tail, f_ix);
|
||||
if (!gfi_ptr || gfi_ptr->key !=
|
||||
gi_ptr) {
|
||||
/* This function appears in the
|
||||
* other program. We need to
|
||||
* buffer the information in
|
||||
* order to write it back out --
|
||||
* we'll be inserting data
|
||||
* before this point, so cannot
|
||||
* simply keep the data in the
|
||||
* file.
|
||||
*/
|
||||
fn_tail = buffer_fn_data(
|
||||
gi_filename, gi_ptr,
|
||||
fn_tail, f_ix);
|
||||
if (!fn_tail)
|
||||
goto read_mismatch;
|
||||
continue;
|
||||
@ -563,30 +566,35 @@ gcov_exit(void)
|
||||
goto read_mismatch;
|
||||
|
||||
ci_ptr = gfi_ptr->ctrs;
|
||||
for (t_ix = 0; t_ix < GCOV_COUNTERS; t_ix++)
|
||||
{
|
||||
gcov_merge_fn merge = gi_ptr->merge[t_ix];
|
||||
for (t_ix = 0; t_ix < GCOV_COUNTERS;
|
||||
t_ix++) {
|
||||
gcov_merge_fn merge =
|
||||
gi_ptr->merge[t_ix];
|
||||
|
||||
if (!merge)
|
||||
continue;
|
||||
|
||||
tag = gcov_read_unsigned();
|
||||
length = gcov_read_unsigned();
|
||||
if (tag != GCOV_TAG_FOR_COUNTER(t_ix)
|
||||
|| length != GCOV_TAG_COUNTER_LENGTH(ci_ptr->num))
|
||||
if (tag != GCOV_TAG_FOR_COUNTER(
|
||||
t_ix) || length !=
|
||||
GCOV_TAG_COUNTER_LENGTH(
|
||||
ci_ptr->num))
|
||||
goto read_mismatch;
|
||||
(*merge)(ci_ptr->values, ci_ptr->num);
|
||||
(*merge)(ci_ptr->values,
|
||||
ci_ptr->num);
|
||||
ci_ptr++;
|
||||
}
|
||||
if ((error = gcov_is_error()))
|
||||
goto read_error;
|
||||
}
|
||||
|
||||
if (tag)
|
||||
{
|
||||
if (tag) {
|
||||
read_mismatch:;
|
||||
fprintf(stderr, "profiling:%s:Merge mismatch for %s %u\n",
|
||||
gi_filename, f_ix >= 0 ? "function" : "summary",
|
||||
fprintf(stderr,
|
||||
"profiling:%s:Merge mismatch for %s %u\n",
|
||||
gi_filename, f_ix >= 0 ?
|
||||
"function" : "summary",
|
||||
f_ix < 0 ? -1 - f_ix : f_ix);
|
||||
goto read_fatal;
|
||||
}
|
||||
@ -601,40 +609,36 @@ gcov_exit(void)
|
||||
|
||||
rewrite:;
|
||||
gcov_rewrite();
|
||||
if (!summary_pos)
|
||||
{
|
||||
if (!summary_pos) {
|
||||
memset(&prg, 0, sizeof(prg));
|
||||
summary_pos = eof_pos;
|
||||
}
|
||||
|
||||
/* Merge the summaries. */
|
||||
for (t_ix = 0; t_ix < GCOV_COUNTERS_SUMMABLE; t_ix++)
|
||||
{
|
||||
for (t_ix = 0; t_ix < GCOV_COUNTERS_SUMMABLE; t_ix++) {
|
||||
cs_prg = &prg.ctrs[t_ix];
|
||||
cs_tprg = &this_prg.ctrs[t_ix];
|
||||
cs_all = &all_prg.ctrs[t_ix];
|
||||
|
||||
if (gi_ptr->merge[t_ix])
|
||||
{
|
||||
if (gi_ptr->merge[t_ix]) {
|
||||
if (!cs_prg->runs++)
|
||||
cs_prg->num = cs_tprg->num;
|
||||
cs_prg->sum_all += cs_tprg->sum_all;
|
||||
if (cs_prg->run_max < cs_tprg->run_max)
|
||||
cs_prg->run_max = cs_tprg->run_max;
|
||||
cs_prg->sum_max += cs_tprg->run_max;
|
||||
}
|
||||
else if (cs_prg->runs)
|
||||
} else if (cs_prg->runs)
|
||||
goto read_mismatch;
|
||||
|
||||
if (!cs_all->runs && cs_prg->runs)
|
||||
memcpy(cs_all, cs_prg, sizeof(*cs_all));
|
||||
else if (!all_prg.checksum
|
||||
&& (!GCOV_LOCKED || cs_all->runs == cs_prg->runs)
|
||||
&& memcmp(cs_all, cs_prg, sizeof(*cs_all)))
|
||||
{
|
||||
fprintf(stderr, "profiling:%s:Invocation mismatch - some data files may have been removed%s\n",
|
||||
gi_filename, GCOV_LOCKED
|
||||
? "" : " or concurrently updated without locking support");
|
||||
&& memcmp(cs_all, cs_prg, sizeof(*cs_all))) {
|
||||
fprintf(stderr,
|
||||
"profiling:%s:Invocation mismatch - some data files may have been removed%s\n",
|
||||
gi_filename, GCOV_LOCKED ? "" :
|
||||
" or concurrently updated without locking support");
|
||||
all_prg.checksum = ~0u;
|
||||
}
|
||||
}
|
||||
@ -642,8 +646,7 @@ gcov_exit(void)
|
||||
prg.checksum = crc32;
|
||||
|
||||
/* Write out the data. */
|
||||
if (!eof_pos)
|
||||
{
|
||||
if (!eof_pos) {
|
||||
gcov_write_tag_length(GCOV_DATA_MAGIC, GCOV_VERSION);
|
||||
gcov_write_unsigned(gi_ptr->stamp);
|
||||
}
|
||||
@ -658,19 +661,15 @@ gcov_exit(void)
|
||||
gcov_seek(eof_pos);
|
||||
|
||||
/* Write execution counts for each function. */
|
||||
for (f_ix = 0; (unsigned int)f_ix != gi_ptr->n_functions; f_ix++)
|
||||
{
|
||||
for (f_ix = 0; (unsigned int)f_ix != gi_ptr->n_functions; f_ix++) {
|
||||
unsigned int buffered = 0;
|
||||
|
||||
if (fn_buffer && fn_buffer->fn_ix == (unsigned int)f_ix)
|
||||
{
|
||||
if (fn_buffer && fn_buffer->fn_ix == (unsigned int)f_ix) {
|
||||
/* Buffered data from another program. */
|
||||
buffered = 1;
|
||||
gfi_ptr = &fn_buffer->info;
|
||||
length = GCOV_TAG_FUNCTION_LENGTH;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
gfi_ptr = gi_ptr->functions[f_ix];
|
||||
if (gfi_ptr && gfi_ptr->key == gi_ptr)
|
||||
length = GCOV_TAG_FUNCTION_LENGTH;
|
||||
@ -687,8 +686,7 @@ gcov_exit(void)
|
||||
gcov_write_unsigned(gfi_ptr->cfg_checksum);
|
||||
|
||||
ci_ptr = gfi_ptr->ctrs;
|
||||
for (t_ix = 0; t_ix < GCOV_COUNTERS; t_ix++)
|
||||
{
|
||||
for (t_ix = 0; t_ix < GCOV_COUNTERS; t_ix++) {
|
||||
if (!gi_ptr->merge[t_ix])
|
||||
continue;
|
||||
|
||||
@ -701,7 +699,8 @@ gcov_exit(void)
|
||||
ci_ptr++;
|
||||
}
|
||||
if (buffered)
|
||||
fn_buffer = free_fn_data(gi_ptr, fn_buffer, GCOV_COUNTERS);
|
||||
fn_buffer = free_fn_data(gi_ptr, fn_buffer,
|
||||
GCOV_COUNTERS);
|
||||
}
|
||||
|
||||
gcov_write_unsigned(0);
|
||||
@ -726,8 +725,7 @@ __gcov_init(struct gcov_info *info)
|
||||
{
|
||||
if (!info->version || !info->n_functions)
|
||||
return;
|
||||
if (gcov_version(info, info->version, 0))
|
||||
{
|
||||
if (gcov_version(info, info->version, 0)) {
|
||||
size_t filename_length = strlen(info->filename);
|
||||
|
||||
/* Refresh the longest file name information */
|
||||
@ -755,24 +753,23 @@ __gcov_flush(void)
|
||||
const struct gcov_info *gi_ptr;
|
||||
|
||||
gcov_exit();
|
||||
for (gi_ptr = gcov_list; gi_ptr; gi_ptr = gi_ptr->next)
|
||||
{
|
||||
for (gi_ptr = gcov_list; gi_ptr; gi_ptr = gi_ptr->next) {
|
||||
unsigned int f_ix;
|
||||
|
||||
for (f_ix = 0; f_ix < gi_ptr->n_functions; f_ix++)
|
||||
{
|
||||
for (f_ix = 0; f_ix < gi_ptr->n_functions; f_ix++) {
|
||||
unsigned int t_ix;
|
||||
const struct gcov_fn_info *gfi_ptr = gi_ptr->functions[f_ix];
|
||||
const struct gcov_fn_info *gfi_ptr =
|
||||
gi_ptr->functions[f_ix];
|
||||
|
||||
if (!gfi_ptr || gfi_ptr->key != gi_ptr)
|
||||
continue;
|
||||
const struct gcov_ctr_info *ci_ptr = gfi_ptr->ctrs;
|
||||
for (t_ix = 0; t_ix != GCOV_COUNTERS; t_ix++)
|
||||
{
|
||||
for (t_ix = 0; t_ix != GCOV_COUNTERS; t_ix++) {
|
||||
if (!gi_ptr->merge[t_ix])
|
||||
continue;
|
||||
|
||||
memset(ci_ptr->values, 0, sizeof(gcov_type) * ci_ptr->num);
|
||||
memset(ci_ptr->values, 0,
|
||||
sizeof(gcov_type) * ci_ptr->num);
|
||||
ci_ptr++;
|
||||
}
|
||||
}
|
||||
@ -824,20 +821,17 @@ __gcov_merge_single(gcov_type *counters, unsigned int n_counters)
|
||||
|
||||
gcc_assert(!(n_counters % 3));
|
||||
n_measures = n_counters / 3;
|
||||
for (i = 0; i < n_measures; i++, counters += 3)
|
||||
{
|
||||
for (i = 0; i < n_measures; i++, counters += 3) {
|
||||
value = gcov_read_counter();
|
||||
counter = gcov_read_counter();
|
||||
all = gcov_read_counter();
|
||||
|
||||
if (counters[0] == value)
|
||||
counters[1] += counter;
|
||||
else if (counter > counters[1])
|
||||
{
|
||||
else if (counter > counters[1]) {
|
||||
counters[0] = value;
|
||||
counters[1] = counter - counters[1];
|
||||
}
|
||||
else
|
||||
} else
|
||||
counters[1] -= counter;
|
||||
counters[2] += all;
|
||||
}
|
||||
@ -864,21 +858,19 @@ __gcov_merge_delta(gcov_type *counters, unsigned int n_counters)
|
||||
|
||||
gcc_assert(!(n_counters % 4));
|
||||
n_measures = n_counters / 4;
|
||||
for (i = 0; i < n_measures; i++, counters += 4)
|
||||
{
|
||||
/* last = */ gcov_read_counter();
|
||||
for (i = 0; i < n_measures; i++, counters += 4) {
|
||||
/* last = */
|
||||
gcov_read_counter();
|
||||
value = gcov_read_counter();
|
||||
counter = gcov_read_counter();
|
||||
all = gcov_read_counter();
|
||||
|
||||
if (counters[1] == value)
|
||||
counters[2] += counter;
|
||||
else if (counter > counters[2])
|
||||
{
|
||||
else if (counter > counters[2]) {
|
||||
counters[1] = value;
|
||||
counters[2] = counter - counters[2];
|
||||
}
|
||||
else
|
||||
} else
|
||||
counters[2] -= counter;
|
||||
counters[3] += all;
|
||||
}
|
||||
@ -934,12 +926,10 @@ __gcov_one_value_profiler_body(gcov_type *counters, gcov_type value)
|
||||
{
|
||||
if (value == counters[0])
|
||||
counters[1]++;
|
||||
else if (counters[1] == 0)
|
||||
{
|
||||
else if (counters[1] == 0) {
|
||||
counters[1] = 1;
|
||||
counters[0] = value;
|
||||
}
|
||||
else
|
||||
} else
|
||||
counters[1]--;
|
||||
counters[2]++;
|
||||
}
|
||||
@ -977,8 +967,9 @@ __gcov_indirect_call_profiler(gcov_type *counter, gcov_type value,
|
||||
void *cur_func, void *callee_func)
|
||||
{
|
||||
/* If the C++ virtual tables contain function descriptors then one
|
||||
function may have multiple descriptors and we need to dereference
|
||||
the descriptors to see if they point to the same function. */
|
||||
* function may have multiple descriptors and we need to dereference
|
||||
* the descriptors to see if they point to the same function.
|
||||
*/
|
||||
if (cur_func == callee_func
|
||||
|| (VTABLE_USES_DESCRIPTORS && callee_func
|
||||
&& *(void **) cur_func == *(void **) callee_func))
|
||||
|
@ -38,7 +38,8 @@
|
||||
: ((look_ahead.dw = *(UInt32 *)Buffer), (Buffer += 4), (look_ahead_ptr = 1), look_ahead.raw[0])))
|
||||
|
||||
#define RC_INIT2 Code = 0; Range = 0xFFFFFFFF; \
|
||||
{ int i; for (i = 0; i < 5; i++) { RC_TEST; Code = (Code << 8) | RC_READ_BYTE; }}
|
||||
{ int i; for (i = 0; i < 5; i++) { RC_TEST; Code = (Code << 8) \
|
||||
| RC_READ_BYTE; }}
|
||||
|
||||
|
||||
#define RC_TEST { if (Buffer == BufferLim) return LZMA_RESULT_DATA_ERROR; }
|
||||
@ -59,9 +60,16 @@
|
||||
#define RC_GET_BIT(p, mi) RC_GET_BIT2(p, mi, ; , ;)
|
||||
|
||||
#define RangeDecoderBitTreeDecode(probs, numLevels, res) \
|
||||
{ int i = numLevels; res = 1; \
|
||||
do { CProb *cp = probs + res; RC_GET_BIT(cp, res) } while (--i != 0); \
|
||||
res -= (1 << numLevels); }
|
||||
{ \
|
||||
int i = numLevels; \
|
||||
\
|
||||
res = 1; \
|
||||
do { \
|
||||
CProb *cp = probs + res; \
|
||||
RC_GET_BIT(cp, res) \
|
||||
} while (--i != 0); \
|
||||
res -= (1 << numLevels); \
|
||||
}
|
||||
|
||||
|
||||
#define kNumPosBitsMax 4
|
||||
@ -123,16 +131,17 @@ int LzmaDecodeProperties(CLzmaProperties *propsRes, const unsigned char *propsDa
|
||||
if (prop0 >= (9 * 5 * 5))
|
||||
return LZMA_RESULT_DATA_ERROR;
|
||||
{
|
||||
for (propsRes->pb = 0; prop0 >= (9 * 5); propsRes->pb++, prop0 -= (9 * 5))
|
||||
for (propsRes->pb = 0; prop0 >= (9 * 5);
|
||||
propsRes->pb++, prop0 -= (9 * 5))
|
||||
;
|
||||
for (propsRes->lp = 0; prop0 >= 9; propsRes->lp++, prop0 -= 9)
|
||||
;
|
||||
propsRes->lc = prop0;
|
||||
/*
|
||||
unsigned char remainder = (unsigned char)(prop0 / 9);
|
||||
propsRes->lc = prop0 % 9;
|
||||
propsRes->pb = remainder / 5;
|
||||
propsRes->lp = remainder % 5;
|
||||
* unsigned char remainder = (unsigned char)(prop0 / 9);
|
||||
* propsRes->lc = prop0 % 9;
|
||||
* propsRes->pb = remainder / 5;
|
||||
* propsRes->lp = remainder % 5;
|
||||
*/
|
||||
}
|
||||
|
||||
@ -159,8 +168,7 @@ int LzmaDecode(CLzmaDecoderState *vs,
|
||||
const Byte *Buffer;
|
||||
const Byte *BufferLim;
|
||||
int look_ahead_ptr = 4;
|
||||
union
|
||||
{
|
||||
union {
|
||||
Byte raw[4];
|
||||
UInt32 dw;
|
||||
} look_ahead;
|
||||
@ -172,7 +180,8 @@ int LzmaDecode(CLzmaDecoderState *vs,
|
||||
|
||||
{
|
||||
UInt32 i;
|
||||
UInt32 numProbs = Literal + ((UInt32)LZMA_LIT_SIZE << (lc + vs->Properties.lp));
|
||||
UInt32 numProbs = Literal + ((UInt32)LZMA_LIT_SIZE << (lc
|
||||
+ vs->Properties.lp));
|
||||
for (i = 0; i < numProbs; i++)
|
||||
p[i] = kBitModelTotal >> 1;
|
||||
}
|
||||
@ -180,43 +189,36 @@ int LzmaDecode(CLzmaDecoderState *vs,
|
||||
RC_INIT(inStream, inSize);
|
||||
|
||||
|
||||
while (nowPos < outSize)
|
||||
{
|
||||
while (nowPos < outSize) {
|
||||
CProb *prob;
|
||||
UInt32 bound;
|
||||
int posState = (int)(
|
||||
(nowPos
|
||||
)
|
||||
& posStateMask);
|
||||
int posState = (int)((nowPos)& posStateMask);
|
||||
|
||||
prob = p + IsMatch + (state << kNumPosBitsMax) + posState;
|
||||
IfBit0(prob)
|
||||
{
|
||||
IfBit0(prob) {
|
||||
int symbol = 1;
|
||||
UpdateBit0(prob)
|
||||
prob = p + Literal + (LZMA_LIT_SIZE *
|
||||
(((
|
||||
(nowPos
|
||||
)
|
||||
& literalPosMask) << lc) + (previousByte >> (8 - lc))));
|
||||
((((nowPos) & literalPosMask) << lc)
|
||||
+ (previousByte >> (8 - lc))));
|
||||
|
||||
if (state >= kNumLitStates)
|
||||
{
|
||||
if (state >= kNumLitStates) {
|
||||
int matchByte;
|
||||
matchByte = outStream[nowPos - rep0];
|
||||
do
|
||||
{
|
||||
do {
|
||||
int bit;
|
||||
CProb *probLit;
|
||||
matchByte <<= 1;
|
||||
bit = (matchByte & 0x100);
|
||||
probLit = prob + 0x100 + bit + symbol;
|
||||
RC_GET_BIT2(probLit, symbol, if (bit != 0) break, if (bit == 0) break)
|
||||
RC_GET_BIT2(probLit, symbol,
|
||||
if (bit != 0)
|
||||
break,
|
||||
if (bit == 0)
|
||||
break)
|
||||
} while (symbol < 0x100);
|
||||
}
|
||||
while (symbol < 0x100);
|
||||
}
|
||||
while (symbol < 0x100)
|
||||
{
|
||||
while (symbol < 0x100) {
|
||||
CProb *probLit = prob + symbol;
|
||||
RC_GET_BIT(probLit, symbol)
|
||||
}
|
||||
@ -229,30 +231,23 @@ int LzmaDecode(CLzmaDecoderState *vs,
|
||||
state -= 3;
|
||||
else
|
||||
state -= 6;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
UpdateBit1(prob);
|
||||
prob = p + IsRep + state;
|
||||
IfBit0(prob)
|
||||
{
|
||||
IfBit0(prob) {
|
||||
UpdateBit0(prob);
|
||||
rep3 = rep2;
|
||||
rep2 = rep1;
|
||||
rep1 = rep0;
|
||||
state = state < kNumLitStates ? 0 : 3;
|
||||
prob = p + LenCoder;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
UpdateBit1(prob);
|
||||
prob = p + IsRepG0 + state;
|
||||
IfBit0(prob)
|
||||
{
|
||||
IfBit0(prob) {
|
||||
UpdateBit0(prob);
|
||||
prob = p + IsRep0Long + (state << kNumPosBitsMax) + posState;
|
||||
IfBit0(prob)
|
||||
{
|
||||
IfBit0(prob) {
|
||||
UpdateBit0(prob);
|
||||
|
||||
if (nowPos == 0)
|
||||
@ -263,33 +258,22 @@ int LzmaDecode(CLzmaDecoderState *vs,
|
||||
outStream[nowPos++] = previousByte;
|
||||
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else
|
||||
UpdateBit1(prob);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
UInt32 distance;
|
||||
UpdateBit1(prob);
|
||||
prob = p + IsRepG1 + state;
|
||||
IfBit0(prob)
|
||||
{
|
||||
IfBit0(prob) {
|
||||
UpdateBit0(prob);
|
||||
distance = rep1;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
UpdateBit1(prob);
|
||||
prob = p + IsRepG2 + state;
|
||||
IfBit0(prob)
|
||||
{
|
||||
IfBit0(prob) {
|
||||
UpdateBit0(prob);
|
||||
distance = rep2;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
UpdateBit1(prob);
|
||||
distance = rep3;
|
||||
rep3 = rep2;
|
||||
@ -305,26 +289,20 @@ int LzmaDecode(CLzmaDecoderState *vs,
|
||||
{
|
||||
int numBits, offset;
|
||||
CProb *probLen = prob + LenChoice;
|
||||
IfBit0(probLen)
|
||||
{
|
||||
IfBit0(probLen) {
|
||||
UpdateBit0(probLen);
|
||||
probLen = prob + LenLow + (posState << kLenNumLowBits);
|
||||
offset = 0;
|
||||
numBits = kLenNumLowBits;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
UpdateBit1(probLen);
|
||||
probLen = prob + LenChoice2;
|
||||
IfBit0(probLen)
|
||||
{
|
||||
IfBit0(probLen) {
|
||||
UpdateBit0(probLen);
|
||||
probLen = prob + LenMid + (posState << kLenNumMidBits);
|
||||
offset = kLenNumLowSymbols;
|
||||
numBits = kLenNumMidBits;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
UpdateBit1(probLen);
|
||||
probLen = prob + LenHigh;
|
||||
offset = kLenNumLowSymbols + kLenNumMidSymbols;
|
||||
@ -335,38 +313,30 @@ int LzmaDecode(CLzmaDecoderState *vs,
|
||||
len += offset;
|
||||
}
|
||||
|
||||
if (state < 4)
|
||||
{
|
||||
if (state < 4) {
|
||||
int posSlot;
|
||||
state += kNumLitStates;
|
||||
prob = p + PosSlot +
|
||||
((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) <<
|
||||
kNumPosSlotBits);
|
||||
RangeDecoderBitTreeDecode(prob, kNumPosSlotBits, posSlot);
|
||||
if (posSlot >= kStartPosModelIndex)
|
||||
{
|
||||
if (posSlot >= kStartPosModelIndex) {
|
||||
int numDirectBits = ((posSlot >> 1) - 1);
|
||||
rep0 = (2 | ((UInt32)posSlot & 1));
|
||||
if (posSlot < kEndPosModelIndex)
|
||||
{
|
||||
if (posSlot < kEndPosModelIndex) {
|
||||
rep0 <<= numDirectBits;
|
||||
prob = p + SpecPos + rep0 - posSlot - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
numDirectBits -= kNumAlignBits;
|
||||
do
|
||||
{
|
||||
do {
|
||||
RC_NORMALIZE
|
||||
Range >>= 1;
|
||||
rep0 <<= 1;
|
||||
if (Code >= Range)
|
||||
{
|
||||
if (Code >= Range) {
|
||||
Code -= Range;
|
||||
rep0 |= 1;
|
||||
}
|
||||
}
|
||||
while (--numDirectBits != 0);
|
||||
} while (--numDirectBits != 0);
|
||||
prob = p + Align;
|
||||
rep0 <<= kNumAlignBits;
|
||||
numDirectBits = kNumAlignBits;
|
||||
@ -374,19 +344,15 @@ int LzmaDecode(CLzmaDecoderState *vs,
|
||||
{
|
||||
int i = 1;
|
||||
int mi = 1;
|
||||
do
|
||||
{
|
||||
do {
|
||||
CProb *prob3 = prob + mi;
|
||||
RC_GET_BIT2(prob3, mi, ; , rep0 |= i);
|
||||
i <<= 1;
|
||||
} while (--numDirectBits != 0);
|
||||
}
|
||||
while (--numDirectBits != 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
} else
|
||||
rep0 = posSlot;
|
||||
if (++rep0 == (UInt32)(0))
|
||||
{
|
||||
if (++rep0 == (UInt32)(0)) {
|
||||
/* it's for stream version */
|
||||
len = kLzmaStreamWasFinishedId;
|
||||
break;
|
||||
@ -398,13 +364,11 @@ int LzmaDecode(CLzmaDecoderState *vs,
|
||||
return LZMA_RESULT_DATA_ERROR;
|
||||
|
||||
|
||||
do
|
||||
{
|
||||
do {
|
||||
previousByte = outStream[nowPos - rep0];
|
||||
len--;
|
||||
outStream[nowPos++] = previousByte;
|
||||
}
|
||||
while (len != 0 && nowPos < outSize);
|
||||
} while (len != 0 && nowPos < outSize);
|
||||
}
|
||||
}
|
||||
RC_NORMALIZE;
|
||||
|
@ -38,8 +38,7 @@ typedef UInt32 SizeT;
|
||||
|
||||
#define LZMA_PROPERTIES_SIZE 5
|
||||
|
||||
typedef struct _CLzmaProperties
|
||||
{
|
||||
typedef struct _CLzmaProperties {
|
||||
int lc;
|
||||
int lp;
|
||||
int pb;
|
||||
@ -51,12 +50,9 @@ int LzmaDecodeProperties(CLzmaProperties *propsRes, const unsigned char *propsDa
|
||||
|
||||
#define kLzmaNeedInitId (-2)
|
||||
|
||||
typedef struct _CLzmaDecoderState
|
||||
{
|
||||
typedef struct _CLzmaDecoderState {
|
||||
CLzmaProperties Properties;
|
||||
CProb *Probs;
|
||||
|
||||
|
||||
} CLzmaDecoderState;
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user