lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi Lua Experts,
Wanted to post an updated patch for VxWorks 7 support with Lua 5.3.5.  
Not a lot different than the last patch I posted, but a couple recent fixes to VxWorks code base enabled the tests around the loader and locale to pass. So it's more of a "validated" patch.  The patch assumes you define CC, LD etc. on your **make** invocation  to point to your VxWorks cross-build environment.

As I mentioned in my last post VxWorks is an RTOS and is missing a few things a full UNIX OS would have, so the patch is mostly convincing Lua to selectively include some POSIX capabilities and not others.   What doesn't pass  the lua test suite is now is mostly because of that delta.   

My next goal is validating Lua in the VxWorks kernel rather than in a process. Probably the more common "use case" for Lua with VxWorks, but I wanted the validation of the test suite before I focused on that. I'll follow with a separate post on my questions with that effort.

ciao

Brian

----------------------------------------------------------------------------------------------------------------

diff -uNdr lua-5.3.5/src/Makefile lua-5.3.5.patch/src/Makefile
--- lua-5.3.5/src/Makefile 2018-06-25 13:46:36.000000000 -0400
+++ lua-5.3.5.patch/src/Makefile 2020-05-09 15:08:08.506574500 -0400
@@ -26,7 +26,7 @@
 
 # == END OF USER SETTINGS -- NO NEED TO CHANGE ANYTHING BELOW THIS LINE =======
 
-PLATS= aix bsd c89 freebsd generic linux macosx mingw posix solaris
+PLATS= aix bsd c89 freebsd generic linux macosx mingw posix solaris vxworks
 
 LUA_A= liblua.a
 CORE_O= lapi.o lcode.o lctype.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o \
