hs_runtime.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621
  1. /*
  2. * Copyright (c) 2015-2018, Intel Corporation
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions are met:
  6. *
  7. * * Redistributions of source code must retain the above copyright notice,
  8. * this list of conditions and the following disclaimer.
  9. * * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * * Neither the name of Intel Corporation nor the names of its contributors
  13. * may be used to endorse or promote products derived from this software
  14. * without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  17. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  18. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  19. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  20. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  21. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  22. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  23. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  24. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  25. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  26. * POSSIBILITY OF SUCH DAMAGE.
  27. */
  28. #ifndef HS_AVX512_RUNTIME_H
  29. #define HS_AVX512_RUNTIME_H
  30. #include <stdlib.h>
  31. /**
  32. * @file
  33. * @brief The Hyperscan runtime API definition.
  34. *
  35. * Hyperscan is a high speed regular expression engine.
  36. *
  37. * This header contains functions for using compiled Hyperscan databases for
  38. * scanning data at runtime.
  39. */
  40. #include "hs_common.h"
  41. #ifdef __cplusplus
  42. extern "C"
  43. {
  44. #endif
  45. /**
  46. * Definition of the stream identifier type.
  47. */
  48. struct hs_stream;
  49. /**
  50. * The stream identifier returned by @ref hs_open_stream().
  51. */
  52. typedef struct hs_stream hs_stream_t;
  53. struct hs_scratch;
  54. /**
  55. * A Hyperscan scratch space.
  56. */
  57. typedef struct hs_scratch hs_scratch_t;
  58. /**
  59. * Definition of the match event callback function type.
  60. *
  61. * A callback function matching the defined type must be provided by the
  62. * application calling the @ref hs_scan(), @ref hs_scan_vector() or @ref
  63. * hs_scan_stream() functions (or other streaming calls which can produce
  64. * matches).
  65. *
  66. * This callback function will be invoked whenever a match is located in the
  67. * target data during the execution of a scan. The details of the match are
  68. * passed in as parameters to the callback function, and the callback function
  69. * should return a value indicating whether or not matching should continue on
  70. * the target data. If no callbacks are desired from a scan call, NULL may be
  71. * provided in order to suppress match production.
  72. *
  73. * This callback function should not attempt to call Hyperscan API functions on
  74. * the same stream nor should it attempt to reuse the scratch space allocated
  75. * for the API calls that caused it to be triggered. Making another call to the
  76. * Hyperscan library with completely independent parameters should work (for
  77. * example, scanning a different database in a new stream and with new scratch
  78. * space), but reusing data structures like stream state and/or scratch space
  79. * will produce undefined behavior.
  80. *
  81. * @param id
  82. * The ID number of the expression that matched. If the expression was a
  83. * single expression compiled with @ref hs_compile(), this value will be
  84. * zero.
  85. *
  86. * @param from
  87. * - If a start of match flag is enabled for the current pattern, this
  88. * argument will be set to the start of match for the pattern assuming
  89. * that that start of match value lies within the current 'start of match
  90. * horizon' chosen by one of the SOM_HORIZON mode flags.
  91. * - If the start of match value lies outside this horizon (possible only
  92. * when the SOM_HORIZON value is not @ref HS_MODE_SOM_HORIZON_LARGE),
  93. * the @p from value will be set to @ref HS_OFFSET_PAST_HORIZON.
  94. * - This argument will be set to zero if the Start of Match flag is not
  95. * enabled for the given pattern.
  96. *
  97. * @param to
  98. * The offset after the last byte that matches the expression.
  99. *
  100. * @param flags
  101. * This is provided for future use and is unused at present.
  102. *
  103. * @param context
  104. * The pointer supplied by the user to the @ref hs_scan(), @ref
  105. * hs_scan_vector() or @ref hs_scan_stream() function.
  106. *
  107. * @return
  108. * Non-zero if the matching should cease, else zero. If scanning is
  109. * performed in streaming mode and a non-zero value is returned, any
  110. * subsequent calls to @ref hs_scan_stream() for that stream will
  111. * immediately return with @ref HS_SCAN_TERMINATED.
  112. */
  113. typedef int (HS_CDECL *match_event_handler)(unsigned int id,
  114. unsigned long long from,
  115. unsigned long long to,
  116. unsigned int flags,
  117. void *context);
  118. /**
  119. * Open and initialise a stream.
  120. *
  121. * @param db
  122. * A compiled pattern database.
  123. *
  124. * @param flags
  125. * Flags modifying the behaviour of the stream. This parameter is provided
  126. * for future use and is unused at present.
  127. *
  128. * @param stream
  129. * On success, a pointer to the generated @ref hs_stream_t will be
  130. * returned; NULL on failure.
  131. *
  132. * @return
  133. * @ref HS_SUCCESS on success, other values on failure.
  134. */
  135. hs_error_t avx512_hs_open_stream(const hs_database_t *db, unsigned int flags,
  136. hs_stream_t **stream);
  137. /**
  138. * Write data to be scanned to the opened stream.
  139. *
  140. * This is the function call in which the actual pattern matching takes place
  141. * as data is written to the stream. Matches will be returned via the @ref
  142. * match_event_handler callback supplied.
  143. *
  144. * @param id
  145. * The stream ID (returned by @ref hs_open_stream()) to which the data
  146. * will be written.
  147. *
  148. * @param data
  149. * Pointer to the data to be scanned.
  150. *
  151. * @param length
  152. * The number of bytes to scan.
  153. *
  154. * @param flags
  155. * Flags modifying the behaviour of the stream. This parameter is provided
  156. * for future use and is unused at present.
  157. *
  158. * @param scratch
  159. * A per-thread scratch space allocated by @ref hs_alloc_scratch().
  160. *
  161. * @param onEvent
  162. * Pointer to a match event callback function. If a NULL pointer is given,
  163. * no matches will be returned.
  164. *
  165. * @param ctxt
  166. * The user defined pointer which will be passed to the callback function
  167. * when a match occurs.
  168. *
  169. * @return
  170. * Returns @ref HS_SUCCESS on success; @ref HS_SCAN_TERMINATED if the
  171. * match callback indicated that scanning should stop; other values on
  172. * error.
  173. */
  174. hs_error_t avx512_hs_scan_stream(hs_stream_t *id, const char *data,
  175. unsigned int length, unsigned int flags,
  176. hs_scratch_t *scratch,
  177. match_event_handler onEvent, void *ctxt);
  178. /**
  179. * Close a stream.
  180. *
  181. * This function completes matching on the given stream and frees the memory
  182. * associated with the stream state. After this call, the stream pointed to by
  183. * @p id is invalid and can no longer be used. To reuse the stream state after
  184. * completion, rather than closing it, the @ref hs_reset_stream function can be
  185. * used.
  186. *
  187. * This function must be called for any stream created with @ref
  188. * hs_open_stream(), even if scanning has been terminated by a non-zero return
  189. * from the match callback function.
  190. *
  191. * Note: This operation may result in matches being returned (via calls to the
  192. * match event callback) for expressions anchored to the end of the data stream
  193. * (for example, via the use of the `$` meta-character). If these matches are
  194. * not desired, NULL may be provided as the @ref match_event_handler callback.
  195. *
  196. * If NULL is provided as the @ref match_event_handler callback, it is
  197. * permissible to provide a NULL scratch.
  198. *
  199. * @param id
  200. * The stream ID returned by @ref hs_open_stream().
  201. *
  202. * @param scratch
  203. * A per-thread scratch space allocated by @ref hs_alloc_scratch(). This is
  204. * allowed to be NULL only if the @p onEvent callback is also NULL.
  205. *
  206. * @param onEvent
  207. * Pointer to a match event callback function. If a NULL pointer is given,
  208. * no matches will be returned.
  209. *
  210. * @param ctxt
  211. * The user defined pointer which will be passed to the callback function
  212. * when a match occurs.
  213. *
  214. * @return
  215. * Returns @ref HS_SUCCESS on success, other values on failure.
  216. */
  217. hs_error_t avx512_hs_close_stream(hs_stream_t *id, hs_scratch_t *scratch,
  218. match_event_handler onEvent, void *ctxt);
  219. /**
  220. * Reset a stream to an initial state.
  221. *
  222. * Conceptually, this is equivalent to performing @ref hs_close_stream() on the
  223. * given stream, followed by a @ref hs_open_stream(). This new stream replaces
  224. * the original stream in memory, avoiding the overhead of freeing the old
  225. * stream and allocating the new one.
  226. *
  227. * Note: This operation may result in matches being returned (via calls to the
  228. * match event callback) for expressions anchored to the end of the original
  229. * data stream (for example, via the use of the `$` meta-character). If these
  230. * matches are not desired, NULL may be provided as the @ref match_event_handler
  231. * callback.
  232. *
  233. * Note: the stream will also be tied to the same database.
  234. *
  235. * @param id
  236. * The stream (as created by @ref hs_open_stream()) to be replaced.
  237. *
  238. * @param flags
  239. * Flags modifying the behaviour of the stream. This parameter is provided
  240. * for future use and is unused at present.
  241. *
  242. * @param scratch
  243. * A per-thread scratch space allocated by @ref hs_alloc_scratch(). This is
  244. * allowed to be NULL only if the @p onEvent callback is also NULL.
  245. *
  246. * @param onEvent
  247. * Pointer to a match event callback function. If a NULL pointer is given,
  248. * no matches will be returned.
  249. *
  250. * @param context
  251. * The user defined pointer which will be passed to the callback function
  252. * when a match occurs.
  253. *
  254. * @return
  255. * @ref HS_SUCCESS on success, other values on failure.
  256. */
  257. hs_error_t avx512_hs_reset_stream(hs_stream_t *id, unsigned int flags,
  258. hs_scratch_t *scratch,
  259. match_event_handler onEvent, void *context);
  260. /**
  261. * Duplicate the given stream. The new stream will have the same state as the
  262. * original including the current stream offset.
  263. *
  264. * @param to_id
  265. * On success, a pointer to the new, copied @ref hs_stream_t will be
  266. * returned; NULL on failure.
  267. *
  268. * @param from_id
  269. * The stream (as created by @ref hs_open_stream()) to be copied.
  270. *
  271. * @return
  272. * @ref HS_SUCCESS on success, other values on failure.
  273. */
  274. hs_error_t avx512_hs_copy_stream(hs_stream_t **to_id,
  275. const hs_stream_t *from_id);
  276. /**
  277. * Duplicate the given 'from' stream state onto the 'to' stream. The 'to' stream
  278. * will first be reset (reporting any EOD matches if a non-NULL @p onEvent
  279. * callback handler is provided).
  280. *
  281. * Note: the 'to' stream and the 'from' stream must be open against the same
  282. * database.
  283. *
  284. * @param to_id
  285. * On success, a pointer to the new, copied @ref hs_stream_t will be
  286. * returned; NULL on failure.
  287. *
  288. * @param from_id
  289. * The stream (as created by @ref hs_open_stream()) to be copied.
  290. *
  291. * @param scratch
  292. * A per-thread scratch space allocated by @ref hs_alloc_scratch(). This is
  293. * allowed to be NULL only if the @p onEvent callback is also NULL.
  294. *
  295. * @param onEvent
  296. * Pointer to a match event callback function. If a NULL pointer is given,
  297. * no matches will be returned.
  298. *
  299. * @param context
  300. * The user defined pointer which will be passed to the callback function
  301. * when a match occurs.
  302. *
  303. * @return
  304. * @ref HS_SUCCESS on success, other values on failure.
  305. */
  306. hs_error_t avx512_hs_reset_and_copy_stream(hs_stream_t *to_id,
  307. const hs_stream_t *from_id,
  308. hs_scratch_t *scratch,
  309. match_event_handler onEvent,
  310. void *context);
  311. /**
  312. * Creates a compressed representation of the provided stream in the buffer
  313. * provided. This compressed representation can be converted back into a stream
  314. * state by using @ref hs_expand_stream() or @ref hs_reset_and_expand_stream().
  315. * The size of the compressed representation will be placed into @p used_space.
  316. *
  317. * If there is not sufficient space in the buffer to hold the compressed
  318. * representation, @ref HS_INSUFFICIENT_SPACE will be returned and @p used_space
  319. * will be populated with the amount of space required.
  320. *
  321. * Note: this function does not close the provided stream, you may continue to
  322. * use the stream or to free it with @ref hs_close_stream().
  323. *
  324. * @param stream
  325. * The stream (as created by @ref hs_open_stream()) to be compressed.
  326. *
  327. * @param buf
  328. * Buffer to write the compressed representation into. Note: if the call is
  329. * just being used to determine the amount of space required, it is allowed
  330. * to pass NULL here and @p buf_space as 0.
  331. *
  332. * @param buf_space
  333. * The number of bytes in @p buf. If buf_space is too small, the call will
  334. * fail with @ref HS_INSUFFICIENT_SPACE.
  335. *
  336. * @param used_space
  337. * Pointer to where the amount of used space will be written to. The used
  338. * buffer space is always less than or equal to @p buf_space. If the call
  339. * fails with @ref HS_INSUFFICIENT_SPACE, this pointer will be used to
  340. * write out the amount of buffer space required.
  341. *
  342. * @return
  343. * @ref HS_SUCCESS on success, @ref HS_INSUFFICIENT_SPACE if the provided
  344. * buffer is too small.
  345. */
  346. hs_error_t avx512_hs_compress_stream(const hs_stream_t *stream, char *buf,
  347. size_t buf_space, size_t *used_space);
  348. /**
  349. * Decompresses a compressed representation created by @ref hs_compress_stream()
  350. * into a new stream.
  351. *
  352. * Note: @p buf must correspond to a complete compressed representation created
  353. * by @ref hs_compress_stream() of a stream that was opened against @p db. It is
  354. * not always possible to detect misuse of this API and behaviour is undefined
  355. * if these properties are not satisfied.
  356. *
  357. * @param db
  358. * The compiled pattern database that the compressed stream was opened
  359. * against.
  360. *
  361. * @param stream
  362. * On success, a pointer to the expanded @ref hs_stream_t will be
  363. * returned; NULL on failure.
  364. *
  365. * @param buf
  366. * A compressed representation of a stream. These compressed forms are
  367. * created by @ref hs_compress_stream().
  368. *
  369. * @param buf_size
  370. * The size in bytes of the compressed representation.
  371. *
  372. * @return
  373. * @ref HS_SUCCESS on success, other values on failure.
  374. */
  375. hs_error_t avx512_hs_expand_stream(const hs_database_t *db,
  376. hs_stream_t **stream, const char *buf,
  377. size_t buf_size);
  378. /**
  379. * Decompresses a compressed representation created by @ref hs_compress_stream()
  380. * on top of the 'to' stream. The 'to' stream will first be reset (reporting
  381. * any EOD matches if a non-NULL @p onEvent callback handler is provided).
  382. *
  383. * Note: the 'to' stream must be opened against the same database as the
  384. * compressed stream.
  385. *
  386. * Note: @p buf must correspond to a complete compressed representation created
  387. * by @ref hs_compress_stream() of a stream that was opened against @p db. It is
  388. * not always possible to detect misuse of this API and behaviour is undefined
  389. * if these properties are not satisfied.
  390. *
  391. * @param to_stream
  392. * A pointer to a valid stream state. A pointer to the expanded @ref
  393. * hs_stream_t will be returned; NULL on failure.
  394. *
  395. * @param buf
  396. * A compressed representation of a stream. These compressed forms are
  397. * created by @ref hs_compress_stream().
  398. *
  399. * @param buf_size
  400. * The size in bytes of the compressed representation.
  401. *
  402. * @param scratch
  403. * A per-thread scratch space allocated by @ref hs_alloc_scratch(). This is
  404. * allowed to be NULL only if the @p onEvent callback is also NULL.
  405. *
  406. * @param onEvent
  407. * Pointer to a match event callback function. If a NULL pointer is given,
  408. * no matches will be returned.
  409. *
  410. * @param context
  411. * The user defined pointer which will be passed to the callback function
  412. * when a match occurs.
  413. *
  414. * @return
  415. * @ref HS_SUCCESS on success, other values on failure.
  416. */
  417. hs_error_t avx512_hs_reset_and_expand_stream(hs_stream_t *to_stream,
  418. const char *buf, size_t buf_size,
  419. hs_scratch_t *scratch,
  420. match_event_handler onEvent,
  421. void *context);
  422. /**
  423. * The block (non-streaming) regular expression scanner.
  424. *
  425. * This is the function call in which the actual pattern matching takes place
  426. * for block-mode pattern databases.
  427. *
  428. * @param db
  429. * A compiled pattern database.
  430. *
  431. * @param data
  432. * Pointer to the data to be scanned.
  433. *
  434. * @param length
  435. * The number of bytes to scan.
  436. *
  437. * @param flags
  438. * Flags modifying the behaviour of this function. This parameter is
  439. * provided for future use and is unused at present.
  440. *
  441. * @param scratch
  442. * A per-thread scratch space allocated by @ref hs_alloc_scratch() for this
  443. * database.
  444. *
  445. * @param onEvent
  446. * Pointer to a match event callback function. If a NULL pointer is given,
  447. * no matches will be returned.
  448. *
  449. * @param context
  450. * The user defined pointer which will be passed to the callback function.
  451. *
  452. * @return
  453. * Returns @ref HS_SUCCESS on success; @ref HS_SCAN_TERMINATED if the
  454. * match callback indicated that scanning should stop; other values on
  455. * error.
  456. */
  457. hs_error_t avx512_hs_scan(const hs_database_t *db, const char *data,
  458. unsigned int length, unsigned int flags,
  459. hs_scratch_t *scratch, match_event_handler onEvent,
  460. void *context);
  461. /**
  462. * The vectored regular expression scanner.
  463. *
  464. * This is the function call in which the actual pattern matching takes place
  465. * for vectoring-mode pattern databases.
  466. *
  467. * @param db
  468. * A compiled pattern database.
  469. *
  470. * @param data
  471. * An array of pointers to the data blocks to be scanned.
  472. *
  473. * @param length
  474. * An array of lengths (in bytes) of each data block to scan.
  475. *
  476. * @param count
  477. * Number of data blocks to scan. This should correspond to the size of
  478. * of the @p data and @p length arrays.
  479. *
  480. * @param flags
  481. * Flags modifying the behaviour of this function. This parameter is
  482. * provided for future use and is unused at present.
  483. *
  484. * @param scratch
  485. * A per-thread scratch space allocated by @ref hs_alloc_scratch() for
  486. * this database.
  487. *
  488. * @param onEvent
  489. * Pointer to a match event callback function. If a NULL pointer is given,
  490. * no matches will be returned.
  491. *
  492. * @param context
  493. * The user defined pointer which will be passed to the callback function.
  494. *
  495. * @return
  496. * Returns @ref HS_SUCCESS on success; @ref HS_SCAN_TERMINATED if the match
  497. * callback indicated that scanning should stop; other values on error.
  498. */
  499. hs_error_t avx512_hs_scan_vector(const hs_database_t *db,
  500. const char *const *data,
  501. const unsigned int *length,
  502. unsigned int count, unsigned int flags,
  503. hs_scratch_t *scratch,
  504. match_event_handler onEvent, void *context);
  505. /**
  506. * Allocate a "scratch" space for use by Hyperscan.
  507. *
  508. * This is required for runtime use, and one scratch space per thread, or
  509. * concurrent caller, is required. Any allocator callback set by @ref
  510. * hs_set_scratch_allocator() or @ref hs_set_allocator() will be used by this
  511. * function.
  512. *
  513. * @param db
  514. * The database, as produced by @ref hs_compile().
  515. *
  516. * @param scratch
  517. * On first allocation, a pointer to NULL should be provided so a new
  518. * scratch can be allocated. If a scratch block has been previously
  519. * allocated, then a pointer to it should be passed back in to see if it
  520. * is valid for this database block. If a new scratch block is required,
  521. * the original will be freed and the new one returned, otherwise the
  522. * previous scratch block will be returned. On success, the scratch block
  523. * will be suitable for use with the provided database in addition to any
  524. * databases that original scratch space was suitable for.
  525. *
  526. * @return
  527. * @ref HS_SUCCESS on successful allocation; @ref HS_NOMEM if the
  528. * allocation fails. Other errors may be returned if invalid parameters
  529. * are specified.
  530. */
  531. hs_error_t avx512_hs_alloc_scratch(const hs_database_t *db,
  532. hs_scratch_t **scratch);
  533. /**
  534. * Allocate a scratch space that is a clone of an existing scratch space.
  535. *
  536. * This is useful when multiple concurrent threads will be using the same set
  537. * of compiled databases, and another scratch space is required. Any allocator
  538. * callback set by @ref hs_set_scratch_allocator() or @ref hs_set_allocator()
  539. * will be used by this function.
  540. *
  541. * @param src
  542. * The existing @ref hs_scratch_t to be cloned.
  543. *
  544. * @param dest
  545. * A pointer to the new scratch space will be returned here.
  546. *
  547. * @return
  548. * @ref HS_SUCCESS on success; @ref HS_NOMEM if the allocation fails.
  549. * Other errors may be returned if invalid parameters are specified.
  550. */
  551. hs_error_t avx512_hs_clone_scratch(const hs_scratch_t *src,
  552. hs_scratch_t **dest);
  553. /**
  554. * Provides the size of the given scratch space.
  555. *
  556. * @param scratch
  557. * A per-thread scratch space allocated by @ref hs_alloc_scratch() or @ref
  558. * hs_clone_scratch().
  559. *
  560. * @param scratch_size
  561. * On success, the size of the scratch space in bytes is placed in this
  562. * parameter.
  563. *
  564. * @return
  565. * @ref HS_SUCCESS on success, other values on failure.
  566. */
  567. hs_error_t avx512_hs_scratch_size(const hs_scratch_t *scratch,
  568. size_t *scratch_size);
  569. /**
  570. * Free a scratch block previously allocated by @ref hs_alloc_scratch() or @ref
  571. * hs_clone_scratch().
  572. *
  573. * The free callback set by @ref hs_set_scratch_allocator() or @ref
  574. * hs_set_allocator() will be used by this function.
  575. *
  576. * @param scratch
  577. * The scratch block to be freed. NULL may also be safely provided.
  578. *
  579. * @return
  580. * @ref HS_SUCCESS on success, other values on failure.
  581. */
  582. hs_error_t avx512_hs_free_scratch(hs_scratch_t *scratch);
  583. /**
  584. * Callback 'from' return value, indicating that the start of this match was
  585. * too early to be tracked with the requested SOM_HORIZON precision.
  586. */
  587. #define HS_OFFSET_PAST_HORIZON (~0ULL)
  588. #ifdef __cplusplus
  589. } /* extern "C" */
  590. #endif
  591. #endif /* HS_AVX512_RUNTIME_H */