libpayload: use PRIu64 type to print u64
The appropriate way to print a u64 variable regardless of the current architecture is to use the PRI*64 macros. libpayload is mostly used in 32 bits but when ported to other projects and compiled in 64 bits it breaks the compilation. Change-Id: I479fd701f992701584d77d43c5cd5910f5ab7633 Signed-off-by: Jeremy Compostella <jeremy.compostella@intel.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/45628 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
This commit is contained in:
committed by
Patrick Georgi
parent
05ea79cf53
commit
612ae2ec7c
@ -26,8 +26,11 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define __STDC_FORMAT_MACROS
|
||||||
|
|
||||||
#include <libpayload.h>
|
#include <libpayload.h>
|
||||||
#include <coreboot_tables.h>
|
#include <coreboot_tables.h>
|
||||||
|
#include <inttypes.h>
|
||||||
|
|
||||||
u8 *mem_accessor_base;
|
u8 *mem_accessor_base;
|
||||||
|
|
||||||
@ -325,7 +328,7 @@ int get_option_as_string(const struct nvram_accessor *nvram, struct cb_cmos_opti
|
|||||||
/* only works on little endian.
|
/* only works on little endian.
|
||||||
26 bytes is enough for a 64bit value in decimal */
|
26 bytes is enough for a 64bit value in decimal */
|
||||||
*dest = malloc(26);
|
*dest = malloc(26);
|
||||||
sprintf(*dest, "%llu", *(u64*)raw);
|
sprintf(*dest, "%" PRIu64, *(u64 *)raw);
|
||||||
break;
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
*dest = strdup(raw);
|
*dest = strdup(raw);
|
||||||
|
@ -31,11 +31,14 @@
|
|||||||
* General time functions
|
* General time functions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define __STDC_FORMAT_MACROS
|
||||||
|
|
||||||
#include <libpayload-config.h>
|
#include <libpayload-config.h>
|
||||||
#include <libpayload.h>
|
#include <libpayload.h>
|
||||||
#if CONFIG(LP_ARCH_X86) && CONFIG(LP_NVRAM)
|
#if CONFIG(LP_ARCH_X86) && CONFIG(LP_NVRAM)
|
||||||
#include <arch/rdtsc.h>
|
#include <arch/rdtsc.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include <inttypes.h>
|
||||||
|
|
||||||
extern u32 cpu_khz;
|
extern u32 cpu_khz;
|
||||||
|
|
||||||
@ -173,7 +176,7 @@ u64 timer_us(u64 base)
|
|||||||
if (hz == 0) {
|
if (hz == 0) {
|
||||||
hz = timer_hz();
|
hz = timer_hz();
|
||||||
if (hz < 1000000) {
|
if (hz < 1000000) {
|
||||||
printf("Timer frequency %lld is too low, "
|
printf("Timer frequency %" PRIu64 " is too low, "
|
||||||
"must be at least 1MHz.\n", hz);
|
"must be at least 1MHz.\n", hz);
|
||||||
halt();
|
halt();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user