diff --git a/.github/workflows/llvm.yml b/.github/workflows/llvm.yml new file mode 100644 index 0000000..e12ce86 --- /dev/null +++ b/.github/workflows/llvm.yml @@ -0,0 +1,37 @@ +name: CI for LLVM + +on: [push, pull_request] + +jobs: + build: + strategy: + matrix: + llvm_version: [16] + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + submodules: true + - uses: leafo/gh-actions-lua@v9 + with: + luaVersion: "5.4" + - name: Install ckb-debugger + run: | + wget 'https://github.com/nervosnetwork/ckb-standalone-debugger/releases/download/v0.107.0/ckb-debugger-linux-x64.tar.gz' + tar zxvf ckb-debugger-linux-x64.tar.gz + chmod +x ckb-debugger + cp ckb-debugger ~/.cargo/bin + ckb-debugger --version + - name: Install LLVM + run: | + curl -sf -L https://apt.llvm.org/llvm.sh | sudo bash -s -- ${{ matrix.llvm_version }} + - name: Build + run: | + make -f Makefile.clang V=1 LLVM_VERSION=${{ matrix.llvm_version }} + - name: Run cases + run: | + cd tests/official && make ci + cd ../test_cases && make ci-no-dylib + cd ../ckb-c-stdlib-tests && make all-via-docker && make ci diff --git a/.gitmodules b/.gitmodules index 42e95e5..df14d9d 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "include/ckb-c-stdlib"] path = include/ckb-c-stdlib url = https://github.com/nervosnetwork/ckb-c-stdlib.git +[submodule "deps/compiler-rt-builtins-riscv"] + path = deps/compiler-rt-builtins-riscv + url = https://github.com/nervosnetwork/compiler-rt-builtins-riscv.git diff --git a/Makefile b/Makefile index 492b167..f338861 100644 --- a/Makefile +++ b/Makefile @@ -63,7 +63,7 @@ clean-local: rm -f build/libckblua* rm -f build/dylibtest rm -f build/dylibexample - rm -f build/spawnexample + rm -f build/spawnexample* clean: clean-local make -C lualib clean diff --git a/Makefile.clang b/Makefile.clang new file mode 100644 index 0000000..df43e3f --- /dev/null +++ b/Makefile.clang @@ -0,0 +1,71 @@ +CURRENT_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) + +ifeq ($(origin LLVM_VERSION),undefined) + LLVM_VERSION = 16 +endif + +LLVM_SUFFIX = $(if $(LLVM_VERSION),-$(LLVM_VERSION),) +CC := clang${LLVM_SUFFIX} +LD := ld.lld${LLVM_SUFFIX} +OBJCOPY := llvm-objcopy${LLVM_SUFFIX} +AR := llvm-ar${LLVM_SUFFIX} +RANLIB := llvm-ranlib${LLVM_SUFFIX} + +CFLAGS := --target=riscv64 -march=rv64imc_zba_zbb_zbc_zbs +CFLAGS += -D__ISO_C_VISIBLE=1999 -DCKB_DECLARATION_ONLY -DCKB_MALLOC_DECLARATION_ONLY -DCKB_PRINTF_DECLARATION_ONLY -fPIC -g -O3 +CFLAGS += -fno-builtin-printf -fno-builtin-memcmp \ + -nostdinc -nostdlib\ + -fdata-sections -ffunction-sections + +CFLAGS += -I lualib -I lualib/c-stdlib -I include/ckb-c-stdlib -I include/ckb-c-stdlib/libc -I include/ckb-c-stdlib/molecule +CFLAGS += -I deps/compiler-rt-builtins-riscv/compiler-rt/lib/builtins +CFLAGS += -Wall -Werror -Wno-error=unused-command-line-argument -Wno-error=incompatible-library-redeclaration -Wno-error=invalid-noreturn -Wno-error=unused-function + +LDFLAGS := -static --gc-sections +LDFLAGS += -Ldeps/compiler-rt-builtins-riscv/build -lcompiler-rt + +all: lualib/liblua.a build/lua-loader build/spawnexample + +deps/compiler-rt-builtins-riscv/build/libcompiler-rt.a: + cd deps/compiler-rt-builtins-riscv && $(MAKE) CC=$(CC) LD=$(LD) OBJCOPY=$(OBJCOPY) AR=$(AR) RANLIB=$(RANLIB) + +build/stdlib.o: include/ckb-c-stdlib/libc/src/impl.c + @echo $(CC) $(filter-out -DCKB_DECLARATION_ONLY, $(CFLAGS)) -c -o $@ $< + @$(CC) $(filter-out -DCKB_DECLARATION_ONLY, $(CFLAGS)) -c -o $@ $< + +lualib/liblua.a: + make -C lualib -f Makefile.clang CC=$(CC) liblua.a + +build/spawnexample.o: examples/spawn.c + $(CC) -c $(CFLAGS) -o $@ $< + +build/spawnexample: build/spawnexample.o build/stdlib.o deps/compiler-rt-builtins-riscv/build/libcompiler-rt.a + $(LD) $(LDFLAGS) -o $@ $^ + cp $@ $@.debug + $(OBJCOPY) --strip-debug --strip-all $@ + +build/lua-loader.o: lua-loader/lua-loader.c + $(CC) -c $(CFLAGS) -o $@ $< + +build/lua-loader: build/lua-loader.o build/stdlib.o lualib/liblua.a deps/compiler-rt-builtins-riscv/build/libcompiler-rt.a + $(LD) $(LDFLAGS) -o $@ $^ + cp $@ $@.debug + $(OBJCOPY) --strip-debug --strip-all $@ + +fmt: + clang-format -style="{BasedOnStyle: google, IndentWidth: 4, SortIncludes: false}" -i lualib/*.c lualib/*.h lua-loader/*.h lua-loader/*.c include/*.c include/*.h tests/test_cases/*.c + +clean-local: + rm -f build/*.o + rm -f build/lua-loader + rm -f build/lua-loader* + rm -f build/libckblua* + rm -f build/dylibtest + rm -f build/dylibexample + rm -f build/spawnexample* + +clean: clean-local + make -C lualib clean + +run-gdb: + riscv64-unknown-linux-gnu-gdb -ex "target remote 127.0.0.1:${PORT}" build/lua-loader.debug diff --git a/deps/compiler-rt-builtins-riscv b/deps/compiler-rt-builtins-riscv new file mode 160000 index 0000000..5dc696f --- /dev/null +++ b/deps/compiler-rt-builtins-riscv @@ -0,0 +1 @@ +Subproject commit 5dc696f2ace0da6789dbb4b5c33a9cb46f1e7ca2 diff --git a/lua-loader/lua-cell-fs-test.c b/lua-loader/lua-cell-fs-test.c index 7d6f9c6..54469e1 100644 --- a/lua-loader/lua-cell-fs-test.c +++ b/lua-loader/lua-cell-fs-test.c @@ -2,7 +2,7 @@ int dochunk(lua_State *L, int status); -int exit(int c); +void exit(int c); FSFile *ckb_must_get_file(char *filename) { FSFile *file = 0; diff --git a/lua-loader/lua-loader.c b/lua-loader/lua-loader.c index ce8eabb..afe8021 100644 --- a/lua-loader/lua-loader.c +++ b/lua-loader/lua-loader.c @@ -27,9 +27,8 @@ extern void malloc_config(uintptr_t min, uintptr_t max); -int exit(int c) { +void exit(int c) { ckb_exit(c); - return 0; } void enable_local_access(int b); void enable_fs_access(int b); diff --git a/lualib/Makefile.clang b/lualib/Makefile.clang new file mode 100644 index 0000000..366e419 --- /dev/null +++ b/lualib/Makefile.clang @@ -0,0 +1,231 @@ +# Makefile for building Lua +# See ../doc/readme.html for installation and customization instructions. + +# == CHANGE THE SETTINGS BELOW TO SUIT YOUR ENVIRONMENT ======================= + +# Your platform. See PLATS for possible values. +PLAT= guess + +CC ?= clang-16 +# -ULUA_USE_LINUX -ULUA_USE_POSIX to make lua dependencies minimal, +# otherwise, we may unable to find various platform dependent symbols, e.g. +# setsignal. +# __ISO_C_VISIBLE=1999 is needed because lua requires LLONG_MAX to be defined. +# And if __ISO_C_VISIBLE=1999 then LLONG_MAX is defined in ckb-c-stdlib +# See https://github.com/nervosnetwork/ckb-c-stdlib/blob/efe1fe6b3cdda12e248e25664f5c04cbf7876265/libc/limits.h#L94 +# and https://github.com/nervosnetwork/ckb-lua/blob/b71d44288e8fb085074d3af056b359b8c6c22afa/lualib/luaconf.h#L502 +CFLAGS= --target=riscv64 -march=rv64imc_zba_zbb_zbc_zbs -Ic-stdlib -I../include/ckb-c-stdlib -I../include/ckb-c-stdlib/libc -O3 -Wall -Wextra -D__ISO_C_VISIBLE=1999 -DCKB_DECLARATION_ONLY -DCKB_MALLOC_DECLARATION_ONLY -DLUA_COMPAT_5_3 -ULUA_USE_LINUX -ULUA_USE_POSIX -fno-builtin-printf -fno-builtin-memcmp -nostdinc -nostdlib $(SYSCFLAGS) $(MYCFLAGS) +LDFLAGS= $(SYSLDFLAGS) $(MYLDFLAGS) +LIBS= -lm $(SYSLIBS) $(MYLIBS) + +AR= ar rc +RANLIB= ranlib +RM= rm -f +UNAME= uname + +SYSCFLAGS= +SYSLDFLAGS= +SYSLIBS= + +MYCFLAGS=-fPIC -fno-builtin -fdata-sections -ffunction-sections -g -Wno-unused-parameter -Wno-int-to-pointer-cast +MYLDFLAGS= +MYLIBS= +MYOBJS= + +# Special flags for compiler modules; -Os reduces code size. +CMCFLAGS= + +# == END OF USER SETTINGS -- NO NEED TO CHANGE ANYTHING BELOW THIS LINE ======= + +PLATS= guess aix bsd c89 freebsd generic linux linux-readline macosx mingw posix solaris + +LUA_A= liblua.a +CORE_O= lapi.o lcode.o lctype.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o ltm.o lundump.o lvm.o lzio.o +LIB_O= lauxlib.o lbaselib.o lcorolib.o ldblib.o liolib.o lmathlib.o loadlib.o lstrlib.o ltablib.o lutf8lib.o linit.o stdlib.o +BASE_O= $(CORE_O) $(LIB_O) $(MYOBJS) + +LUA_T= lua +LUA_O= lua.o + +LUAC_T= luac +LUAC_O= luac.o + +ALL_O= $(BASE_O) $(LUA_O) $(LUAC_O) +ALL_T= $(LUA_A) $(LUA_T) $(LUAC_T) +ALL_A= $(LUA_A) + +# Targets start here. +default: $(PLAT) + +all: $(ALL_T) + +o: $(ALL_O) + +a: $(ALL_A) + +$(LUA_A): $(BASE_O) + $(AR) $@ $(BASE_O) + $(RANLIB) $@ + +$(LUA_T): $(LUA_O) $(LUA_A) + $(CC) -o $@ $(LDFLAGS) $(LUA_O) $(LUA_A) $(LIBS) + +$(LUAC_T): $(LUAC_O) $(LUA_A) + $(CC) -o $@ $(LDFLAGS) $(LUAC_O) $(LUA_A) $(LIBS) + +test: + ./$(LUA_T) -v + +clean: + $(RM) $(ALL_T) $(ALL_O) + +depend: + @$(CC) $(CFLAGS) -MM l*.c + +echo: + @echo "PLAT= $(PLAT)" + @echo "CC= $(CC)" + @echo "CFLAGS= $(CFLAGS)" + @echo "LDFLAGS= $(LDFLAGS)" + @echo "LIBS= $(LIBS)" + @echo "AR= $(AR)" + @echo "RANLIB= $(RANLIB)" + @echo "RM= $(RM)" + @echo "UNAME= $(UNAME)" + +# Convenience targets for popular platforms. +ALL= all + +help: + @echo "Do 'make PLATFORM' where PLATFORM is one of these:" + @echo " $(PLATS)" + @echo "See doc/readme.html for complete instructions." + +guess: + @echo Guessing `$(UNAME)` + @$(MAKE) `$(UNAME)` + +AIX aix: + $(MAKE) $(ALL) CC="xlc" CFLAGS="-O2 -DLUA_USE_POSIX -DLUA_USE_DLOPEN" SYSLIBS="-ldl" SYSLDFLAGS="-brtl -bexpall" + +bsd: + $(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN" SYSLIBS="-Wl,-E" + +c89: + $(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_C89" CC="gcc -std=c89" + @echo '' + @echo '*** C89 does not guarantee 64-bit integers for Lua.' + @echo '*** Make sure to compile all external Lua libraries' + @echo '*** with LUA_USE_C89 to ensure consistency' + @echo '' + +FreeBSD NetBSD OpenBSD freebsd: + $(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_LINUX -DLUA_USE_READLINE -I/usr/include/edit" SYSLIBS="-Wl,-E -ledit" CC="cc" + +generic: $(ALL) + +Linux linux: linux-noreadline + +linux-noreadline: + $(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_LINUX" SYSLIBS="-Wl,-E -ldl" + +linux-readline: + $(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_LINUX -DLUA_USE_READLINE" SYSLIBS="-Wl,-E -ldl -lreadline" + +Darwin macos macosx: + $(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_MACOSX -DLUA_USE_READLINE" SYSLIBS="-lreadline" + +mingw: + $(MAKE) "LUA_A=lua54.dll" "LUA_T=lua.exe" \ + "AR=$(CC) -shared -o" "RANLIB=strip --strip-unneeded" \ + "SYSCFLAGS=-DLUA_BUILD_AS_DLL" "SYSLIBS=" "SYSLDFLAGS=-s" lua.exe + $(MAKE) "LUAC_T=luac.exe" luac.exe + +posix: + $(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_POSIX" + +SunOS solaris: + $(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN -D_REENTRANT" SYSLIBS="-ldl" + +# Targets that do not create files (not all makes understand .PHONY). +.PHONY: all $(PLATS) help test clean default o a depend echo + +# Compiler modules may use special flags. +llex.o: + $(CC) $(CFLAGS) $(CMCFLAGS) -c llex.c + +lparser.o: + $(CC) $(CFLAGS) $(CMCFLAGS) -c lparser.c + +lcode.o: + $(CC) $(CFLAGS) $(CMCFLAGS) -c lcode.c + +stdlib.o: + $(CC) -I../include/ckb-c-stdlib -DCKB_DECLARATION_ONLY=1 $(CFLAGS) $(CMCFLAGS) -o $@ -c c-stdlib/src/impl.c + +# DO NOT DELETE + +lapi.o: lapi.c lprefix.h lua.h luaconf.h lapi.h llimits.h lstate.h \ + lobject.h ltm.h lzio.h lmem.h ldebug.h ldo.h lfunc.h lgc.h lstring.h \ + ltable.h lundump.h lvm.h +lauxlib.o: lauxlib.c lprefix.h lua.h luaconf.h lauxlib.h +lbaselib.o: lbaselib.c lprefix.h lua.h luaconf.h lauxlib.h lualib.h +lcode.o: lcode.c lprefix.h lua.h luaconf.h lcode.h llex.h lobject.h \ + llimits.h lzio.h lmem.h lopcodes.h lparser.h ldebug.h lstate.h ltm.h \ + ldo.h lgc.h lstring.h ltable.h lvm.h +lcorolib.o: lcorolib.c lprefix.h lua.h luaconf.h lauxlib.h lualib.h +lctype.o: lctype.c lprefix.h lctype.h lua.h luaconf.h llimits.h +ldblib.o: ldblib.c lprefix.h lua.h luaconf.h lauxlib.h lualib.h +ldebug.o: ldebug.c lprefix.h lua.h luaconf.h lapi.h llimits.h lstate.h \ + lobject.h ltm.h lzio.h lmem.h lcode.h llex.h lopcodes.h lparser.h \ + ldebug.h ldo.h lfunc.h lstring.h lgc.h ltable.h lvm.h +ldo.o: ldo.c lprefix.h lua.h luaconf.h lapi.h llimits.h lstate.h \ + lobject.h ltm.h lzio.h lmem.h ldebug.h ldo.h lfunc.h lgc.h lopcodes.h \ + lparser.h lstring.h ltable.h lundump.h lvm.h +ldump.o: ldump.c lprefix.h lua.h luaconf.h lobject.h llimits.h lstate.h \ + ltm.h lzio.h lmem.h lundump.h +lfunc.o: lfunc.c lprefix.h lua.h luaconf.h ldebug.h lstate.h lobject.h \ + llimits.h ltm.h lzio.h lmem.h ldo.h lfunc.h lgc.h +lgc.o: lgc.c lprefix.h lua.h luaconf.h ldebug.h lstate.h lobject.h \ + llimits.h ltm.h lzio.h lmem.h ldo.h lfunc.h lgc.h lstring.h ltable.h +linit.o: linit.c lprefix.h lua.h luaconf.h lualib.h lauxlib.h +liolib.o: liolib.c lprefix.h lua.h luaconf.h lauxlib.h lualib.h +llex.o: llex.c lprefix.h lua.h luaconf.h lctype.h llimits.h ldebug.h \ + lstate.h lobject.h ltm.h lzio.h lmem.h ldo.h lgc.h llex.h lparser.h \ + lstring.h ltable.h +lmathlib.o: lmathlib.c lprefix.h lua.h luaconf.h lauxlib.h lualib.h +lmem.o: lmem.c lprefix.h lua.h luaconf.h ldebug.h lstate.h lobject.h \ + llimits.h ltm.h lzio.h lmem.h ldo.h lgc.h +loadlib.o: loadlib.c lprefix.h lua.h luaconf.h lauxlib.h lualib.h +lobject.o: lobject.c lprefix.h lua.h luaconf.h lctype.h llimits.h \ + ldebug.h lstate.h lobject.h ltm.h lzio.h lmem.h ldo.h lstring.h lgc.h \ + lvm.h +lopcodes.o: lopcodes.c lprefix.h lopcodes.h llimits.h lua.h luaconf.h +lparser.o: lparser.c lprefix.h lua.h luaconf.h lcode.h llex.h lobject.h \ + llimits.h lzio.h lmem.h lopcodes.h lparser.h ldebug.h lstate.h ltm.h \ + ldo.h lfunc.h lstring.h lgc.h ltable.h +lstate.o: lstate.c lprefix.h lua.h luaconf.h lapi.h llimits.h lstate.h \ + lobject.h ltm.h lzio.h lmem.h ldebug.h ldo.h lfunc.h lgc.h llex.h \ + lstring.h ltable.h +lstring.o: lstring.c lprefix.h lua.h luaconf.h ldebug.h lstate.h \ + lobject.h llimits.h ltm.h lzio.h lmem.h ldo.h lstring.h lgc.h +lstrlib.o: lstrlib.c lprefix.h lua.h luaconf.h lauxlib.h lualib.h +ltable.o: ltable.c lprefix.h lua.h luaconf.h ldebug.h lstate.h lobject.h \ + llimits.h ltm.h lzio.h lmem.h ldo.h lgc.h lstring.h ltable.h lvm.h +ltablib.o: ltablib.c lprefix.h lua.h luaconf.h lauxlib.h lualib.h +ltm.o: ltm.c lprefix.h lua.h luaconf.h ldebug.h lstate.h lobject.h \ + llimits.h ltm.h lzio.h lmem.h ldo.h lgc.h lstring.h ltable.h lvm.h +lua.o: lua.c lprefix.h lua.h luaconf.h lauxlib.h lualib.h +luac.o: luac.c lprefix.h lua.h luaconf.h lauxlib.h ldebug.h lstate.h \ + lobject.h llimits.h ltm.h lzio.h lmem.h lopcodes.h lopnames.h lundump.h +lundump.o: lundump.c lprefix.h lua.h luaconf.h ldebug.h lstate.h \ + lobject.h llimits.h ltm.h lzio.h lmem.h ldo.h lfunc.h lstring.h lgc.h \ + lundump.h +lutf8lib.o: lutf8lib.c lprefix.h lua.h luaconf.h lauxlib.h lualib.h +lvm.o: lvm.c lprefix.h lua.h luaconf.h ldebug.h lstate.h lobject.h \ + llimits.h ltm.h lzio.h lmem.h ldo.h lfunc.h lgc.h lopcodes.h lstring.h \ + ltable.h lvm.h ljumptab.h +lzio.o: lzio.c lprefix.h lua.h luaconf.h llimits.h lmem.h lstate.h \ + lobject.h ltm.h lzio.h + +# (end of Makefile) diff --git a/lualib/c-stdlib/my_ctype.h b/lualib/c-stdlib/my_ctype.h index a771c88..24c5ad0 100644 --- a/lualib/c-stdlib/my_ctype.h +++ b/lualib/c-stdlib/my_ctype.h @@ -4,11 +4,20 @@ extern "C" { #endif -int islower(int); -int isupper(int); +int islower(int); +int isupper(int); -int tolower(int); -int toupper(int); +int tolower(int); +int toupper(int); + +int isalnum(int ch); +int isdigit(int ch); +int isxdigit(int ch); +int isspace(int ch); +int isalpha(int ch); +int iscntrl(int ch); +int isgraph(int ch); +int ispunct(int ch); #ifdef __cplusplus } diff --git a/lualib/c-stdlib/my_float.h b/lualib/c-stdlib/my_float.h new file mode 100644 index 0000000..01c1f5b --- /dev/null +++ b/lualib/c-stdlib/my_float.h @@ -0,0 +1,135 @@ +#ifndef _STDLIB_FLOAT_H_ +#define _STDLIB_FLOAT_H_ + +#include + +#undef FLT_MAX +#undef DBL_MAX +#undef LDBL_MAX +#define FLT_MAX __FLT_MAX__ +#define DBL_MAX __DBL_MAX__ +#define LDBL_MAX __LDBL_MAX__ + +#undef DBL_MAX_10_EXP +#define DBL_MAX_10_EXP __DBL_MAX_10_EXP__ + +#undef DBL_MANT_DIG +#define DBL_MANT_DIG __DBL_MANT_DIG__ + +#ifndef HUGE_VAL +# define HUGE_VAL (__builtin_huge_val()) +#endif + +typedef union { + double value; + struct { + uint32_t lsw; + uint32_t msw; + } parts; + struct { + uint64_t w; + } xparts; +} ieee_double_shape_type; + +/* Get two 32 bit ints from a double. */ + +#define EXTRACT_WORDS(ix0, ix1, d) \ + do { \ + ieee_double_shape_type ew_u; \ + ew_u.value = (d); \ + (ix0) = ew_u.parts.msw; \ + (ix1) = ew_u.parts.lsw; \ + } while (0) + +/* Get the more significant 32 bit int from a double. */ + +#define GET_HIGH_WORD(i, d) \ + do { \ + ieee_double_shape_type gh_u; \ + gh_u.value = (d); \ + (i) = gh_u.parts.msw; \ + } while (0) + +/* Get the less significant 32 bit int from a double. */ + +#define GET_LOW_WORD(i, d) \ + do { \ + ieee_double_shape_type gl_u; \ + gl_u.value = (d); \ + (i) = gl_u.parts.lsw; \ + } while (0) + +/* Set the more significant 32 bits of a double from an int. */ + +#define SET_HIGH_WORD(d, v) \ + do { \ + ieee_double_shape_type sh_u; \ + sh_u.value = (d); \ + sh_u.parts.msw = (v); \ + (d) = sh_u.value; \ + } while (0) + +/* Set the less significant 32 bits of a double from an int. */ + +#define SET_LOW_WORD(d, v) \ + do { \ + ieee_double_shape_type sl_u; \ + sl_u.value = (d); \ + sl_u.parts.lsw = (v); \ + (d) = sl_u.value; \ + } while (0) + +static const double ln2_hi = 6.93147180369123816490e-01, /* 3fe62e42 fee00000 */ + ln2_lo = 1.90821492927058770002e-10, /* 3dea39ef 35793c76 */ + two54 = 1.80143985094819840000e+16, /* 43500000 00000000 */ + twom54 = 5.55111512312578270212e-17, /* 0x3C900000, 0x00000000 */ + huge = 1.0e+300, tiny = 1.0e-300, Lg1 = 6.666666666666735130e-01, /* 3FE55555 55555593 */ + Lg2 = 3.999999999940941908e-01, /* 3FD99999 9997FA04 */ + Lg3 = 2.857142874366239149e-01, /* 3FD24924 94229359 */ + Lg4 = 2.222219843214978396e-01, /* 3FCC71C5 1D8E78AF */ + Lg5 = 1.818357216161805012e-01, /* 3FC74664 96CB03DE */ + Lg6 = 1.531383769920937332e-01, /* 3FC39A09 D078C69F */ + Lg7 = 1.479819860511658591e-01; /* 3FC2F112 DF3E5244 */ + +static const double zero = 0.0; + +static const double bp[] = + { + 1.0, + 1.5, +}, + dp_h[] = + { + 0.0, + 5.84962487220764160156e-01, +}, /* 0x3FE2B803, 0x40000000 */ + dp_l[] = + { + 0.0, + 1.35003920212974897128e-08, +}, /* 0x3E4CFDEB, 0x43CFD006 */ + one = 1.0, two = 2.0, two53 = 9007199254740992.0, /* 0x43400000, 0x00000000 */ + /* poly coefs for (3/2)*(log(x)-2s-2/3*s**3 */ + L1 = 5.99999999999994648725e-01, /* 0x3FE33333, 0x33333303 */ + L2 = 4.28571428578550184252e-01, /* 0x3FDB6DB6, 0xDB6FABFF */ + L3 = 3.33333329818377432918e-01, /* 0x3FD55555, 0x518F264D */ + L4 = 2.72728123808534006489e-01, /* 0x3FD17460, 0xA91D4101 */ + L5 = 2.30660745775561754067e-01, /* 0x3FCD864A, 0x93C9DB65 */ + L6 = 2.06975017800338417784e-01, /* 0x3FCA7E28, 0x4A454EEF */ + P1 = 1.66666666666666019037e-01, /* 0x3FC55555, 0x5555553E */ + P2 = -2.77777777770155933842e-03, /* 0xBF66C16C, 0x16BEBD93 */ + P3 = 6.61375632143793436117e-05, /* 0x3F11566A, 0xAF25DE2C */ + P4 = -1.65339022054652515390e-06, /* 0xBEBBBD41, 0xC5D26BF1 */ + P5 = 4.13813679705723846039e-08, /* 0x3E663769, 0x72BEA4D0 */ + lg2 = 6.93147180559945286227e-01, /* 0x3FE62E42, 0xFEFA39EF */ + lg2_h = 6.93147182464599609375e-01, /* 0x3FE62E43, 0x00000000 */ + lg2_l = -1.90465429995776804525e-09, /* 0xBE205C61, 0x0CA86C39 */ + ovt = 8.0085662595372944372e-0017, /* -(1024-log2(ovfl+.5ulp)) */ + cp = 9.61796693925975554329e-01, /* 0x3FEEC709, 0xDC3A03FD =2/(3ln2) */ + cp_h = 9.61796700954437255859e-01, /* 0x3FEEC709, 0xE0000000 =(float)cp */ + cp_l = -7.02846165095275826516e-09, /* 0xBE3E2FE0, 0x145B01F5 =tail of cp_h*/ + ivln2 = 1.44269504088896338700e+00, /* 0x3FF71547, 0x652B82FE =1/ln2 */ + ivln2_h = 1.44269502162933349609e+00, /* 0x3FF71547, 0x60000000 =24b 1/ln2*/ + ivln2_l = 1.92596299112661746887e-08; /* 0x3E54AE0B, 0xF85DDF44 =1/ln2 tail*/ + +#endif diff --git a/lualib/c-stdlib/my_math.h b/lualib/c-stdlib/my_math.h index 43b25d3..6f4a6fd 100644 --- a/lualib/c-stdlib/my_math.h +++ b/lualib/c-stdlib/my_math.h @@ -82,6 +82,14 @@ double scalbn(double, int); double ldexp(double, int); +double floor(double x); + +double ceil(double x); + +double frexp(double arg, int* exp); + +double fmod(double numer, double denom); + #ifdef __cplusplus } #endif diff --git a/lualib/c-stdlib/my_setjmp.h b/lualib/c-stdlib/my_setjmp.h index 675e953..6e6b7c0 100644 --- a/lualib/c-stdlib/my_setjmp.h +++ b/lualib/c-stdlib/my_setjmp.h @@ -5,7 +5,7 @@ extern "C" { #endif -#include +#include "my_features.h" typedef unsigned long __jmp_buf[26]; diff --git a/lualib/c-stdlib/my_signal.h b/lualib/c-stdlib/my_signal.h new file mode 100644 index 0000000..1f8e15c --- /dev/null +++ b/lualib/c-stdlib/my_signal.h @@ -0,0 +1,6 @@ +#ifndef LUA_C_STDLIB_SIGNAL_H_ +#define LUA_C_STDLIB_SIGNAL_H_ + +#define sig_atomic_t int + +#endif diff --git a/lualib/c-stdlib/my_stddef.h b/lualib/c-stdlib/my_stddef.h index 0edfc8d..5a18c43 100644 --- a/lualib/c-stdlib/my_stddef.h +++ b/lualib/c-stdlib/my_stddef.h @@ -3,4 +3,6 @@ typedef signed long ptrdiff_t; +#define offsetof(TYPE, MEMBER) __builtin_offsetof (TYPE, MEMBER) + #endif /* LUA_C_STDLIB_STDDEF_H_ */ diff --git a/lualib/c-stdlib/my_stdint.h b/lualib/c-stdlib/my_stdint.h new file mode 100644 index 0000000..4d7ff17 --- /dev/null +++ b/lualib/c-stdlib/my_stdint.h @@ -0,0 +1,14 @@ +#ifndef LUA_C_STDLIB_STDINT_H_ +#define LUA_C_STDLIB_STDINT_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +int abs (int i); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/lualib/c-stdlib/my_stdio.h b/lualib/c-stdlib/my_stdio.h index 7133fb0..a996e66 100644 --- a/lualib/c-stdlib/my_stdio.h +++ b/lualib/c-stdlib/my_stdio.h @@ -22,9 +22,9 @@ typedef struct FILE { uint32_t offset; } FILE; -FILE *stdin; -FILE *stdout; -FILE *stderr; +extern FILE *stdin; +extern FILE *stdout; +extern FILE *stderr; int remove(const char *__filename); diff --git a/lualib/c-stdlib/my_stdlib.h b/lualib/c-stdlib/my_stdlib.h index df6c58e..f027d40 100644 --- a/lualib/c-stdlib/my_stdlib.h +++ b/lualib/c-stdlib/my_stdlib.h @@ -6,5 +6,9 @@ double strtod(const char *__restrict, char **__restrict); long double strtold(const char *__restrict, char **__restrict); int abs (int); +void exit(int); +void abort(void); + +char *getenv(const char *name); #endif /* LUA_C_STDLIB_STDLIB_H_ */ diff --git a/lualib/c-stdlib/my_string.h b/lualib/c-stdlib/my_string.h index 61310e0..ac94622 100644 --- a/lualib/c-stdlib/my_string.h +++ b/lualib/c-stdlib/my_string.h @@ -2,16 +2,21 @@ #define LUA_C_STDLIB_STRING_H_ #include +#include char *strchr (const char *, int); int strncmp(const char *_l, const char *_r, size_t n); char *strpbrk (const char *, const char *); size_t strcspn (const char *, const char *); size_t strspn (const char *, const char *); -void *memchr (const void *, int, size_t); int strcoll (const char *, const char *); char *strerror (int); +char *strstr(const char *str, const char *substr); + +void *memchr(const void *, int, size_t); +void* memcpy(void *dest, const void *src, size_t count); + #endif /* LUA_C_STDLIB_STRING_H_ */ diff --git a/lualib/c-stdlib/src/impl.c b/lualib/c-stdlib/src/impl.c index 0ec96fc..b48f749 100644 --- a/lualib/c-stdlib/src/impl.c +++ b/lualib/c-stdlib/src/impl.c @@ -1,12 +1,12 @@ #include -#include -#include -#include -#include +#include "my_locale.h" +#include "my_math.h" +#include "my_setjmp.h" +#include "my_stdint.h" #include #include -#include -#include +#include "my_stddef.h" +#include "my_string.h" #include "printf_impl.h" #include "malloc_impl.h" @@ -927,3 +927,39 @@ long double strtold(const char *s, char **endptr) { return value * sign; } + +int iscntrl(int c) +{ + return (unsigned)c < 0x20 || c == 0x7f; +} + +int isgraph(int c) +{ + return (unsigned)c-0x21 < 0x5e; +} + + +int isalpha(int c) +{ + return ((unsigned)c|32)-'a' < 26; +} + +int isdigit(int c) +{ + return (unsigned)c-'0' < 10; +} + +int isxdigit(int c) +{ + return isdigit(c) || ((unsigned)c|32)-'a' < 6; +} + +int isalnum(int c) +{ + return isalpha(c) || isdigit(c); +} + +int ispunct(int c) +{ + return isgraph(c) && !isalnum(c); +} diff --git a/lualib/c-stdlib/src/malloc_impl.h b/lualib/c-stdlib/src/malloc_impl.h index 9231ca2..f60cae3 100644 --- a/lualib/c-stdlib/src/malloc_impl.h +++ b/lualib/c-stdlib/src/malloc_impl.h @@ -1,6 +1,8 @@ #ifndef LUA_C_STDLIB_MALLOC_H_ #define LUA_C_STDLIB_MALLOC_H_ +#include "my_string.h" + #define CKB_MALLOC_DECLARATION_ONLY 1 #if defined(malloc) diff --git a/lualib/c-stdlib/src/math_log.c b/lualib/c-stdlib/src/math_log.c index 41bc1c0..bad3c30 100644 --- a/lualib/c-stdlib/src/math_log.c +++ b/lualib/c-stdlib/src/math_log.c @@ -64,9 +64,7 @@ * to produce the hexadecimal values shown. */ -#include - -#include "math_private.h" +#include "my_float.h" double log(double x) { double hfsq, f, s, z, R, w, t1, t2, dk; diff --git a/lualib/c-stdlib/src/math_pow.c b/lualib/c-stdlib/src/math_pow.c index d83be03..323afe0 100644 --- a/lualib/c-stdlib/src/math_pow.c +++ b/lualib/c-stdlib/src/math_pow.c @@ -57,22 +57,9 @@ * to produce the hexadecimal values shown. */ -#include +#include "my_stdio.h" -#include - -#include "math_private.h" - -typedef union { - double value; - struct { - uint32_t lsw; - uint32_t msw; - } parts; - struct { - uint64_t w; - } xparts; -} ieee_double_shape_type; +#include "my_float.h" double copysign(double x, double y) { uint32_t hx, hy; diff --git a/lualib/c-stdlib/src/math_private.h b/lualib/c-stdlib/src/math_private.h deleted file mode 100644 index a234eb8..0000000 --- a/lualib/c-stdlib/src/math_private.h +++ /dev/null @@ -1,109 +0,0 @@ -#ifndef MATH_PRIVATE_H -#define MATH_PRIVATE_H - -/* Get two 32 bit ints from a double. */ - -#define EXTRACT_WORDS(ix0, ix1, d) \ - do { \ - ieee_double_shape_type ew_u; \ - ew_u.value = (d); \ - (ix0) = ew_u.parts.msw; \ - (ix1) = ew_u.parts.lsw; \ - } while (0) - -/* Get the more significant 32 bit int from a double. */ - -#define GET_HIGH_WORD(i, d) \ - do { \ - ieee_double_shape_type gh_u; \ - gh_u.value = (d); \ - (i) = gh_u.parts.msw; \ - } while (0) - -/* Get the less significant 32 bit int from a double. */ - -#define GET_LOW_WORD(i, d) \ - do { \ - ieee_double_shape_type gl_u; \ - gl_u.value = (d); \ - (i) = gl_u.parts.lsw; \ - } while (0) - -/* Set the more significant 32 bits of a double from an int. */ - -#define SET_HIGH_WORD(d, v) \ - do { \ - ieee_double_shape_type sh_u; \ - sh_u.value = (d); \ - sh_u.parts.msw = (v); \ - (d) = sh_u.value; \ - } while (0) - -/* Set the less significant 32 bits of a double from an int. */ - -#define SET_LOW_WORD(d, v) \ - do { \ - ieee_double_shape_type sl_u; \ - sl_u.value = (d); \ - sl_u.parts.lsw = (v); \ - (d) = sl_u.value; \ - } while (0) - -static const double ln2_hi = 6.93147180369123816490e-01, /* 3fe62e42 fee00000 */ - ln2_lo = 1.90821492927058770002e-10, /* 3dea39ef 35793c76 */ - two54 = 1.80143985094819840000e+16, /* 43500000 00000000 */ - twom54 = 5.55111512312578270212e-17, /* 0x3C900000, 0x00000000 */ - huge = 1.0e+300, tiny = 1.0e-300, - Lg1 = 6.666666666666735130e-01, /* 3FE55555 55555593 */ - Lg2 = 3.999999999940941908e-01, /* 3FD99999 9997FA04 */ - Lg3 = 2.857142874366239149e-01, /* 3FD24924 94229359 */ - Lg4 = 2.222219843214978396e-01, /* 3FCC71C5 1D8E78AF */ - Lg5 = 1.818357216161805012e-01, /* 3FC74664 96CB03DE */ - Lg6 = 1.531383769920937332e-01, /* 3FC39A09 D078C69F */ - Lg7 = 1.479819860511658591e-01; /* 3FC2F112 DF3E5244 */ - -static const double zero = 0.0; - -static const double bp[] = - { - 1.0, - 1.5, -}, - dp_h[] = - { - 0.0, - 5.84962487220764160156e-01, -}, /* 0x3FE2B803, 0x40000000 */ - dp_l[] = - { - 0.0, - 1.35003920212974897128e-08, -}, /* 0x3E4CFDEB, 0x43CFD006 */ - one = 1.0, two = 2.0, - two53 = 9007199254740992.0, /* 0x43400000, 0x00000000 */ - /* poly coefs for (3/2)*(log(x)-2s-2/3*s**3 */ - L1 = 5.99999999999994648725e-01, /* 0x3FE33333, 0x33333303 */ - L2 = 4.28571428578550184252e-01, /* 0x3FDB6DB6, 0xDB6FABFF */ - L3 = 3.33333329818377432918e-01, /* 0x3FD55555, 0x518F264D */ - L4 = 2.72728123808534006489e-01, /* 0x3FD17460, 0xA91D4101 */ - L5 = 2.30660745775561754067e-01, /* 0x3FCD864A, 0x93C9DB65 */ - L6 = 2.06975017800338417784e-01, /* 0x3FCA7E28, 0x4A454EEF */ - P1 = 1.66666666666666019037e-01, /* 0x3FC55555, 0x5555553E */ - P2 = -2.77777777770155933842e-03, /* 0xBF66C16C, 0x16BEBD93 */ - P3 = 6.61375632143793436117e-05, /* 0x3F11566A, 0xAF25DE2C */ - P4 = -1.65339022054652515390e-06, /* 0xBEBBBD41, 0xC5D26BF1 */ - P5 = 4.13813679705723846039e-08, /* 0x3E663769, 0x72BEA4D0 */ - lg2 = 6.93147180559945286227e-01, /* 0x3FE62E42, 0xFEFA39EF */ - lg2_h = 6.93147182464599609375e-01, /* 0x3FE62E43, 0x00000000 */ - lg2_l = -1.90465429995776804525e-09, /* 0xBE205C61, 0x0CA86C39 */ - ovt = 8.0085662595372944372e-0017, /* -(1024-log2(ovfl+.5ulp)) */ - cp = 9.61796693925975554329e-01, /* 0x3FEEC709, 0xDC3A03FD =2/(3ln2) */ - cp_h = 9.61796700954437255859e-01, /* 0x3FEEC709, 0xE0000000 =(float)cp */ - cp_l = - -7.02846165095275826516e-09, /* 0xBE3E2FE0, 0x145B01F5 =tail of cp_h*/ - ivln2 = 1.44269504088896338700e+00, /* 0x3FF71547, 0x652B82FE =1/ln2 */ - ivln2_h = 1.44269502162933349609e+00, /* 0x3FF71547, 0x60000000 =24b 1/ln2*/ - ivln2_l = - 1.92596299112661746887e-08; /* 0x3E54AE0B, 0xF85DDF44 =1/ln2 tail*/ - -#endif diff --git a/lualib/c-stdlib/src/printf_impl.h b/lualib/c-stdlib/src/printf_impl.h index 9843313..48489bf 100644 --- a/lualib/c-stdlib/src/printf_impl.h +++ b/lualib/c-stdlib/src/printf_impl.h @@ -8,9 +8,9 @@ // https://github.com/mpaland/printf/tree/d3b984684bb8a8bdc48cc7a1abecb93ce59bbe3e #include -#include +#include "my_stddef.h" #include -#include +#include "my_stdint.h" /** * Output a character to a custom device like UART, used by the printf() @@ -190,7 +190,7 @@ int fctprintf(void (*out)(char character, void *arg), void *arg, // import float.h for DBL_MAX #if defined(PRINTF_SUPPORT_FLOAT) -#include +#include "my_float.h" #endif // output function type @@ -778,8 +778,7 @@ static int _vsnprintf(out_fct_type out, char *buffer, const size_t maxlen, break; #endif case 'j': - flags |= - (sizeof(intmax_t) == sizeof(long) ? FLAGS_LONG : FLAGS_LONG_LONG); + flags |= FLAGS_LONG; format++; break; case 'z': diff --git a/lualib/lauxlib.c b/lualib/lauxlib.c index 6aa1786..672febb 100644 --- a/lualib/lauxlib.c +++ b/lualib/lauxlib.c @@ -7,10 +7,10 @@ #define lauxlib_c #define LUA_LIB -#include +#include "my_errno.h" #include #include -#include +#include "my_string.h" #include "my_stdio.h" #include "lprefix.h" diff --git a/lualib/lbaselib.c b/lualib/lbaselib.c index 2aa02f4..d8bf397 100644 --- a/lualib/lbaselib.c +++ b/lualib/lbaselib.c @@ -7,10 +7,10 @@ #define lbaselib_c #define LUA_LIB -#include +#include "my_ctype.h" #include #include -#include +#include "my_string.h" #include "lauxlib.h" #include "lprefix.h" diff --git a/lualib/lcode.c b/lualib/lcode.c index c5541d4..570eb88 100644 --- a/lualib/lcode.c +++ b/lualib/lcode.c @@ -9,9 +9,10 @@ #include "lcode.h" -#include +#include "my_float.h" +#include "my_stdint.h" #include -#include +#include "my_math.h" #include #include "ldebug.h" diff --git a/lualib/lctype.h b/lualib/lctype.h index 975a04d..d753723 100644 --- a/lualib/lctype.h +++ b/lualib/lctype.h @@ -75,7 +75,7 @@ LUAI_DDEC(const lu_byte luai_ctype_[UCHAR_MAX + 2];) ** use standard C ctypes */ -#include +#include "my_ctype.h" #define lislalpha(c) (isalpha(c) || (c) == '_') #define lislalnum(c) (isalnum(c) || (c) == '_') diff --git a/lualib/ldblib.c b/lualib/ldblib.c index 26ff3d8..2b81844 100644 --- a/lualib/ldblib.c +++ b/lualib/ldblib.c @@ -9,7 +9,7 @@ #include #include -#include +#include "my_string.h" #include "lauxlib.h" #include "lprefix.h" diff --git a/lualib/ldebug.c b/lualib/ldebug.c index ec52f6c..a2ee3a8 100644 --- a/lualib/ldebug.c +++ b/lualib/ldebug.c @@ -11,7 +11,7 @@ #include #include -#include +#include "my_string.h" #include "lapi.h" #include "lcode.h" diff --git a/lualib/ldo.c b/lualib/ldo.c index ccc87a6..a7dcbd0 100644 --- a/lualib/ldo.c +++ b/lualib/ldo.c @@ -9,9 +9,10 @@ #include "ldo.h" -#include +#include "my_setjmp.h" #include -#include +#include "my_string.h" +#include "my_stdlib.h" #include "lapi.h" #include "ldebug.h" diff --git a/lualib/lgc.c b/lualib/lgc.c index 7cb05b7..0d863f0 100644 --- a/lualib/lgc.c +++ b/lualib/lgc.c @@ -9,7 +9,7 @@ #include "lgc.h" -#include +#include "my_string.h" #include "my_stdio.h" #include "ldebug.h" diff --git a/lualib/liolib.c b/lualib/liolib.c index f321890..0334c4a 100644 --- a/lualib/liolib.c +++ b/lualib/liolib.c @@ -7,11 +7,11 @@ #define liolib_c #define LUA_LIB -#include -#include -#include +#include "my_ctype.h" +#include "my_errno.h" +#include "my_locale.h" #include -#include +#include "my_string.h" #include "my_stdio.h" #include "lauxlib.h" diff --git a/lualib/llex.c b/lualib/llex.c index f484d25..7426fdd 100644 --- a/lualib/llex.c +++ b/lualib/llex.c @@ -9,8 +9,8 @@ #include "llex.h" -#include -#include +#include "my_locale.h" +#include "my_string.h" #include "lctype.h" #include "ldebug.h" diff --git a/lualib/lmathlib.c b/lualib/lmathlib.c index 3fc8498..ee465a1 100644 --- a/lualib/lmathlib.c +++ b/lualib/lmathlib.c @@ -7,11 +7,9 @@ #define lmathlib_c #define LUA_LIB -#include +#include "my_float.h" #include -#include - #include "my_math.h" #include diff --git a/lualib/loadlib.c b/lualib/loadlib.c index 2a2835e..c1220e4 100644 --- a/lualib/loadlib.c +++ b/lualib/loadlib.c @@ -11,8 +11,8 @@ #define loadlib_c #define LUA_LIB -#include -#include +#include "my_stdlib.h" +#include "my_string.h" #include "my_stdio.h" #include "lauxlib.h" diff --git a/lualib/lobject.c b/lualib/lobject.c index d95d916..0b37854 100644 --- a/lualib/lobject.c +++ b/lualib/lobject.c @@ -9,11 +9,11 @@ #include "lobject.h" -#include -#include +#include "my_locale.h" +#include "my_math.h" #include #include -#include +#include "my_string.h" #include "my_stdio.h" #include "lctype.h" diff --git a/lualib/lobject.h b/lualib/lobject.h index 335aecb..5990504 100644 --- a/lualib/lobject.h +++ b/lualib/lobject.h @@ -9,6 +9,7 @@ #include +#include "my_stddef.h" #include "llimits.h" #include "lua.h" @@ -473,14 +474,14 @@ typedef struct Udata0 { } bindata; } Udata0; +/* get the address of the memory block inside 'Udata' */ +#define getudatamem(u) (cast_charp(u) + udatamemoffset((u)->nuvalue)) + /* compute the offset of the memory area of a userdata */ #define udatamemoffset(nuv) \ ((nuv) == 0 ? offsetof(Udata0, bindata) \ : offsetof(Udata, uv) + (sizeof(UValue) * (nuv))) -/* get the address of the memory block inside 'Udata' */ -#define getudatamem(u) (cast_charp(u) + udatamemoffset((u)->nuvalue)) - /* compute the size of a userdata */ #define sizeudata(nuv, nb) (udatamemoffset(nuv) + (nb)) diff --git a/lualib/lstate.h b/lualib/lstate.h index f8932fa..e19f38a 100644 --- a/lualib/lstate.h +++ b/lualib/lstate.h @@ -112,7 +112,7 @@ struct lua_longjmp; /* defined in ldo.c */ ** is thread safe */ #if !defined(l_signalT) -#include +#include "my_signal.h" #define l_signalT sig_atomic_t #endif diff --git a/lualib/lstrlib.c b/lualib/lstrlib.c index b8ab5e6..df6112d 100644 --- a/lualib/lstrlib.c +++ b/lualib/lstrlib.c @@ -7,14 +7,14 @@ #define lstrlib_c #define LUA_LIB -#include -#include +#include "my_ctype.h" +#include "my_float.h" #include -#include -#include +#include "my_locale.h" +#include "my_math.h" #include #include -#include +#include "my_string.h" #include "my_stdio.h" #include "lauxlib.h" diff --git a/lualib/ltable.c b/lualib/ltable.c index 0f9e318..6248220 100644 --- a/lualib/ltable.c +++ b/lualib/ltable.c @@ -23,7 +23,7 @@ */ #include -#include +#include "my_math.h" #include "ldebug.h" #include "ldo.h" diff --git a/lualib/luac.c b/lualib/luac.c index c308e45..fa6b025 100644 --- a/lualib/luac.c +++ b/lualib/luac.c @@ -7,10 +7,10 @@ #define luac_c #define LUA_CORE -#include -#include +#include "my_ctype.h" +#include "my_errno.h" #include -#include +#include "my_string.h" #include "my_stdio.h" #include "lauxlib.h" diff --git a/lualib/luaconf.h b/lualib/luaconf.h index 0f3e7f4..875e82a 100644 --- a/lualib/luaconf.h +++ b/lualib/luaconf.h @@ -10,6 +10,8 @@ #include #include #include "my_stddef.h" +#include "my_stdlib.h" +#include "my_float.h" /* ** =================================================================== diff --git a/lualib/lutf8lib.c b/lualib/lutf8lib.c index 6ebcfe4..2b3a161 100644 --- a/lualib/lutf8lib.c +++ b/lualib/lutf8lib.c @@ -7,10 +7,9 @@ #define lutf8lib_c #define LUA_LIB -#include #include #include -#include +#include "my_string.h" #include "lauxlib.h" #include "lprefix.h" diff --git a/lualib/lvm.c b/lualib/lvm.c index ce5defe..d387bfb 100644 --- a/lualib/lvm.c +++ b/lualib/lvm.c @@ -9,11 +9,11 @@ #include "lvm.h" -#include +#include "my_float.h" #include -#include +#include "my_math.h" #include -#include +#include "my_string.h" #include "my_stdio.h" #include "ldebug.h" diff --git a/tests/test_cases/Makefile b/tests/test_cases/Makefile index 9cb0be4..6b75be7 100644 --- a/tests/test_cases/Makefile +++ b/tests/test_cases/Makefile @@ -69,6 +69,8 @@ all: $(call run_with_mocked_tx, test_ckbsyscalls.lua) $(call run, bn.lua) +ci-no-dylib: hello_world save-and-load-file-system-data partial_loading memory_leak lua-fs-util + ci: hello_world save-and-load-file-system-data partial_loading memory_leak dylibtest lua-fs-util $(call run_ci, test_require.lua) $(call run_ci, test_loadfile.lua)