mirror of
https://github.com/versity/scoutfs.git
synced 2026-01-06 20:16:25 +00:00
scoutfs-utils: add get_unaligned helpers
Signed-off-by: Zach Brown <zab@versity.com>
This commit is contained in:
@@ -6,6 +6,8 @@
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "sparse.h"
|
||||
|
||||
/*
|
||||
* Generate build warnings if the condition is false but generate no
|
||||
* code at run time if it's true.
|
||||
@@ -85,6 +87,17 @@ do { \
|
||||
((unsigned long)log2l((long double)x)); \
|
||||
})
|
||||
|
||||
#define emit_get_unaligned_le(nr) \
|
||||
static inline __u##nr get_unaligned_le##nr(void *buf) \
|
||||
{ \
|
||||
__le##nr x; \
|
||||
memcpy(&x, buf, sizeof(x)); \
|
||||
return le##nr##_to_cpu(x); \
|
||||
}
|
||||
emit_get_unaligned_le(16)
|
||||
emit_get_unaligned_le(32)
|
||||
emit_get_unaligned_le(64)
|
||||
|
||||
/*
|
||||
* return -1,0,+1 based on the memcmp comparison of the minimum of their
|
||||
* two lengths. If their min shared bytes are equal but the lengths
|
||||
|
||||
Reference in New Issue
Block a user