Header file for common utility functions.
More...
Go to the source code of this file.
Macros |
| #define | XSTR(a) #a |
| | Internal to the STR macro.
|
| #define | STR(a) XSTR(a) |
| | Stringify a macro value.
|
| #define | ntohll(x) |
| | Byte-swap a 64-bit integer.
|
| #define | htonll(x) ntohll(x) |
| | Byte-swap a 64-bit integer.
|
Functions |
| void | bytes_htons (uint8_t *bytes, uint16_t u16) |
| | Convert a host ordered short to a network ordered byte array.
|
| void | bytes_htonl (uint8_t *bytes, uint32_t u32) |
| | Convert a host ordered long to a network ordered byte array.
|
| void | bytes_htonll (uint8_t *bytes, uint64_t u64) |
| | Convert a host ordered long-long (64 bit) to a network ordered byte array.
|
| void | gettimeofday_wrap (struct timeval *tv) |
| | Convenience function to get the current time of day.
|
| void * | malloc_zero (const size_t size) |
| | Allocate memory and set it to zero.
|
| int | timeval_subtract (struct timeval *result, const struct timeval *x, const struct timeval *y) |
| | Find the delta between two timevals.
|
Detailed Description
Header file for common utility functions.
- Author:
- Alistair King
Definition in file utils.h.
Macro Definition Documentation
Value:(((uint64_t)(ntohl((int)((x << 32) >> 32))) << 32) | \
(uint32_t)ntohl(((int)(x >> 32))))
Byte-swap a 64-bit integer.
Definition at line 51 of file utils.h.
Internal to the STR macro.
Definition at line 43 of file utils.h.
Function Documentation
| void bytes_htonl |
( |
uint8_t * |
bytes, |
|
|
uint32_t |
u32 |
|
) |
| |
Convert a host ordered long to a network ordered byte array.
- Parameters:
-
| [out] | bytes | The converted byte array |
| u32 | The host-ordered long |
Definition at line 57 of file utils.c.
| void bytes_htonll |
( |
uint8_t * |
bytes, |
|
|
uint64_t |
u64 |
|
) |
| |
Convert a host ordered long-long (64 bit) to a network ordered byte array.
- Parameters:
-
| [out] | bytes | The converted byte array |
| u64 | The host-ordered long-long (64 bit) |
Definition at line 64 of file utils.c.
References htonll.
| void bytes_htons |
( |
uint8_t * |
bytes, |
|
|
uint16_t |
u16 |
|
) |
| |
Convert a host ordered short to a network ordered byte array.
- Parameters:
-
| [out] | bytes | The converted byte array |
| u16 | The host-ordered short |
Definition at line 50 of file utils.c.
| void gettimeofday_wrap |
( |
struct timeval * |
tv | ) |
|
Convenience function to get the current time of day.
- Parameters:
-
| [out] | tv | A pointer to a timeval containing the time of day |
Definition at line 71 of file utils.c.
| void* malloc_zero |
( |
const size_t |
size | ) |
|
Allocate memory and set it to zero.
- Parameters:
-
| size | The size of memory to allocate |
- Returns:
- a pointer to zeroed memory if successful, -1 if an error occurs
Definition at line 78 of file utils.c.
| int timeval_subtract |
( |
struct timeval * |
result, |
|
|
const struct timeval * |
x, |
|
|
const struct timeval * |
y |
|
) |
| |
Find the delta between two timevals.
- Parameters:
-
| [out] | result | A pointer to a timeval containing the delta |
| x | The start timeval |
| y | The end timeval |
- Returns:
- 1 if the result is negative, 0 otherwise
Definition at line 88 of file utils.c.