summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Garber <jgarber1@ualberta.ca>2019-08-07 19:10:52 -0600
committerNico Huber <nico.h@gmx.de>2019-08-10 08:47:08 +0000
commit3a323808f62709c463d38dc30f06ace6b957d1d9 (patch)
treed30dea05738748acc2c5edeab1823dda843d4547
parentd073a0b9832dc94d447d6c38275a6f8f46381e4f (diff)
downloadcoreboot-3a323808f62709c463d38dc30f06ace6b957d1d9.tar.xz
include, lib: Add <inttypes.h> printf macros
In general, third party code (such as vboot) doesn't know what the underlying types are for the integers in <stdint.h>, so these macros are useful for portably printing them. Of these definitions, coreboot so far has only used PRIu64 (in one place), which isn't needed anymore since we know what the underlying type of a u64 is. Change-Id: I9e3a300f9b1c38e4831b030ff8af3fed2fa60f14 Signed-off-by: Jacob Garber <jgarber1@ualberta.ca> Reviewed-on: https://review.coreboot.org/c/coreboot/+/33823 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Nico Huber <nico.h@gmx.de>
-rw-r--r--src/include/inttypes.h63
-rw-r--r--src/include/stdint.h6
-rw-r--r--src/lib/timestamp.c3
3 files changed, 64 insertions, 8 deletions
diff --git a/src/include/inttypes.h b/src/include/inttypes.h
index 77c39c4199..4e2476dd03 100644
--- a/src/include/inttypes.h
+++ b/src/include/inttypes.h
@@ -1,4 +1,67 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
#ifndef INTTYPES_H
#define INTTYPES_H
+
#include <stdint.h>
+
+/* int8_t and uint8_t */
+#define PRId8 "d"
+#define PRIi8 "i"
+#define PRIu8 "u"
+#define PRIo8 "o"
+#define PRIx8 "x"
+#define PRIX8 "X"
+
+/* int16_t and uint16_t */
+#define PRId16 "d"
+#define PRIi16 "i"
+#define PRIu16 "u"
+#define PRIo16 "o"
+#define PRIx16 "x"
+#define PRIX16 "X"
+
+/* int32_t and uint32_t */
+#define PRId32 "d"
+#define PRIi32 "i"
+#define PRIu32 "u"
+#define PRIo32 "o"
+#define PRIx32 "x"
+#define PRIX32 "X"
+
+/* int64_t and uint64_t */
+#define PRId64 "lld"
+#define PRIi64 "lli"
+#define PRIu64 "llu"
+#define PRIo64 "llo"
+#define PRIx64 "llx"
+#define PRIX64 "llX"
+
+/* intptr_t and uintptr_t */
+#define PRIdPTR "ld"
+#define PRIiPTR "li"
+#define PRIuPTR "lu"
+#define PRIoPTR "lo"
+#define PRIxPTR "lx"
+#define PRIXPTR "lX"
+
+/* intmax_t and uintmax_t */
+#define PRIdMAX "jd"
+#define PRIiMAX "ji"
+#define PRIuMAX "ju"
+#define PRIoMAX "jo"
+#define PRIxMAX "jx"
+#define PRIXMAX "jX"
+
#endif /* INTTYPES_H */
diff --git a/src/include/stdint.h b/src/include/stdint.h
index f363aab08a..0a8e153d6a 100644
--- a/src/include/stdint.h
+++ b/src/include/stdint.h
@@ -110,10 +110,4 @@ typedef _Bool bool;
#define true 1
#define false 0
-/* TODO: move into inttypes.h */
-#ifndef __ROMCC__
-#define PRIu64 "llu"
-#define PRIxPTR "lx"
-#endif
-
#endif /* STDINT_H */
diff --git a/src/lib/timestamp.c b/src/lib/timestamp.c
index adacf6b1b3..1319b86670 100644
--- a/src/lib/timestamp.c
+++ b/src/lib/timestamp.c
@@ -180,8 +180,7 @@ static void timestamp_add_table_entry(struct timestamp_table *ts_table,
tse->entry_stamp = ts_time - ts_table->base_time;
if (CONFIG(TIMESTAMPS_ON_CONSOLE))
- printk(BIOS_SPEW, "Timestamp - %s: %" PRIu64 "\n",
- timestamp_name(id), ts_time);
+ printk(BIOS_SPEW, "Timestamp - %s: %llu\n", timestamp_name(id), ts_time);
if (ts_table->num_entries == ts_table->max_entries)
printk(BIOS_ERR, "ERROR: Timestamp table full\n");