Lua behaves strangely on the PowerPC / LynxOS platform, why?

I choose Lua 5.1 as my built-in scripting language, but when I port the application to the legacy platform, it starts LynxOS on PowerPC, the thing seems wrong.

I get the following code that runs on a PC and everything looks good:

void test_lua() { const char *code = "foo = 5\n"; double vfoo=0; lua_State *L = luaL_newstate(); (void)luaL_loadbuffer(L, code, strlen(code), "line"); (void)lua_pcall (L, 0, 0, 0); lua_getglobal(L, "foo"); vfoo = lua_tonumber(L, -1); lua_close(L); myTrace("vfoo = %f", vfoo); for(;;); } 

from PC (Visual C ++ 6.0) I was expecting "vfoo = 5.000000"

But with LynxOS / PowerPC, I got "vfoo = 0.000000".

So what is happening for Lua on LynxOS / PowerPC? I am wondering if there are any configurations for a large-core machine, I looked for it in "luaconf.h", but did not find anything. I also tried the configuration item "LUA_USE_POSIX", but did not help.

I know this is not a typical lua programming platform. However, any suggestions are welcome and appreciated.

+7
source share
1 answer

Endian-ness should not affect the operation of lua code. I ported several platforms that are not Win32, and I came across times when LUA_IEEE754TRICK, which is used to convert a 64-bit double to an integer, does not always work, but it is turned on by default. Try defining the macro LUA_IEEE754TRICK in the luaconf.h file.

I also ran into clippers where the printf / scanf floating point functions were broken or unreliable, and I had to write my own custom version of lua_number2str.

However, I feel for you. The lua engine is a large black box that baffles you step by step and debugs when something is wrong with its insides. In my case, this is usually a compiler / clip error, but that does not make it easier to make 2 get along with each other.
+2
source

All Articles