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