ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
xz_config.h
Go to the documentation of this file.
1
51#pragma once
52
53#include <stddef.h>
54#include <stdint.h>
55#include <string.h>
56
57#include "unarch_xz_pool.h"
58
59/* The porting-seam macro names below (kmalloc, memeq, min_t, get_le32, ...) are
60 * fixed by the xz-embedded SOUP contract (see the @details above) and cannot be
61 * renamed to project UPPER_CASE conventions without forking the vendored tree. */
62/* NOLINTBEGIN(readability-identifier-naming) -- porting-seam names fixed by the xz-embedded SOUP contract. */
63
74#define XZ_DEC_PREALLOC
75
84#define XZ_USE_CRC64
85
86#include "xz.h"
87
97#define kmalloc(size, flags) unarch_xz_pool_alloc((uint32_t)(size))
98
107#define kfree(ptr) ((void)(ptr))
108
117#define vmalloc(size) unarch_xz_pool_alloc((uint32_t)(size))
118
126#define vfree(ptr) ((void)(ptr))
127
135#define memeq(a, b, size) (memcmp((a), (b), (size)) == 0)
136
144#define memzero(buf, size) memset((buf), 0, (size))
145
155#ifndef min
157#define min(x, y) (((x) < (y)) ? (x) : (y))
158#endif
159
169#define min_t(type, x, y) (((type)(x) < (type)(y)) ? (type)(x) : (type)(y))
170
179#ifndef fallthrough
181#define fallthrough [[fallthrough]]
182#endif
183
192#ifndef __always_inline
194#define __always_inline [[gnu::always_inline]] inline
195#endif
196
209
224static inline uint32_t ra8_xz_cfg_get_unaligned_le32(const uint8_t* buf)
225{
226 return (uint32_t)buf[0] | ((uint32_t)buf[1] << (uint8_t)k_ra8_xz_cfg_shift_b1) |
227 ((uint32_t)buf[2] << (uint8_t)k_ra8_xz_cfg_shift_b2) |
228 ((uint32_t)buf[3] << (uint8_t)k_ra8_xz_cfg_shift_b3);
229}
230
238#define get_unaligned_le32(buf) ra8_xz_cfg_get_unaligned_le32(buf)
239
248#define get_le32(buf) ra8_xz_cfg_get_unaligned_le32(buf)
249/* NOLINTEND(readability-identifier-naming) */
Caller-owned bump arena backing xz-embedded's allocator seam.
ra8_xz_cfg_shift_t
Byte-lane shift distances for the little-endian load shim.
Definition xz_config.h:204
@ k_ra8_xz_cfg_shift_b1
Second byte lane shift.
Definition xz_config.h:205
@ k_ra8_xz_cfg_shift_b2
Third byte lane shift.
Definition xz_config.h:206
@ k_ra8_xz_cfg_shift_b3
Fourth byte lane shift.
Definition xz_config.h:207
static uint32_t ra8_xz_cfg_get_unaligned_le32(const uint8_t *buf)
Load an unaligned little-endian 32-bit value byte by byte.
Definition xz_config.h:224