@@ -124,6 +124,10 @@
 solaris:
  $(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN -D_REENTRANT" SYSLIBS="-ldl"
 
+vxworks:
+ $(MAKE) $(ALL) "LUAC_T=luac.vxe" "LUA_T=lua.vxe" SYSLDFLAGS="-Wl,-E" \
+ SYSCFLAGS="-DLUA_USE_VXWORKS -DLUA_USE_DLOPEN -D_XOPEN_SOURCE=0 -DRTLD_LOCAL=0"
+
 # list targets that do not create files (but not all makes understand .PHONY)
 .PHONY: all $(PLATS) default o a clean depend echo none
 
diff -uNdr lua-5.3.5/src/lauxlib.c lua-5.3.5.patch/src/lauxlib.c
--- lua-5.3.5/src/lauxlib.c 2017-04-19 13:20:42.000000000 -0400
+++ lua-5.3.5.patch/src/lauxlib.c 2020-05-09 15:08:08.470843800 -0400
@@ -251,7 +251,7 @@
 
 #if !defined(l_inspectstat) /* { */
 
-#if defined(LUA_USE_POSIX)
+#if defined(LUA_USE_BASIC_POSIX)
 
 #include <sys/wait.h>
 
diff -uNdr lua-5.3.5/src/ldo.c lua-5.3.5.patch/src/ldo.c
--- lua-5.3.5/src/ldo.c 2017-04-19 13:20:42.000000000 -0400
+++ lua-5.3.5.patch/src/ldo.c 2020-05-09 15:08:08.476522800 -0400
@@ -60,7 +60,7 @@
  try { a } catch(...) { if ((c)->status == 0) (c)->status = -1; }
 #define luai_jmpbuf int  /* dummy variable */
 
-#elif defined(LUA_USE_POSIX) /* }{ */
+#elif defined(LUA_USE__LONGJMP) /* }{ */
 
 /* in POSIX, try _longjmp/_setjmp (more efficient) */
 #define LUAI_THROW(L,c) _longjmp((c)->b, 1)
diff -uNdr lua-5.3.5/src/liolib.c lua-5.3.5.patch/src/liolib.c
--- lua-5.3.5/src/liolib.c 2017-04-19 13:29:57.000000000 -0400
+++ lua-5.3.5.patch/src/liolib.c 2020-05-09 15:08:08.480513200 -0400
@@ -54,7 +54,7 @@
 
 #if !defined(l_popen) /* { */
 
-#if defined(LUA_USE_POSIX) /* { */
+#if defined(LUA_USE_POPEN) /* { */
 
 #define l_popen(L,c,m) (fflush(NULL), popen(c,m))
 #define l_pclose(L,file) (pclose(file))
@@ -82,7 +82,7 @@
 
 #if !defined(l_getc) /* { */
 
-#if defined(LUA_USE_POSIX)
+#if defined(LUA_USE_BASIC_POSIX)
 #define l_getc(f) getc_unlocked(f)
 #define l_lockfile(f) flockfile(f)
 #define l_unlockfile(f) funlockfile(f)
@@ -103,7 +103,7 @@
 
 #if !defined(l_fseek) /* { */
 
-#if defined(LUA_USE_POSIX) /* { */
+#if defined(LUA_USE_BASIC_POSIX) /* { */
 
 #include <sys/types.h>
 
diff -uNdr lua-5.3.5/src/lmathlib.c lua-5.3.5.patch/src/lmathlib.c
--- lua-5.3.5/src/lmathlib.c 2017-04-19 13:20:42.000000000 -0400
+++ lua-5.3.5.patch/src/lmathlib.c 2020-05-09 15:08:08.487577200 -0400
@@ -24,7 +24,7 @@
 
 
 #if !defined(l_rand) /* { */
-#if defined(LUA_USE_POSIX)
+#if defined(LUA_USE_RANDOM)
 #define l_rand() random()
 #define l_srand(x) srandom(x)
 #define L_RANDMAX 2147483647 /* (2^31 - 1), following POSIX */
diff -uNdr lua-5.3.5/src/loslib.c lua-5.3.5.patch/src/loslib.c
--- lua-5.3.5/src/loslib.c 2017-04-19 13:29:57.000000000 -0400
+++ lua-5.3.5.patch/src/loslib.c 2020-05-09 15:08:08.491612900 -0400
@@ -81,7 +81,7 @@
 ** where it uses gmtime_r/localtime_r
 */
 
-#if defined(LUA_USE_POSIX) /* { */
+#if defined(LUA_USE_BASIC_POSIX) /* { */
 
 #define l_gmtime(t,r) gmtime_r(t,r)
 #define l_localtime(t,r) localtime_r(t,r)
@@ -108,7 +108,7 @@
 */
 #if !defined(lua_tmpnam) /* { */
 
-#if defined(LUA_USE_POSIX) /* { */
+#if defined(LUA_USE_MKSTEMP) /* { */
 
 #include <unistd.h>
 
diff -uNdr lua-5.3.5/src/lua.c lua-5.3.5.patch/src/lua.c
--- lua-5.3.5/src/lua.c 2017-04-19 13:29:57.000000000 -0400
+++ lua-5.3.5.patch/src/lua.c 2020-05-09 15:08:08.496636300 -0400
@@ -47,7 +47,7 @@
 */
 #if !defined(lua_stdin_is_tty) /* { */
 
-#if defined(LUA_USE_POSIX) /* { */
+#if defined(LUA_USE_BASIC_POSIX) /* { */
 
 #include <unistd.h>
 #define lua_stdin_is_tty() isatty(0)
diff -uNdr lua-5.3.5/src/luaconf.h lua-5.3.5.patch/src/luaconf.h
--- lua-5.3.5/src/luaconf.h 2017-04-19 13:29:57.000000000 -0400
+++ lua-5.3.5.patch/src/luaconf.h 2020-05-09 15:50:16.913796800 -0400
@@ -51,12 +51,18 @@
 #define LUA_USE_WINDOWS  /* enable goodies for regular Windows */
 #endif
 
-
 #if defined(LUA_USE_WINDOWS)
 #define LUA_DL_DLL /* enable support for DLL */
 #define LUA_USE_C89 /* broadly, Windows is C89 */
 #endif
 
+#if defined(LUA_USE_VXWORKS)
+#define LUA_USE_BASIC_POSIX
+#ifdef _CLOCK_T
+extern clock_t tickGet(void);
+#define clock(a) tickGet(a) /* no process timekeeping, use system */
+#endif
+#endif
 
 #if defined(LUA_USE_LINUX)
 #define LUA_USE_POSIX
@@ -71,6 +77,13 @@
 #define LUA_USE_READLINE /* needs an extra library: -lreadline */
 #endif
 
+#if defined(LUA_USE_POSIX)
+#define LUA_USE_BASIC_POSIX
+#define LUA_USE__LONGJMP
+#define LUA_USE_POPEN
+#define LUA_USE_RANDOM
+#define LUA_USE_MKSTEMP
+#endif
 
 /*
 @@ LUA_C89_NUMBERS ensures that Lua uses the largest types available for
  
_______________________________________________
lua-l mailing list -- lua-l@lists.lua.org
To unsubscribe send an email to lua-l-leave@lists.lua.org