lua-users home
lua-l archive

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


Hi guys.

It's my first post to this list, so first of all: thank you for Lua and sorry I discovered it so late ;). But better late then never.

I've been looking for a small and fast scripting language for an Atari ST running on FPGA board called the "MIST". Don't ask why, I simply felt the need (Christmas break) and MIST has this STEroids mode, which is running Atari TOS software at approximately twice the speed of Atari TT.

Unfortunately Lua compiled with gcc4.6 (on Aranym/Freemint) is much slower than old binaries of Lua-5.0.2 compiled in PureC by Thorsten Butchke (back in 2006) or my compilation of 5.0.3. So I tried with Lua-5.2.3 and was able to build it, but it was crashing with bus errors so i gave up. Luckily 5.3.0-rc3 compiled just fine and it works, well sort of. There is some unusual behavior I can't explain (I'm neither a coder, nor an Atari ST guru):

print() doesn't work when called from for loop (and it's possibly just one manifestation of this issue). While loop seems to work fine.

I attach:
- diff with my totally lame changes to the original sourcecode + prj file for PureC (sorry for my ignorance),
- screenshot showing this strange behavior in Lua run from Gulam shell on Atari TOS 2.6.

I'll be grateful for any hints and suggestions.

Thank you once again for your hard work on Lua.

Cheers,
W.

--
Talkers are no good doers.
diff -Nur lua530o/src/liolib.c lua530n/src/liolib.c
--- lua530o/src/liolib.c	2015-01-02 13:50:28.000000000 +0100
+++ lua530n/src/liolib.c	2015-01-05 20:50:56.000000000 +0100
@@ -410,10 +410,10 @@
 }
 
 
-/* access to locale "radix character" (decimal point) */
+/* access to locale "radix character" (decimal point) 
 #if !defined(l_getlocaledecpoint)
 #define l_getlocaledecpoint()     (localeconv()->decimal_point[0])
-#endif
+#endif */
 
 
 /*
@@ -427,7 +427,7 @@
   int hex = 0;
   char decp[2] = ".";
   rn.f = f; rn.n = 0;
-  decp[0] = l_getlocaledecpoint();  /* get decimal point from locale */
+  decp[0] = '.'; /*l_getlocaledecpoint();  get decimal point from locale */
   l_lockfile(rn.f);
   do { rn.c = l_getc(rn.f); } while (isspace(rn.c));  /* skip spaces */
   test2(&rn, "-+");  /* optional signal */
