diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/crc32.c | 9 | ||||
-rw-r--r-- | lib/display_options.c | 3 | ||||
-rw-r--r-- | lib/vsprintf.c | 23 |
3 files changed, 34 insertions, 1 deletions
diff --git a/lib/crc32.c b/lib/crc32.c index 27335a3..76205da 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 694d2f2..0339970 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 3c432f8..533a96b 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) { |