mirror of
https://github.com/freebsd/freebsd-src
synced 2024-10-15 04:43:53 +00:00
nvmecontrol: Create letoh to generically convert to host order
Using _Generic, create letoh which will generically convert uintXX_t types from little endian to host, regardless of the size. This name has been floated as a possible addition to endian.h. Sponsored by: Netflix Discussed with: jhb Reviewed by: chuck Differential Revision: https://reviews.freebsd.org/D44649
This commit is contained in:
parent
de22251127
commit
67163bc485
|
@ -60,6 +60,17 @@ struct kv_name {
|
||||||
const char *name;
|
const char *name;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Generically convert little endian to host endian, based on the type of the thing
|
||||||
|
* being converted. Use the proposed name for future changes to endian.h.
|
||||||
|
*/
|
||||||
|
#define letoh(x) \
|
||||||
|
_Generic(x, \
|
||||||
|
uint8_t: (x), \
|
||||||
|
uint16_t: le16toh(x), \
|
||||||
|
uint32_t: le32toh(x), \
|
||||||
|
uint64_t: le64toh(x))
|
||||||
|
|
||||||
const char *kv_lookup(const struct kv_name *kv, size_t kv_count, uint32_t key);
|
const char *kv_lookup(const struct kv_name *kv, size_t kv_count, uint32_t key);
|
||||||
|
|
||||||
void logpage_register(struct logpage_function *p);
|
void logpage_register(struct logpage_function *p);
|
||||||
|
|
Loading…
Reference in a new issue