diff -Nur lua530o/src/llex.c lua530n/src/llex.c
--- lua530o/src/llex.c	2014-11-14 17:06:09.000000000 +0100
+++ lua530n/src/llex.c	2015-01-05 20:50:56.000000000 +0100
@@ -234,7 +234,7 @@
 */
 static void trydecpoint (LexState *ls, TValue *o) {
   char old = ls->decpoint;
-  ls->decpoint = l_getlocaledecpoint();
+  ls->decpoint = '.'; /*l_getlocaledecpoint();*/
   buffreplace(ls, old, ls->decpoint);  /* try new decimal separator */
   if (!buff2num(ls->buff, o)) {
     /* format error with correct decimal point: no more options */
diff -Nur lua530o/src/loslib.c lua530n/src/loslib.c
--- lua530o/src/loslib.c	2014-12-26 15:46:07.000000000 +0100
+++ lua530n/src/loslib.c	2015-01-05 20:50:56.000000000 +0100
@@ -152,7 +152,7 @@
 
 
 static int os_clock (lua_State *L) {
-  lua_pushnumber(L, ((lua_Number)clock())/(lua_Number)CLOCKS_PER_SEC);
+  lua_pushnumber(L, ((lua_Number)clock())/(lua_Number)60);
   return 1;
 }
 
@@ -225,7 +225,7 @@
 
 static int os_date (lua_State *L) {
   const char *s = luaL_optstring(L, 1, "%c");
-  time_t t = luaL_opt(L, l_checktime, 2, time(NULL));
+  time_t t = luaL_opt(L, luaL_checkinteger, 2, time(NULL));
   struct tm tmr, *stm;
   if (*s == '!') {  /* UTC? */
     stm = l_gmtime(&t, &tmr);
@@ -297,7 +297,7 @@
 
 
 static int os_difftime (lua_State *L) {
-  double res = difftime((l_checktime(L, 1)), (l_checktime(L, 2)));
+  double res = difftime((luaL_checkinteger(L, 1)), (luaL_checkinteger(L, 2)));
   lua_pushnumber(L, (lua_Number)res);
   return 1;
 }
@@ -312,7 +312,7 @@
      "numeric", "time", NULL};
   const char *l = luaL_optstring(L, 1, NULL);
   int op = luaL_checkoption(L, 2, "all", catnames);
-  lua_pushstring(L, setlocale(cat[op], l));
+  lua_pushstring(L, "C"); /*setlocale(cat[op], l));*/
   return 1;
 }
 
diff -Nur lua530o/src/lua.c lua530n/src/lua.c
--- lua530o/src/lua.c	2014-11-11 20:41:27.000000000 +0100
+++ lua530n/src/lua.c	2015-01-05 20:50:56.000000000 +0100
@@ -110,7 +110,7 @@
 */
 static void lstop (lua_State *L, lua_Debug *ar) {
   (void)ar;  /* unused arg. */
-  lua_sethook(L, NULL, 0, 0);  /* reset hook */
+  lua_sethook(L, 0, 0, 0);  /* reset hook */
   luaL_error(L, "interrupted!");
 }
 
diff -Nur lua530o/src/lua.h lua530n/src/lua.h
--- lua530o/src/lua.h	2014-12-26 18:24:27.000000000 +0100
+++ lua530n/src/lua.h	2015-01-05 20:50:56.000000000 +0100
@@ -269,11 +269,11 @@
 */
 LUA_API void  (lua_callk) (lua_State *L, int nargs, int nresults,
                            lua_KContext ctx, lua_KFunction k);
-#define lua_call(L,n,r)		lua_callk(L, (n), (r), 0, NULL)
+#define lua_call(L,n,r)		lua_callk(L, (n), (r), 0, 0)
 
 LUA_API int   (lua_pcallk) (lua_State *L, int nargs, int nresults, int errfunc,
                             lua_KContext ctx, lua_KFunction k);
-#define lua_pcall(L,n,r,f)	lua_pcallk(L, (n), (r), (f), 0, NULL)
+#define lua_pcall(L,n,r,f)	lua_pcallk(L, (n), (r), (f), 0, 0)
 
 LUA_API int   (lua_load) (lua_State *L, lua_Reader reader, void *dt,
                           const char *chunkname, const char *mode);
@@ -290,7 +290,7 @@
 LUA_API int  (lua_status)     (lua_State *L);
 LUA_API int (lua_isyieldable) (lua_State *L);
 
-#define lua_yield(L,n)		lua_yieldk(L, (n), 0, NULL)
+#define lua_yield(L,n)		lua_yieldk(L, (n), 0, 0)
 
 
 /*
diff -Nur lua530o/src/lua.prj lua530n/src/lua.prj
--- lua530o/src/lua.prj	1970-01-01 01:00:00.000000000 +0100
+++ lua530n/src/lua.prj	2015-01-05 20:50:56.000000000 +0100
@@ -0,0 +1,77 @@
+;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+;	OUTPUT FILENAME
+;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+
+g:\lua\lua.prg
+
+;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+;	OPTIONS
+;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+
+;.C [ -Y -W-par ]
+.C [ -W-par ]
+.C [ -DLUA_USE_C89 ]
+.C [ -DLUA_COMPAT_5_2 ]
+;.L [ -Y ]
+
+=
+
+;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+;	STARTUP MODULE
+;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+
+LIB\PCSTART.O       
+
+;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+;	Actuall projet stuff
+;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+
+
+lapi.c  (lua.h, lapi.h, ldebug.h, ldo.h, lfunc.h, lgc.h, lmem.h, lobject.h, lstate.h, lstring.h, ltable.h, ltm.h, lundump.h, lvm.h)
+lcode.c (lua.h, lcode.h, ldebug.h, ldo.h, lgc.h, llex.h, lmem.h, lobject.h, lopcodes.h, lparser.h, lstring.h, ltable.h, lvm.h)
+lctype.c (lctype.h)
+ldebug.c (lua.h, lapi.h, lcode.h, ldebug.h, ldo.h, lfunc.h, lobject.h, lopcodes.h, lstate.h, lstring.h, ltable.h, ltm.h, lvm.h)
+ldo.c (lua.h, lapi.h, ldebug.h, ldo.h, lfunc.h, lgc.h, lmem.h, lobject.h, lopcodes.h, lparser.h, lstate.h, lstring.h, ltable.h, ltm.h, lundump.h, lvm.h, lzio.h)
+ldump.c (lua.h, lobject.h, lstate.h, lundump.h)
+lfunc.c (lua.h, lfunc.h, lgc.h, lmem.h, lobject.h, lstate.h)
+lgc.c (lua.h, ldebug.h, ldo.h, lfunc.h, lgc.h, lmem.h, lobject.h, lstate.h, lstring.h, ltable.h, ltm.h)
+llex.c (lua.h, lctype.h, ldo.h, llex.h, lobject.h, lparser.h, lstate.h, lstring.h, ltable.h, lzio.h)
+lmem.c (lua.h, ldebug.h, ldo.h, lgc.h, lmem.h, lobject.h, lstate.h)
+lobject.c (lua.h, lctype.h, ldebug.h, ldo.h, lmem.h, lobject.h, lstate.h, lstring.h, lvm.h)
+lopcodes.c (lopcodes.h)
+lparser.c (lua.h, lcode.h, ldebug.h, ldo.h, lfunc.h, llex.h, lmem.h, lobject.h, lopcodes.h, lparser.h, lstate.h, lstring.h, ltable.h)
+lstate.c (lua.h, lapi.h, ldebug.h, ldo.h, lfunc.h, lgc.h, llex.h, lmem.h, lstate.h, lstring.h, ltable.h, ltm.h)
+lstring.c (lua.h, lmem.h, lobject.h, lstate.h, lstring.h)
+ltable.c (lua.h, ldebug.h, ldo.h, lgc.h, lmem.h, lobject.h, lstate.h, lstring.h, ltable.h, lvm.h)
+ltm.c (lua.h, lobject.h, lstate.h, lstring.h, ltable.h, ltm.h)
+lundump.c (lua.h, ldebug.h, ldo.h, lfunc.h, lmem.h, lobject.h, lstring.h, lundump.h, lzio.h)
+lvm.c (lua.h, ldebug.h, ldo.h, lfunc.h, lgc.h, lobject.h, lopcodes.h, lstate.h, lstring.h, ltable.h, ltm.h, lvm.h)
+lzio.c (lua.h, llimits.h, lmem.h, lstate.h, lzio.h)
+lauxlib.c (lua.h, lauxlib.h)
+lbaselib.c (lua.h, lauxlib.h, lualib.h) 
+lbitlib.c (lua.h, lauxlib.h, lualib.h)
+lcorolib.c (lua.h, lauxlib.h, lualib.h)
+ldblib.c (lua.h, lauxlib.h, lualib.h)
+liolib.c (lua.h, lauxlib.h, lualib.h)
+lmathlib.c (lua.h, lauxlib.h, lualib.h)
+loslib.c (lua.h, lauxlib.h, lualib.h)
+lstrlib.c (lua.h, lauxlib.h, lualib.h)
+ltablib.c (lua.h, lauxlib.h, lualib.h)
+lutf8lib.c (lua.h, lauxlib.h, lualib.h)
+loadlib.c (lua.h, lauxlib.h, lualib.h)
+linit.c (lua.h, lualib.h, lauxlib.h)
+lua.c (lua.h, lauxlib.h, lualib.h)
+
+;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+;	PURE C LIBRARIES
+;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
+
+LIB\PCFLTLIB.LIB       ; floating point library
+LIB\PCSTDLIB.LIB       ; stanhard library
+
+;******** Librarys *********
+
+h:\lib\PCEXTLIB.LIB       	; stanhard library
+h:\lib\PCTOSLIB.LIB       	; TOS library
+
+;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
diff -Nur lua530o/src/lvm.c lua530n/src/lvm.c
--- lua530o/src/lvm.c	2014-12-27 21:30:38.000000000 +0100
+++ lua530n/src/lvm.c	2015-01-05 20:50:56.000000000 +0100
@@ -243,7 +243,7 @@
   const char *r = getstr(rs);
   size_t lr = rs->len;
   for (;;) {  /* for each segment */
-    int temp = strcoll(l, r);
+    int temp = strcmp(l, r);
     if (temp != 0)  /* not equal? */
       return temp;  /* done */
     else {  /* strings are equal up to a '\0' */

Attachment: lua53_tos.png
Description: PNG image