#ifndef DATABASE_H_D467FD6F343DDE
#define DATABASE_H_D467FD6F343DDE
#ifdef __cplusplus
extern "C"
{
#endif
#include "hs_compile.h"
#include "hs_version.h"
#include "ue2common.h"
#include "util/arch.h"
#define HS_DB_VERSION HS_VERSION_32BIT
#define HS_DB_MAGIC (0xdbdbdbdbU)
#define HS_PLATFORM_INTEL 1
#define HS_PLATFORM_CPU_MASK 0x3F
#define HS_PLATFORM_NOAVX2 (4<<13)
#define HS_PLATFORM_NOAVX512 (8<<13)
#define HS_PLATFORM_NOAVX512VBMI (0x10<<13)
typedef u64a platform_t;
static UNUSED
const platform_t hs_current_platform = {
#if !defined(HAVE_AVX2)
HS_PLATFORM_NOAVX2 |
#endif
#if !defined(HAVE_AVX512)
HS_PLATFORM_NOAVX512 |
#endif
#if !defined(HAVE_AVX512VBMI)
HS_PLATFORM_NOAVX512VBMI |
#endif
0,
};
static UNUSED
const platform_t hs_current_platform_no_avx2 = {
HS_PLATFORM_NOAVX2 |
HS_PLATFORM_NOAVX512 |
HS_PLATFORM_NOAVX512VBMI |
0,
};
static UNUSED
const platform_t hs_current_platform_no_avx512 = {
HS_PLATFORM_NOAVX512 |
HS_PLATFORM_NOAVX512VBMI |
0,
};
static UNUSED
const platform_t hs_current_platform_no_avx512vbmi = {
HS_PLATFORM_NOAVX512VBMI |
0,
};
struct hs_database {
u32 magic;
u32 version;
u32 length;
u64a platform;
u32 crc32;
u32 reserved0;
u32 reserved1;
u32 bytecode; u32 padding[16];
char bytes[];
};
static really_inline
const void *hs_get_bytecode(const struct hs_database *db) {
return ((const char *)db + db->bytecode);
}
static really_inline
hs_error_t validDatabase(const hs_database_t *db) {
if (!db || db->magic != HS_DB_MAGIC) {
return HS_INVALID;
}
if (db->version != HS_DB_VERSION) {
return HS_DB_VERSION_ERROR;
}
return HS_SUCCESS;
}
hs_error_t dbIsValid(const struct hs_database *db);
#ifdef __cplusplus
}
#endif
#endif