Parolin 0.7.9 6796
Console (soon DLLs) to do a tar like job
Loading...
Searching...
No Matches
zstd_cwksp.h File Reference

Go to the source code of this file.

Data Structures

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_buffers , ZSTD_cwksp_alloc_aligned }
 
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_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 (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 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 size_t ZSTD_cwksp_sizeof (const ZSTD_cwksp *ws)
 
MEM_STATIC size_t ZSTD_cwksp_used (const ZSTD_cwksp *ws)
 
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, int resizedWorkspace)
 
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

◆ ZSTD_CWKSP_ASAN_REDZONE_SIZE

#define ZSTD_CWKSP_ASAN_REDZONE_SIZE   128

Enumeration Type Documentation

◆ ZSTD_cwksp_alloc_phase_e

Enumerator
ZSTD_cwksp_alloc_objects 
ZSTD_cwksp_alloc_buffers 
ZSTD_cwksp_alloc_aligned 

◆ 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 

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.

◆ 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".

◆ 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().

◆ ZSTD_cwksp_assert_internal_consistency()

MEM_STATIC void ZSTD_cwksp_assert_internal_consistency ( ZSTD_cwksp * ws)

◆ ZSTD_cwksp_available_space()

MEM_STATIC size_t ZSTD_cwksp_available_space ( ZSTD_cwksp * ws)

◆ ZSTD_cwksp_bump_oversized_duration()

MEM_STATIC void ZSTD_cwksp_bump_oversized_duration ( ZSTD_cwksp * ws,
size_t additionalNeededSpace )

◆ 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.

◆ ZSTD_cwksp_check_available()

MEM_STATIC int ZSTD_cwksp_check_available ( ZSTD_cwksp * ws,
size_t additionalNeededSpace )

◆ ZSTD_cwksp_check_too_large()

MEM_STATIC int ZSTD_cwksp_check_too_large ( ZSTD_cwksp * ws,
size_t additionalNeededSpace )

◆ ZSTD_cwksp_check_wasteful()

MEM_STATIC int ZSTD_cwksp_check_wasteful ( ZSTD_cwksp * ws,
size_t additionalNeededSpace )

◆ 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.

◆ ZSTD_cwksp_clear()

MEM_STATIC void ZSTD_cwksp_clear ( ZSTD_cwksp * ws)

Invalidates all buffer, aligned, and table allocations. Object allocations remain valid.

◆ ZSTD_cwksp_clear_tables()

MEM_STATIC void ZSTD_cwksp_clear_tables ( ZSTD_cwksp * ws)

Invalidates table allocations. All other allocations remain valid.

◆ ZSTD_cwksp_create()

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

◆ ZSTD_cwksp_estimated_space_within_bounds()

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

◆ ZSTD_cwksp_free()

MEM_STATIC void ZSTD_cwksp_free ( ZSTD_cwksp * ws,
ZSTD_customMem customMem )

◆ 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).

◆ 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

◆ ZSTD_cwksp_mark_tables_clean()

MEM_STATIC void ZSTD_cwksp_mark_tables_clean ( ZSTD_cwksp * ws)

◆ ZSTD_cwksp_mark_tables_dirty()

MEM_STATIC void ZSTD_cwksp_mark_tables_dirty ( ZSTD_cwksp * ws)

◆ 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).

◆ 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.

◆ 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).

◆ ZSTD_cwksp_reserve_buffer()

MEM_STATIC BYTE * ZSTD_cwksp_reserve_buffer ( ZSTD_cwksp * ws,
size_t bytes )

Reserves and returns unaligned memory.

◆ ZSTD_cwksp_reserve_failed()

MEM_STATIC int ZSTD_cwksp_reserve_failed ( const ZSTD_cwksp * ws)

◆ 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.

◆ 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.

◆ 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

◆ 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 re-use them without memset()-ing them.

◆ ZSTD_cwksp_sizeof()

MEM_STATIC size_t ZSTD_cwksp_sizeof ( const ZSTD_cwksp * ws)

◆ 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).

◆ ZSTD_cwksp_used()

MEM_STATIC size_t ZSTD_cwksp_used ( const ZSTD_cwksp * ws)