Add jit.security().

This commit is contained in:
Mike Pall 2020-06-23 03:12:32 +02:00
parent ff34b48ddd
commit 2e68e1fc18
2 changed files with 17 additions and 0 deletions

View File

@ -113,6 +113,13 @@ LJLIB_CF(jit_status)
#endif
}
LJLIB_CF(jit_security)
{
int idx = lj_lib_checkopt(L, 1, -1, LJ_SECURITY_MODESTRING);
setintV(L->top++, ((LJ_SECURITY_MODE >> (2*idx)) & 3));
return 1;
}
LJLIB_CF(jit_attach)
{
#ifdef LUAJIT_DISABLE_VMEVENT

View File

@ -665,4 +665,14 @@ extern void *LJ_WIN_LOADLIBA(const char *path);
#define LUAJIT_SECURITY_MCODE 1
#endif
#define LJ_SECURITY_MODE \
( 0u \
| ((LUAJIT_SECURITY_PRNG & 3) << 0) \
| ((LUAJIT_SECURITY_STRHASH & 3) << 2) \
| ((LUAJIT_SECURITY_STRID & 3) << 4) \
| ((LUAJIT_SECURITY_MCODE & 3) << 6) \
)
#define LJ_SECURITY_MODESTRING \
"\004prng\007strhash\005strid\005mcode"
#endif