Project Alice
Loading...
Searching...
No Matches
zstd_cwksp.h File Reference
Include dependency graph for zstd_cwksp.h:
This graph shows which files directly or indirectly include this file:

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
 

Enumerations

enum  ZSTD_cwksp_alloc_phase_e { ZSTD_cwksp_alloc_objects , ZSTD_cwksp_alloc_aligned_init_once , ZSTD_cwksp_alloc_aligned , ZSTD_cwksp_alloc_buffers }
 
enum  ZSTD_cwksp_static_alloc_e { ZSTD_cwksp_dynamic_alloc , ZSTD_cwksp_static_alloc }
 

Functions

MEM_STATIC size_t ZSTD_cwksp_available_space (ZSTD_cwksp *ws)
 
MEM_STATIC void * ZSTD_cwksp_initialAllocStart (ZSTD_cwksp *ws)
 
MEM_STATIC void ZSTD_cwksp_assert_internal_consistency (ZSTD_cwksp *ws)
 
MEM_STATIC size_t ZSTD_cwksp_align (size_t size, size_t const align)
 
MEM_STATIC size_t ZSTD_cwksp_alloc_size (size_t size)
 
MEM_STATIC size_t ZSTD_cwksp_aligned_alloc_size (size_t size)
 
MEM_STATIC size_t ZSTD_cwksp_slack_space_required (void)
 
MEM_STATIC size_t ZSTD_cwksp_bytes_to_align_ptr (void *ptr, const size_t alignBytes)
 
MEM_STATIC void * ZSTD_cwksp_reserve_internal_buffer_space (ZSTD_cwksp *ws, size_t const bytes)
 
MEM_STATIC size_t ZSTD_cwksp_internal_advance_phase (ZSTD_cwksp *ws, ZSTD_cwksp_alloc_phase_e phase)
 
MEM_STATIC int ZSTD_cwksp_owns_buffer (const ZSTD_cwksp *ws, const void *ptr)
 
MEM_STATIC void * ZSTD_cwksp_reserve_internal (ZSTD_cwksp *ws, size_t bytes, ZSTD_cwksp_alloc_phase_e phase)
 
MEM_STATIC BYTEZSTD_cwksp_reserve_buffer (ZSTD_cwksp *ws, size_t bytes)
 
MEM_STATIC void * ZSTD_cwksp_reserve_aligned_init_once (ZSTD_cwksp *ws, size_t bytes)
 
MEM_STATIC void * ZSTD_cwksp_reserve_aligned (ZSTD_cwksp *ws, size_t bytes)
 
MEM_STATIC void * ZSTD_cwksp_reserve_table (ZSTD_cwksp *ws, size_t bytes)
 
MEM_STATIC void * ZSTD_cwksp_reserve_object (ZSTD_cwksp *ws, size_t bytes)
 
MEM_STATIC void ZSTD_cwksp_mark_tables_dirty (ZSTD_cwksp *ws)
 
MEM_STATIC void ZSTD_cwksp_mark_tables_clean (ZSTD_cwksp *ws)
 
MEM_STATIC void ZSTD_cwksp_clean_tables (ZSTD_cwksp *ws)
 
MEM_STATIC void ZSTD_cwksp_clear_tables (ZSTD_cwksp *ws)
 
MEM_STATIC void ZSTD_cwksp_clear (ZSTD_cwksp *ws)
 
MEM_STATIC size_t ZSTD_cwksp_sizeof (const ZSTD_cwksp *ws)
 
MEM_STATIC size_t ZSTD_cwksp_used (const ZSTD_cwksp *ws)
 
MEM_STATIC void ZSTD_cwksp_init (ZSTD_cwksp *ws, void *start, size_t size, ZSTD_cwksp_static_alloc_e isStatic)
 
MEM_STATIC size_t ZSTD_cwksp_create (ZSTD_cwksp *ws, size_t size, ZSTD_customMem customMem)
 
MEM_STATIC void ZSTD_cwksp_free (ZSTD_cwksp *ws, ZSTD_customMem customMem)
 
MEM_STATIC void ZSTD_cwksp_move (ZSTD_cwksp *dst, ZSTD_cwksp *src)
 
MEM_STATIC int ZSTD_cwksp_reserve_failed (const ZSTD_cwksp *ws)
 
MEM_STATIC int ZSTD_cwksp_estimated_space_within_bounds (const ZSTD_cwksp *const ws, size_t const estimatedSpace)
 
MEM_STATIC int ZSTD_cwksp_check_available (ZSTD_cwksp *ws, size_t additionalNeededSpace)
 
MEM_STATIC int ZSTD_cwksp_check_too_large (ZSTD_cwksp *ws, size_t additionalNeededSpace)
 
MEM_STATIC int ZSTD_cwksp_check_wasteful (ZSTD_cwksp *ws, size_t additionalNeededSpace)
 
MEM_STATIC void ZSTD_cwksp_bump_oversized_duration (ZSTD_cwksp *ws, size_t additionalNeededSpace)
 

Macro Definition Documentation

◆ ZSTD_CWKSP_ALIGNMENT_BYTES

#define ZSTD_CWKSP_ALIGNMENT_BYTES   64

Definition at line 42 of file zstd_cwksp.h.

◆ ZSTD_CWKSP_ASAN_REDZONE_SIZE

#define ZSTD_CWKSP_ASAN_REDZONE_SIZE   128

