summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/crc32.c9
-rw-r--r--lib/display_options.c3
-rw-r--r--lib/vsprintf.c23
3 files changed, 34 insertions, 1 deletions
diff --git a/lib/crc32.c b/lib/crc32.c
index 27335a3ed9..76205da4f3 100644
--- a/lib/crc32.c
+++ b/lib/crc32.c
@@ -249,3 +249,12 @@ uint32_t ZEXPORT crc32_wd (uint32_t crc,
return crc;
}
+
+void crc32_wd_buf(const unsigned char *input, unsigned int ilen,
+ unsigned char *output, unsigned int chunk_sz)
+{
+ uint32_t crc;
+
+ crc = crc32_wd(0, input, ilen, chunk_sz);
+ memcpy(output, &crc, sizeof(crc));
+}
diff --git a/lib/display_options.c b/lib/display_options.c
index 694d2f22e8..0339970e7d 100644
--- a/lib/display_options.c
+++ b/lib/display_options.c
@@ -98,7 +98,8 @@ void print_size(unsigned long long size, const char *s)
*/
#define MAX_LINE_LENGTH_BYTES (64)
#define DEFAULT_LINE_LENGTH_BYTES (16)
-int print_buffer (ulong addr, void* data, uint width, uint count, uint linelen)
+int print_buffer(ulong addr, const void *data, uint width, uint count,
+ uint linelen)
{
/* linebuf as a union causes proper alignment */
union linebuf {
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 3c432f8764..533a96b85e 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -126,6 +126,29 @@ unsigned long ustrtoul(const char *cp, char **endp, unsigned int base)
return result;
}
+unsigned long long ustrtoull(const char *cp, char **endp, unsigned int base)
+{
+ unsigned long long result = simple_strtoull(cp, endp, base);
+ switch (**endp) {
+ case 'G':
+ result *= 1024;
+ /* fall through */
+ case 'M':
+ result *= 1024;
+ /* fall through */
+ case 'K':
+ case 'k':
+ result *= 1024;
+ if ((*endp)[1] == 'i') {
+ if ((*endp)[2] == 'B')
+ (*endp) += 3;
+ else
+ (*endp) += 2;
+ }
+ }
+ return result;
+}
+
unsigned long long simple_strtoull(const char *cp, char **endp,
unsigned int base)
{
OpenPOWER on IntegriCloud