mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-10-10 00:02:24 +03:00
runtime: add error for "scratch in use"
This commit adds the HS_SCRATCH_IN_USE error, which is returned when Hyperscan detects that a scratch region is already in use on entry to an API function.
This commit is contained in:
committed by
Matthew Barr
parent
11896dcf42
commit
c12b953131
@@ -140,6 +140,7 @@ struct match_deduper {
|
||||
*/
|
||||
struct ALIGN_CL_DIRECTIVE hs_scratch {
|
||||
u32 magic;
|
||||
u8 in_use; /**< non-zero when being used by an API call. */
|
||||
char *scratch_alloc; /* user allocated scratch object */
|
||||
u32 queueCount;
|
||||
u32 bStateSize; /**< sizeof block mode states */
|
||||
@@ -198,6 +199,34 @@ char can_stop_matching(const struct hs_scratch *scratch) {
|
||||
return scratch->core_info.status & (STATUS_TERMINATED | STATUS_EXHAUSTED);
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Mark scratch as in use.
|
||||
*
|
||||
* Returns non-zero if it was already in use, zero otherwise.
|
||||
*/
|
||||
static really_inline
|
||||
char markScratchInUse(struct hs_scratch *scratch) {
|
||||
DEBUG_PRINTF("marking scratch as in use\n");
|
||||
assert(scratch && scratch->magic == SCRATCH_MAGIC);
|
||||
if (scratch->in_use) {
|
||||
DEBUG_PRINTF("scratch already in use!\n");
|
||||
return 1;
|
||||
}
|
||||
scratch->in_use = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Mark scratch as no longer in use.
|
||||
*/
|
||||
static really_inline
|
||||
void unmarkScratchInUse(struct hs_scratch *scratch) {
|
||||
DEBUG_PRINTF("marking scratch as not in use\n");
|
||||
assert(scratch && scratch->magic == SCRATCH_MAGIC);
|
||||
assert(scratch->in_use == 1);
|
||||
scratch->in_use = 0;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user