Definition at line 37 of file zstd_cwksp.h.

Enumeration Type Documentation

◆ ZSTD_cwksp_alloc_phase_e

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.

◆ ZSTD_cwksp_static_alloc_e

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.

Function Documentation

◆ ZSTD_cwksp_align()

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.

Here is the caller graph for this function:

◆ ZSTD_cwksp_aligned_alloc_size()

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.

Here is the call graph for this function:

◆ ZSTD_cwksp_alloc_size()

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.

Here is the caller graph for this function:

◆ ZSTD_cwksp_assert_internal_consistency()

MEM_STATIC void ZSTD_cwksp_assert_internal_consistency ( ZSTD_cwksp ws)

Definition at line 181 of file zstd_cwksp.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ZSTD_cwksp_available_space()

MEM_STATIC size_t ZSTD_cwksp_available_space ( ZSTD_cwksp ws)

Definition at line 717 of file zstd_cwksp.h.

Here is the caller graph for this function:

◆ ZSTD_cwksp_bump_oversized_duration()

MEM_STATIC void ZSTD_cwksp_bump_oversized_duration ( ZSTD_cwksp ws,
size_t  additionalNeededSpace 
)

Definition at line 735 of file zstd_cwksp.h.

Here is the call graph for this function:

◆ ZSTD_cwksp_bytes_to_align_ptr()

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.

Here is the caller graph for this function:

◆ ZSTD_cwksp_check_available()

MEM_STATIC int ZSTD_cwksp_check_available ( ZSTD_cwksp ws,
size_t  additionalNeededSpace 
)

Definition at line 721 of file zstd_cwksp.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ZSTD_cwksp_check_too_large()

MEM_STATIC int ZSTD_cwksp_check_too_large ( ZSTD_cwksp ws,
size_t  additionalNeededSpace 
)

Definition at line 725 of file zstd_cwksp.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ZSTD_cwksp_check_wasteful()

MEM_STATIC int ZSTD_cwksp_check_wasteful ( ZSTD_cwksp ws,
size_t  additionalNeededSpace 
)

Definition at line 730 of file zstd_cwksp.h.

Here is the call graph for this function:

◆ ZSTD_cwksp_clean_tables()

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.

Here is the call graph for this function:

◆ ZSTD_cwksp_clear()

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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ZSTD_cwksp_clear_tables()

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.

Here is the call graph for this function:

◆ ZSTD_cwksp_create()

MEM_STATIC size_t ZSTD_cwksp_create ( ZSTD_cwksp ws,
size_t  size,
ZSTD_customMem  customMem 
)

Definition at line 668 of file zstd_cwksp.h.

Here is the call graph for this function:

◆ ZSTD_cwksp_estimated_space_within_bounds()

MEM_STATIC int ZSTD_cwksp_estimated_space_within_bounds ( const ZSTD_cwksp *const  ws,
size_t const  estimatedSpace 
)

Definition at line 709 of file zstd_cwksp.h.

Here is the call graph for this function:

◆ ZSTD_cwksp_free()

MEM_STATIC void ZSTD_cwksp_free ( ZSTD_cwksp ws,
ZSTD_customMem  customMem 
)

Definition at line 676 of file zstd_cwksp.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ZSTD_cwksp_init()

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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ZSTD_cwksp_initialAllocStart()

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.

Here is the caller graph for this function:

◆ ZSTD_cwksp_internal_advance_phase()

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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ZSTD_cwksp_mark_tables_clean()

MEM_STATIC void ZSTD_cwksp_mark_tables_clean ( ZSTD_cwksp ws)

Definition at line 553 of file zstd_cwksp.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ZSTD_cwksp_mark_tables_dirty()

MEM_STATIC void ZSTD_cwksp_mark_tables_dirty ( ZSTD_cwksp ws)

Definition at line 524 of file zstd_cwksp.h.

Here is the call graph for this function:

◆ ZSTD_cwksp_move()

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.

Here is the caller graph for this function:

◆ ZSTD_cwksp_owns_buffer()

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.

Here is the caller graph for this function:

◆ ZSTD_cwksp_reserve_aligned()

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.

Here is the call graph for this function:

◆ ZSTD_cwksp_reserve_aligned_init_once()

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.

Here is the call graph for this function:

◆ ZSTD_cwksp_reserve_buffer()

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.

Here is the call graph for this function:

◆ ZSTD_cwksp_reserve_failed()

MEM_STATIC int ZSTD_cwksp_reserve_failed ( const ZSTD_cwksp ws)

Definition at line 697 of file zstd_cwksp.h.

◆ ZSTD_cwksp_reserve_internal()

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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ZSTD_cwksp_reserve_internal_buffer_space()

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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ZSTD_cwksp_reserve_object()

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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ZSTD_cwksp_reserve_table()

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.

Here is the call graph for this function:

◆ ZSTD_cwksp_sizeof()

MEM_STATIC size_t ZSTD_cwksp_sizeof ( const ZSTD_cwksp ws)

Definition at line 639 of file zstd_cwksp.h.

Here is the caller graph for this function:

◆ ZSTD_cwksp_slack_space_required()

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.

Here is the caller graph for this function:

◆ ZSTD_cwksp_used()

MEM_STATIC size_t ZSTD_cwksp_used ( const ZSTD_cwksp ws)

Definition at line 643 of file zstd_cwksp.h.

Here is the caller graph for this function: