Project Alice
|
#include "../common/allocations.h"
#include "../common/zstd_internal.h"
#include "../common/portability_macros.h"
Go to the source code of this file.
Classes | |
struct | ZSTD_cwksp |
Macros | |
#define | ZSTD_CWKSP_ASAN_REDZONE_SIZE 128 |
#define | ZSTD_CWKSP_ALIGNMENT_BYTES 64 |
#define ZSTD_CWKSP_ALIGNMENT_BYTES 64 |
Definition at line 42 of file zstd_cwksp.h.
#define ZSTD_CWKSP_ASAN_REDZONE_SIZE 128 |
Definition at line 37 of file zstd_cwksp.h.
Enumerator | |
---|---|
ZSTD_cwksp_alloc_objects | |
ZSTD_cwksp_alloc_aligned_init_once | |
ZSTD_cwksp_alloc_aligned | |
ZSTD_cwksp_alloc_buffers |
Definition at line 47 of file zstd_cwksp.h.
Used to describe whether the workspace is statically allocated (and will not necessarily ever be freed), or if it's dynamically allocated and we can expect a well-formed caller to free this.
Enumerator | |
---|---|
ZSTD_cwksp_dynamic_alloc | |
ZSTD_cwksp_static_alloc |
Definition at line 59 of file zstd_cwksp.h.
MEM_STATIC size_t ZSTD_cwksp_align | ( | size_t | size, |
size_t const | align | ||
) |
Align must be a power of 2.
Definition at line 209 of file zstd_cwksp.h.
MEM_STATIC size_t ZSTD_cwksp_aligned_alloc_size | ( | size_t | size | ) |
Returns an adjusted alloc size that is the nearest larger multiple of 64 bytes. Used to determine the number of bytes required for a given "aligned".
Definition at line 241 of file zstd_cwksp.h.
MEM_STATIC size_t ZSTD_cwksp_alloc_size | ( | size_t | size | ) |
Use this to determine how much space in the workspace we will consume to allocate this object. (Normally it should be exactly the size of the object, but under special conditions, like ASAN, where we pad each object, it might be larger.)
Since tables aren't currently redzoned, you don't need to call through this to figure out how much space you need for the matchState tables. Everything else is though.
Do not use for sizing aligned buffers. Instead, use ZSTD_cwksp_aligned_alloc_size().
Definition at line 227 of file zstd_cwksp.h.
MEM_STATIC void ZSTD_cwksp_assert_internal_consistency | ( | ZSTD_cwksp * | ws | ) |
Definition at line 181 of file zstd_cwksp.h.
MEM_STATIC size_t ZSTD_cwksp_available_space | ( | ZSTD_cwksp * | ws | ) |
MEM_STATIC void ZSTD_cwksp_bump_oversized_duration | ( | ZSTD_cwksp * | ws, |
size_t | additionalNeededSpace | ||
) |
MEM_STATIC size_t ZSTD_cwksp_bytes_to_align_ptr | ( | void * | ptr, |
const size_t | alignBytes | ||
) |
Return the number of additional bytes required to align a pointer to the given number of bytes. alignBytes must be a power of two.
Definition at line 262 of file zstd_cwksp.h.
MEM_STATIC int ZSTD_cwksp_check_available | ( | ZSTD_cwksp * | ws, |
size_t | additionalNeededSpace | ||
) |
Definition at line 721 of file zstd_cwksp.h.
MEM_STATIC int ZSTD_cwksp_check_too_large | ( | ZSTD_cwksp * | ws, |
size_t | additionalNeededSpace | ||
) |
Definition at line 725 of file zstd_cwksp.h.
MEM_STATIC int ZSTD_cwksp_check_wasteful | ( | ZSTD_cwksp * | ws, |
size_t | additionalNeededSpace | ||
) |
MEM_STATIC void ZSTD_cwksp_clean_tables | ( | ZSTD_cwksp * | ws | ) |
Zero the part of the allocated tables not already marked clean.
Definition at line 566 of file zstd_cwksp.h.
MEM_STATIC void ZSTD_cwksp_clear | ( | ZSTD_cwksp * | ws | ) |
Invalidates all buffer, aligned, and table allocations. Object allocations remain valid.
Definition at line 602 of file zstd_cwksp.h.
MEM_STATIC void ZSTD_cwksp_clear_tables | ( | ZSTD_cwksp * | ws | ) |
Invalidates table allocations. All other allocations remain valid.
Definition at line 580 of file zstd_cwksp.h.
MEM_STATIC size_t ZSTD_cwksp_create | ( | ZSTD_cwksp * | ws, |
size_t | size, | ||
ZSTD_customMem | customMem | ||
) |
MEM_STATIC int ZSTD_cwksp_estimated_space_within_bounds | ( | const ZSTD_cwksp *const | ws, |
size_t const | estimatedSpace | ||
) |
MEM_STATIC void ZSTD_cwksp_free | ( | ZSTD_cwksp * | ws, |
ZSTD_customMem | customMem | ||
) |
Definition at line 676 of file zstd_cwksp.h.
MEM_STATIC void ZSTD_cwksp_init | ( | ZSTD_cwksp * | ws, |
void * | start, | ||
size_t | size, | ||
ZSTD_cwksp_static_alloc_e | isStatic | ||
) |
The provided workspace takes ownership of the buffer [start, start+size). Any existing values in the workspace are ignored (the previously managed buffer, if present, must be separately freed).
Definition at line 653 of file zstd_cwksp.h.
MEM_STATIC void * ZSTD_cwksp_initialAllocStart | ( | ZSTD_cwksp * | ws | ) |
Returns the initial value for allocStart which is used to determine the position from which we can allocate from the end of the workspace.
Definition at line 274 of file zstd_cwksp.h.
MEM_STATIC size_t ZSTD_cwksp_internal_advance_phase | ( | ZSTD_cwksp * | ws, |
ZSTD_cwksp_alloc_phase_e | phase | ||
) |
Moves the cwksp to the next phase, and does any necessary allocations. cwksp initialization must necessarily go through each phase in order. Returns a 0 on success, or zstd error
Definition at line 314 of file zstd_cwksp.h.
MEM_STATIC void ZSTD_cwksp_mark_tables_clean | ( | ZSTD_cwksp * | ws | ) |
Definition at line 553 of file zstd_cwksp.h.
MEM_STATIC void ZSTD_cwksp_mark_tables_dirty | ( | ZSTD_cwksp * | ws | ) |
MEM_STATIC void ZSTD_cwksp_move | ( | ZSTD_cwksp * | dst, |
ZSTD_cwksp * | src | ||
) |
Moves the management of a workspace from one cwksp to another. The src cwksp is left in an invalid state (src must be re-init()'ed before it's used again).
Definition at line 692 of file zstd_cwksp.h.
MEM_STATIC int ZSTD_cwksp_owns_buffer | ( | const ZSTD_cwksp * | ws, |
const void * | ptr | ||
) |
Returns whether this object/buffer/etc was allocated in this workspace.
Definition at line 347 of file zstd_cwksp.h.
MEM_STATIC void * ZSTD_cwksp_reserve_aligned | ( | ZSTD_cwksp * | ws, |
size_t | bytes | ||
) |
Reserves and returns memory sized on and aligned on ZSTD_CWKSP_ALIGNMENT_BYTES (64 bytes).
Definition at line 427 of file zstd_cwksp.h.
MEM_STATIC void * ZSTD_cwksp_reserve_aligned_init_once | ( | ZSTD_cwksp * | ws, |
size_t | bytes | ||
) |
Reserves and returns memory sized on and aligned on ZSTD_CWKSP_ALIGNMENT_BYTES (64 bytes). This memory has been initialized at least once in the past. This doesn't mean it has been initialized this time, and it might contain data from previous operations. The main usage is for algorithms that might need read access into uninitialized memory. The algorithm must maintain safety under these conditions and must make sure it doesn't leak any of the past data (directly or in side channels).
Definition at line 403 of file zstd_cwksp.h.
MEM_STATIC BYTE * ZSTD_cwksp_reserve_buffer | ( | ZSTD_cwksp * | ws, |
size_t | bytes | ||
) |
Reserves and returns unaligned memory.
Definition at line 389 of file zstd_cwksp.h.
MEM_STATIC int ZSTD_cwksp_reserve_failed | ( | const ZSTD_cwksp * | ws | ) |
Definition at line 697 of file zstd_cwksp.h.
MEM_STATIC void * ZSTD_cwksp_reserve_internal | ( | ZSTD_cwksp * | ws, |
size_t | bytes, | ||
ZSTD_cwksp_alloc_phase_e | phase | ||
) |
Internal function. Do not use directly.
Definition at line 356 of file zstd_cwksp.h.
MEM_STATIC void * ZSTD_cwksp_reserve_internal_buffer_space | ( | ZSTD_cwksp * | ws, |
size_t const | bytes | ||
) |
Internal function. Do not use directly. Reserves the given number of bytes within the aligned/buffer segment of the wksp, which counts from the end of the wksp (as opposed to the object/table segment).
Returns a pointer to the beginning of that space.
Definition at line 286 of file zstd_cwksp.h.
MEM_STATIC void * ZSTD_cwksp_reserve_object | ( | ZSTD_cwksp * | ws, |
size_t | bytes | ||
) |
Aligned on sizeof(void*). Note : should happen only once, at workspace first initialization
Definition at line 485 of file zstd_cwksp.h.
MEM_STATIC void * ZSTD_cwksp_reserve_table | ( | ZSTD_cwksp * | ws, |
size_t | bytes | ||
) |
Aligned on 64 bytes. These buffers have the special property that their values remain constrained, allowing us to reuse them without memset()-ing them.
Definition at line 440 of file zstd_cwksp.h.
MEM_STATIC size_t ZSTD_cwksp_sizeof | ( | const ZSTD_cwksp * | ws | ) |
MEM_STATIC size_t ZSTD_cwksp_slack_space_required | ( | void | ) |
Returns the amount of additional space the cwksp must allocate for internal purposes (currently only alignment).
Definition at line 249 of file zstd_cwksp.h.
MEM_STATIC size_t ZSTD_cwksp_used | ( | const ZSTD_cwksp * | ws | ) |