2 * Copyright (c) Yann Collet, Meta Platforms, Inc.
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.
11 #include "fuzz_third_party_seq_prod.h"
17 _Thread_local size_t threadLocalState;
19 size_t FUZZ_seqProdSetup(void) {
24 size_t FUZZ_seqProdTearDown(void) {
28 void* FUZZ_createSeqProdState(void) {
29 return calloc(1, sizeof(size_t));
32 size_t FUZZ_freeSeqProdState(void* state) {
37 size_t FUZZ_thirdPartySeqProd(
38 void* sequenceProducerState,
39 ZSTD_Sequence* outSeqs, size_t outSeqsCapacity,
40 const void* src, size_t srcSize,
41 const void* dict, size_t dictSize,
45 /* Try to catch unsafe use of the shared state */
46 size_t* const sharedStatePtr = (size_t*)sequenceProducerState;
47 assert(*sharedStatePtr == threadLocalState);
48 (*sharedStatePtr)++; threadLocalState++;
50 /* Check that fallback is enabled when FUZZ_THIRD_PARTY_SEQ_PROD is defined */
51 return ZSTD_SEQUENCE_PRODUCER_ERROR;