1*8c784bb8SWarner Losh /* 2*8c784bb8SWarner Losh * Copyright (c) 2023, Netflix, Inc 3*8c784bb8SWarner Losh * 4*8c784bb8SWarner Losh * SPDX-License-Identifier: BSD-2-Clause 5*8c784bb8SWarner Losh */ 6*8c784bb8SWarner Losh 7*8c784bb8SWarner Losh #pragma once 8*8c784bb8SWarner Losh /* 9*8c784bb8SWarner Losh * We need to always define this. For the boot loader, we use it. For flua 10*8c784bb8SWarner Losh * we don't, but it needs to be defined to keep some ifdefs happy. 11*8c784bb8SWarner Losh */ 12*8c784bb8SWarner Losh #define LUA_FLOAT_INT64 4 13*8c784bb8SWarner Losh 14*8c784bb8SWarner Losh /* set the paths we want */ 15*8c784bb8SWarner Losh #undef LUA_ROOT 16*8c784bb8SWarner Losh #undef LUA_LDIR 17*8c784bb8SWarner Losh #undef LUA_CDIR 18*8c784bb8SWarner Losh #define LUA_ROOT LUA_PATH "/" LUA_VDIR "/" 19*8c784bb8SWarner Losh #define LUA_LDIR LUA_ROOT "share/" 20*8c784bb8SWarner Losh #define LUA_CDIR LUA_ROOT "lib/" 21*8c784bb8SWarner Losh 22*8c784bb8SWarner Losh /* Simplify this, since it's always an int */ 23*8c784bb8SWarner Losh #undef lua_numbertointeger 24*8c784bb8SWarner Losh #define lua_numbertointeger(n,p) \ 25*8c784bb8SWarner Losh (*(p) = (LUA_INTEGER)(n), 1) 26*8c784bb8SWarner Losh 27*8c784bb8SWarner Losh /* Define our number type by brute force, but first undo the default defines */ 28*8c784bb8SWarner Losh #undef panic 29*8c784bb8SWarner Losh #undef LUA_NUMBER 30*8c784bb8SWarner Losh #undef l_floatatt 31*8c784bb8SWarner Losh #undef LUAI_UACNUMBER 32*8c784bb8SWarner Losh #undef LUA_NUMBER_FRMLEN 33*8c784bb8SWarner Losh #undef LUA_NUMBER_FMT 34*8c784bb8SWarner Losh #undef l_mathop 35*8c784bb8SWarner Losh #undef lua_str2number 36*8c784bb8SWarner Losh #undef lua_getlocaledecpoint 37*8c784bb8SWarner Losh 38*8c784bb8SWarner Losh #undef LUA_FLOAT_TYPE 39*8c784bb8SWarner Losh #define LUA_FLOAT_TYPE LUA_FLOAT_INT64 40*8c784bb8SWarner Losh 41*8c784bb8SWarner Losh #include "lstd.h" 42*8c784bb8SWarner Losh 43*8c784bb8SWarner Losh #include <machine/_inttypes.h> 44*8c784bb8SWarner Losh 45*8c784bb8SWarner Losh #define panic lua_panic 46*8c784bb8SWarner Losh /* Hack to use int64 as the LUA_NUMBER from ZFS code, kinda */ 47*8c784bb8SWarner Losh 48*8c784bb8SWarner Losh #define LUA_NUMBER int64_t 49*8c784bb8SWarner Losh 50*8c784bb8SWarner Losh #define l_floatatt(n) (LUA_FLOAT_INT_HACK_##n) 51*8c784bb8SWarner Losh #define LUA_FLOAT_INT_HACK_MANT_DIG 32 52*8c784bb8SWarner Losh #define LUA_FLOAT_INT_HACK_MAX_10_EXP 32 53*8c784bb8SWarner Losh 54*8c784bb8SWarner Losh #define LUAI_UACNUMBER int64_t 55*8c784bb8SWarner Losh 56*8c784bb8SWarner Losh #define LUA_NUMBER_FRMLEN "" 57*8c784bb8SWarner Losh #define LUA_NUMBER_FMT "%" PRId64 58*8c784bb8SWarner Losh 59*8c784bb8SWarner Losh #define l_mathop(x) (lstd_ ## x) 60*8c784bb8SWarner Losh 61*8c784bb8SWarner Losh #define lua_str2number(s,p) strtoll((s), (p), 0) 62*8c784bb8SWarner Losh 63*8c784bb8SWarner Losh #define lua_getlocaledecpoint() '.' 64*8c784bb8SWarner Losh 65*8c784bb8SWarner Losh /* Better buffer size */ 66*8c784bb8SWarner Losh #undef LUAL_BUFFERSIZE 67*8c784bb8SWarner Losh #define LUAL_BUFFERSIZE 128 68*8c784bb8SWarner Losh 69*8c784bb8SWarner Losh /* Maxalign can't reference double */ 70*8c784bb8SWarner Losh #undef LUAI_MAXALIGN 71*8c784bb8SWarner Losh #define LUAI_MAXALIGN lua_Number n; void *s; lua_Integer i; long l 72*8c784bb8SWarner Losh 73*8c784bb8SWarner Losh #define LUA_AVOID_FLOAT 74