Merging upstream version 2.12.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
078c0dbcc0
commit
635faa7346
571 changed files with 10718 additions and 2738 deletions
23
util/types.c
23
util/types.c
|
@ -5,6 +5,7 @@
|
|||
#include <string.h>
|
||||
#include <locale.h>
|
||||
#include <time.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include <ccan/endian/endian.h>
|
||||
|
||||
|
@ -36,18 +37,30 @@ long double int128_to_double(__u8 *data)
|
|||
return result;
|
||||
}
|
||||
|
||||
uint64_t int48_to_long(__u8 *data)
|
||||
static uint64_t int_to_long(int bits, const __u8 *data)
|
||||
{
|
||||
int i;
|
||||
uint64_t result = 0;
|
||||
int bytes = (bits + CHAR_BIT - 1) / CHAR_BIT;
|
||||
|
||||
for (i = 0; i < 6; i++) {
|
||||
result *= 256;
|
||||
result += data[5 - i];
|
||||
for (i = 0; i < bytes; i++) {
|
||||
result <<= CHAR_BIT;
|
||||
result += data[bytes - 1 - i];
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
uint64_t int48_to_long(const __u8 *data)
|
||||
{
|
||||
return int_to_long(48, data);
|
||||
}
|
||||
|
||||
uint64_t int56_to_long(const __u8 *data)
|
||||
{
|
||||
return int_to_long(56, data);
|
||||
}
|
||||
|
||||
long double uint128_t_to_double(nvme_uint128_t data)
|
||||
{
|
||||
long double result = 0;
|
||||
|
@ -166,7 +179,7 @@ int convert_ts(time_t time, char *ts_buf)
|
|||
gmtime_r((const time_t *)&time_human, &time_info);
|
||||
|
||||
strftime(buf, sizeof(buf), "%Y-%m-%dD|%H:%M:%S", &time_info);
|
||||
sprintf(ts_buf, "%s:%03ld", buf, time_ms);
|
||||
sprintf(ts_buf, "%s:%03llu", buf, (unsigned long long)time_ms);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue