From 9f552ff5aa043eddc5b6d59db09728d83faf97dd Mon Sep 17 00:00:00 2001 From: Randall Spangler Date: Fri, 20 Apr 2012 13:07:42 -0700 Subject: Implement 64-bit integer printing in uart_printf() Signed-off-by: Randall Spangler BUG=chrome-os-partner:7490 TEST=timerinfo; numbers should look reasonable Change-Id: I698be99c87bf311013427ac0ed9e93e5687f40c0 --- include/uart.h | 11 ++++------- include/util.h | 22 ++++++++++++++++------ 2 files changed, 20 insertions(+), 13 deletions(-) (limited to 'include') diff --git a/include/uart.h b/include/uart.h index 3ca34c67f1..67a2968d6c 100644 --- a/include/uart.h +++ b/include/uart.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2011 The Chromium OS Authors. All rights reserved. +/* Copyright (c) 2012 The Chromium OS Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ @@ -46,16 +46,13 @@ int uart_puts(const char *outstr); * string (%s) * native int (signed/unsigned) (%d / %u / %x) * int32_t / uint32_t (%d / %x) + * int64_t / uint64_t (%ld / %lu / %lx) * pointer (%p) * And the following special format codes: * current time in us (%T) - * including padding (%-5s, %8d, %08x) - * - * Support planned for: - * int64_t / uint64_t (%ld / %lu / %lx) + * including padding (%-5s, %8d, %08x, %016lx) * - * Note: Floating point output (%f / %g) is not supported. - */ + * Floating point output (%f / %g) is not supported. */ int uart_printf(const char *format, ...); /* Flushes output. Blocks until UART has transmitted all output. */ diff --git a/include/util.h b/include/util.h index d11b3a587f..5b9dd364db 100644 --- a/include/util.h +++ b/include/util.h @@ -1,15 +1,14 @@ -/* Copyright (c) 2011 The Chromium OS Authors. All rights reserved. +/* Copyright (c) 2012 The Chromium OS Authors. All rights reserved. * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* Various utility functions and macros */ -#ifndef __UTIL_H -#define __UTIL_H - -#include +#ifndef __CROS_EC_UTIL_H +#define __CROS_EC_UTIL_H +#include "common.h" #include "config.h" /** @@ -60,7 +59,18 @@ void *memset(void *dest, int c, int len); int strcasecmp(const char *s1, const char *s2); int strlen(const char *s); int strtoi(const char *nptr, char **endptr, int base); + +/* Like strncpy(), but guarantees null termination. */ char *strzcpy(char *dest, const char *src, int len); + int tolower(int c); -#endif /* __UTIL_H */ +/* 64-bit divide-and-modulo. Does the equivalent of: + * + * r = *n % d; + * *n /= d; + * return r; + */ +int uint64divmod(uint64_t *v, int by); + +#endif /* __CROS_EC_UTIL_H */ -- cgit v1.2.1