summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lib/edid.c32
-rw-r--r--src/lib/gcov-io.c516
-rw-r--r--src/lib/gcov-io.h128
-rw-r--r--src/lib/generic_sdram.c2
-rw-r--r--src/lib/hardwaremain.c10
-rw-r--r--src/lib/imd_cbmem.c14
-rw-r--r--src/lib/jpeg.c224
-rw-r--r--src/lib/libgcov.c1347
-rw-r--r--src/lib/lzmadecode.c560
-rw-r--r--src/lib/lzmadecode.h22
-rw-r--r--src/lib/memrange.c62
-rw-r--r--src/lib/mocked_tlcl.c4
-rw-r--r--src/lib/reg_script.c8
-rw-r--r--src/lib/rmodule.c8
-rw-r--r--src/lib/selfboot.c52
-rw-r--r--src/lib/spd_bin.c8
-rw-r--r--src/lib/thread.c6
-rw-r--r--src/lib/timer_queue.c4
-rw-r--r--src/lib/tlcl.c18
-rw-r--r--src/lib/tlcl_structures.h76
20 files changed, 1518 insertions, 1583 deletions
diff --git a/src/lib/edid.c b/src/lib/edid.c
index 50a023819f..50bb2c282a 100644
--- a/src/lib/edid.c
+++ b/src/lib/edid.c
@@ -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)
@@ -1188,7 +1186,7 @@ int decode_edid(unsigned char *edid, int size, struct edid *out)
break;
}
extra_info.type = edid[0x14] & 0x0f;
- } else if (c.claims_one_point_two) {
+ } else if (c.claims_one_point_two) {
conformance_mask = 0x7E;
if (edid[0x14] & 0x01)
printk(BIOS_SPEW, "DFP 1.x compatible TMDS\n");
@@ -1273,18 +1271,18 @@ int decode_edid(unsigned char *edid, int size, struct edid *out)
/* FIXME: this is from 1.4 spec, check earlier */
if (analog) {
switch (edid[0x18] & 0x18) {
- case 0x00:
- printk(BIOS_SPEW, "Monochrome or grayscale display\n");
- break;
- case 0x08:
- printk(BIOS_SPEW, "RGB color display\n");
- break;
- case 0x10:
- printk(BIOS_SPEW, "Non-RGB color display\n");
- break;
- case 0x18:
- printk(BIOS_SPEW, "Undefined display color type\n");
- break;
+ case 0x00:
+ printk(BIOS_SPEW, "Monochrome or grayscale display\n");
+ break;
+ case 0x08:
+ printk(BIOS_SPEW, "RGB color display\n");
+ break;
+ case 0x10:
+ printk(BIOS_SPEW, "Non-RGB color display\n");
+ break;
+ case 0x18:
+ printk(BIOS_SPEW, "Undefined display color type\n");
+ break;
}
} else {
printk(BIOS_SPEW, "Supported color formats: RGB 4:4:4");
diff --git a/src/lib/gcov-io.c b/src/lib/gcov-io.c
index 7f3b7281f4..e14252412e 100644
--- a/src/lib/gcov-io.c
+++ b/src/lib/gcov-io.c
@@ -36,13 +36,12 @@ static void gcov_allocate(unsigned int);
static inline gcov_unsigned_t from_file(gcov_unsigned_t value)
{
#if !IN_LIBGCOV
- if (gcov_var.endian)
- {
- value = (value >> 16) | (value << 16);
- value = ((value & 0xff00ff) << 8) | ((value >> 8) & 0xff00ff);
- }
+ if (gcov_var.endian) {
+ value = (value >> 16) | (value << 16);
+ value = ((value & 0xff00ff) << 8) | ((value >> 8) & 0xff00ff);
+ }
#endif
- return value;
+ return value;
}
/* Open a gcov file. NAME is the name of the file to open and MODE
@@ -63,91 +62,83 @@ gcov_open(const char *name, int mode)
#endif
{
#if IN_LIBGCOV
- const int mode = 0;
+ const int mode = 0;
#endif
#if GCOV_LOCKED
- struct flock s_flock;
- int fd;
+ struct flock s_flock;
+ int fd;
- s_flock.l_whence = SEEK_SET;
- s_flock.l_start = 0;
- s_flock.l_len = 0; /* Until EOF. */
- s_flock.l_pid = getpid();
+ s_flock.l_whence = SEEK_SET;
+ s_flock.l_start = 0;
+ s_flock.l_len = 0; /* Until EOF. */
+ s_flock.l_pid = getpid();
#endif
- gcc_assert(!gcov_var.file);
- gcov_var.start = 0;
- gcov_var.offset = gcov_var.length = 0;
- gcov_var.overread = -1u;
- gcov_var.error = 0;
+ gcc_assert(!gcov_var.file);
+ gcov_var.start = 0;
+ gcov_var.offset = gcov_var.length = 0;
+ gcov_var.overread = -1u;
+ gcov_var.error = 0;
#if !IN_LIBGCOV
- gcov_var.endian = 0;
+ gcov_var.endian = 0;
#endif
#if GCOV_LOCKED
- if (mode > 0)
- {
- /* Read-only mode - acquire a read-lock. */
- s_flock.l_type = F_RDLCK;
- fd = open(name, O_RDONLY);
- }
- else
- {
- /* Write mode - acquire a write-lock. */
- s_flock.l_type = F_WRLCK;
- fd = open(name, O_RDWR | O_CREAT, 0666);
- }
- if (fd < 0)
- return 0;
-
- while (fcntl(fd, F_SETLKW, &s_flock) && errno == EINTR)
- continue;
-
- gcov_var.file = fdopen(fd, (mode > 0) ? "rb" : "r+b");
-
- if (!gcov_var.file)
- {
- close(fd);
- return 0;
- }
-
- if (mode > 0)
- gcov_var.mode = 1;
- else if (mode == 0)
- {
- struct stat st;
-
- if (fstat(fd, &st) < 0)
- {
- fclose(gcov_var.file);
- gcov_var.file = 0;
- return 0;
+ if (mode > 0) {
+ /* Read-only mode - acquire a read-lock. */
+ s_flock.l_type = F_RDLCK;
+ fd = open(name, O_RDONLY);
+ } else {
+ /* Write mode - acquire a write-lock. */
+ s_flock.l_type = F_WRLCK;
+ fd = open(name, O_RDWR | O_CREAT, 0666);
}
- if (st.st_size != 0)
- gcov_var.mode = 1;
- else
- gcov_var.mode = mode * 2 + 1;
- }
- else
- gcov_var.mode = mode * 2 + 1;
+ if (fd < 0)
+ return 0;
+
+ while (fcntl(fd, F_SETLKW, &s_flock) && errno == EINTR)
+ continue;
+
+ gcov_var.file = fdopen(fd, (mode > 0) ? "rb" : "r+b");
+
+ if (!gcov_var.file) {
+ close(fd);
+ return 0;
+ }
+
+ if (mode > 0)
+ gcov_var.mode = 1;
+ else if (mode == 0) {
+ struct stat st;
+
+ if (fstat(fd, &st) < 0) {
+ fclose(gcov_var.file);
+ gcov_var.file = 0;
+ return 0;
+ }
+ if (st.st_size != 0)
+ gcov_var.mode = 1;
+ else
+ gcov_var.mode = mode * 2 + 1;
+ } else
+ gcov_var.mode = mode * 2 + 1;
#else
- if (mode >= 0)
- gcov_var.file = fopen(name, (mode > 0) ? "rb" : "r+b");
-
- if (gcov_var.file)
- gcov_var.mode = 1;
- else if (mode <= 0)
- {
- gcov_var.file = fopen(name, "w+b");
- if (gcov_var.file)
- gcov_var.mode = mode * 2 + 1;
- }
- if (!gcov_var.file)
- return 0;
+ if (mode >= 0)
+ gcov_var.file = fopen(name, (mode > 0) ? "rb" : "r+b");
+
+ if (gcov_var.file)
+ gcov_var.mode = 1;
+ else if (mode <= 0) {
+ gcov_var.file = fopen(name, "w+b");
+ if (gcov_var.file)
+ gcov_var.mode = mode * 2 + 1;
+ }
+ if (!gcov_var.file)
+ return 0;
#endif
- setbuf(gcov_var.file, (char *)0);
+ setbuf(gcov_var.file, (char *)0);
- return 1;
+ return 1;
}
/* Close the current gcov file. Flushes data to disk. Returns nonzero
@@ -156,23 +147,22 @@ 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);
+ if (gcov_var.offset && gcov_var.mode < 0)
+ gcov_write_block(gcov_var.offset);
#endif
- fclose(gcov_var.file);
- gcov_var.file = 0;
- gcov_var.length = 0;
- }
+ fclose(gcov_var.file);
+ gcov_var.file = 0;
+ gcov_var.length = 0;
+ }
#if !IN_LIBGCOV
- free(gcov_var.buffer);
- gcov_var.alloc = 0;
- gcov_var.buffer = 0;
+ free(gcov_var.buffer);
+ gcov_var.alloc = 0;
+ gcov_var.buffer = 0;
#endif
- gcov_var.mode = 0;
- return gcov_var.error;
+ gcov_var.mode = 0;
+ return gcov_var.error;
}
#if !IN_LIBGCOV
@@ -183,16 +173,15 @@ gcov_close(void)
GCOV_LINKAGE int
gcov_magic(gcov_unsigned_t magic, gcov_unsigned_t expected)
{
- if (magic == expected)
- return 1;
- magic = (magic >> 16) | (magic << 16);
- magic = ((magic & 0xff00ff) << 8) | ((magic >> 8) & 0xff00ff);
- if (magic == expected)
- {
- gcov_var.endian = 1;
- return -1;
- }
- return 0;
+ if (magic == expected)
+ return 1;
+ magic = (magic >> 16) | (magic << 16);
+ magic = ((magic & 0xff00ff) << 8) | ((magic >> 8) & 0xff00ff);
+ if (magic == expected) {
+ gcov_var.endian = 1;
+ return -1;
+ }
+ return 0;
}
#endif
@@ -200,15 +189,16 @@ gcov_magic(gcov_unsigned_t magic, gcov_unsigned_t expected)
static void
gcov_allocate(unsigned int length)
{
- size_t new_size = gcov_var.alloc;
+ size_t new_size = gcov_var.alloc;
- if (!new_size)
- new_size = GCOV_BLOCK_SIZE;
- new_size += length;
- new_size *= 2;
+ if (!new_size)
+ new_size = GCOV_BLOCK_SIZE;
+ new_size += length;
+ new_size *= 2;
- gcov_var.alloc = new_size;
- gcov_var.buffer = XRESIZEVAR(gcov_unsigned_t, gcov_var.buffer, new_size << 2);
+ gcov_var.alloc = new_size;
+ gcov_var.buffer = XRESIZEVAR(gcov_unsigned_t, gcov_var.buffer,
+ new_size << 2);
}
#endif
@@ -218,10 +208,10 @@ gcov_allocate(unsigned int length)
static void
gcov_write_block(unsigned int size)
{
- if (fwrite(gcov_var.buffer, size << 2, 1, gcov_var.file) != 1)
- gcov_var.error = 1;
- gcov_var.start += size;
- gcov_var.offset -= size;
+ if (fwrite(gcov_var.buffer, size << 2, 1, gcov_var.file) != 1)
+ gcov_var.error = 1;
+ gcov_var.start += size;
+ gcov_var.offset -= size;
}
/* Allocate space to write BYTES bytes to the gcov file. Return a
@@ -230,27 +220,26 @@ gcov_write_block(unsigned int size)
static gcov_unsigned_t *
gcov_write_words(unsigned int words)
{
- gcov_unsigned_t *result;
+ gcov_unsigned_t *result;
- gcc_assert(gcov_var.mode < 0);
+ gcc_assert(gcov_var.mode < 0);
#if IN_LIBGCOV
- if (gcov_var.offset >= GCOV_BLOCK_SIZE)
- {
- gcov_write_block(GCOV_BLOCK_SIZE);
- if (gcov_var.offset)
- {
- gcc_assert(gcov_var.offset == 1);
- memcpy(gcov_var.buffer, gcov_var.buffer + GCOV_BLOCK_SIZE, 4);
+ if (gcov_var.offset >= GCOV_BLOCK_SIZE) {
+ gcov_write_block(GCOV_BLOCK_SIZE);
+ if (gcov_var.offset) {
+ gcc_assert(gcov_var.offset == 1);
+ memcpy(gcov_var.buffer, gcov_var.buffer
+ + GCOV_BLOCK_SIZE, 4);
+ }
}
- }
#else
- if (gcov_var.offset + words > gcov_var.alloc)
- gcov_allocate(gcov_var.offset + words);
+ if (gcov_var.offset + words > gcov_var.alloc)
+ gcov_allocate(gcov_var.offset + words);
#endif
- result = &gcov_var.buffer[gcov_var.offset];
- gcov_var.offset += words;
+ result = &gcov_var.buffer[gcov_var.offset];
+ gcov_var.offset += words;
- return result;
+ return result;
}
/* Write unsigned VALUE to coverage file. Sets error flag
@@ -259,9 +248,9 @@ gcov_write_words(unsigned int words)
GCOV_LINKAGE void
gcov_write_unsigned(gcov_unsigned_t value)
{
- gcov_unsigned_t *buffer = gcov_write_words(1);
+ gcov_unsigned_t *buffer = gcov_write_words(1);
- buffer[0] = value;
+ buffer[0] = value;
}
/* Write counter VALUE to coverage file. Sets error flag
@@ -271,13 +260,13 @@ gcov_write_unsigned(gcov_unsigned_t value)
GCOV_LINKAGE void
gcov_write_counter(gcov_type value)
{
- gcov_unsigned_t *buffer = gcov_write_words(2);
+ gcov_unsigned_t *buffer = gcov_write_words(2);
- buffer[0] = (gcov_unsigned_t) value;
- if (sizeof(value) > sizeof(gcov_unsigned_t))
- buffer[1] = (gcov_unsigned_t) (value >> 32);
- else
- buffer[1] = 0;
+ buffer[0] = (gcov_unsigned_t) value;
+ if (sizeof(value) > sizeof(gcov_unsigned_t))
+ buffer[1] = (gcov_unsigned_t) (value >> 32);
+ else
+ buffer[1] = 0;
}
#endif /* IN_LIBGCOV */
@@ -288,21 +277,20 @@ gcov_write_counter(gcov_type value)
GCOV_LINKAGE void
gcov_write_string(const char *string)
{
- unsigned int length = 0;
- unsigned int alloc = 0;
- gcov_unsigned_t *buffer;
+ unsigned int length = 0;
+ unsigned int alloc = 0;
+ gcov_unsigned_t *buffer;
- if (string)
- {
- length = strlen(string);
- alloc = (length + 4) >> 2;
- }
+ if (string) {
+ length = strlen(string);
+ alloc = (length + 4) >> 2;
+ }
- buffer = gcov_write_words(1 + alloc);
+ buffer = gcov_write_words(1 + alloc);
- buffer[0] = alloc;
- buffer[alloc] = 0;
- memcpy(&buffer[1], string, length);
+ buffer[0] = alloc;
+ buffer[alloc] = 0;
+ memcpy(&buffer[1], string, length);
}
#endif
@@ -313,13 +301,13 @@ gcov_write_string(const char *string)
GCOV_LINKAGE gcov_position_t
gcov_write_tag(gcov_unsigned_t tag)
{
- gcov_position_t result = gcov_var.start + gcov_var.offset;
- gcov_unsigned_t *buffer = gcov_write_words(2);
+ gcov_position_t result = gcov_var.start + gcov_var.offset;
+ gcov_unsigned_t *buffer = gcov_write_words(2);
- buffer[0] = tag;
- buffer[1] = 0;
+ buffer[0] = tag;
+ buffer[1] = 0;
- return result;
+ return result;
}
/* Write a record length using POSITION, which was returned by
@@ -330,19 +318,19 @@ gcov_write_tag(gcov_unsigned_t tag)
GCOV_LINKAGE void
gcov_write_length(gcov_position_t position)
{
- unsigned int offset;
- gcov_unsigned_t length;
- gcov_unsigned_t *buffer;
-
- gcc_assert(gcov_var.mode < 0);
- gcc_assert(position + 2 <= gcov_var.start + gcov_var.offset);
- gcc_assert(position >= gcov_var.start);
- offset = position - gcov_var.start;
- length = gcov_var.offset - offset - 2;
- buffer = (gcov_unsigned_t *) &gcov_var.buffer[offset];
- buffer[1] = length;
- if (gcov_var.offset >= GCOV_BLOCK_SIZE)
- gcov_write_block(gcov_var.offset);
+ unsigned int offset;
+ gcov_unsigned_t length;
+ gcov_unsigned_t *buffer;
+
+ gcc_assert(gcov_var.mode < 0);
+ gcc_assert(position + 2 <= gcov_var.start + gcov_var.offset);
+ gcc_assert(position >= gcov_var.start);
+ offset = position - gcov_var.start;
+ length = gcov_var.offset - offset - 2;
+ buffer = (gcov_unsigned_t *) &gcov_var.buffer[offset];
+ buffer[1] = length;
+ if (gcov_var.offset >= GCOV_BLOCK_SIZE)
+ gcov_write_block(gcov_var.offset);
}
#else /* IN_LIBGCOV */
@@ -352,10 +340,10 @@ gcov_write_length(gcov_position_t position)
GCOV_LINKAGE void
gcov_write_tag_length(gcov_unsigned_t tag, gcov_unsigned_t length)
{
- gcov_unsigned_t *buffer = gcov_write_words(2);
+ gcov_unsigned_t *buffer = gcov_write_words(2);
- buffer[0] = tag;
- buffer[1] = length;
+ buffer[0] = tag;
+ buffer[1] = length;
}
/* Write a summary structure to the gcov file. Return nonzero on
@@ -364,19 +352,18 @@ gcov_write_tag_length(gcov_unsigned_t tag, gcov_unsigned_t length)
GCOV_LINKAGE void
gcov_write_summary(gcov_unsigned_t tag, const struct gcov_summary *summary)
{
- unsigned int ix;
- const struct gcov_ctr_summary *csum;
-
- gcov_write_tag_length(tag, GCOV_TAG_SUMMARY_LENGTH);
- gcov_write_unsigned(summary->checksum);
- 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);
- gcov_write_counter(csum->run_max);
- gcov_write_counter(csum->sum_max);
- }
+ unsigned int ix;
+ const struct gcov_ctr_summary *csum;
+
+ gcov_write_tag_length(tag, GCOV_TAG_SUMMARY_LENGTH);
+ gcov_write_unsigned(summary->checksum);
+ 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);
+ gcov_write_counter(csum->run_max);
+ gcov_write_counter(csum->sum_max);
+ }
}
#endif /* IN_LIBGCOV */
@@ -388,45 +375,44 @@ gcov_write_summary(gcov_unsigned_t tag, const struct gcov_summary *summary)
static const gcov_unsigned_t *
gcov_read_words(unsigned int words)
{
- const gcov_unsigned_t *result;
- unsigned int excess = gcov_var.length - gcov_var.offset;
+ const gcov_unsigned_t *result;
+ unsigned int excess = gcov_var.length - gcov_var.offset;
- gcc_assert(gcov_var.mode > 0);
- if (excess < words)
- {
- gcov_var.start += gcov_var.offset;
+ gcc_assert(gcov_var.mode > 0);
+ if (excess < words) {
+ gcov_var.start += gcov_var.offset;
#if IN_LIBGCOV
- if (excess)
- {
- gcc_assert(excess == 1);
- memcpy(gcov_var.buffer, gcov_var.buffer + gcov_var.offset, 4);
- }
+ if (excess) {
+ gcc_assert(excess == 1);
+ 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;
+ gcov_var.offset = 0;
+ gcov_var.length = excess;
#if IN_LIBGCOV
- gcc_assert(!gcov_var.length || gcov_var.length == 1);
- excess = GCOV_BLOCK_SIZE;
+ gcc_assert(!gcov_var.length || gcov_var.length == 1);
+ excess = GCOV_BLOCK_SIZE;
#else
- if (gcov_var.length + words > gcov_var.alloc)
- gcov_allocate(gcov_var.length + words);
- excess = gcov_var.alloc - gcov_var.length;
+ if (gcov_var.length + words > gcov_var.alloc)
+ gcov_allocate(gcov_var.length + words);
+ excess = gcov_var.alloc - gcov_var.length;
#endif
- excess = fread(gcov_var.buffer + gcov_var.length,
- 1, excess << 2, gcov_var.file) >> 2;
- gcov_var.length += excess;
- if (gcov_var.length < words)
- {
- gcov_var.overread += words - gcov_var.length;
- gcov_var.length = 0;
- return 0;
+ excess = fread(gcov_var.buffer + gcov_var.length,
+ 1, excess << 2, gcov_var.file) >> 2;
+ gcov_var.length += excess;
+ if (gcov_var.length < words) {
+ gcov_var.overread += words - gcov_var.length;
+ gcov_var.length = 0;
+ return 0;
+ }
}
- }
- result = &gcov_var.buffer[gcov_var.offset];
- gcov_var.offset += words;
- return result;
+ result = &gcov_var.buffer[gcov_var.offset];
+ gcov_var.offset += words;
+ return result;
}
/* Read unsigned value from a coverage file. Sets error flag on file
@@ -435,13 +421,13 @@ gcov_read_words(unsigned int words)
GCOV_LINKAGE gcov_unsigned_t
gcov_read_unsigned(void)
{
- gcov_unsigned_t value;
- const gcov_unsigned_t *buffer = gcov_read_words(1);
+ gcov_unsigned_t value;
+ const gcov_unsigned_t *buffer = gcov_read_words(1);
- if (!buffer)
- return 0;
- value = from_file(buffer[0]);
- return value;
+ if (!buffer)
+ return 0;
+ value = from_file(buffer[0]);
+ return value;
}
/* Read counter value from a coverage file. Sets error flag on file
@@ -450,18 +436,18 @@ gcov_read_unsigned(void)
GCOV_LINKAGE gcov_type
gcov_read_counter(void)
{
- gcov_type value;
- const gcov_unsigned_t *buffer = gcov_read_words(2);
-
- if (!buffer)
- return 0;
- value = from_file(buffer[0]);
- if (sizeof(value) > sizeof(gcov_unsigned_t))
- value |= ((gcov_type) from_file(buffer[1])) << 32;
- else if (buffer[1])
- gcov_var.error = -1;
-
- return value;
+ gcov_type value;
+ const gcov_unsigned_t *buffer = gcov_read_words(2);
+
+ if (!buffer)
+ return 0;
+ value = from_file(buffer[0]);
+ if (sizeof(value) > sizeof(gcov_unsigned_t))
+ value |= ((gcov_type) from_file(buffer[1])) << 32;
+ else if (buffer[1])
+ gcov_var.error = -1;
+
+ return value;
}
/* Read string from coverage file. Returns a pointer to a static
@@ -472,30 +458,29 @@ gcov_read_counter(void)
GCOV_LINKAGE const char *
gcov_read_string(void)
{
- unsigned int length = gcov_read_unsigned();
+ unsigned int length = gcov_read_unsigned();
- if (!length)
- return 0;
+ if (!length)
+ return 0;
- return (const char *) gcov_read_words(length);
+ return (const char *) gcov_read_words(length);
}
#endif
GCOV_LINKAGE void
gcov_read_summary(struct gcov_summary *summary)
{
- unsigned int ix;
- struct gcov_ctr_summary *csum;
-
- summary->checksum = gcov_read_unsigned();
- 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();
- csum->run_max = gcov_read_counter();
- csum->sum_max = gcov_read_counter();
- }
+ unsigned int ix;
+ struct gcov_ctr_summary *csum;
+
+ summary->checksum = gcov_read_unsigned();
+ 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();
+ csum->run_max = gcov_read_counter();
+ csum->sum_max = gcov_read_counter();
+ }
}
#if !IN_LIBGCOV
@@ -505,16 +490,15 @@ gcov_read_summary(struct gcov_summary *summary)
GCOV_LINKAGE void
gcov_sync(gcov_position_t base, gcov_unsigned_t length)
{
- gcc_assert(gcov_var.mode > 0);
- base += length;
- if (base - gcov_var.start <= gcov_var.length)
- gcov_var.offset = base - gcov_var.start;
- else
- {
- gcov_var.offset = gcov_var.length = 0;
- fseek(gcov_var.file, base << 2, SEEK_SET);
- gcov_var.start = ftell(gcov_var.file) >> 2;
- }
+ gcc_assert(gcov_var.mode > 0);
+ base += length;
+ if (base - gcov_var.start <= gcov_var.length)
+ gcov_var.offset = base - gcov_var.start;
+ else {
+ gcov_var.offset = gcov_var.length = 0;
+ fseek(gcov_var.file, base << 2, SEEK_SET);
+ gcov_var.start = ftell(gcov_var.file) >> 2;
+ }
}
#endif
@@ -524,11 +508,11 @@ gcov_sync(gcov_position_t base, gcov_unsigned_t length)
GCOV_LINKAGE void
gcov_seek(gcov_position_t base)
{
- gcc_assert(gcov_var.mode < 0);
- if (gcov_var.offset)
- gcov_write_block(gcov_var.offset);
- fseek(gcov_var.file, base << 2, SEEK_SET);
- gcov_var.start = ftell(gcov_var.file) >> 2;
+ gcc_assert(gcov_var.mode < 0);
+ if (gcov_var.offset)
+ gcov_write_block(gcov_var.offset);
+ fseek(gcov_var.file, base << 2, SEEK_SET);
+ gcov_var.start = ftell(gcov_var.file) >> 2;
}
#endif
@@ -538,11 +522,11 @@ gcov_seek(gcov_position_t base)
GCOV_LINKAGE time_t
gcov_time(void)
{
- struct stat status;
+ struct stat status;
- if (fstat(fileno(gcov_var.file), &status))
- return 0;
- else
- return status.st_mtime;
+ if (fstat(fileno(gcov_var.file), &status))
+ return 0;
+ else
+ return status.st_mtime;
}
#endif /* IN_GCOV */
diff --git a/src/lib/gcov-io.h b/src/lib/gcov-io.h
index a033c288a0..89cbe49e7c 100644
--- a/src/lib/gcov-io.h
+++ b/src/lib/gcov-io.h
@@ -105,8 +105,8 @@ permissions described in the GCC Runtime Library Exception, version
basic_block: header int32:flags*
arcs: header int32:block_no arc*
arc: int32:dest_block int32:flags
- lines: header int32:block_no line*
- int32:0 string:NULL
+ lines: header int32:block_no line*
+ int32:0 string:NULL
line: int32:line_no | int32:0 string:filename
The BASIC_BLOCK record holds per-bb flags. The number of blocks
@@ -126,9 +126,9 @@ permissions described in the GCC Runtime Library Exception, version
blocks they are for.
The data file contains the following records.
- data: {unit summary:object summary:program* function-data*}*
+ data: {unit summary:object summary:program* function-data*}*
unit: header int32:checksum
- function-data: announce_function present counts
+ function-data: announce_function present counts
announce_function: header int32:ident
int32:lineno_checksum int32:cfg_checksum
present: header int32:present
@@ -301,10 +301,10 @@ typedef HOST_WIDEST_INT gcov_type;
/* Convert a magic or version number to a 4 character string. */
#define GCOV_UNSIGNED2STRING(ARRAY,VALUE) \
- ((ARRAY)[0] = (char)((VALUE) >> 24), \
- (ARRAY)[1] = (char)((VALUE) >> 16), \
- (ARRAY)[2] = (char)((VALUE) >> 8), \
- (ARRAY)[3] = (char)((VALUE) >> 0))
+ ((ARRAY)[0] = (char)((VALUE) >> 24), \
+ (ARRAY)[1] = (char)((VALUE) >> 16), \
+ (ARRAY)[2] = (char)((VALUE) >> 8), \
+ (ARRAY)[3] = (char)((VALUE) >> 0))
/* The record tags. Values [1..3f] are for tags which may be in either
file. Values [41..9f] for those in the note file and [a1..ff] for
@@ -320,7 +320,7 @@ typedef HOST_WIDEST_INT gcov_type;
#define GCOV_TAG_ARCS_LENGTH(NUM) (1 + (NUM) * 2)
#define GCOV_TAG_ARCS_NUM(LENGTH) (((LENGTH) - 1) / 2)
#define GCOV_TAG_LINES ((gcov_unsigned_t)0x01450000)
-#define GCOV_TAG_COUNTER_BASE ((gcov_unsigned_t)0x01a10000)
+#define GCOV_TAG_COUNTER_BASE ((gcov_unsigned_t)0x01a10000)
#define GCOV_TAG_COUNTER_LENGTH(NUM) ((NUM) * 2)
#define GCOV_TAG_COUNTER_NUM(LENGTH) ((LENGTH) / 2)
#define GCOV_TAG_OBJECT_SUMMARY ((gcov_unsigned_t)0xa1000000) /* Obsolete */
@@ -329,7 +329,7 @@ typedef HOST_WIDEST_INT gcov_type;
(1 + GCOV_COUNTERS_SUMMABLE * (2 + 3 * 2))
/* Counters that are collected. */
-#define GCOV_COUNTER_ARCS 0 /* Arc transitions. */
+#define GCOV_COUNTER_ARCS 0 /* Arc transitions. */
#define GCOV_COUNTERS_SUMMABLE 1 /* Counters which can be
summed. */
#define GCOV_FIRST_VALUE_COUNTER 1 /* The first of counters used for value
@@ -355,7 +355,7 @@ typedef HOST_WIDEST_INT gcov_type;
/* Number of counters used for value profiling. */
#define GCOV_N_VALUE_COUNTERS \
- (GCOV_LAST_VALUE_COUNTER - GCOV_FIRST_VALUE_COUNTER + 1)
+ (GCOV_LAST_VALUE_COUNTER - GCOV_FIRST_VALUE_COUNTER + 1)
/* A list of human readable names of the counters */
#define GCOV_COUNTER_NAMES {"arcs", "interval", "pow2", "single", \
@@ -399,7 +399,7 @@ typedef HOST_WIDEST_INT gcov_type;
#define GCOV_BLOCK_UNEXPECTED (1 << 1)
/* Arc flags. */
-#define GCOV_ARC_ON_TREE (1 << 0)
+#define GCOV_ARC_ON_TREE (1 << 0)
#define GCOV_ARC_FAKE (1 << 1)
#define GCOV_ARC_FALLTHROUGH (1 << 2)
@@ -408,18 +408,18 @@ typedef HOST_WIDEST_INT gcov_type;
/* Cumulative counter data. */
struct gcov_ctr_summary
{
- gcov_unsigned_t num; /* number of counters. */
- gcov_unsigned_t runs; /* number of program runs */
- gcov_type sum_all; /* sum of all counters accumulated. */
- gcov_type run_max; /* maximum value on a single run. */
- gcov_type sum_max; /* sum of individual run max values. */
+ gcov_unsigned_t num; /* number of counters. */
+ gcov_unsigned_t runs; /* number of program runs */
+ gcov_type sum_all; /* sum of all counters accumulated. */
+ gcov_type run_max; /* maximum value on a single run. */
+ gcov_type sum_max; /* sum of individual run max values. */
};
/* Object & program summary record. */
struct gcov_summary
{
- gcov_unsigned_t checksum; /* checksum of program */
- struct gcov_ctr_summary ctrs[GCOV_COUNTERS_SUMMABLE];
+ gcov_unsigned_t checksum; /* checksum of program */
+ struct gcov_ctr_summary ctrs[GCOV_COUNTERS_SUMMABLE];
};
/* Structures embedded in coverage program. The structures generated
@@ -429,8 +429,8 @@ struct gcov_summary
/* Information about counters for a single function. */
struct gcov_ctr_info
{
- gcov_unsigned_t num; /* number of counters. */
- gcov_type *values; /* their values. */
+ gcov_unsigned_t num; /* number of counters. */
+ gcov_type *values; /* their values. */
};
/* Information about a single function. This uses the trailing array
@@ -441,11 +441,11 @@ struct gcov_ctr_info
struct gcov_fn_info
{
- const struct gcov_info *key; /* comdat key */
- gcov_unsigned_t ident; /* unique ident of function */
- gcov_unsigned_t lineno_checksum; /* function lineo_checksum */
- gcov_unsigned_t cfg_checksum; /* function cfg checksum */
- struct gcov_ctr_info ctrs[0]; /* instrumented counters */
+ const struct gcov_info *key; /* comdat key */
+ gcov_unsigned_t ident; /* unique ident of function */
+ gcov_unsigned_t lineno_checksum; /* function lineo_checksum */
+ gcov_unsigned_t cfg_checksum; /* function cfg checksum */
+ struct gcov_ctr_info ctrs[0]; /* instrumented counters */
};
/* Type of function used to merge counters. */
@@ -454,18 +454,18 @@ typedef void (*gcov_merge_fn) (gcov_type *, gcov_unsigned_t);
/* Information about a single object file. */
struct gcov_info
{
- gcov_unsigned_t version; /* expected version number */
- struct gcov_info *next; /* link to next, used by libgcov */
+ gcov_unsigned_t version; /* expected version number */
+ struct gcov_info *next; /* link to next, used by libgcov */
- gcov_unsigned_t stamp; /* uniquifying time stamp */
- const char *filename; /* output file name */
+ gcov_unsigned_t stamp; /* uniquifying time stamp */
+ const char *filename; /* output file name */
- gcov_merge_fn merge[GCOV_COUNTERS]; /* merge functions (null for
- unused) */
+ gcov_merge_fn merge[GCOV_COUNTERS]; /* merge functions (null for
+ unused) */
- unsigned int n_functions; /* number of functions */
- const struct gcov_fn_info *const *functions; /* pointer to pointers
- to function information */
+ unsigned int n_functions; /* number of functions */
+ const struct gcov_fn_info *const *functions; /* pointer to pointers to
+ function information */
};
/* Register a new object file module. */
@@ -506,7 +506,7 @@ extern int __gcov_execle(const char *, char *, ...) ATTRIBUTE_HIDDEN;
extern int __gcov_execv(const char *, char *const []) ATTRIBUTE_HIDDEN;
extern int __gcov_execvp(const char *, char *const []) ATTRIBUTE_HIDDEN;
extern int __gcov_execve(const char *, char *const [], char *const [])
- ATTRIBUTE_HIDDEN;
+ ATTRIBUTE_HIDDEN;
#endif
#endif /* IN_LIBGCOV */
@@ -518,25 +518,27 @@ extern int __gcov_execve(const char *, char *const [], char *const [])
GCOV_LINKAGE struct gcov_var
{
- FILE *file;
- gcov_position_t start; /* Position of first byte of block */
- unsigned int offset; /* Read/write position within the block. */
- unsigned int length; /* Read limit in the block. */
- unsigned int overread; /* Number of words overread. */
- int error; /* < 0 overflow, > 0 disk error. */
- int mode; /* < 0 writing, > 0 reading */
+ FILE *file;
+ gcov_position_t start; /* Position of first byte of block */
+ unsigned int offset; /* Read/write position within the block. */
+ unsigned int length; /* Read limit in the block. */
+ unsigned int overread; /* Number of words overread. */
+ int error; /* < 0 overflow, > 0 disk error. */
+ 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. */
- gcov_unsigned_t buffer[GCOV_BLOCK_SIZE + 1];
+ /* 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.
+ */
+ 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. */
- size_t alloc;
- gcov_unsigned_t *buffer;
+ int endian; /* Swap endianness. */
+ /* Holds a variable length block, as the compiler can write
+ * strings and needs to backtrack.
+ */
+ size_t alloc;
+ gcov_unsigned_t *buffer;
#endif
} gcov_var ATTRIBUTE_HIDDEN;
@@ -569,10 +571,10 @@ GCOV_LINKAGE void gcov_read_summary(struct gcov_summary *) ATTRIBUTE_HIDDEN;
/* Available only in libgcov */
GCOV_LINKAGE void gcov_write_counter(gcov_type) ATTRIBUTE_HIDDEN;
GCOV_LINKAGE void gcov_write_tag_length(gcov_unsigned_t, gcov_unsigned_t)
- ATTRIBUTE_HIDDEN;
+ ATTRIBUTE_HIDDEN;
GCOV_LINKAGE void gcov_write_summary(gcov_unsigned_t /*tag*/,
const struct gcov_summary *)
- ATTRIBUTE_HIDDEN;
+ ATTRIBUTE_HIDDEN;
static void gcov_rewrite(void);
GCOV_LINKAGE void gcov_seek(gcov_position_t /*position*/) ATTRIBUTE_HIDDEN;
#else
@@ -604,8 +606,8 @@ GCOV_LINKAGE time_t gcov_time(void);
static inline gcov_position_t
gcov_position(void)
{
- gcc_assert(gcov_var.mode > 0);
- return gcov_var.start + gcov_var.offset;
+ gcc_assert(gcov_var.mode > 0);
+ return gcov_var.start + gcov_var.offset;
}
/* Return nonzero if the error flag is set. */
@@ -613,7 +615,7 @@ gcov_position(void)
static inline int
gcov_is_error(void)
{
- return gcov_var.file ? gcov_var.error : 1;
+ return gcov_var.file ? gcov_var.error : 1;
}
#if IN_LIBGCOV
@@ -622,11 +624,11 @@ gcov_is_error(void)
static inline void
gcov_rewrite(void)
{
- gcc_assert(gcov_var.mode > 0);
- gcov_var.mode = -1;
- gcov_var.start = 0;
- gcov_var.offset = 0;
- fseek(gcov_var.file, 0L, SEEK_SET);
+ gcc_assert(gcov_var.mode > 0);
+ gcov_var.mode = -1;
+ gcov_var.start = 0;
+ gcov_var.offset = 0;
+ fseek(gcov_var.file, 0L, SEEK_SET);
}
#endif
diff --git a/src/lib/generic_sdram.c b/src/lib/generic_sdram.c
index f050f86265..f671375749 100644
--- a/src/lib/generic_sdram.c
+++ b/src/lib/generic_sdram.c
@@ -26,7 +26,7 @@ void sdram_initialize(int controllers, const struct mem_controller *ctrl)
#if CONFIG_RAMINIT_SYSINFO
sdram_set_spd_registers(ctrl + i, sysinfo);
#else
- sdram_set_spd_registers(ctrl + i);
+ sdram_set_spd_registers(ctrl + i);
#endif
}
diff --git a/src/lib/hardwaremain.c b/src/lib/hardwaremain.c
index 75e4824c13..a56d68e3f5 100644
--- a/src/lib/hardwaremain.c
+++ b/src/lib/hardwaremain.c
@@ -283,7 +283,7 @@ static void bs_run_timers(int drain) {}
#endif
static void bs_call_callbacks(struct boot_state *state,
- boot_state_sequence_t seq)
+ boot_state_sequence_t seq)
{
struct boot_phase *phase = &state->phases[seq];
@@ -385,8 +385,8 @@ static void bs_walk_state_machine(void)
}
static int boot_state_sched_callback(struct boot_state *state,
- struct boot_state_callback *bscb,
- boot_state_sequence_t seq)
+ struct boot_state_callback *bscb,
+ boot_state_sequence_t seq)
{
if (state->complete) {
printk(BIOS_WARNING,
@@ -403,7 +403,7 @@ static int boot_state_sched_callback(struct boot_state *state,
}
int boot_state_sched_on_entry(struct boot_state_callback *bscb,
- boot_state_t state_id)
+ boot_state_t state_id)
{
struct boot_state *state = &boot_states[state_id];
@@ -411,7 +411,7 @@ int boot_state_sched_on_entry(struct boot_state_callback *bscb,
}
int boot_state_sched_on_exit(struct boot_state_callback *bscb,
- boot_state_t state_id)
+ boot_state_t state_id)
{
struct boot_state *state = &boot_states[state_id];
diff --git a/src/lib/imd_cbmem.c b/src/lib/imd_cbmem.c
index b0273f4d56..f53a2639c5 100644
--- a/src/lib/imd_cbmem.c
+++ b/src/lib/imd_cbmem.c
@@ -62,14 +62,14 @@ static inline const struct imd_entry *cbmem_to_imd(const struct cbmem_entry *e)
/* These are the different situations to handle:
* CONFIG_EARLY_CBMEM_INIT:
- * In ramstage cbmem_initialize() attempts a recovery of the
- * cbmem region set up by romstage. It uses cbmem_top() as the
- * starting point of recovery.
+ * In ramstage cbmem_initialize() attempts a recovery of the
+ * cbmem region set up by romstage. It uses cbmem_top() as the
+ * starting point of recovery.
*
- * In romstage, similar to ramstage, cbmem_initialize() needs to
- * attempt recovery of the cbmem area using cbmem_top() as the limit.
- * cbmem_initialize_empty() initializes an empty cbmem area from
- * cbmem_top();
+ * In romstage, similar to ramstage, cbmem_initialize() needs to
+ * attempt recovery of the cbmem area using cbmem_top() as the limit.
+ * cbmem_initialize_empty() initializes an empty cbmem area from
+ * cbmem_top();
*
*/
static struct imd *imd_init_backing(struct imd *backing)
diff --git a/src/lib/jpeg.c b/src/lib/jpeg.c
index c07109d099..751ef0e624 100644
--- a/src/lib/jpeg.c
+++ b/src/lib/jpeg.c
@@ -267,15 +267,15 @@ void jpeg_fetch_size(unsigned char *buf, int *width, int *height)
int jpeg_check_size(unsigned char *buf, int width, int height)
{
- datap = buf;
+ datap = buf;
getbyte();
getbyte();
readtables(M_SOF0);
getword();
getbyte();
- if (height != getword() || width != getword())
+ if (height != getword() || width != getword())
return 0;
- return 1;
+ return 1;
}
int jpeg_decode(unsigned char *buf, unsigned char *pic,
@@ -476,14 +476,14 @@ static int dec_readmarker(struct in *in)
#define LEBI_GET(in) (le = in->left, bi = in->bits)
#define LEBI_PUT(in) (in->left = le, in->bits = bi)
-#define GETBITS(in, n) ( \
- (le < (n) ? le = fillbits(in, le, bi), bi = in->bits : 0), \
- (le -= (n)), \
- bi >> le & ((1 << (n)) - 1) \
-)
+#define GETBITS(in, n) ( \
+ (le < (n) ? le = fillbits(in, le, bi), bi = in->bits : 0), \
+ (le -= (n)), \
+ bi >> le & ((1 << (n)) - 1) \
+ )
#define UNGETBITS(in, n) ( \
- le += (n) \
+ le += (n) \
)
@@ -520,22 +520,22 @@ static int dec_rec2(struct in *in, struct dec_hufftbl *hu, int *runp, int c,
return c;
}
-#define DEC_REC(in, hu, r, i) ( \
- r = GETBITS(in, DECBITS), \
- i = hu->llvals[r], \
- i & 128 ? \
- ( \
- UNGETBITS(in, i & 127), \
- r = i >> 8 & 15, \
- i >> 16 \
- ) \
- : \
- ( \
- LEBI_PUT(in), \
- i = dec_rec2(in, hu, &r, r, i), \
- LEBI_GET(in), \
- i \
- ) \
+#define DEC_REC(in, hu, r, i) ( \
+ r = GETBITS(in, DECBITS), \
+ i = hu->llvals[r], \
+ i & 128 ? \
+ ( \
+ UNGETBITS(in, i & 127), \
+ r = i >> 8 & 15, \
+ i >> 16 \
+ ) \
+ : \
+ ( \
+ LEBI_PUT(in), \
+ i = dec_rec2(in, hu, &r, r, i), \
+ LEBI_GET(in), \
+ i \
+ ) \
)
static void decode_mcus(struct in *in, int *dct, int n, struct scan *sc, int *maxp)
@@ -604,7 +604,7 @@ static void dec_makehuff(struct dec_hufftbl *hu, int *hufflen, unsigned char *hu
(DECBITS - (i + 1 + v)) | 128;
} else
x = v << 16 | (hu-> vals[k] & 0xf0) << 4 |
- (DECBITS - (i + 1));
+ (DECBITS - (i + 1));
hu->llvals[c | d] = x;
}
}
@@ -641,25 +641,25 @@ static void dec_makehuff(struct dec_hufftbl *hu, int *hufflen, unsigned char *hu
a = IMULT(a, c - s) + t, \
b = IMULT(b, c + s) - t)
-#define IDCT \
-( \
- XPP(t0, t1), \
- XMP(t2, t3), \
- t2 = IMULT(t2, IC4) - t3, \
- XPP(t0, t3), \
- XPP(t1, t2), \
- XMP(t4, t7), \
- XPP(t5, t6), \
- XMP(t5, t7), \
- t5 = IMULT(t5, IC4), \
- ROT(t4, t6, S22, C22),\
- t6 -= t7, \
- t5 -= t6, \
- t4 -= t5, \
- XPP(t0, t7), \
- XPP(t1, t6), \
- XPP(t2, t5), \
- XPP(t3, t4) \
+#define IDCT \
+( \
+ XPP(t0, t1), \
+ XMP(t2, t3), \
+ t2 = IMULT(t2, IC4) - t3, \
+ XPP(t0, t3), \
+ XPP(t1, t2), \
+ XMP(t4, t7), \
+ XPP(t5, t6), \
+ XMP(t5, t7), \
+ t5 = IMULT(t5, IC4), \
+ ROT(t4, t6, S22, C22), \
+ t6 -= t7, \
+ t5 -= t6, \
+ t4 -= t5, \
+ XPP(t0, t7), \
+ XPP(t1, t6), \
+ XPP(t2, t5), \
+ XPP(t3, t4) \
)
static unsigned char zig2[64] = {
@@ -765,7 +765,7 @@ static void idctqtab(unsigned char *qin, PREC *qout)
for (i = 0; i < 8; i++)
for (j = 0; j < 8; j++)
qout[zig[i * 8 + j]] = qin[zig[i * 8 + j]] *
- IMULT(aaidct[i], aaidct[j]);
+ IMULT(aaidct[i], aaidct[j]);
}
static void scaleidctqtab(PREC *q, PREC sc)
@@ -812,11 +812,11 @@ static void initcol(PREC q[][64])
/* This is optimized for the stupid sun SUNWspro compiler. */
#define STORECLAMP(a,x) \
( \
- (a) = (x), \
- (unsigned int)(x) >= 256 ? \
- ((a) = (x) < 0 ? 0 : 255) \
- : \
- 0 \
+ (a) = (x), \
+ (unsigned int)(x) >= 256 ? \
+ ((a) = (x) < 0 ? 0 : 255) \
+ : \
+ 0 \
)
#define CLAMP(x) ((unsigned int)(x) >= 256 ? ((x) < 0 ? 0 : 255) : (x))
@@ -825,98 +825,98 @@ static void initcol(PREC q[][64])
#define CBCRCG(yin, xin) \
( \
- cb = outc[0 +yin*8+xin], \
- cr = outc[64+yin*8+xin], \
- cg = (50 * cb + 130 * cr + 128) >> 8 \
+ cb = outc[0 +yin*8+xin], \
+ cr = outc[64+yin*8+xin], \
+ cg = (50 * cb + 130 * cr + 128) >> 8 \
)
#else
#define CBCRCG(yin, xin) \
( \
- cb = outc[0 +yin*8+xin], \
- cr = outc[64+yin*8+xin], \
- cg = (3 * cb + 8 * cr) >> 4 \
+ cb = outc[0 +yin*8+xin], \
+ cr = outc[64+yin*8+xin], \
+ cg = (3 * cb + 8 * cr) >> 4 \
)
#endif
#define PIC(yin, xin, p, xout) \
( \
- y = outy[(yin) * 8 + xin], \
- STORECLAMP(p[(xout) * 3 + 0], y + cr), \
- STORECLAMP(p[(xout) * 3 + 1], y - cg), \
- STORECLAMP(p[(xout) * 3 + 2], y + cb) \
+ y = outy[(yin) * 8 + xin], \
+ STORECLAMP(p[(xout) * 3 + 0], y + cr), \
+ STORECLAMP(p[(xout) * 3 + 1], y - cg), \
+ STORECLAMP(p[(xout) * 3 + 2], y + cb) \
)
#ifdef __LITTLE_ENDIAN
-#define PIC_16(yin, xin, p, xout, add) \
-( \
- y = outy[(yin) * 8 + xin], \
- y = ((CLAMP(y + cr + add*2+1) & 0xf8) << 8) | \
- ((CLAMP(y - cg + add) & 0xfc) << 3) | \
- ((CLAMP(y + cb + add*2+1)) >> 3), \
- p[(xout) * 2 + 0] = y & 0xff, \
- p[(xout) * 2 + 1] = y >> 8 \
+#define PIC_16(yin, xin, p, xout, add) \
+( \
+ y = outy[(yin) * 8 + xin], \
+ y = ((CLAMP(y + cr + add*2+1) & 0xf8) << 8) | \
+ ((CLAMP(y - cg + add) & 0xfc) << 3) | \
+ ((CLAMP(y + cb + add*2+1)) >> 3), \
+ p[(xout) * 2 + 0] = y & 0xff, \
+ p[(xout) * 2 + 1] = y >> 8 \
)
#else
#ifdef CONFIG_PPC
-#define PIC_16(yin, xin, p, xout, add) \
-( \
- y = outy[(yin) * 8 + xin], \
- y = ((CLAMP(y + cr + add*2+1) & 0xf8) << 7) | \
- ((CLAMP(y - cg + add*2+1) & 0xf8) << 2) | \
- ((CLAMP(y + cb + add*2+1)) >> 3), \
- p[(xout) * 2 + 0] = y >> 8, \
- p[(xout) * 2 + 1] = y & 0xff \
+#define PIC_16(yin, xin, p, xout, add) \
+( \
+ y = outy[(yin) * 8 + xin], \
+ y = ((CLAMP(y + cr + add*2+1) & 0xf8) << 7) | \
+ ((CLAMP(y - cg + add*2+1) & 0xf8) << 2) | \
+ ((CLAMP(y + cb + add*2+1)) >> 3), \
+ p[(xout) * 2 + 0] = y >> 8, \
+ p[(xout) * 2 + 1] = y & 0xff \
)
#else
-#define PIC_16(yin, xin, p, xout, add) \
-( \
- y = outy[(yin) * 8 + xin], \
- y = ((CLAMP(y + cr + add*2+1) & 0xf8) << 8) | \
- ((CLAMP(y - cg + add) & 0xfc) << 3) | \
- ((CLAMP(y + cb + add*2+1)) >> 3), \
- p[(xout) * 2 + 0] = y >> 8, \
- p[(xout) * 2 + 1] = y & 0xff \
+#define PIC_16(yin, xin, p, xout, add) \
+( \
+ y = outy[(yin) * 8 + xin], \
+ y = ((CLAMP(y + cr + add*2+1) & 0xf8) << 8) | \
+ ((CLAMP(y - cg + add) & 0xfc) << 3) | \
+ ((CLAMP(y + cb + add*2+1)) >> 3), \
+ p[(xout) * 2 + 0] = y >> 8, \
+ p[(xout) * 2 + 1] = y & 0xff \
)
#endif
#endif
#define PIC_32(yin, xin, p, xout) \
( \
- y = outy[(yin) * 8 + xin], \
- STORECLAMP(p[(xout) * 4 + 0], y + cr), \
- STORECLAMP(p[(xout) * 4 + 1], y - cg), \
- STORECLAMP(p[(xout) * 4 + 2], y + cb), \
- p[(xout) * 4 + 3] = 0 \
+ y = outy[(yin) * 8 + xin], \
+ STORECLAMP(p[(xout) * 4 + 0], y + cr), \
+ STORECLAMP(p[(xout) * 4 + 1], y - cg), \
+ STORECLAMP(p[(xout) * 4 + 2], y + cb), \
+ p[(xout) * 4 + 3] = 0 \
)
-#define PIC221111(xin) \
-( \
- CBCRCG(0, xin), \
- PIC(xin / 4 * 8 + 0, (xin & 3) * 2 + 0, pic0, xin * 2 + 0), \
- PIC(xin / 4 * 8 + 0, (xin & 3) * 2 + 1, pic0, xin * 2 + 1), \
- PIC(xin / 4 * 8 + 1, (xin & 3) * 2 + 0, pic1, xin * 2 + 0), \
- PIC(xin / 4 * 8 + 1, (xin & 3) * 2 + 1, pic1, xin * 2 + 1) \
+#define PIC221111(xin) \
+( \
+ CBCRCG(0, xin), \
+ PIC(xin / 4 * 8 + 0, (xin & 3) * 2 + 0, pic0, xin * 2 + 0), \
+ PIC(xin / 4 * 8 + 0, (xin & 3) * 2 + 1, pic0, xin * 2 + 1), \
+ PIC(xin / 4 * 8 + 1, (xin & 3) * 2 + 0, pic1, xin * 2 + 0), \
+ PIC(xin / 4 * 8 + 1, (xin & 3) * 2 + 1, pic1, xin * 2 + 1) \
)
-#define PIC221111_16(xin) \
-( \
- CBCRCG(0, xin), \
- PIC_16(xin / 4 * 8 + 0, (xin & 3) * 2 + 0, pic0, xin * 2 + 0, 3), \
- PIC_16(xin / 4 * 8 + 0, (xin & 3) * 2 + 1, pic0, xin * 2 + 1, 0), \
- PIC_16(xin / 4 * 8 + 1, (xin & 3) * 2 + 0, pic1, xin * 2 + 0, 1), \
- PIC_16(xin / 4 * 8 + 1, (xin & 3) * 2 + 1, pic1, xin * 2 + 1, 2) \
+#define PIC221111_16(xin) \
+( \
+ CBCRCG(0, xin), \
+ PIC_16(xin / 4 * 8 + 0, (xin & 3) * 2 + 0, pic0, xin * 2 + 0, 3), \
+ PIC_16(xin / 4 * 8 + 0, (xin & 3) * 2 + 1, pic0, xin * 2 + 1, 0), \
+ PIC_16(xin / 4 * 8 + 1, (xin & 3) * 2 + 0, pic1, xin * 2 + 0, 1), \
+ PIC_16(xin / 4 * 8 + 1, (xin & 3) * 2 + 1, pic1, xin * 2 + 1, 2) \
)
-#define PIC221111_32(xin) \
-( \
- CBCRCG(0, xin), \
- PIC_32(xin / 4 * 8 + 0, (xin & 3) * 2 + 0, pic0, xin * 2 + 0),\
- PIC_32(xin / 4 * 8 + 0, (xin & 3) * 2 + 1, pic0, xin * 2 + 1),\
- PIC_32(xin / 4 * 8 + 1, (xin & 3) * 2 + 0, pic1, xin * 2 + 0),\
- PIC_32(xin / 4 * 8 + 1, (xin & 3) * 2 + 1, pic1, xin * 2 + 1) \
+#define PIC221111_32(xin) \
+( \
+ CBCRCG(0, xin), \
+ PIC_32(xin / 4 * 8 + 0, (xin & 3) * 2 + 0, pic0, xin * 2 + 0), \
+ PIC_32(xin / 4 * 8 + 0, (xin & 3) * 2 + 1, pic0, xin * 2 + 1), \
+ PIC_32(xin / 4 * 8 + 1, (xin & 3) * 2 + 0, pic1, xin * 2 + 0), \
+ PIC_32(xin / 4 * 8 + 1, (xin & 3) * 2 + 1, pic1, xin * 2 + 1) \
)
static void col221111(int *out, unsigned char *pic, int width)
@@ -957,7 +957,7 @@ static void col221111_16(int *out, unsigned char *pic, int width)
for (i = 2; i > 0; i--) {
for (j = 4; j > 0; j--) {
for (k = 0; k < 8; k++)
- PIC221111_16(k);
+ PIC221111_16(k);
outc += 8;
outy += 16;
pic0 += 2 * width;
diff --git a/src/lib/libgcov.c b/src/lib/libgcov.c
index 024b2c38ba..d1d2c6e769 100644
--- a/src/lib/libgcov.c
+++ b/src/lib/libgcov.c
@@ -111,10 +111,10 @@ void __gcov_merge_add(gcov_type *counters __attribute__ ((unused)),
struct gcov_fn_buffer
{
- struct gcov_fn_buffer *next;
- unsigned int fn_ix;
- struct gcov_fn_info info;
- /* note gcov_fn_info ends in a trailing array. */
+ struct gcov_fn_buffer *next;
+ unsigned int fn_ix;
+ struct gcov_fn_info info;
+ /* note gcov_fn_info ends in a trailing array. */
};
/* Chain of per-object gcov structures. */
@@ -131,46 +131,47 @@ static int
create_file_directory(char *filename)
{
#ifdef __COREBOOT__
- (void) filename;
- return 0;
+ (void) filename;
+ return 0;
#else
#if !defined(TARGET_POSIX_IO) && !defined(_WIN32)
- (void) filename;
- return -1;
+ (void) filename;
+ return -1;
#else
- char *s;
-
- s = filename;
-
- if (HAS_DRIVE_SPEC(s))
- s += 2;
- if (IS_DIR_SEPARATOR(*s))
- ++s;
- for (; *s != '\0'; s++)
- if (IS_DIR_SEPARATOR(*s))
- {
- char sep = *s;
- *s = '\0';
-
- /* Try to make directory if it doesn't already exist. */
- if (access(filename, F_OK) == -1
+ char *s;
+
+ s = filename;
+
+ if (HAS_DRIVE_SPEC(s))
+ s += 2;
+ if (IS_DIR_SEPARATOR(*s))
+ ++s;
+ for (; *s != '\0'; s++)
+ if (IS_DIR_SEPARATOR(*s)) {
+ char sep = *s;
+ *s = '\0';
+
+ /* Try to make directory if it doesn't already exist. */
+ if (access(filename, F_OK) == -1
#ifdef TARGET_POSIX_IO
- && mkdir(filename, 0755) == -1
+ && mkdir(filename, 0755) == -1
#else
- && mkdir(filename) == -1
+ && mkdir(filename) == -1
#endif
- /* The directory might have been made by another process. */
- && errno != EEXIST)
- {
- fprintf(stderr, "profiling:%s:Cannot create directory\n",
- filename);
- *s = sep;
- return -1;
- };
-
- *s = sep;
- };
- return 0;
+ /* The directory might have been made by another
+ * process.
+ */
+ && errno != EEXIST) {
+ fprintf(stderr,
+ "profiling:%s:Cannot create directory\n",
+ filename);
+ *s = sep;
+ return -1;
+ };
+
+ *s = sep;
+ };
+ return 0;
#endif
#endif
}
@@ -179,80 +180,78 @@ static struct gcov_fn_buffer *
free_fn_data(const struct gcov_info *gi_ptr, struct gcov_fn_buffer *buffer,
unsigned int limit)
{
- struct gcov_fn_buffer *next;
- unsigned int ix, n_ctr = 0;
-
- if (!buffer)
- return 0;
- next = buffer->next;
-
- for (ix = 0; ix != limit; ix++)
- if (gi_ptr->merge[ix])
- free(buffer->info.ctrs[n_ctr++].values);
- free(buffer);
- return next;
+ struct gcov_fn_buffer *next;
+ unsigned int ix, n_ctr = 0;
+
+ if (!buffer)
+ return 0;
+ next = buffer->next;
+
+ for (ix = 0; ix != limit; ix++)
+ if (gi_ptr->merge[ix])
+ free(buffer->info.ctrs[n_ctr++].values);
+ free(buffer);
+ return next;
}
static struct gcov_fn_buffer **
buffer_fn_data(const char *filename, const struct gcov_info *gi_ptr,
struct gcov_fn_buffer **end_ptr, unsigned int fn_ix)
{
- unsigned int n_ctrs = 0, ix = 0;
- struct gcov_fn_buffer *fn_buffer;
- unsigned int len;
+ unsigned int n_ctrs = 0, ix = 0;
+ struct gcov_fn_buffer *fn_buffer;
+ unsigned int len;
- for (ix = GCOV_COUNTERS; ix--;)
- if (gi_ptr->merge[ix])
- n_ctrs++;
+ for (ix = GCOV_COUNTERS; ix--;)
+ if (gi_ptr->merge[ix])
+ n_ctrs++;
- len = sizeof(*fn_buffer) + sizeof(fn_buffer->info.ctrs[0]) * n_ctrs;
- fn_buffer = (struct gcov_fn_buffer *)malloc(len);
+ len = sizeof(*fn_buffer) + sizeof(fn_buffer->info.ctrs[0]) * n_ctrs;
+ fn_buffer = (struct gcov_fn_buffer *)malloc(len);
- if (!fn_buffer)
- goto fail;
+ if (!fn_buffer)
+ goto fail;
- fn_buffer->next = 0;
- fn_buffer->fn_ix = fn_ix;
- fn_buffer->info.ident = gcov_read_unsigned();
- fn_buffer->info.lineno_checksum = gcov_read_unsigned();
- fn_buffer->info.cfg_checksum = gcov_read_unsigned();
+ fn_buffer->next = 0;
+ fn_buffer->fn_ix = fn_ix;
+ fn_buffer->info.ident = gcov_read_unsigned();
+ 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++)
- {
- gcov_unsigned_t length;
- gcov_type *values;
+ for (n_ctrs = ix = 0; ix != GCOV_COUNTERS; ix++) {
+ gcov_unsigned_t length;
+ gcov_type *values;
- if (!gi_ptr->merge[ix])
- continue;
+ if (!gi_ptr->merge[ix])
+ continue;
- if (gcov_read_unsigned() != GCOV_TAG_FOR_COUNTER(ix))
- {
- len = 0;
- goto fail;
- }
+ if (gcov_read_unsigned() != GCOV_TAG_FOR_COUNTER(ix)) {
+ len = 0;
+ goto fail;
+ }
- length = GCOV_TAG_COUNTER_NUM(gcov_read_unsigned());
- len = length * sizeof(gcov_type);
- values = (gcov_type *)malloc(len);
- if (!values)
- goto fail;
+ length = GCOV_TAG_COUNTER_NUM(gcov_read_unsigned());
+ len = length * sizeof(gcov_type);
+ values = (gcov_type *)malloc(len);
+ if (!values)
+ goto fail;
- fn_buffer->info.ctrs[n_ctrs].num = length;
- fn_buffer->info.ctrs[n_ctrs].values = values;
+ fn_buffer->info.ctrs[n_ctrs].num = length;
+ fn_buffer->info.ctrs[n_ctrs].values = values;
- while (length--)
- *values++ = gcov_read_counter();
- n_ctrs++;
- }
+ while (length--)
+ *values++ = gcov_read_counter();
+ n_ctrs++;
+ }
- *end_ptr = fn_buffer;
- return &fn_buffer->next;
+ *end_ptr = fn_buffer;
+ return &fn_buffer->next;
fail:
- fprintf(stderr, "profiling:%s:Function %u %s %u \n", filename, fn_ix,
- len ? "cannot allocate" : "counter mismatch", len ? len : ix);
+ fprintf(stderr, "profiling:%s:Function %u %s %u \n", filename, fn_ix,
+ len ? "cannot allocate" : "counter mismatch", len ? len : ix);
- return (struct gcov_fn_buffer **)free_fn_data(gi_ptr, fn_buffer, ix);
+ return (struct gcov_fn_buffer **)free_fn_data(gi_ptr, fn_buffer, ix);
}
/* Add an unsigned value to the current crc */
@@ -260,18 +259,17 @@ fail:
static gcov_unsigned_t
crc32_unsigned(gcov_unsigned_t crc32, gcov_unsigned_t value)
{
- unsigned int ix;
+ unsigned int ix;
- for (ix = 32; ix--; value <<= 1)
- {
- unsigned int feedback;
+ for (ix = 32; ix--; value <<= 1) {
+ unsigned int feedback;
- feedback = (value ^ crc32) & 0x80000000 ? 0x04c11db7 : 0;
- crc32 <<= 1;
- crc32 ^= feedback;
- }
+ feedback = (value ^ crc32) & 0x80000000 ? 0x04c11db7 : 0;
+ crc32 <<= 1;
+ crc32 ^= feedback;
+ }
- return crc32;
+ return crc32;
}
/* Check if VERSION of the info block PTR matches libgcov one.
@@ -283,19 +281,18 @@ static int
gcov_version(struct gcov_info *ptr, gcov_unsigned_t version,
const char *filename)
{
- if (version != GCOV_VERSION)
- {
- char v[4], e[4];
-
- GCOV_UNSIGNED2STRING(v, version);
- GCOV_UNSIGNED2STRING(e, GCOV_VERSION);
-
- fprintf(stderr,
- "profiling:%s:Version mismatch - expected %.4s got %.4s\n",
- filename? filename : ptr->filename, e, v);
- return 0;
- }
- return 1;
+ if (version != GCOV_VERSION) {
+ char v[4], e[4];
+
+ GCOV_UNSIGNED2STRING(v, version);
+ GCOV_UNSIGNED2STRING(e, GCOV_VERSION);
+
+ fprintf(stderr,
+ "profiling:%s:Version mismatch - expected %.4s got %.4s\n",
+ filename? filename : ptr->filename, e, v);
+ return 0;
+ }
+ return 1;
}
/* Dump the coverage counts. We merge with existing counts when
@@ -308,414 +305,416 @@ gcov_version(struct gcov_info *ptr, gcov_unsigned_t version,
static void
gcov_exit(void)
{
- struct gcov_info *gi_ptr;
- const struct gcov_fn_info *gfi_ptr;
- struct gcov_summary this_prg; /* summary for program. */
- struct gcov_summary all_prg; /* summary for all instances of program. */
- struct gcov_ctr_summary *cs_ptr;
- const struct gcov_ctr_info *ci_ptr;
- unsigned int t_ix;
- int f_ix = 0;
- gcov_unsigned_t c_num;
- const char *gcov_prefix;
- int gcov_prefix_strip = 0;
- size_t prefix_length;
- char *gi_filename, *gi_filename_up;
- gcov_unsigned_t crc32 = 0;
-
- 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)
- {
- 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++)
- {
- 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->lineno_checksum : 0);
- if (!gfi_ptr)
- continue;
-
- ci_ptr = gfi_ptr->ctrs;
- for (t_ix = 0; t_ix != GCOV_COUNTERS_SUMMABLE; t_ix++)
- {
- if (!gi_ptr->merge[t_ix])
- continue;
-
- cs_ptr = &this_prg.ctrs[t_ix];
- 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];
+ struct gcov_info *gi_ptr;
+ const struct gcov_fn_info *gfi_ptr;
+ struct gcov_summary this_prg; /* summary for program. */
+ struct gcov_summary all_prg; /* summary for all instances of program. */
+ struct gcov_ctr_summary *cs_ptr;
+ const struct gcov_ctr_info *ci_ptr;
+ unsigned int t_ix;
+ int f_ix = 0;
+ gcov_unsigned_t c_num;
+ const char *gcov_prefix;
+ int gcov_prefix_strip = 0;
+ size_t prefix_length;
+ char *gi_filename, *gi_filename_up;
+ gcov_unsigned_t crc32 = 0;
+
+ 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) {
+ 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++) {
+ 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->lineno_checksum : 0);
+ if (!gfi_ptr)
+ continue;
+
+ ci_ptr = gfi_ptr->ctrs;
+ for (t_ix = 0; t_ix != GCOV_COUNTERS_SUMMABLE; t_ix++) {
+ if (!gi_ptr->merge[t_ix])
+ continue;
+
+ cs_ptr = &this_prg.ctrs[t_ix];
+ 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];
+ }
+ ci_ptr++;
+ }
}
- ci_ptr++;
- }
}
- }
#ifndef __COREBOOT__
- {
- /* Check if the level of dirs to strip off specified. */
- char *tmp = getenv("GCOV_PREFIX_STRIP");
- if (tmp)
- {
- gcov_prefix_strip = atoi(tmp);
- /* Do not consider negative values. */
- if (gcov_prefix_strip < 0)
- gcov_prefix_strip = 0;
- }
- }
-
- /* Get file name relocation prefix. Non-absolute values are ignored. */
- gcov_prefix = getenv("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
-#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)
- {
- gcov_prefix = ".";
- prefix_length = 1;
- }
- /* Allocate and initialize the filename scratch space plus one. */
- gi_filename = (char *) alloca(prefix_length + gcov_max_filename + 2);
- if (prefix_length)
- memcpy(gi_filename, gcov_prefix, prefix_length);
- gi_filename_up = gi_filename + prefix_length;
-
- /* Now merge each file. */
- 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. */
- struct gcov_ctr_summary *cs_prg, *cs_tprg, *cs_all;
- int error = 0;
- gcov_unsigned_t tag, length;
- gcov_position_t summary_pos = 0;
- gcov_position_t eof_pos = 0;
- const char *fname, *s;
- struct gcov_fn_buffer *fn_buffer = 0;
- struct gcov_fn_buffer **fn_tail = &fn_buffer;
-
- fname = gi_ptr->filename;
-
- /* Avoid to add multiple drive letters into combined path. */
- if (prefix_length != 0 && HAS_DRIVE_SPEC(fname))
- fname += 2;
-
- /* Build relocated filename, stripping off leading
- 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))
- {
- fname = s;
- level++;
- }
- }
-
- /* Update complete filename with stripped original. */
- 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
- strcpy(gi_filename_up, fname);
-
- 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);
- continue;
- }
- if (!gcov_open(gi_filename))
- {
- fprintf(stderr, "profiling:%s:Cannot open\n", gi_filename);
- continue;
- }
- }
-
- tag = gcov_read_unsigned();
- if (tag)
{
- /* Merge data from file. */
- if (tag != GCOV_DATA_MAGIC)
- {
- fprintf(stderr, "profiling:%s:Not a gcov data file\n",
- gi_filename);
- goto read_fatal;
- }
- length = gcov_read_unsigned();
- if (!gcov_version(gi_ptr, length, gi_filename))
- goto read_fatal;
-
- length = gcov_read_unsigned();
- if (length != gi_ptr->stamp)
- /* Read from a different compilation. Overwrite the file. */
- goto rewrite;
-
- /* Look for program summary. */
- for (f_ix = 0;;)
- {
- struct gcov_summary tmp;
-
- eof_pos = gcov_position();
- tag = gcov_read_unsigned();
- if (tag != GCOV_TAG_PROGRAM_SUMMARY)
- break;
-
- f_ix--;
- length = gcov_read_unsigned();
- if (length != GCOV_TAG_SUMMARY_LENGTH)
- goto read_mismatch;
- gcov_read_summary(&tmp);
- if ((error = gcov_is_error()))
- goto read_error;
- 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)
- goto next_summary;
- prg = tmp;
- summary_pos = eof_pos;
-
- next_summary:;
- }
-
- /* Merge execution counts for each function. */
- 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)
- goto read_mismatch;
-
- length = gcov_read_unsigned();
- if (!length)
- /* 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 (!fn_tail)
- goto read_mismatch;
- continue;
+ /* Check if the level of dirs to strip off specified. */
+ char *tmp = getenv("GCOV_PREFIX_STRIP");
+ if (tmp) {
+ gcov_prefix_strip = atoi(tmp);
+ /* Do not consider negative values. */
+ if (gcov_prefix_strip < 0)
+ gcov_prefix_strip = 0;
}
-
- length = gcov_read_unsigned();
- if (length != gfi_ptr->ident)
- goto read_mismatch;
-
- length = gcov_read_unsigned();
- if (length != gfi_ptr->lineno_checksum)
- goto read_mismatch;
-
- length = gcov_read_unsigned();
- if (length != gfi_ptr->cfg_checksum)
- 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];
-
- 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))
- goto read_mismatch;
- (*merge)(ci_ptr->values, ci_ptr->num);
- ci_ptr++;
- }
- if ((error = gcov_is_error()))
- goto read_error;
- }
-
- if (tag)
- {
- read_mismatch:;
- 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;
- }
}
- goto rewrite;
- read_error:;
- fprintf(stderr, "profiling:%s:%s merging\n", gi_filename,
- error < 0 ? "Overflow": "Error");
+ /* Get file name relocation prefix. Non-absolute values are ignored. */
+ gcov_prefix = getenv("GCOV_PREFIX");
+ if (gcov_prefix) {
+ prefix_length = strlen(gcov_prefix);
- goto read_fatal;
+ /* Remove an unnecessary trailing '/' */
+ if (IS_DIR_SEPARATOR(gcov_prefix[prefix_length - 1]))
+ prefix_length--;
+ } else
+#endif
+ prefix_length = 0;
- rewrite:;
- gcov_rewrite();
- if (!summary_pos)
- {
- memset(&prg, 0, sizeof(prg));
- summary_pos = eof_pos;
+ /* If no prefix was specified and a prefix strip, then we assume
+ relative. */
+ if (gcov_prefix_strip != 0 && prefix_length == 0) {
+ gcov_prefix = ".";
+ prefix_length = 1;
}
+ /* Allocate and initialize the filename scratch space plus one. */
+ gi_filename = (char *) alloca(prefix_length + gcov_max_filename + 2);
+ if (prefix_length)
+ memcpy(gi_filename, gcov_prefix, prefix_length);
+ gi_filename_up = gi_filename + prefix_length;
+
+ /* Now merge each file. */
+ 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. */
+ struct gcov_ctr_summary *cs_prg, *cs_tprg, *cs_all;
+ int error = 0;
+ gcov_unsigned_t tag, length;
+ gcov_position_t summary_pos = 0;
+ gcov_position_t eof_pos = 0;
+ const char *fname, *s;
+ struct gcov_fn_buffer *fn_buffer = 0;
+ struct gcov_fn_buffer **fn_tail = &fn_buffer;
+
+ fname = gi_ptr->filename;
+
+ /* Avoid to add multiple drive letters into combined path. */
+ if (prefix_length != 0 && HAS_DRIVE_SPEC(fname))
+ fname += 2;
+
+ /* Build relocated filename, stripping off leading
+ * 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)) {
+ fname = s;
+ level++;
+ }
+ }
+
+ /* Update complete filename with stripped original. */
+ 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
+ strcpy(gi_filename_up, fname);
+
+ 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);
+ continue;
+ }
+ if (!gcov_open(gi_filename)) {
+ fprintf(stderr,
+ "profiling:%s:Cannot open\n",
+ gi_filename);
+ continue;
+ }
+ }
+
+ tag = gcov_read_unsigned();
+ if (tag) {
+ /* Merge data from file. */
+ if (tag != GCOV_DATA_MAGIC) {
+ fprintf(stderr,
+ "profiling:%s:Not a gcov data file\n",
+ gi_filename);
+ goto read_fatal;
+ }
+ length = gcov_read_unsigned();
+ if (!gcov_version(gi_ptr, length, gi_filename))
+ goto read_fatal;
+
+ length = gcov_read_unsigned();
+ if (length != gi_ptr->stamp)
+ /* Read from a different compilation.
+ * Overwrite the file.
+ */
+ goto rewrite;
+
+ /* Look for program summary. */
+ for (f_ix = 0;;) {
+ struct gcov_summary tmp;
+
+ eof_pos = gcov_position();
+ tag = gcov_read_unsigned();
+ if (tag != GCOV_TAG_PROGRAM_SUMMARY)
+ break;
+
+ f_ix--;
+ length = gcov_read_unsigned();
+ if (length != GCOV_TAG_SUMMARY_LENGTH)
+ goto read_mismatch;
+ gcov_read_summary(&tmp);
+ if ((error = gcov_is_error()))
+ goto read_error;
+ 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)
+ goto next_summary;
+ prg = tmp;
+ summary_pos = eof_pos;
+
+ next_summary:;
+ }
+
+ /* Merge execution counts for each function. */
+ 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)
+ goto read_mismatch;
+
+ length = gcov_read_unsigned();
+ if (!length)
+ /* 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 (!fn_tail)
+ goto read_mismatch;
+ continue;
+ }
+
+ length = gcov_read_unsigned();
+ if (length != gfi_ptr->ident)
+ goto read_mismatch;
+
+ length = gcov_read_unsigned();
+ if (length != gfi_ptr->lineno_checksum)
+ goto read_mismatch;
+
+ length = gcov_read_unsigned();
+ if (length != gfi_ptr->cfg_checksum)
+ 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];
+
+ 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))
+ goto read_mismatch;
+ (*merge)(ci_ptr->values,
+ ci_ptr->num);
+ ci_ptr++;
+ }
+ if ((error = gcov_is_error()))
+ goto read_error;
+ }
+
+ if (tag) {
+ read_mismatch:;
+ 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;
+ }
+ }
+ goto rewrite;
+
+read_error:;
+ fprintf(stderr, "profiling:%s:%s merging\n", gi_filename,
+ error < 0 ? "Overflow": "Error");
+
+ goto read_fatal;
+
+rewrite:;
+ gcov_rewrite();
+ 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++)
- {
- 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 (!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)
- 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");
- all_prg.checksum = ~0u;
- }
- }
+ /* Merge the summaries. */
+ 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 (!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)
+ 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");
+ all_prg.checksum = ~0u;
+ }
+ }
- prg.checksum = crc32;
+ prg.checksum = crc32;
- /* Write out the data. */
- if (!eof_pos)
- {
- gcov_write_tag_length(GCOV_DATA_MAGIC, GCOV_VERSION);
- gcov_write_unsigned(gi_ptr->stamp);
- }
+ /* Write out the data. */
+ if (!eof_pos) {
+ gcov_write_tag_length(GCOV_DATA_MAGIC, GCOV_VERSION);
+ gcov_write_unsigned(gi_ptr->stamp);
+ }
- if (summary_pos)
- gcov_seek(summary_pos);
+ if (summary_pos)
+ gcov_seek(summary_pos);
+
+ /* Generate whole program statistics. */
+ gcov_write_summary(GCOV_TAG_PROGRAM_SUMMARY, &prg);
+
+ if (summary_pos < eof_pos)
+ gcov_seek(eof_pos);
+
+ /* Write execution counts for each function. */
+ 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) {
+ /* Buffered data from another program. */
+ buffered = 1;
+ gfi_ptr = &fn_buffer->info;
+ length = GCOV_TAG_FUNCTION_LENGTH;
+ } else {
+ gfi_ptr = gi_ptr->functions[f_ix];
+ if (gfi_ptr && gfi_ptr->key == gi_ptr)
+ length = GCOV_TAG_FUNCTION_LENGTH;
+ else
+ length = 0;
+ }
+
+ gcov_write_tag_length(GCOV_TAG_FUNCTION, length);
+ if (!length)
+ continue;
+
+ gcov_write_unsigned(gfi_ptr->ident);
+ gcov_write_unsigned(gfi_ptr->lineno_checksum);
+ gcov_write_unsigned(gfi_ptr->cfg_checksum);
+
+ ci_ptr = gfi_ptr->ctrs;
+ for (t_ix = 0; t_ix < GCOV_COUNTERS; t_ix++) {
+ if (!gi_ptr->merge[t_ix])
+ continue;
+
+ n_counts = ci_ptr->num;
+ gcov_write_tag_length(GCOV_TAG_FOR_COUNTER(t_ix),
+ GCOV_TAG_COUNTER_LENGTH(n_counts));
+ gcov_type *c_ptr = ci_ptr->values;
+ while (n_counts--)
+ gcov_write_counter(*c_ptr++);
+ ci_ptr++;
+ }
+ if (buffered)
+ fn_buffer = free_fn_data(gi_ptr, fn_buffer,
+ GCOV_COUNTERS);
+ }
- /* Generate whole program statistics. */
- gcov_write_summary(GCOV_TAG_PROGRAM_SUMMARY, &prg);
+ gcov_write_unsigned(0);
- if (summary_pos < eof_pos)
- gcov_seek(eof_pos);
+read_fatal:;
+ while (fn_buffer)
+ fn_buffer = free_fn_data(gi_ptr, fn_buffer, GCOV_COUNTERS);
- /* Write execution counts for each function. */
- 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)
- {
- /* Buffered data from another program. */
- buffered = 1;
- gfi_ptr = &fn_buffer->info;
- length = GCOV_TAG_FUNCTION_LENGTH;
- }
- else
- {
- gfi_ptr = gi_ptr->functions[f_ix];
- if (gfi_ptr && gfi_ptr->key == gi_ptr)
- length = GCOV_TAG_FUNCTION_LENGTH;
- else
- length = 0;
- }
-
- gcov_write_tag_length(GCOV_TAG_FUNCTION, length);
- if (!length)
- continue;
-
- gcov_write_unsigned(gfi_ptr->ident);
- gcov_write_unsigned(gfi_ptr->lineno_checksum);
- gcov_write_unsigned(gfi_ptr->cfg_checksum);
-
- ci_ptr = gfi_ptr->ctrs;
- for (t_ix = 0; t_ix < GCOV_COUNTERS; t_ix++)
- {
- if (!gi_ptr->merge[t_ix])
- continue;
-
- n_counts = ci_ptr->num;
- gcov_write_tag_length(GCOV_TAG_FOR_COUNTER(t_ix),
- GCOV_TAG_COUNTER_LENGTH(n_counts));
- gcov_type *c_ptr = ci_ptr->values;
- while (n_counts--)
- gcov_write_counter(*c_ptr++);
- ci_ptr++;
- }
- if (buffered)
- fn_buffer = free_fn_data(gi_ptr, fn_buffer, GCOV_COUNTERS);
+ if ((error = gcov_close()))
+ fprintf(stderr, error < 0 ?
+ "profiling:%s:Overflow writing\n" :
+ "profiling:%s:Error writing\n",
+ gi_filename);
}
-
- gcov_write_unsigned(0);
-
- read_fatal:;
- while (fn_buffer)
- fn_buffer = free_fn_data(gi_ptr, fn_buffer, GCOV_COUNTERS);
-
- if ((error = gcov_close()))
- fprintf(stderr, error < 0 ?
- "profiling:%s:Overflow writing\n" :
- "profiling:%s:Error writing\n",
- gi_filename);
- }
}
/* Add a new object file onto the bb chain. Invoked automatically
@@ -724,25 +723,24 @@ gcov_exit(void)
void
__gcov_init(struct gcov_info *info)
{
- if (!info->version || !info->n_functions)
- return;
- if (gcov_version(info, info->version, 0))
- {
- size_t filename_length = strlen(info->filename);
+ if (!info->version || !info->n_functions)
+ return;
+ if (gcov_version(info, info->version, 0)) {
+ size_t filename_length = strlen(info->filename);
- /* Refresh the longest file name information */
- if (filename_length > gcov_max_filename)
- gcov_max_filename = filename_length;
+ /* Refresh the longest file name information */
+ if (filename_length > gcov_max_filename)
+ gcov_max_filename = filename_length;
#ifndef __COREBOOT__
- if (!gcov_list)
- atexit(gcov_exit);
+ if (!gcov_list)
+ atexit(gcov_exit);
#endif
- info->next = gcov_list;
- gcov_list = info;
- }
- info->version = 0;
+ info->next = gcov_list;
+ gcov_list = info;
+ }
+ info->version = 0;
}
/* Called before fork or exec - write out profile information gathered so
@@ -752,31 +750,30 @@ __gcov_init(struct gcov_info *info)
void
__gcov_flush(void)
{
- const struct gcov_info *gi_ptr;
-
- gcov_exit();
- 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++)
- {
- unsigned int t_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++)
- {
- if (!gi_ptr->merge[t_ix])
- continue;
-
- memset(ci_ptr->values, 0, sizeof(gcov_type) * ci_ptr->num);
- ci_ptr++;
- }
+ const struct gcov_info *gi_ptr;
+
+ gcov_exit();
+ 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++) {
+ unsigned int t_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++) {
+ if (!gi_ptr->merge[t_ix])
+ continue;
+
+ memset(ci_ptr->values, 0,
+ sizeof(gcov_type) * ci_ptr->num);
+ ci_ptr++;
+ }
+ }
}
- }
}
#endif /* L_gcov */
@@ -788,8 +785,8 @@ __gcov_flush(void)
void
__gcov_merge_add(gcov_type *counters, unsigned int n_counters)
{
- for (; n_counters; counters++, n_counters--)
- *counters += gcov_read_counter();
+ for (; n_counters; counters++, n_counters--)
+ *counters += gcov_read_counter();
}
#endif /* L_gcov_merge_add */
@@ -800,8 +797,8 @@ __gcov_merge_add(gcov_type *counters, unsigned int n_counters)
void
__gcov_merge_ior(gcov_type *counters, unsigned int n_counters)
{
- for (; n_counters; counters++, n_counters--)
- *counters |= gcov_read_counter();
+ for (; n_counters; counters++, n_counters--)
+ *counters |= gcov_read_counter();
}
#endif
@@ -819,28 +816,25 @@ __gcov_merge_ior(gcov_type *counters, unsigned int n_counters)
void
__gcov_merge_single(gcov_type *counters, unsigned int n_counters)
{
- unsigned int i, n_measures;
- gcov_type value, counter, all;
-
- gcc_assert(!(n_counters % 3));
- n_measures = n_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])
- {
- counters[0] = value;
- counters[1] = counter - counters[1];
+ unsigned int i, n_measures;
+ gcov_type value, counter, all;
+
+ gcc_assert(!(n_counters % 3));
+ n_measures = n_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]) {
+ counters[0] = value;
+ counters[1] = counter - counters[1];
+ } else
+ counters[1] -= counter;
+ counters[2] += all;
}
- else
- counters[1] -= counter;
- counters[2] += all;
- }
}
#endif /* L_gcov_merge_single */
@@ -859,29 +853,27 @@ __gcov_merge_single(gcov_type *counters, unsigned int n_counters)
void
__gcov_merge_delta(gcov_type *counters, unsigned int n_counters)
{
- unsigned int i, n_measures;
- gcov_type value, counter, all;
-
- gcc_assert(!(n_counters % 4));
- n_measures = n_counters / 4;
- 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])
- {
- counters[1] = value;
- counters[2] = counter - counters[2];
+ unsigned int i, n_measures;
+ gcov_type value, counter, all;
+
+ gcc_assert(!(n_counters % 4));
+ n_measures = n_counters / 4;
+ 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]) {
+ counters[1] = value;
+ counters[2] = counter - counters[2];
+ } else
+ counters[2] -= counter;
+ counters[3] += all;
}
- else
- counters[2] -= counter;
- counters[3] += all;
- }
}
#endif /* L_gcov_merge_delta */
@@ -895,13 +887,13 @@ void
__gcov_interval_profiler(gcov_type *counters, gcov_type value,
int start, unsigned int steps)
{
- gcov_type delta = value - start;
- if (delta < 0)
- counters[steps + 1]++;
- else if (delta >= steps)
- counters[steps]++;
- else
- counters[delta]++;
+ gcov_type delta = value - start;
+ if (delta < 0)
+ counters[steps + 1]++;
+ else if (delta >= steps)
+ counters[steps]++;
+ else
+ counters[delta]++;
}
#endif
@@ -912,10 +904,10 @@ __gcov_interval_profiler(gcov_type *counters, gcov_type value,
void
__gcov_pow2_profiler(gcov_type *counters, gcov_type value)
{
- if (value & (value - 1))
- counters[0]++;
- else
- counters[1]++;
+ if (value & (value - 1))
+ counters[0]++;
+ else
+ counters[1]++;
}
#endif
@@ -932,23 +924,21 @@ __gcov_pow2_profiler(gcov_type *counters, gcov_type value)
static inline void
__gcov_one_value_profiler_body(gcov_type *counters, gcov_type value)
{
- if (value == counters[0])
- counters[1]++;
- else if (counters[1] == 0)
- {
- counters[1] = 1;
- counters[0] = value;
- }
- else
- counters[1]--;
- counters[2]++;
+ if (value == counters[0])
+ counters[1]++;
+ else if (counters[1] == 0) {
+ counters[1] = 1;
+ counters[0] = value;
+ } else
+ counters[1]--;
+ counters[2]++;
}
#ifdef L_gcov_one_value_profiler
void
__gcov_one_value_profiler(gcov_type *counters, gcov_type value)
{
- __gcov_one_value_profiler_body(counters, value);
+ __gcov_one_value_profiler_body(counters, value);
}
#endif
@@ -976,13 +966,14 @@ void
__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. */
- if (cur_func == callee_func
- || (VTABLE_USES_DESCRIPTORS && callee_func
- && *(void **) cur_func == *(void **) callee_func))
- __gcov_one_value_profiler_body(counter, value);
+ /* 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.
+ */
+ if (cur_func == callee_func
+ || (VTABLE_USES_DESCRIPTORS && callee_func
+ && *(void **) cur_func == *(void **) callee_func))
+ __gcov_one_value_profiler_body(counter, value);
}
#endif
@@ -994,8 +985,8 @@ __gcov_indirect_call_profiler(gcov_type *counter, gcov_type value,
void
__gcov_average_profiler(gcov_type *counters, gcov_type value)
{
- counters[0] += value;
- counters[1] ++;
+ counters[0] += value;
+ counters[1] ++;
}
#endif
@@ -1006,7 +997,7 @@ __gcov_average_profiler(gcov_type *counters, gcov_type value)
void
__gcov_ior_profiler(gcov_type *counters, gcov_type value)
{
- *counters |= value;
+ *counters |= value;
}
#endif
@@ -1017,8 +1008,8 @@ __gcov_ior_profiler(gcov_type *counters, gcov_type value)
pid_t
__gcov_fork(void)
{
- __gcov_flush();
- return fork();
+ __gcov_flush();
+ return fork();
}
#endif
@@ -1029,27 +1020,27 @@ __gcov_fork(void)
int
__gcov_execl(const char *path, char *arg, ...)
{
- va_list ap, aq;
- unsigned int i, length;
- char **args;
+ va_list ap, aq;
+ unsigned int i, length;
+ char **args;
- __gcov_flush();
+ __gcov_flush();
- va_start(ap, arg);
- va_copy(aq, ap);
+ va_start(ap, arg);
+ va_copy(aq, ap);
- length = 2;
- while (va_arg(ap, char *))
- length++;
- va_end(ap);
+ length = 2;
+ while (va_arg(ap, char *))
+ length++;
+ va_end(ap);
- args = (char **) alloca(length * sizeof(void *));
- args[0] = arg;
- for (i = 1; i < length; i++)
- args[i] = va_arg(aq, char *);
- va_end(aq);
+ args = (char **) alloca(length * sizeof(void *));
+ args[0] = arg;
+ for (i = 1; i < length; i++)
+ args[i] = va_arg(aq, char *);
+ va_end(aq);
- return execv(path, args);
+ return execv(path, args);
}
#endif
@@ -1060,27 +1051,27 @@ __gcov_execl(const char *path, char *arg, ...)
int
__gcov_execlp(const char *path, char *arg, ...)
{
- va_list ap, aq;
- unsigned int i, length;
- char **args;
+ va_list ap, aq;
+ unsigned int i, length;
+ char **args;
- __gcov_flush();
+ __gcov_flush();
- va_start(ap, arg);
- va_copy(aq, ap);
+ va_start(ap, arg);
+ va_copy(aq, ap);
- length = 2;
- while (va_arg(ap, char *))
- length++;
- va_end(ap);
+ length = 2;
+ while (va_arg(ap, char *))
+ length++;
+ va_end(ap);
- args = (char **) alloca(length * sizeof(void *));
- args[0] = arg;
- for (i = 1; i < length; i++)
- args[i] = va_arg(aq, char *);
- va_end(aq);
+ args = (char **) alloca(length * sizeof(void *));
+ args[0] = arg;
+ for (i = 1; i < length; i++)
+ args[i] = va_arg(aq, char *);
+ va_end(aq);
- return execvp(path, args);
+ return execvp(path, args);
}
#endif
@@ -1091,29 +1082,29 @@ __gcov_execlp(const char *path, char *arg, ...)
int
__gcov_execle(const char *path, char *arg, ...)
{
- va_list ap, aq;
- unsigned int i, length;
- char **args;
- char **envp;
+ va_list ap, aq;
+ unsigned int i, length;
+ char **args;
+ char **envp;
- __gcov_flush();
+ __gcov_flush();
- va_start(ap, arg);
- va_copy(aq, ap);
+ va_start(ap, arg);
+ va_copy(aq, ap);
- length = 2;
- while (va_arg(ap, char *))
- length++;
- va_end(ap);
+ length = 2;
+ while (va_arg(ap, char *))
+ length++;
+ va_end(ap);
- args = (char **) alloca(length * sizeof(void *));
- args[0] = arg;
- for (i = 1; i < length; i++)
- args[i] = va_arg(aq, char *);
- envp = va_arg(aq, char **);
- va_end(aq);
+ args = (char **) alloca(length * sizeof(void *));
+ args[0] = arg;
+ for (i = 1; i < length; i++)
+ args[i] = va_arg(aq, char *);
+ envp = va_arg(aq, char **);
+ va_end(aq);
- return execve(path, args, envp);
+ return execve(path, args, envp);
}
#endif
@@ -1124,8 +1115,8 @@ __gcov_execle(const char *path, char *arg, ...)
int
__gcov_execv(const char *path, char *const argv[])
{
- __gcov_flush();
- return execv(path, argv);
+ __gcov_flush();
+ return execv(path, argv);
}
#endif
@@ -1136,8 +1127,8 @@ __gcov_execv(const char *path, char *const argv[])
int
__gcov_execvp(const char *path, char *const argv[])
{
- __gcov_flush();
- return execvp(path, argv);
+ __gcov_flush();
+ return execvp(path, argv);
}
#endif
@@ -1148,8 +1139,8 @@ __gcov_execvp(const char *path, char *const argv[])
int
__gcov_execve(const char *path, char *const argv[], char *const envp[])
{
- __gcov_flush();
- return execve(path, argv, envp);
+ __gcov_flush();
+ return execve(path, argv, envp);
}
#endif
#endif /* inhibit_libc */
diff --git a/src/lib/lzmadecode.c b/src/lib/lzmadecode.c
index 2b03c22224..c0efda5f8d 100644
--- a/src/lib/lzmadecode.c
+++ b/src/lib/lzmadecode.c
@@ -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; }
@@ -53,15 +54,22 @@
#define UpdateBit1(p) Range -= bound; Code -= bound; *(p) -= (*(p)) >> kNumMoveBits;
#define RC_GET_BIT2(p, mi, A0, A1) IfBit0(p) \
- { UpdateBit0(p); mi <<= 1; A0; } else \
- { UpdateBit1(p); mi = (mi + mi) + 1; A1; }
+ { UpdateBit0(p); mi <<= 1; A0; } else \
+ { UpdateBit1(p); mi = (mi + mi) + 1; A1; }
#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); }
+#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); \
+}
#define kNumPosBitsMax 4
@@ -116,301 +124,257 @@ StopCompilingDueBUG
int LzmaDecodeProperties(CLzmaProperties *propsRes, const unsigned char *propsData, int size)
{
- unsigned char prop0;
- if (size < LZMA_PROPERTIES_SIZE)
- return LZMA_RESULT_DATA_ERROR;
- prop0 = propsData[0];
- if (prop0 >= (9 * 5 * 5))
- return LZMA_RESULT_DATA_ERROR;
- {
- 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;
- */
- }
-
- return LZMA_RESULT_OK;
+ unsigned char prop0;
+ if (size < LZMA_PROPERTIES_SIZE)
+ return LZMA_RESULT_DATA_ERROR;
+ prop0 = propsData[0];
+ if (prop0 >= (9 * 5 * 5))
+ return LZMA_RESULT_DATA_ERROR;
+ {
+ 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;
+ */
+ }
+
+ return LZMA_RESULT_OK;
}
#define kLzmaStreamWasFinishedId (-1)
int LzmaDecode(CLzmaDecoderState *vs,
- const unsigned char *inStream, SizeT inSize, SizeT *inSizeProcessed,
- unsigned char *outStream, SizeT outSize, SizeT *outSizeProcessed)
+ const unsigned char *inStream, SizeT inSize, SizeT *inSizeProcessed,
+ unsigned char *outStream, SizeT outSize, SizeT *outSizeProcessed)
{
- CProb *p = vs->Probs;
- SizeT nowPos = 0;
- Byte previousByte = 0;
- UInt32 posStateMask = (1 << (vs->Properties.pb)) - 1;
- UInt32 literalPosMask = (1 << (vs->Properties.lp)) - 1;
- int lc = vs->Properties.lc;
-
-
- int state = 0;
- UInt32 rep0 = 1, rep1 = 1, rep2 = 1, rep3 = 1;
- int len = 0;
- const Byte *Buffer;
- const Byte *BufferLim;
- int look_ahead_ptr = 4;
- union
- {
- Byte raw[4];
- UInt32 dw;
- } look_ahead;
- UInt32 Range;
- UInt32 Code;
-
- *inSizeProcessed = 0;
- *outSizeProcessed = 0;
-
- {
- UInt32 i;
- UInt32 numProbs = Literal + ((UInt32)LZMA_LIT_SIZE << (lc + vs->Properties.lp));
- for (i = 0; i < numProbs; i++)
- p[i] = kBitModelTotal >> 1;
- }
-
- RC_INIT(inStream, inSize);
-
-
- while (nowPos < outSize)
- {
- CProb *prob;
- UInt32 bound;
- int posState = (int)(
- (nowPos
- )
- & posStateMask);
-
- prob = p + IsMatch + (state << kNumPosBitsMax) + posState;
- IfBit0(prob)
- {
- int symbol = 1;
- UpdateBit0(prob)
- prob = p + Literal + (LZMA_LIT_SIZE *
- (((
- (nowPos
- )
- & literalPosMask) << lc) + (previousByte >> (8 - lc))));
-
- if (state >= kNumLitStates)
- {
- int matchByte;
- matchByte = outStream[nowPos - rep0];
- 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)
- }
- while (symbol < 0x100);
- }
- while (symbol < 0x100)
- {
- CProb *probLit = prob + symbol;
- RC_GET_BIT(probLit, symbol)
- }
- previousByte = (Byte)symbol;
-
- outStream[nowPos++] = previousByte;
- if (state < 4)
- state = 0;
- else if (state < 10)
- state -= 3;
- else
- state -= 6;
- }
- else
- {
- UpdateBit1(prob);
- prob = p + IsRep + state;
- IfBit0(prob)
- {
- UpdateBit0(prob);
- rep3 = rep2;
- rep2 = rep1;
- rep1 = rep0;
- state = state < kNumLitStates ? 0 : 3;
- prob = p + LenCoder;
- }
- else
- {
- UpdateBit1(prob);
- prob = p + IsRepG0 + state;
- IfBit0(prob)
- {
- UpdateBit0(prob);
- prob = p + IsRep0Long + (state << kNumPosBitsMax) + posState;
- IfBit0(prob)
- {
- UpdateBit0(prob);
-
- if (nowPos == 0)
- return LZMA_RESULT_DATA_ERROR;
-
- state = state < kNumLitStates ? 9 : 11;
- previousByte = outStream[nowPos - rep0];
- outStream[nowPos++] = previousByte;
-
- continue;
- }
- else
- {
- UpdateBit1(prob);
- }
- }
- else
- {
- UInt32 distance;
- UpdateBit1(prob);
- prob = p + IsRepG1 + state;
- IfBit0(prob)
- {
- UpdateBit0(prob);
- distance = rep1;
- }
- else
- {
- UpdateBit1(prob);
- prob = p + IsRepG2 + state;
- IfBit0(prob)
- {
- UpdateBit0(prob);
- distance = rep2;
- }
- else
- {
- UpdateBit1(prob);
- distance = rep3;
- rep3 = rep2;
- }
- rep2 = rep1;
- }
- rep1 = rep0;
- rep0 = distance;
- }
- state = state < kNumLitStates ? 8 : 11;
- prob = p + RepLenCoder;
- }
- {
- int numBits, offset;
- CProb *probLen = prob + LenChoice;
- IfBit0(probLen)
- {
- UpdateBit0(probLen);
- probLen = prob + LenLow + (posState << kLenNumLowBits);
- offset = 0;
- numBits = kLenNumLowBits;
- }
- else
- {
- UpdateBit1(probLen);
- probLen = prob + LenChoice2;
- IfBit0(probLen)
- {
- UpdateBit0(probLen);
- probLen = prob + LenMid + (posState << kLenNumMidBits);
- offset = kLenNumLowSymbols;
- numBits = kLenNumMidBits;
- }
- else
- {
- UpdateBit1(probLen);
- probLen = prob + LenHigh;
- offset = kLenNumLowSymbols + kLenNumMidSymbols;
- numBits = kLenNumHighBits;
- }
- }
- RangeDecoderBitTreeDecode(probLen, numBits, len);
- len += offset;
- }
-
- if (state < 4)
- {
- int posSlot;
- state += kNumLitStates;
- prob = p + PosSlot +
- ((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) <<
- kNumPosSlotBits);
- RangeDecoderBitTreeDecode(prob, kNumPosSlotBits, posSlot);
- if (posSlot >= kStartPosModelIndex)
- {
- int numDirectBits = ((posSlot >> 1) - 1);
- rep0 = (2 | ((UInt32)posSlot & 1));
- if (posSlot < kEndPosModelIndex)
- {
- rep0 <<= numDirectBits;
- prob = p + SpecPos + rep0 - posSlot - 1;
- }
- else
- {
- numDirectBits -= kNumAlignBits;
- do
- {
- RC_NORMALIZE
- Range >>= 1;
- rep0 <<= 1;
- if (Code >= Range)
- {
- Code -= Range;
- rep0 |= 1;
- }
- }
- while (--numDirectBits != 0);
- prob = p + Align;
- rep0 <<= kNumAlignBits;
- numDirectBits = kNumAlignBits;
- }
- {
- int i = 1;
- int mi = 1;
- do
- {
- CProb *prob3 = prob + mi;
- RC_GET_BIT2(prob3, mi, ; , rep0 |= i);
- i <<= 1;
- }
- while (--numDirectBits != 0);
- }
- }
- else
- rep0 = posSlot;
- if (++rep0 == (UInt32)(0))
- {
- /* it's for stream version */
- len = kLzmaStreamWasFinishedId;
- break;
- }
- }
-
- len += kMatchMinLen;
- if (rep0 > nowPos)
- return LZMA_RESULT_DATA_ERROR;
-
-
- do
- {
- previousByte = outStream[nowPos - rep0];
- len--;
- outStream[nowPos++] = previousByte;
- }
- while (len != 0 && nowPos < outSize);
- }
- }
- RC_NORMALIZE;
-
-
- *inSizeProcessed = (SizeT)(Buffer - inStream);
- *outSizeProcessed = nowPos;
- return LZMA_RESULT_OK;
+ CProb *p = vs->Probs;
+ SizeT nowPos = 0;
+ Byte previousByte = 0;
+ UInt32 posStateMask = (1 << (vs->Properties.pb)) - 1;
+ UInt32 literalPosMask = (1 << (vs->Properties.lp)) - 1;
+ int lc = vs->Properties.lc;
+
+
+ int state = 0;
+ UInt32 rep0 = 1, rep1 = 1, rep2 = 1, rep3 = 1;
+ int len = 0;
+ const Byte *Buffer;
+ const Byte *BufferLim;
+ int look_ahead_ptr = 4;
+ union {
+ Byte raw[4];
+ UInt32 dw;
+ } look_ahead;
+ UInt32 Range;
+ UInt32 Code;
+
+ *inSizeProcessed = 0;
+ *outSizeProcessed = 0;
+
+ {
+ UInt32 i;
+ UInt32 numProbs = Literal + ((UInt32)LZMA_LIT_SIZE << (lc
+ + vs->Properties.lp));
+ for (i = 0; i < numProbs; i++)
+ p[i] = kBitModelTotal >> 1;
+ }
+
+ RC_INIT(inStream, inSize);
+
+
+ while (nowPos < outSize) {
+ CProb *prob;
+ UInt32 bound;
+ int posState = (int)((nowPos)& posStateMask);
+
+ prob = p + IsMatch + (state << kNumPosBitsMax) + posState;
+ IfBit0(prob) {
+ int symbol = 1;
+ UpdateBit0(prob)
+ prob = p + Literal + (LZMA_LIT_SIZE *
+ ((((nowPos) & literalPosMask) << lc)
+ + (previousByte >> (8 - lc))));
+
+ if (state >= kNumLitStates) {
+ int matchByte;
+ matchByte = outStream[nowPos - rep0];
+ 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)
+ } while (symbol < 0x100);
+ }
+ while (symbol < 0x100) {
+ CProb *probLit = prob + symbol;
+ RC_GET_BIT(probLit, symbol)
+ }
+ previousByte = (Byte)symbol;
+
+ outStream[nowPos++] = previousByte;
+ if (state < 4)
+ state = 0;
+ else if (state < 10)
+ state -= 3;
+ else
+ state -= 6;
+ } else {
+ UpdateBit1(prob);
+ prob = p + IsRep + state;
+ IfBit0(prob) {
+ UpdateBit0(prob);
+ rep3 = rep2;
+ rep2 = rep1;
+ rep1 = rep0;
+ state = state < kNumLitStates ? 0 : 3;
+ prob = p + LenCoder;
+ } else {
+ UpdateBit1(prob);
+ prob = p + IsRepG0 + state;
+ IfBit0(prob) {
+ UpdateBit0(prob);
+ prob = p + IsRep0Long + (state << kNumPosBitsMax) + posState;
+ IfBit0(prob) {
+ UpdateBit0(prob);
+
+ if (nowPos == 0)
+ return LZMA_RESULT_DATA_ERROR;
+
+ state = state < kNumLitStates ? 9 : 11;
+ previousByte = outStream[nowPos - rep0];
+ outStream[nowPos++] = previousByte;
+
+ continue;
+ } else
+ UpdateBit1(prob);
+ } else {
+ UInt32 distance;
+ UpdateBit1(prob);
+ prob = p + IsRepG1 + state;
+ IfBit0(prob) {
+ UpdateBit0(prob);
+ distance = rep1;
+ } else {
+ UpdateBit1(prob);
+ prob = p + IsRepG2 + state;
+ IfBit0(prob) {
+ UpdateBit0(prob);
+ distance = rep2;
+ } else {
+ UpdateBit1(prob);
+ distance = rep3;
+ rep3 = rep2;
+ }
+ rep2 = rep1;
+ }
+ rep1 = rep0;
+ rep0 = distance;
+ }
+ state = state < kNumLitStates ? 8 : 11;
+ prob = p + RepLenCoder;
+ }
+ {
+ int numBits, offset;
+ CProb *probLen = prob + LenChoice;
+ IfBit0(probLen) {
+ UpdateBit0(probLen);
+ probLen = prob + LenLow + (posState << kLenNumLowBits);
+ offset = 0;
+ numBits = kLenNumLowBits;
+ } else {
+ UpdateBit1(probLen);
+ probLen = prob + LenChoice2;
+ IfBit0(probLen) {
+ UpdateBit0(probLen);
+ probLen = prob + LenMid + (posState << kLenNumMidBits);
+ offset = kLenNumLowSymbols;
+ numBits = kLenNumMidBits;
+ } else {
+ UpdateBit1(probLen);
+ probLen = prob + LenHigh;
+ offset = kLenNumLowSymbols + kLenNumMidSymbols;
+ numBits = kLenNumHighBits;
+ }
+ }
+ RangeDecoderBitTreeDecode(probLen, numBits, len);
+ len += offset;
+ }
+
+ if (state < 4) {
+ int posSlot;
+ state += kNumLitStates;
+ prob = p + PosSlot +
+ ((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) <<
+ kNumPosSlotBits);
+ RangeDecoderBitTreeDecode(prob, kNumPosSlotBits, posSlot);
+ if (posSlot >= kStartPosModelIndex) {
+ int numDirectBits = ((posSlot >> 1) - 1);
+ rep0 = (2 | ((UInt32)posSlot & 1));
+ if (posSlot < kEndPosModelIndex) {
+ rep0 <<= numDirectBits;
+ prob = p + SpecPos + rep0 - posSlot - 1;
+ } else {
+ numDirectBits -= kNumAlignBits;
+ do {
+ RC_NORMALIZE
+ Range >>= 1;
+ rep0 <<= 1;
+ if (Code >= Range) {
+ Code -= Range;
+ rep0 |= 1;
+ }
+ } while (--numDirectBits != 0);
+ prob = p + Align;
+ rep0 <<= kNumAlignBits;
+ numDirectBits = kNumAlignBits;
+ }
+ {
+ int i = 1;
+ int mi = 1;
+ do {
+ CProb *prob3 = prob + mi;
+ RC_GET_BIT2(prob3, mi, ; , rep0 |= i);
+ i <<= 1;
+ } while (--numDirectBits != 0);
+ }
+ } else
+ rep0 = posSlot;
+ if (++rep0 == (UInt32)(0)) {
+ /* it's for stream version */
+ len = kLzmaStreamWasFinishedId;
+ break;
+ }
+ }
+
+ len += kMatchMinLen;
+ if (rep0 > nowPos)
+ return LZMA_RESULT_DATA_ERROR;
+
+
+ do {
+ previousByte = outStream[nowPos - rep0];
+ len--;
+ outStream[nowPos++] = previousByte;
+ } while (len != 0 && nowPos < outSize);
+ }
+ }
+ RC_NORMALIZE;
+
+
+ *inSizeProcessed = (SizeT)(Buffer - inStream);
+ *outSizeProcessed = nowPos;
+ return LZMA_RESULT_OK;
}
diff --git a/src/lib/lzmadecode.h b/src/lib/lzmadecode.h
index 34c9f14c33..892ad403db 100644
--- a/src/lib/lzmadecode.h
+++ b/src/lib/lzmadecode.h
@@ -38,11 +38,10 @@ typedef UInt32 SizeT;
#define LZMA_PROPERTIES_SIZE 5
-typedef struct _CLzmaProperties
-{
- int lc;
- int lp;
- int pb;
+typedef struct _CLzmaProperties {
+ int lc;
+ int lp;
+ int pb;
}CLzmaProperties;
int LzmaDecodeProperties(CLzmaProperties *propsRes, const unsigned char *propsData, int size);
@@ -51,17 +50,14 @@ int LzmaDecodeProperties(CLzmaProperties *propsRes, const unsigned char *propsDa
#define kLzmaNeedInitId (-2)
-typedef struct _CLzmaDecoderState
-{
- CLzmaProperties Properties;
- CProb *Probs;
-
-
+typedef struct _CLzmaDecoderState {
+ CLzmaProperties Properties;
+ CProb *Probs;
} CLzmaDecoderState;
int LzmaDecode(CLzmaDecoderState *vs,
- const unsigned char *inStream, SizeT inSize, SizeT *inSizeProcessed,
- unsigned char *outStream, SizeT outSize, SizeT *outSizeProcessed);
+ const unsigned char *inStream, SizeT inSize, SizeT *inSizeProcessed,
+ unsigned char *outStream, SizeT outSize, SizeT *outSizeProcessed);
#endif
diff --git a/src/lib/memrange.c b/src/lib/memrange.c
index 489b56212a..d3cda121f1 100644
--- a/src/lib/memrange.c
+++ b/src/lib/memrange.c
@@ -17,22 +17,22 @@
#include <memrange.h>
static inline void range_entry_link(struct range_entry **prev_ptr,
- struct range_entry *r)
+ struct range_entry *r)
{
r->next = *prev_ptr;
*prev_ptr = r;
}
static inline void range_entry_unlink(struct range_entry **prev_ptr,
- struct range_entry *r)
+ struct range_entry *r)
{
*prev_ptr = r->next;
r->next = NULL;
}
static inline void range_entry_unlink_and_free(struct memranges *ranges,
- struct range_entry **prev_ptr,
- struct range_entry *r)
+ struct range_entry **prev_ptr,
+ struct range_entry *r)
{
range_entry_unlink(prev_ptr, r);
range_entry_link(&ranges->free_list, r);
@@ -54,7 +54,7 @@ static struct range_entry *alloc_range(struct memranges *ranges)
static inline struct range_entry *
range_list_add(struct memranges *ranges, struct range_entry **prev_ptr,
- resource_t begin, resource_t end, unsigned long tag)
+ resource_t begin, resource_t end, unsigned long tag)
{
struct range_entry *new_entry;
@@ -102,8 +102,8 @@ static void merge_neighbor_entries(struct memranges *ranges)
}
static void remove_memranges(struct memranges *ranges,
- resource_t begin, resource_t end,
- unsigned long unused)
+ resource_t begin, resource_t end,
+ unsigned long unused)
{
struct range_entry *cur;
struct range_entry *next;
@@ -136,7 +136,7 @@ static void remove_memranges(struct memranges *ranges,
if (end >= cur->end) {
begin = cur->end + 1;
range_entry_unlink_and_free(ranges, prev_ptr,
- cur);
+ cur);
continue;
}
}
@@ -152,7 +152,7 @@ static void remove_memranges(struct memranges *ranges,
/* Hole punched in middle of entry. */
if (begin > cur->begin && tmp_end < cur->end) {
range_list_add(ranges, &cur->next, end + 1, cur->end,
- cur->tag);
+ cur->tag);
cur->end = begin - 1;
break;
}
@@ -168,8 +168,8 @@ static void remove_memranges(struct memranges *ranges,
}
static void merge_add_memranges(struct memranges *ranges,
- resource_t begin, resource_t end,
- unsigned long tag)
+ resource_t begin, resource_t end,
+ unsigned long tag)
{
struct range_entry *cur;
struct range_entry **prev_ptr;
@@ -202,7 +202,7 @@ static void merge_add_memranges(struct memranges *ranges,
}
void memranges_update_tag(struct memranges *ranges, unsigned long old_tag,
- unsigned long new_tag)
+ unsigned long new_tag)
{
struct range_entry *r;
@@ -215,12 +215,12 @@ void memranges_update_tag(struct memranges *ranges, unsigned long old_tag,
}
typedef void (*range_action_t)(struct memranges *ranges,
- resource_t begin, resource_t end,
- unsigned long tag);
+ resource_t begin, resource_t end,
+ unsigned long tag);
static void do_action(struct memranges *ranges,
- resource_t base, resource_t size, unsigned long tag,
- range_action_t action)
+ resource_t base, resource_t size, unsigned long tag,
+ range_action_t action)
{
resource_t end;
resource_t begin;
@@ -238,13 +238,13 @@ static void do_action(struct memranges *ranges,
}
void memranges_create_hole(struct memranges *ranges,
- resource_t base, resource_t size)
+ resource_t base, resource_t size)
{
do_action(ranges, base, size, -1, remove_memranges);
}
void memranges_insert(struct memranges *ranges,
- resource_t base, resource_t size, unsigned long tag)
+ resource_t base, resource_t size, unsigned long tag)
{
do_action(ranges, base, size, tag, merge_add_memranges);
}
@@ -267,9 +267,9 @@ static void collect_ranges(void *gp, struct device *dev, struct resource *res)
}
void memranges_add_resources_filter(struct memranges *ranges,
- unsigned long mask, unsigned long match,
- unsigned long tag,
- memrange_filter_t filter)
+ unsigned long mask, unsigned long match,
+ unsigned long tag,
+ memrange_filter_t filter)
{
struct collect_context context;
@@ -284,14 +284,14 @@ void memranges_add_resources_filter(struct memranges *ranges,
}
void memranges_add_resources(struct memranges *ranges,
- unsigned long mask, unsigned long match,
- unsigned long tag)
+ unsigned long mask, unsigned long match,
+ unsigned long tag)
{
memranges_add_resources_filter(ranges, mask, match, tag, NULL);
}
void memranges_init_empty(struct memranges *ranges, struct range_entry *to_free,
- size_t num_free)
+ size_t num_free)
{
size_t i;
@@ -303,8 +303,8 @@ void memranges_init_empty(struct memranges *ranges, struct range_entry *to_free,
}
void memranges_init(struct memranges *ranges,
- unsigned long mask, unsigned long match,
- unsigned long tag)
+ unsigned long mask, unsigned long match,
+ unsigned long tag)
{
memranges_init_empty(ranges, NULL, 0);
memranges_add_resources(ranges, mask, match, tag);
@@ -314,12 +314,12 @@ void memranges_teardown(struct memranges *ranges)
{
while (ranges->entries != NULL) {
range_entry_unlink_and_free(ranges, &ranges->entries,
- ranges->entries);
+ ranges->entries);
}
}
void memranges_fill_holes_up_to(struct memranges *ranges,
- resource_t limit, unsigned long tag)
+ resource_t limit, unsigned long tag)
{
struct range_entry *cur;
struct range_entry *prev;
@@ -341,7 +341,7 @@ void memranges_fill_holes_up_to(struct memranges *ranges,
if (end >= limit)
end = limit - 1;
range_list_add(ranges, &prev->next,
- range_entry_end(prev), end, tag);
+ range_entry_end(prev), end, tag);
}
prev = cur;
@@ -356,14 +356,14 @@ void memranges_fill_holes_up_to(struct memranges *ranges,
* to be added to cover the range up to the limit. */
if (prev != NULL && range_entry_end(prev) < limit)
range_list_add(ranges, &prev->next, range_entry_end(prev),
- limit - 1, tag);
+ limit - 1, tag);
/* Merge all entries that were newly added. */
merge_neighbor_entries(ranges);
}
struct range_entry *memranges_next_entry(struct memranges *ranges,
- const struct range_entry *r)
+ const struct range_entry *r)
{
return r->next;
}
diff --git a/src/lib/mocked_tlcl.c b/src/lib/mocked_tlcl.c
index d6bcc9f950..6a8043d63f 100644
--- a/src/lib/mocked_tlcl.c
+++ b/src/lib/mocked_tlcl.c
@@ -112,7 +112,7 @@ uint32_t tlcl_get_permanent_flags(TPM_PERMANENT_FLAGS *pflags)
}
uint32_t tlcl_get_flags(uint8_t *disable, uint8_t *deactivated,
- uint8_t *nvlocked)
+ uint8_t *nvlocked)
{
VBDEBUG("MOCK_TPM: %s\n", __func__);
return TPM_E_NO_DEVICE;
@@ -125,7 +125,7 @@ uint32_t tlcl_set_global_lock(void)
}
uint32_t tlcl_extend(int pcr_num, const uint8_t *in_digest,
- uint8_t *out_digest)
+ uint8_t *out_digest)
{
VBDEBUG("MOCK_TPM: %s\n", __func__);
return TPM_E_NO_DEVICE;
diff --git a/src/lib/reg_script.c b/src/lib/reg_script.c
index b63a05b248..a7bd7ccd5f 100644
--- a/src/lib/reg_script.c
+++ b/src/lib/reg_script.c
@@ -41,14 +41,14 @@
#endif
static inline void reg_script_set_dev(struct reg_script_context *ctx,
- device_t dev)
+ device_t dev)
{
ctx->dev = dev;
ctx->res = NULL;
}
static inline void reg_script_set_step(struct reg_script_context *ctx,
- const struct reg_script *step)
+ const struct reg_script *step)
{
ctx->step = step;
}
@@ -603,7 +603,7 @@ static void reg_script_rxw(struct reg_script_context *ctx)
* as the previous one. That will run to completion and then move on to the
* next step of the previous context. */
static void reg_script_run_next(struct reg_script_context *ctx,
- const struct reg_script *step);
+ const struct reg_script *step);
static void reg_script_run_step(struct reg_script_context *ctx,
@@ -670,7 +670,7 @@ static void reg_script_run_with_context(struct reg_script_context *ctx)
}
static void reg_script_run_next(struct reg_script_context *prev_ctx,
- const struct reg_script *step)
+ const struct reg_script *step)
{
struct reg_script_context ctx;
diff --git a/src/lib/rmodule.c b/src/lib/rmodule.c
index 70431579e0..a3a74ac613 100644
--- a/src/lib/rmodule.c
+++ b/src/lib/rmodule.c
@@ -33,7 +33,7 @@ static inline int rmodule_is_loaded(const struct rmodule *module)
/* Calculate a loaded program address based on the blob address. */
static inline void *rmodule_load_addr(const struct rmodule *module,
- uintptr_t blob_addr)
+ uintptr_t blob_addr)
{
char *loc = module->location;
return &loc[blob_addr - module->header->module_link_start_address];
@@ -66,7 +66,7 @@ int rmodule_parse(void *ptr, struct rmodule *module)
/* The payload lives after the header. */
module->payload = &base[rhdr->payload_begin_offset];
module->payload_size = rhdr->payload_end_offset -
- rhdr->payload_begin_offset;
+ rhdr->payload_begin_offset;
module->relocations = &base[rhdr->relocations_begin_offset];
return 0;
@@ -204,7 +204,7 @@ int rmodule_load(void *base, struct rmodule *module)
}
int rmodule_calc_region(unsigned int region_alignment, size_t rmodule_size,
- size_t *region_size, int *load_offset)
+ size_t *region_size, int *load_offset)
{
/* region_alignment must be a power of 2. */
if (region_alignment & (region_alignment - 1))
@@ -270,7 +270,7 @@ int rmodule_stage_load(struct rmod_stage_load *rsl)
rmodule_offset =
rmodule_calc_region(DYN_CBMEM_ALIGN_SIZE,
- stage.memlen, &region_size, &load_offset);
+ stage.memlen, &region_size, &load_offset);
stage_region = cbmem_add(rsl->cbmem_id, region_size);
diff --git a/src/lib/selfboot.c b/src/lib/selfboot.c
index 86f77f72df..ada2cadbf5 100644
--- a/src/lib/selfboot.c
+++ b/src/lib/selfboot.c
@@ -416,32 +416,32 @@ static int load_self_segments(struct segment *head, struct prog *payload,
/* Copy data from the initial buffer */
switch (ptr->compression) {
- case CBFS_COMPRESS_LZMA: {
- printk(BIOS_DEBUG, "using LZMA\n");
- timestamp_add_now(TS_START_ULZMA);
- len = ulzman(src, len, dest, memsz);
- timestamp_add_now(TS_END_ULZMA);
- if (!len) /* Decompression Error. */
- return 0;
- break;
- }
- case CBFS_COMPRESS_LZ4: {
- printk(BIOS_DEBUG, "using LZ4\n");
- timestamp_add_now(TS_START_ULZ4F);
- len = ulz4fn(src, len, dest, memsz);
- timestamp_add_now(TS_END_ULZ4F);
- if (!len) /* Decompression Error. */
- return 0;
- break;
- }
- case CBFS_COMPRESS_NONE: {
- printk(BIOS_DEBUG, "it's not compressed!\n");
- memcpy(dest, src, len);
- break;
- }
- default:
- printk(BIOS_INFO, "CBFS: Unknown compression type %d\n", ptr->compression);
- return -1;
+ case CBFS_COMPRESS_LZMA: {
+ printk(BIOS_DEBUG, "using LZMA\n");
+ timestamp_add_now(TS_START_ULZMA);
+ len = ulzman(src, len, dest, memsz);
+ timestamp_add_now(TS_END_ULZMA);
+ if (!len) /* Decompression Error. */
+ return 0;
+ break;
+ }
+ case CBFS_COMPRESS_LZ4: {
+ printk(BIOS_DEBUG, "using LZ4\n");
+ timestamp_add_now(TS_START_ULZ4F);
+ len = ulz4fn(src, len, dest, memsz);
+ timestamp_add_now(TS_END_ULZ4F);
+ if (!len) /* Decompression Error. */
+ return 0;
+ break;
+ }
+ case CBFS_COMPRESS_NONE: {
+ printk(BIOS_DEBUG, "it's not compressed!\n");
+ memcpy(dest, src, len);
+ break;
+ }
+ default:
+ printk(BIOS_INFO, "CBFS: Unknown compression type %d\n", ptr->compression);
+ return -1;
}
/* Calculate middle after any changes to len. */
middle = dest + len;
diff --git a/src/lib/spd_bin.c b/src/lib/spd_bin.c
index ff00e6191e..556dfec682 100644
--- a/src/lib/spd_bin.c
+++ b/src/lib/spd_bin.c
@@ -190,8 +190,8 @@ int read_ddr3_spd_from_cbfs(u8 *buf, int idx)
u16 crc = spd_ddr3_calc_crc(buf, CONFIG_DIMM_SPD_SIZE);
if (((buf[SPD_CRC_LO] == 0) && (buf[SPD_CRC_HI] == 0))
- || (buf[SPD_CRC_LO] != (crc & 0xff))
- || (buf[SPD_CRC_HI] != (crc >> 8))) {
+ || (buf[SPD_CRC_LO] != (crc & 0xff))
+ || (buf[SPD_CRC_HI] != (crc >> 8))) {
printk(BIOS_WARNING, "SPD CRC %02x%02x is invalid, should be %04x\n",
buf[SPD_CRC_HI], buf[SPD_CRC_LO], crc);
buf[SPD_CRC_LO] = crc & 0xff;
@@ -204,7 +204,7 @@ int read_ddr3_spd_from_cbfs(u8 *buf, int idx)
printk(BIOS_WARNING, "%02x ", buf[i]);
}
printk(BIOS_WARNING, "\n");
- }
- return 0;
+ }
+ return 0;
}
#endif
diff --git a/src/lib/thread.c b/src/lib/thread.c
index 53ffb92c59..703034b8a8 100644
--- a/src/lib/thread.c
+++ b/src/lib/thread.c
@@ -186,8 +186,8 @@ static void asmlinkage call_wrapper_block_state(void *arg)
/* Prepare a thread so that it starts by executing thread_entry(thread_arg).
* Within thread_entry() it will call func(arg). */
static void prepare_thread(struct thread *t, void *func, void *arg,
- asmlinkage void(*thread_entry)(void *),
- void *thread_arg)
+ asmlinkage void(*thread_entry)(void *),
+ void *thread_arg)
{
/* Stash the function and argument to run. */
t->entry = func;
@@ -305,7 +305,7 @@ int thread_run(void (*func)(void *), void *arg)
}
int thread_run_until(void (*func)(void *), void *arg,
- boot_state_t state, boot_state_sequence_t seq)
+ boot_state_t state, boot_state_sequence_t seq)
{
struct thread *current;
struct thread *t;
diff --git a/src/lib/timer_queue.c b/src/lib/timer_queue.c
index fe3e8b59a5..7cc814bee1 100644
--- a/src/lib/timer_queue.c
+++ b/src/lib/timer_queue.c
@@ -49,7 +49,7 @@ static inline struct timeout_callback *timer_queue_head(struct timer_queue *tq)
}
static int timer_queue_insert(struct timer_queue *tq,
- struct timeout_callback *tocb)
+ struct timeout_callback *tocb)
{
int index;
@@ -99,7 +99,7 @@ static int timer_queue_min_child_index(struct timer_queue *tq, int index)
return left_child_index;
if (mono_time_cmp(&tq->queue[left_child_index]->expiration,
- &tq->queue[right_child_index]->expiration) < 0) {
+ &tq->queue[right_child_index]->expiration) < 0) {
return left_child_index;
}
return right_child_index;
diff --git a/src/lib/tlcl.c b/src/lib/tlcl.c
index a15126e934..fc989dea32 100644
--- a/src/lib/tlcl.c
+++ b/src/lib/tlcl.c
@@ -75,7 +75,7 @@ static inline int tpm_return_code(const uint8_t *buffer) {
* DOING_SELFTEST errors are returned.
*/
static uint32_t tlcl_send_receive_no_retry(const uint8_t *request,
- uint8_t *response, int max_length) {
+ uint8_t *response, int max_length) {
uint32_t response_length = max_length;
uint32_t result;
@@ -116,7 +116,7 @@ uint32_t tlcl_send_receive(const uint8_t *request, uint8_t *response,
#if defined(TPM_BLOCKING_CONTINUESELFTEST) || defined(VB_RECOVERY_MODE)
/* Retry only once */
result = tlcl_send_receive_no_retry(request, response,
- max_length);
+ max_length);
#else
/* This needs serious testing. The TPM specification says: "iii.
* The caller MUST wait for the actions of TPM_ContinueSelfTest
@@ -125,7 +125,7 @@ uint32_t tlcl_send_receive(const uint8_t *request, uint8_t *response,
* actions have completed other than trying again? */
do {
result = tlcl_send_receive_no_retry(request, response,
- max_length);
+ max_length);
} while (result == TPM_E_DOING_SELFTEST);
#endif
}
@@ -163,8 +163,8 @@ uint32_t tlcl_startup(void) {
}
uint32_t tlcl_resume(void) {
- VBDEBUG("TPM: Resume\n");
- return send(tpm_resume_cmd.buffer);
+ VBDEBUG("TPM: Resume\n");
+ return send(tpm_resume_cmd.buffer);
}
uint32_t tlcl_self_test_full(void)
@@ -179,7 +179,7 @@ uint32_t tlcl_continue_self_test(void)
VBDEBUG("TPM: Continue self test\n");
/* Call the No Retry version of SendReceive to avoid recursion. */
return tlcl_send_receive_no_retry(tpm_continueselftest_cmd.buffer,
- response, sizeof(response));
+ response, sizeof(response));
}
uint32_t tlcl_define_space(uint32_t index, uint32_t perm, uint32_t size)
@@ -280,7 +280,7 @@ uint32_t tlcl_get_permanent_flags(TPM_PERMANENT_FLAGS *pflags)
uint8_t response[TPM_LARGE_ENOUGH_COMMAND_SIZE];
uint32_t size;
uint32_t result = tlcl_send_receive(tpm_getflags_cmd.buffer, response,
- sizeof(response));
+ sizeof(response));
if (result != TPM_SUCCESS)
return result;
from_tpm_uint32(response + kTpmResponseHeaderLength, &size);
@@ -291,7 +291,7 @@ uint32_t tlcl_get_permanent_flags(TPM_PERMANENT_FLAGS *pflags)
}
uint32_t tlcl_get_flags(uint8_t *disable, uint8_t *deactivated,
- uint8_t *nvlocked)
+ uint8_t *nvlocked)
{
TPM_PERMANENT_FLAGS pflags;
uint32_t result = tlcl_get_permanent_flags(&pflags);
@@ -316,7 +316,7 @@ uint32_t tlcl_set_global_lock(void)
}
uint32_t tlcl_extend(int pcr_num, const uint8_t *in_digest,
- uint8_t *out_digest)
+ uint8_t *out_digest)
{
struct s_tpm_extend_cmd cmd;
uint8_t response[kTpmResponseHeaderLength + kPcrDigestLength];
diff --git a/src/lib/tlcl_structures.h b/src/lib/tlcl_structures.h
index 36c1bb9ed8..b73fe8386a 100644
--- a/src/lib/tlcl_structures.h
+++ b/src/lib/tlcl_structures.h
@@ -1,136 +1,136 @@
/* This file is automatically generated */
const struct s_tpm_extend_cmd{
- uint8_t buffer[34];
- uint16_t pcrNum;
- uint16_t inDigest;
+ uint8_t buffer[34];
+ uint16_t pcrNum;
+ uint16_t inDigest;
} tpm_extend_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0x22, 0x0, 0x0, 0x0, 0x14, },
10, 14, };
const struct s_tpm_get_random_cmd{
- uint8_t buffer[14];
- uint16_t bytesRequested;
+ uint8_t buffer[14];
+ uint16_t bytesRequested;
} tpm_get_random_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xe, 0x0, 0x0, 0x0, 0x46, },
10, };
const struct s_tpm_getownership_cmd{
- uint8_t buffer[22];
+ uint8_t buffer[22];
} tpm_getownership_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0x16, 0x0, 0x0, 0x0, 0x65, 0x0, 0x0, 0x0, 0x5, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x1, 0x11, },
};
const struct s_tpm_getpermissions_cmd{
- uint8_t buffer[22];
- uint16_t index;
+ uint8_t buffer[22];
+ uint16_t index;
} tpm_getpermissions_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0x16, 0x0, 0x0, 0x0, 0x65, 0x0, 0x0, 0x0, 0x11, 0x0, 0x0, 0x0, 0x4, },
18, };
const struct s_tpm_getstclearflags_cmd{
- uint8_t buffer[22];
+ uint8_t buffer[22];
} tpm_getstclearflags_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0x16, 0x0, 0x0, 0x0, 0x65, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x1, 0x9, },
};
const struct s_tpm_getflags_cmd{
- uint8_t buffer[22];
+ uint8_t buffer[22];
} tpm_getflags_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0x16, 0x0, 0x0, 0x0, 0x65, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x0, 0x4, 0x0, 0x0, 0x1, 0x8, },
};
const struct s_tpm_physicalsetdeactivated_cmd{
- uint8_t buffer[11];
- uint16_t deactivated;
+ uint8_t buffer[11];
+ uint16_t deactivated;
} tpm_physicalsetdeactivated_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xb, 0x0, 0x0, 0x0, 0x72, },
10, };
const struct s_tpm_physicalenable_cmd{
- uint8_t buffer[10];
+ uint8_t buffer[10];
} tpm_physicalenable_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0, 0x0, 0x6f, },
};
const struct s_tpm_physicaldisable_cmd{
- uint8_t buffer[10];
+ uint8_t buffer[10];
} tpm_physicaldisable_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0, 0x0, 0x70, },
};
const struct s_tpm_forceclear_cmd{
- uint8_t buffer[10];
+ uint8_t buffer[10];
} tpm_forceclear_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0, 0x0, 0x5d, },
};
const struct s_tpm_readpubek_cmd{
- uint8_t buffer[30];
+ uint8_t buffer[30];
} tpm_readpubek_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0x1e, 0x0, 0x0, 0x0, 0x7c, },
};
const struct s_tpm_continueselftest_cmd{
- uint8_t buffer[10];
+ uint8_t buffer[10];
} tpm_continueselftest_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0, 0x0, 0x53, },
};
const struct s_tpm_selftestfull_cmd{
- uint8_t buffer[10];
+ uint8_t buffer[10];
} tpm_selftestfull_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0, 0x0, 0x50, },
};
const struct s_tpm_resume_cmd{
- uint8_t buffer[12];
+ uint8_t buffer[12];
} tpm_resume_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xc, 0x0, 0x0, 0x0, 0x99, 0x0, 0x2, },
};
const struct s_tpm_savestate_cmd{
- uint8_t buffer[10];
+ uint8_t buffer[10];
} tpm_savestate_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0, 0x0, 0x98, },
};
const struct s_tpm_startup_cmd{
- uint8_t buffer[12];
+ uint8_t buffer[12];
} tpm_startup_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xc, 0x0, 0x0, 0x0, 0x99, 0x0, 0x1, },
};
const struct s_tpm_finalizepp_cmd{
- uint8_t buffer[12];
+ uint8_t buffer[12];
} tpm_finalizepp_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xc, 0x40, 0x0, 0x0, 0xa, 0x2, 0xa0, },
};
const struct s_tpm_pplock_cmd{
- uint8_t buffer[12];
+ uint8_t buffer[12];
} tpm_pplock_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xc, 0x40, 0x0, 0x0, 0xa, 0x0, 0x4, },
};
const struct s_tpm_ppenable_cmd{
- uint8_t buffer[12];
+ uint8_t buffer[12];
} tpm_ppenable_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xc, 0x40, 0x0, 0x0, 0xa, 0x0, 0x20, },
};
const struct s_tpm_ppassert_cmd{
- uint8_t buffer[12];
+ uint8_t buffer[12];
} tpm_ppassert_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xc, 0x40, 0x0, 0x0, 0xa, 0x0, 0x8, },
};
const struct s_tpm_pcr_read_cmd{
- uint8_t buffer[14];
- uint16_t pcrNum;
+ uint8_t buffer[14];
+ uint16_t pcrNum;
} tpm_pcr_read_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0xe, 0x0, 0x0, 0x0, 0x15, },
10, };
const struct s_tpm_nv_read_cmd{
- uint8_t buffer[22];
- uint16_t index;
- uint16_t length;
+ uint8_t buffer[22];
+ uint16_t index;
+ uint16_t length;
} tpm_nv_read_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0x16, 0x0, 0x0, 0x0, 0xcf, },
10, 18, };
const struct s_tpm_nv_write_cmd{
- uint8_t buffer[256];
- uint16_t index;
- uint16_t length;
- uint16_t data;
+ uint8_t buffer[256];
+ uint16_t index;
+ uint16_t length;
+ uint16_t data;
} tpm_nv_write_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xcd, },
10, 18, 22, };
const struct s_tpm_nv_definespace_cmd{
- uint8_t buffer[101];
- uint16_t index;
- uint16_t perm;
- uint16_t size;
+ uint8_t buffer[101];
+ uint16_t index;
+ uint16_t perm;
+ uint16_t size;
} tpm_nv_definespace_cmd = {{0x0, 0xc1, 0x0, 0x0, 0x0, 0x65, 0x0, 0x0, 0x0, 0xcc, 0x0, 0x18, 0, 0, 0, 0, 0x0, 0x3, 0, 0, 0, 0x1f, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x0, 0x3, 0, 0, 0, 0x1f, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x0, 0x17, },
12, 70, 77, };