mirror of
https://gitlab.com/chrony/chrony.git
synced 2025-12-04 00:05:06 -05:00
cmdmon: define 64-bit integer
Add a structure for 64-bit integers without requiring 64-bit alignment to be usable in CMD_Reply without struct packing. Add utility functions for conversion to/from network order. Avoid using be64toh() and htobe64() as they don't seem to be available on all supported systems.
This commit is contained in:
19
util.c
19
util.c
@@ -909,6 +909,25 @@ UTI_TimespecHostToNetwork(const struct timespec *src, Timespec *dest)
|
||||
|
||||
/* ================================================== */
|
||||
|
||||
uint64_t
|
||||
UTI_Integer64NetworkToHost(Integer64 i)
|
||||
{
|
||||
return (uint64_t)ntohl(i.high) << 32 | ntohl(i.low);
|
||||
}
|
||||
|
||||
/* ================================================== */
|
||||
|
||||
Integer64
|
||||
UTI_Integer64HostToNetwork(uint64_t i)
|
||||
{
|
||||
Integer64 r;
|
||||
r.high = htonl(i >> 32);
|
||||
r.low = htonl(i);
|
||||
return r;
|
||||
}
|
||||
|
||||
/* ================================================== */
|
||||
|
||||
#define FLOAT_EXP_BITS 7
|
||||
#define FLOAT_EXP_MIN (-(1 << (FLOAT_EXP_BITS - 1)))
|
||||
#define FLOAT_EXP_MAX (-FLOAT_EXP_MIN - 1)
|
||||
|
||||
Reference in New Issue
Block a user