Project Alice
Loading...
Searching...
No Matches
zstd_cwksp.h
Go to the documentation of this file.
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 * All rights reserved.
4 *
5 * This source code is licensed under both the BSD-style license (found in the
6 * LICENSE file in the root directory of this source tree) and the GPLv2 (found
7 * in the COPYING file in the root directory of this source tree).
8 * You may select, at your option, one of the above-listed licenses.
9 */
10
11#ifndef ZSTD_CWKSP_H
12#define ZSTD_CWKSP_H
13
14/*-*************************************
15* Dependencies
16***************************************/
17#include "../common/allocations.h" /* ZSTD_customMalloc, ZSTD_customFree */
18#include "../common/zstd_internal.h"
19#include "../common/portability_macros.h"
20
21#if defined (__cplusplus)
22extern "C" {
23#endif
24
25/*-*************************************
26* Constants
27***************************************/
28
29/* Since the workspace is effectively its own little malloc implementation /
30 * arena, when we run under ASAN, we should similarly insert redzones between
31 * each internal element of the workspace, so ASAN will catch overruns that
32 * reach outside an object but that stay inside the workspace.
33 *
34 * This defines the size of that redzone.
35 */
36#ifndef ZSTD_CWKSP_ASAN_REDZONE_SIZE
37#define ZSTD_CWKSP_ASAN_REDZONE_SIZE 128
38#endif
39
40
41/* Set our tables and aligneds to align by 64 bytes */
42#define ZSTD_CWKSP_ALIGNMENT_BYTES 64
43
44/*-*************************************
45* Structures
46***************************************/
47typedef enum {
53
59typedef enum {
63
158typedef struct {
161
163 void* tableEnd;
167
172} ZSTD_cwksp;
173
174/*-*************************************
175* Functions
176***************************************/
177
180
182 (void)ws;
183 assert(ws->workspace <= ws->objectEnd);
184 assert(ws->objectEnd <= ws->tableEnd);
185 assert(ws->objectEnd <= ws->tableValidEnd);
186 assert(ws->tableEnd <= ws->allocStart);
187 assert(ws->tableValidEnd <= ws->allocStart);
188 assert(ws->allocStart <= ws->workspaceEnd);
190 assert(ws->workspace <= ws->initOnceStart);
191#if ZSTD_MEMORY_SANITIZER
192 {
193 intptr_t const offset = __msan_test_shadow(ws->initOnceStart,
195 (void)offset;
196#if defined(ZSTD_MSAN_PRINT)
197 if(offset!=-1) {
198 __msan_print_shadow((U8*)ws->initOnceStart + offset - 8, 32);
199 }
200#endif
201 assert(offset==-1);
202 };
203#endif
204}
205
209MEM_STATIC size_t ZSTD_cwksp_align(size_t size, size_t const align) {
210 size_t const mask = align - 1;
211 assert((align & mask) == 0);
212 return (size + mask) & ~mask;
213}
214
228 if (size == 0)
229 return 0;
230#if ZSTD_ADDRESS_SANITIZER && !defined (ZSTD_ASAN_DONT_POISON_WORKSPACE)
231 return size + 2 * ZSTD_CWKSP_ASAN_REDZONE_SIZE;
232#else
233 return size;
234#endif
235}
236
243}
244
250 /* For alignment, the wksp will always allocate an additional 2*ZSTD_CWKSP_ALIGNMENT_BYTES
251 * bytes to align the beginning of tables section and end of buffers;
252 */
253 size_t const slackSpace = ZSTD_CWKSP_ALIGNMENT_BYTES * 2;
254 return slackSpace;
255}
256
257
262MEM_STATIC size_t ZSTD_cwksp_bytes_to_align_ptr(void* ptr, const size_t alignBytes) {
263 size_t const alignBytesMask = alignBytes - 1;
264 size_t const bytes = (alignBytes - ((size_t)ptr & (alignBytesMask))) & alignBytesMask;
265 assert((alignBytes & alignBytesMask) == 0);
266 assert(bytes < alignBytes);
267 return bytes;
268}
269
275 return (void*)((size_t)ws->workspaceEnd & ~(ZSTD_CWKSP_ALIGNMENT_BYTES-1));
276}
277
285MEM_STATIC void*
287{
288 void* const alloc = (BYTE*)ws->allocStart - bytes;
289 void* const bottom = ws->tableEnd;
290 DEBUGLOG(5, "cwksp: reserving %p %zd bytes, %zd bytes remaining",
291 alloc, bytes, ZSTD_cwksp_available_space(ws) - bytes);
293 assert(alloc >= bottom);
294 if (alloc < bottom) {
295 DEBUGLOG(4, "cwksp: alloc failed!");
296 ws->allocFailed = 1;
297 return NULL;
298 }
299 /* the area is reserved from the end of wksp.
300 * If it overlaps with tableValidEnd, it voids guarantees on values' range */
301 if (alloc < ws->tableValidEnd) {
302 ws->tableValidEnd = alloc;
303 }
304 ws->allocStart = alloc;
305 return alloc;
306}
307
313MEM_STATIC size_t
315{
316 assert(phase >= ws->phase);
317 if (phase > ws->phase) {
318 /* Going from allocating objects to allocating initOnce / tables */
321 ws->tableValidEnd = ws->objectEnd;
323
324 { /* Align the start of the tables to 64 bytes. Use [0, 63] bytes */
325 void *const alloc = ws->objectEnd;
326 size_t const bytesToAlign = ZSTD_cwksp_bytes_to_align_ptr(alloc, ZSTD_CWKSP_ALIGNMENT_BYTES);
327 void *const objectEnd = (BYTE *) alloc + bytesToAlign;
328 DEBUGLOG(5, "reserving table alignment addtl space: %zu", bytesToAlign);
329 RETURN_ERROR_IF(objectEnd > ws->workspaceEnd, memory_allocation,
330 "table phase - alignment initial allocation failed!");
331 ws->objectEnd = objectEnd;
332 ws->tableEnd = objectEnd; /* table area starts being empty */
333 if (ws->tableValidEnd < ws->tableEnd) {
334 ws->tableValidEnd = ws->tableEnd;
335 }
336 }
337 }
338 ws->phase = phase;
340 }
341 return 0;
342}
343
347MEM_STATIC int ZSTD_cwksp_owns_buffer(const ZSTD_cwksp* ws, const void* ptr)
348{
349 return (ptr != NULL) && (ws->workspace <= ptr) && (ptr < ws->workspaceEnd);
350}
351
355MEM_STATIC void*
357{
358 void* alloc;
359 if (ZSTD_isError(ZSTD_cwksp_internal_advance_phase(ws, phase)) || bytes == 0) {
360 return NULL;
361 }
362
363#if ZSTD_ADDRESS_SANITIZER && !defined (ZSTD_ASAN_DONT_POISON_WORKSPACE)
364 /* over-reserve space */
365 bytes += 2 * ZSTD_CWKSP_ASAN_REDZONE_SIZE;
366#endif
367
369
370#if ZSTD_ADDRESS_SANITIZER && !defined (ZSTD_ASAN_DONT_POISON_WORKSPACE)
371 /* Move alloc so there's ZSTD_CWKSP_ASAN_REDZONE_SIZE unused space on
372 * either size. */
373 if (alloc) {
374 alloc = (BYTE *)alloc + ZSTD_CWKSP_ASAN_REDZONE_SIZE;
376 /* We need to keep the redzone poisoned while unpoisoning the bytes that
377 * are actually allocated. */
378 __asan_unpoison_memory_region(alloc, bytes - 2 * ZSTD_CWKSP_ASAN_REDZONE_SIZE);
379 }
380 }
381#endif
382
383 return alloc;
384}
385
390{
392}
393
404{
405 size_t const alignedBytes = ZSTD_cwksp_align(bytes, ZSTD_CWKSP_ALIGNMENT_BYTES);
407 assert(((size_t)ptr & (ZSTD_CWKSP_ALIGNMENT_BYTES-1))== 0);
408 if(ptr && ptr < ws->initOnceStart) {
409 /* We assume the memory following the current allocation is either:
410 * 1. Not usable as initOnce memory (end of workspace)
411 * 2. Another initOnce buffer that has been allocated before (and so was previously memset)
412 * 3. An ASAN redzone, in which case we don't want to write on it
413 * For these reasons it should be fine to not explicitly zero every byte up to ws->initOnceStart.
414 * Note that we assume here that MSAN and ASAN cannot run in the same time. */
415 ZSTD_memset(ptr, 0, MIN((size_t)((U8*)ws->initOnceStart - (U8*)ptr), alignedBytes));
416 ws->initOnceStart = ptr;
417 }
418#if ZSTD_MEMORY_SANITIZER
419 assert(__msan_test_shadow(ptr, bytes) == -1);
420#endif
421 return ptr;
422}
423
428{
431 assert(((size_t)ptr & (ZSTD_CWKSP_ALIGNMENT_BYTES-1))== 0);
432 return ptr;
433}
434
441{
443 void* alloc;
444 void* end;
445 void* top;
446
447 /* We can only start allocating tables after we are done reserving space for objects at the
448 * start of the workspace */
449 if(ws->phase < phase) {
451 return NULL;
452 }
453 }
454 alloc = ws->tableEnd;
455 end = (BYTE *)alloc + bytes;
456 top = ws->allocStart;
457
458 DEBUGLOG(5, "cwksp: reserving %p table %zd bytes, %zd bytes remaining",
459 alloc, bytes, ZSTD_cwksp_available_space(ws) - bytes);
460 assert((bytes & (sizeof(U32)-1)) == 0);
462 assert(end <= top);
463 if (end > top) {
464 DEBUGLOG(4, "cwksp: table alloc failed!");
465 ws->allocFailed = 1;
466 return NULL;
467 }
468 ws->tableEnd = end;
469
470#if ZSTD_ADDRESS_SANITIZER && !defined (ZSTD_ASAN_DONT_POISON_WORKSPACE)
472 __asan_unpoison_memory_region(alloc, bytes);
473 }
474#endif
475
476 assert((bytes & (ZSTD_CWKSP_ALIGNMENT_BYTES-1)) == 0);
477 assert(((size_t)alloc & (ZSTD_CWKSP_ALIGNMENT_BYTES-1))== 0);
478 return alloc;
479}
480
486{
487 size_t const roundedBytes = ZSTD_cwksp_align(bytes, sizeof(void*));
488 void* alloc = ws->objectEnd;
489 void* end = (BYTE*)alloc + roundedBytes;
490
491#if ZSTD_ADDRESS_SANITIZER && !defined (ZSTD_ASAN_DONT_POISON_WORKSPACE)
492 /* over-reserve space */
493 end = (BYTE *)end + 2 * ZSTD_CWKSP_ASAN_REDZONE_SIZE;
494#endif
495
496 DEBUGLOG(4,
497 "cwksp: reserving %p object %zd bytes (rounded to %zd), %zd bytes remaining",
498 alloc, bytes, roundedBytes, ZSTD_cwksp_available_space(ws) - roundedBytes);
499 assert((size_t)alloc % ZSTD_ALIGNOF(void*) == 0);
500 assert(bytes % ZSTD_ALIGNOF(void*) == 0);
502 /* we must be in the first phase, no advance is possible */
503 if (ws->phase != ZSTD_cwksp_alloc_objects || end > ws->workspaceEnd) {
504 DEBUGLOG(3, "cwksp: object alloc failed!");
505 ws->allocFailed = 1;
506 return NULL;
507 }
508 ws->objectEnd = end;
509 ws->tableEnd = end;
510 ws->tableValidEnd = end;
511
512#if ZSTD_ADDRESS_SANITIZER && !defined (ZSTD_ASAN_DONT_POISON_WORKSPACE)
513 /* Move alloc so there's ZSTD_CWKSP_ASAN_REDZONE_SIZE unused space on
514 * either size. */
515 alloc = (BYTE*)alloc + ZSTD_CWKSP_ASAN_REDZONE_SIZE;
517 __asan_unpoison_memory_region(alloc, bytes);
518 }
519#endif
520
521 return alloc;
522}
523
525{
526 DEBUGLOG(4, "cwksp: ZSTD_cwksp_mark_tables_dirty");
527
528#if ZSTD_MEMORY_SANITIZER && !defined (ZSTD_MSAN_DONT_POISON_WORKSPACE)
529 /* To validate that the table reuse logic is sound, and that we don't
530 * access table space that we haven't cleaned, we re-"poison" the table
531 * space every time we mark it dirty.
532 * Since tableValidEnd space and initOnce space may overlap we don't poison
533 * the initOnce portion as it break its promise. This means that this poisoning
534 * check isn't always applied fully. */
535 {
536 size_t size = (BYTE*)ws->tableValidEnd - (BYTE*)ws->objectEnd;
537 assert(__msan_test_shadow(ws->objectEnd, size) == -1);
538 if((BYTE*)ws->tableValidEnd < (BYTE*)ws->initOnceStart) {
539 __msan_poison(ws->objectEnd, size);
540 } else {
541 assert(ws->initOnceStart >= ws->objectEnd);
542 __msan_poison(ws->objectEnd, (BYTE*)ws->initOnceStart - (BYTE*)ws->objectEnd);
543 }
544 }
545#endif
546
547 assert(ws->tableValidEnd >= ws->objectEnd);
548 assert(ws->tableValidEnd <= ws->allocStart);
549 ws->tableValidEnd = ws->objectEnd;
551}
552
554 DEBUGLOG(4, "cwksp: ZSTD_cwksp_mark_tables_clean");
555 assert(ws->tableValidEnd >= ws->objectEnd);
556 assert(ws->tableValidEnd <= ws->allocStart);
557 if (ws->tableValidEnd < ws->tableEnd) {
558 ws->tableValidEnd = ws->tableEnd;
559 }
561}
562
567 DEBUGLOG(4, "cwksp: ZSTD_cwksp_clean_tables");
568 assert(ws->tableValidEnd >= ws->objectEnd);
569 assert(ws->tableValidEnd <= ws->allocStart);
570 if (ws->tableValidEnd < ws->tableEnd) {
571 ZSTD_memset(ws->tableValidEnd, 0, (size_t)((BYTE*)ws->tableEnd - (BYTE*)ws->tableValidEnd));
572 }
574}
575
581 DEBUGLOG(4, "cwksp: clearing tables!");
582
583#if ZSTD_ADDRESS_SANITIZER && !defined (ZSTD_ASAN_DONT_POISON_WORKSPACE)
584 /* We don't do this when the workspace is statically allocated, because
585 * when that is the case, we have no capability to hook into the end of the
586 * workspace's lifecycle to unpoison the memory.
587 */
589 size_t size = (BYTE*)ws->tableValidEnd - (BYTE*)ws->objectEnd;
590 __asan_poison_memory_region(ws->objectEnd, size);
591 }
592#endif
593
594 ws->tableEnd = ws->objectEnd;
596}
597
603 DEBUGLOG(4, "cwksp: clearing!");
604
605#if ZSTD_MEMORY_SANITIZER && !defined (ZSTD_MSAN_DONT_POISON_WORKSPACE)
606 /* To validate that the context reuse logic is sound, and that we don't
607 * access stuff that this compression hasn't initialized, we re-"poison"
608 * the workspace except for the areas in which we expect memory reuse
609 * without initialization (objects, valid tables area and init once
610 * memory). */
611 {
612 if((BYTE*)ws->tableValidEnd < (BYTE*)ws->initOnceStart) {
613 size_t size = (BYTE*)ws->initOnceStart - (BYTE*)ws->tableValidEnd;
614 __msan_poison(ws->tableValidEnd, size);
615 }
616 }
617#endif
618
619#if ZSTD_ADDRESS_SANITIZER && !defined (ZSTD_ASAN_DONT_POISON_WORKSPACE)
620 /* We don't do this when the workspace is statically allocated, because
621 * when that is the case, we have no capability to hook into the end of the
622 * workspace's lifecycle to unpoison the memory.
623 */
625 size_t size = (BYTE*)ws->workspaceEnd - (BYTE*)ws->objectEnd;
626 __asan_poison_memory_region(ws->objectEnd, size);
627 }
628#endif
629
630 ws->tableEnd = ws->objectEnd;
632 ws->allocFailed = 0;
635 }
637}
638
640 return (size_t)((BYTE*)ws->workspaceEnd - (BYTE*)ws->workspace);
641}
642
644 return (size_t)((BYTE*)ws->tableEnd - (BYTE*)ws->workspace)
645 + (size_t)((BYTE*)ws->workspaceEnd - (BYTE*)ws->allocStart);
646}
647
653MEM_STATIC void ZSTD_cwksp_init(ZSTD_cwksp* ws, void* start, size_t size, ZSTD_cwksp_static_alloc_e isStatic) {
654 DEBUGLOG(4, "cwksp: init'ing workspace with %zd bytes", size);
655 assert(((size_t)start & (sizeof(void*)-1)) == 0); /* ensure correct alignment */
656 ws->workspace = start;
657 ws->workspaceEnd = (BYTE*)start + size;
658 ws->objectEnd = ws->workspace;
659 ws->tableValidEnd = ws->objectEnd;
662 ws->isStatic = isStatic;
666}
667
668MEM_STATIC size_t ZSTD_cwksp_create(ZSTD_cwksp* ws, size_t size, ZSTD_customMem customMem) {
669 void* workspace = ZSTD_customMalloc(size, customMem);
670 DEBUGLOG(4, "cwksp: creating new workspace with %zd bytes", size);
671 RETURN_ERROR_IF(workspace == NULL, memory_allocation, "NULL pointer!");
672 ZSTD_cwksp_init(ws, workspace, size, ZSTD_cwksp_dynamic_alloc);
673 return 0;
674}
675
676MEM_STATIC void ZSTD_cwksp_free(ZSTD_cwksp* ws, ZSTD_customMem customMem) {
677 void *ptr = ws->workspace;
678 DEBUGLOG(4, "cwksp: freeing workspace");
679#if ZSTD_MEMORY_SANITIZER && !defined(ZSTD_MSAN_DONT_POISON_WORKSPACE)
680 if (ptr != NULL && customMem.customFree != NULL) {
681 __msan_unpoison(ptr, ZSTD_cwksp_sizeof(ws));
682 }
683#endif
684 ZSTD_memset(ws, 0, sizeof(ZSTD_cwksp));
685 ZSTD_customFree(ptr, customMem);
686}
687
693 *dst = *src;
694 ZSTD_memset(src, 0, sizeof(ZSTD_cwksp));
695}
696
698 return ws->allocFailed;
699}
700
701/*-*************************************
702* Functions Checking Free Space
703***************************************/
704
705/* ZSTD_alignmentSpaceWithinBounds() :
706 * Returns if the estimated space needed for a wksp is within an acceptable limit of the
707 * actual amount of space used.
708 */
709MEM_STATIC int ZSTD_cwksp_estimated_space_within_bounds(const ZSTD_cwksp *const ws, size_t const estimatedSpace) {
710 /* We have an alignment space between objects and tables between tables and buffers, so we can have up to twice
711 * the alignment bytes difference between estimation and actual usage */
712 return (estimatedSpace - ZSTD_cwksp_slack_space_required()) <= ZSTD_cwksp_used(ws) &&
713 ZSTD_cwksp_used(ws) <= estimatedSpace;
714}
715
716
718 return (size_t)((BYTE*)ws->allocStart - (BYTE*)ws->tableEnd);
719}
720
721MEM_STATIC int ZSTD_cwksp_check_available(ZSTD_cwksp* ws, size_t additionalNeededSpace) {
722 return ZSTD_cwksp_available_space(ws) >= additionalNeededSpace;
723}
724
725MEM_STATIC int ZSTD_cwksp_check_too_large(ZSTD_cwksp* ws, size_t additionalNeededSpace) {
727 ws, additionalNeededSpace * ZSTD_WORKSPACETOOLARGE_FACTOR);
728}
729
730MEM_STATIC int ZSTD_cwksp_check_wasteful(ZSTD_cwksp* ws, size_t additionalNeededSpace) {
731 return ZSTD_cwksp_check_too_large(ws, additionalNeededSpace)
733}
734
736 ZSTD_cwksp* ws, size_t additionalNeededSpace) {
737 if (ZSTD_cwksp_check_too_large(ws, additionalNeededSpace)) {
739 } else {
741 }
742}
743
744#if defined (__cplusplus)
745}
746#endif
747
748#endif /* ZSTD_CWKSP_H */
MEM_STATIC void ZSTD_customFree(void *ptr, ZSTD_customMem customMem)
Definition: allocations.h:45
MEM_STATIC void * ZSTD_customMalloc(size_t size, ZSTD_customMem customMem)
Definition: allocations.h:26
#define ZSTD_ALIGNOF(T)
Definition: compiler.h:299
#define MEM_STATIC
Definition: compiler.h:103
#define DEBUGLOG(l,...)
Definition: debug.h:108
#define assert(condition)
Definition: debug.h:74
#define RETURN_ERROR_IF(cond, err,...)
unsigned char U8
Definition: mem.h:59
unsigned char BYTE
Definition: mem.h:58
unsigned int U32
Definition: mem.h:69
#define MIN(a, b)
void * tableValidEnd
Definition: zstd_cwksp.h:164
void * workspaceEnd
Definition: zstd_cwksp.h:160
int workspaceOversizedDuration
Definition: zstd_cwksp.h:169
void * tableEnd
Definition: zstd_cwksp.h:163
BYTE allocFailed
Definition: zstd_cwksp.h:168
ZSTD_cwksp_alloc_phase_e phase
Definition: zstd_cwksp.h:170
void * initOnceStart
Definition: zstd_cwksp.h:166
void * objectEnd
Definition: zstd_cwksp.h:162
void * workspace
Definition: zstd_cwksp.h:159
void * allocStart
Definition: zstd_cwksp.h:165
ZSTD_cwksp_static_alloc_e isStatic
Definition: zstd_cwksp.h:171
MEM_STATIC size_t ZSTD_cwksp_create(ZSTD_cwksp *ws, size_t size, ZSTD_customMem customMem)
Definition: zstd_cwksp.h:668
MEM_STATIC size_t ZSTD_cwksp_align(size_t size, size_t const align)
Definition: zstd_cwksp.h:209
MEM_STATIC void ZSTD_cwksp_mark_tables_clean(ZSTD_cwksp *ws)
Definition: zstd_cwksp.h:553
MEM_STATIC int ZSTD_cwksp_reserve_failed(const ZSTD_cwksp *ws)
Definition: zstd_cwksp.h:697
ZSTD_cwksp_static_alloc_e
Definition: zstd_cwksp.h:59
@ ZSTD_cwksp_dynamic_alloc
Definition: zstd_cwksp.h:60
@ ZSTD_cwksp_static_alloc
Definition: zstd_cwksp.h:61
MEM_STATIC void * ZSTD_cwksp_reserve_internal_buffer_space(ZSTD_cwksp *ws, size_t const bytes)
Definition: zstd_cwksp.h:286
MEM_STATIC void ZSTD_cwksp_move(ZSTD_cwksp *dst, ZSTD_cwksp *src)
Definition: zstd_cwksp.h:692
MEM_STATIC size_t ZSTD_cwksp_internal_advance_phase(ZSTD_cwksp *ws, ZSTD_cwksp_alloc_phase_e phase)
Definition: zstd_cwksp.h:314
MEM_STATIC size_t ZSTD_cwksp_used(const ZSTD_cwksp *ws)
Definition: zstd_cwksp.h:643
#define ZSTD_CWKSP_ALIGNMENT_BYTES
Definition: zstd_cwksp.h:42
MEM_STATIC void ZSTD_cwksp_clean_tables(ZSTD_cwksp *ws)
Definition: zstd_cwksp.h:566
MEM_STATIC int ZSTD_cwksp_check_too_large(ZSTD_cwksp *ws, size_t additionalNeededSpace)
Definition: zstd_cwksp.h:725
MEM_STATIC size_t ZSTD_cwksp_bytes_to_align_ptr(void *ptr, const size_t alignBytes)
Definition: zstd_cwksp.h:262
MEM_STATIC void ZSTD_cwksp_clear_tables(ZSTD_cwksp *ws)
Definition: zstd_cwksp.h:580
MEM_STATIC void ZSTD_cwksp_assert_internal_consistency(ZSTD_cwksp *ws)
Definition: zstd_cwksp.h:181
MEM_STATIC int ZSTD_cwksp_owns_buffer(const ZSTD_cwksp *ws, const void *ptr)
Definition: zstd_cwksp.h:347
MEM_STATIC int ZSTD_cwksp_check_wasteful(ZSTD_cwksp *ws, size_t additionalNeededSpace)
Definition: zstd_cwksp.h:730
MEM_STATIC void * ZSTD_cwksp_reserve_aligned_init_once(ZSTD_cwksp *ws, size_t bytes)
Definition: zstd_cwksp.h:403
MEM_STATIC size_t ZSTD_cwksp_sizeof(const ZSTD_cwksp *ws)
Definition: zstd_cwksp.h:639
MEM_STATIC void ZSTD_cwksp_bump_oversized_duration(ZSTD_cwksp *ws, size_t additionalNeededSpace)
Definition: zstd_cwksp.h:735
MEM_STATIC size_t ZSTD_cwksp_slack_space_required(void)
Definition: zstd_cwksp.h:249
MEM_STATIC void ZSTD_cwksp_mark_tables_dirty(ZSTD_cwksp *ws)
Definition: zstd_cwksp.h:524
ZSTD_cwksp_alloc_phase_e
Definition: zstd_cwksp.h:47
@ ZSTD_cwksp_alloc_objects
Definition: zstd_cwksp.h:48
@ ZSTD_cwksp_alloc_buffers
Definition: zstd_cwksp.h:51
@ ZSTD_cwksp_alloc_aligned
Definition: zstd_cwksp.h:50
@ ZSTD_cwksp_alloc_aligned_init_once
Definition: zstd_cwksp.h:49
MEM_STATIC void ZSTD_cwksp_free(ZSTD_cwksp *ws, ZSTD_customMem customMem)
Definition: zstd_cwksp.h:676
MEM_STATIC void * ZSTD_cwksp_reserve_internal(ZSTD_cwksp *ws, size_t bytes, ZSTD_cwksp_alloc_phase_e phase)
Definition: zstd_cwksp.h:356
MEM_STATIC BYTE * ZSTD_cwksp_reserve_buffer(ZSTD_cwksp *ws, size_t bytes)
Definition: zstd_cwksp.h:389
MEM_STATIC int ZSTD_cwksp_estimated_space_within_bounds(const ZSTD_cwksp *const ws, size_t const estimatedSpace)
Definition: zstd_cwksp.h:709
MEM_STATIC void ZSTD_cwksp_clear(ZSTD_cwksp *ws)
Definition: zstd_cwksp.h:602
MEM_STATIC void * ZSTD_cwksp_reserve_object(ZSTD_cwksp *ws, size_t bytes)
Definition: zstd_cwksp.h:485
MEM_STATIC void ZSTD_cwksp_init(ZSTD_cwksp *ws, void *start, size_t size, ZSTD_cwksp_static_alloc_e isStatic)
Definition: zstd_cwksp.h:653
MEM_STATIC size_t ZSTD_cwksp_aligned_alloc_size(size_t size)
Definition: zstd_cwksp.h:241
MEM_STATIC size_t ZSTD_cwksp_alloc_size(size_t size)
Definition: zstd_cwksp.h:227
MEM_STATIC int ZSTD_cwksp_check_available(ZSTD_cwksp *ws, size_t additionalNeededSpace)
Definition: zstd_cwksp.h:721
MEM_STATIC void * ZSTD_cwksp_initialAllocStart(ZSTD_cwksp *ws)
Definition: zstd_cwksp.h:274
MEM_STATIC void * ZSTD_cwksp_reserve_table(ZSTD_cwksp *ws, size_t bytes)
Definition: zstd_cwksp.h:440
#define ZSTD_CWKSP_ASAN_REDZONE_SIZE
Definition: zstd_cwksp.h:37
MEM_STATIC void * ZSTD_cwksp_reserve_aligned(ZSTD_cwksp *ws, size_t bytes)
Definition: zstd_cwksp.h:427
MEM_STATIC size_t ZSTD_cwksp_available_space(ZSTD_cwksp *ws)
Definition: zstd_cwksp.h:717
#define ZSTD_memset(p, v, l)
Definition: zstd_deps.h:38
#define ZSTD_WORKSPACETOOLARGE_MAXDURATION
#define ZSTD_isError
Definition: zstd_internal.h:48
#define ZSTD_WORKSPACETOOLARGE_FACTOR