summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorEvan Green <evgreen@chromium.org>2019-09-23 11:02:41 -0700
committerCommit Bot <commit-bot@chromium.org>2019-10-05 00:47:44 +0000
commite34fca3e01d75552ad8d712879c3ccd6a6168584 (patch)
treee2a71c2fa4dd52ffe459d10156276fbb0b5aa597 /test
parenta1216326c5d58af300b7c6f24c8597a232ced131 (diff)
downloadchrome-ec-e34fca3e01d75552ad8d712879c3ccd6a6168584.tar.gz
builtin: Introduce and use inttypes.h
In order to pass the right printf format specifiers for certain types that are compiled both in 32-bit EC and 64-bit host environments, standard macros PRIx64 and PRId64 must be introduced. These specify the correct printf format specifier in the given compilation environment for printing a 64-bit value. On the host, inttypes.h already exists. Add an inttypes.h for the EC codebase so that these macros can be used where they're needed. BUG=chromium:984041 TEST=make -j buildall BRANCH=none Change-Id: I76e3bdc88aef7da6e5234d5b86b595f7138ea9a1 Signed-off-by: Evan Green <evgreen@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1819642 Reviewed-by: caveh jalali <caveh@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
Diffstat (limited to 'test')
-rw-r--r--test/entropy.c2
-rw-r--r--test/utils.c12
2 files changed, 7 insertions, 7 deletions
diff --git a/test/entropy.c b/test/entropy.c
index 7498d4edf9..a19a8eb33f 100644
--- a/test/entropy.c
+++ b/test/entropy.c
@@ -51,7 +51,7 @@ void run_test(void)
}
t1 = get_time();
if (i == 0)
- ccprintf("Got %d bytes in %ld us\n",
+ ccprintf("Got %zd bytes in %" PRId64 " us\n",
sizeof(buffer), t1.val - t0.val);
for (j = 0; j < sizeof(buffer); j++)
diff --git a/test/utils.c b/test/utils.c
index cd05aa9f3e..201f607f0c 100644
--- a/test/utils.c
+++ b/test/utils.c
@@ -35,13 +35,13 @@ static int test_memmove(void)
memmove(buf + 101, buf, len); /* unaligned */
t1 = get_time();
TEST_ASSERT_ARRAY_EQ(buf + 101, buf, len);
- ccprintf(" (speed gain: %d ->", t1.val-t0.val);
+ ccprintf(" (speed gain: %" PRId64 " ->", t1.val-t0.val);
t2 = get_time();
for (i = 0; i < iteration; ++i)
memmove(buf + 100, buf, len); /* aligned */
t3 = get_time();
- ccprintf(" %d us) ", t3.val-t2.val);
+ ccprintf(" %" PRId64 " us) ", t3.val-t2.val);
TEST_ASSERT_ARRAY_EQ(buf + 100, buf, len);
/* Expected about 4x speed gain. Use 3x because it fluctuates */
@@ -86,13 +86,13 @@ static int test_memcpy(void)
memcpy(buf + dest_offset + 1, buf, len); /* unaligned */
t1 = get_time();
TEST_ASSERT_ARRAY_EQ(buf + dest_offset + 1, buf, len);
- ccprintf(" (speed gain: %d ->", t1.val-t0.val);
+ ccprintf(" (speed gain: %" PRId64 " ->", t1.val-t0.val);
t2 = get_time();
for (i = 0; i < iteration; ++i)
memcpy(buf + dest_offset, buf, len); /* aligned */
t3 = get_time();
- ccprintf(" %d us) ", t3.val-t2.val);
+ ccprintf(" %" PRId64 " us) ", t3.val-t2.val);
TEST_ASSERT_ARRAY_EQ(buf + dest_offset, buf, len);
/* Expected about 4x speed gain. Use 3x because it fluctuates */
@@ -148,14 +148,14 @@ static int test_memset(void)
dumb_memset(buf, 1, len);
t1 = get_time();
TEST_ASSERT_MEMSET(buf, (char)1, len);
- ccprintf(" (speed gain: %d ->", t1.val-t0.val);
+ ccprintf(" (speed gain: %" PRId64 " ->", t1.val-t0.val);
t2 = get_time();
for (i = 0; i < iteration; ++i)
memset(buf, 1, len);
t3 = get_time();
TEST_ASSERT_MEMSET(buf, (char)1, len);
- ccprintf(" %d us) ", t3.val-t2.val);
+ ccprintf(" %" PRId64 " us) ", t3.val-t2.val);
/* Expected about 4x speed gain. Use 3x because it fluctuates */
#ifndef EMU_BUILD