diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2018-09-28 15:13:04 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2018-09-28 15:13:04 +0200 |
commit | abfa3ec0598ff431407224c6b81682f7d0d35495 (patch) | |
tree | e5387999595e1f0c383c4aced38fe5a24dd90ef0 /include/libbb.h | |
parent | aae428f0bf0fcd6cd0a2503b3a50de43785b8fd0 (diff) | |
download | busybox-w32-abfa3ec0598ff431407224c6b81682f7d0d35495.tar.gz busybox-w32-abfa3ec0598ff431407224c6b81682f7d0d35495.tar.bz2 busybox-w32-abfa3ec0598ff431407224c6b81682f7d0d35495.zip |
move storage helpers to libbb.h
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'include/libbb.h')
-rw-r--r-- | include/libbb.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/include/libbb.h b/include/libbb.h index 7cad12c44..61fa1e03e 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
@@ -2127,6 +2127,23 @@ extern const char bb_default_login_shell[] ALIGN1; | |||
2127 | # define FB_0 "/dev/fb0" | 2127 | # define FB_0 "/dev/fb0" |
2128 | #endif | 2128 | #endif |
2129 | 2129 | ||
2130 | // storage helpers for mk*fs utilities | ||
2131 | char BUG_wrong_field_size(void); | ||
2132 | #define STORE_LE(field, value) \ | ||
2133 | do { \ | ||
2134 | if (sizeof(field) == 4) \ | ||
2135 | field = SWAP_LE32((uint32_t)(value)); \ | ||
2136 | else if (sizeof(field) == 2) \ | ||
2137 | field = SWAP_LE16((uint16_t)(value)); \ | ||
2138 | else if (sizeof(field) == 1) \ | ||
2139 | field = (uint8_t)(value); \ | ||
2140 | else \ | ||
2141 | BUG_wrong_field_size(); \ | ||
2142 | } while (0) | ||
2143 | |||
2144 | #define FETCH_LE32(field) \ | ||
2145 | (sizeof(field) == 4 ? SWAP_LE32(field) : BUG_wrong_field_size()) | ||
2146 | |||
2130 | 2147 | ||
2131 | #define ARRAY_SIZE(x) ((unsigned)(sizeof(x) / sizeof((x)[0]))) | 2148 | #define ARRAY_SIZE(x) ((unsigned)(sizeof(x) / sizeof((x)[0]))) |
2132 | #define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)])) | 2149 | #define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)])) |