|
13 | 13 | #include <errno.h> |
14 | 14 | #include <inttypes.h> |
15 | 15 | #include <linux/kernel.h> |
16 | | -#include <linux/unaligned.h> |
17 | 16 |
|
18 | 17 | #include "libbpf.h" |
19 | 18 | #include "libbpf_internal.h" |
@@ -149,6 +148,16 @@ const char *libbpf_errstr(int err) |
149 | 148 | } |
150 | 149 | } |
151 | 150 |
|
| 151 | +#pragma GCC diagnostic push |
| 152 | +#pragma GCC diagnostic ignored "-Wpacked" |
| 153 | +struct __packed_u32 { __u32 __val; } __attribute__((packed)); |
| 154 | +#pragma GCC diagnostic pop |
| 155 | + |
| 156 | +#define get_unaligned_be32(p) be32_to_cpu((((struct __packed_u32 *)(p))->__val)) |
| 157 | +#define put_unaligned_be32(v, p) do { \ |
| 158 | + ((struct __packed_u32 *)(p))->__val = cpu_to_be32(v); \ |
| 159 | +} while (0) |
| 160 | + |
152 | 161 | #define SHA256_BLOCK_LENGTH 64 |
153 | 162 | #define Ch(x, y, z) (((x) & (y)) ^ (~(x) & (z))) |
154 | 163 | #define Maj(x, y, z) (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z))) |
@@ -232,7 +241,7 @@ void libbpf_sha256(const void *data, size_t len, __u8 out[SHA256_DIGEST_LENGTH]) |
232 | 241 |
|
233 | 242 | memcpy(final_data, data + len - final_len, final_len); |
234 | 243 | final_data[final_len] = 0x80; |
235 | | - final_len = round_up(final_len + 9, SHA256_BLOCK_LENGTH); |
| 244 | + final_len = roundup(final_len + 9, SHA256_BLOCK_LENGTH); |
236 | 245 | memcpy(&final_data[final_len - 8], &bitcount, 8); |
237 | 246 |
|
238 | 247 | sha256_blocks(state, final_data, final_len / SHA256_BLOCK_LENGTH); |
|
0 commit comments