Lua cư xử kỳ lạ trên nền tảng PowerPC / LynxOS, tại sao? (Lua behaves weird on PowerPC/LynxOS platform, why?)


問題描述

Lua cư xử kỳ lạ trên nền tảng PowerPC / LynxOS, tại sao? (Lua behaves weird on PowerPC/LynxOS platform, why?)

I choose Lua 5.1 as my application's embedded scripting language, but  when I port the application to a legacy platform runs LynxOS on PowerPC, thing seems going wrong.

I get following code run up on PC and every thing 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(;;);
}

with PC (Visual C++ 6.0) I got expecting "vfoo = 5.000000"

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

So what's going on for Lua on LynxOS/PowerPC ? I am wondering if there are some configurations for big‑endian machine, I looked for it in "luaconf.h" but find nothing. I also tried the configuration item "LUA_USE_POSIX" but no help.

I know it's not a typical platform for lua programming. However, any suggestions are welcome and be appreciated.


參考解法

方法 1:

Endian‑ness shouldn't affect the operation of the lua code.  I have ported to several platforms that are not Win32, and I've run into times where the LUA_IEEE754TRICK that is used to convert a 64‑bit double into an integer does not always work, but is enabled by default.  Try undefining the LUA_IEEE754TRICK macro in luaconf.h.

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

I feel for you though.  The lua engine is a large, black box that is confusing to step through and debug when something goes wrong with its internals.  In my case it has usually been the compiler/clib's fault, but that doesn't make it any easier to make the 2 get along with each other.

(by Haiyuan LiNathan Wiebe)

參考文件

  1. Lua behaves weird on PowerPC/LynxOS platform, why? (CC BY‑SA 3.0/4.0)

#powerpc #lua #lynxos






相關問題

在 MacOSX/PPC 上,關於如何在 0x0000000000000000 處捕獲 KERN_PROTECTION_FAILURE 的建議 (On MacOSX/PPC, suggestions on how to catch KERN_PROTECTION_FAILURE at 0x0000000000000000)

ppc avd 管理器和 android sdk (ppc avd manager and android sdk)

PowerPC Linux 上的 D(和 Tango) (D (and Tango) on PowerPC Linux)

Làm cách nào để trích xuất nguyên mẫu hàm từ tệp ELF? (How to extract function prototype from an ELF file?)

Lua cư xử kỳ lạ trên nền tảng PowerPC / LynxOS, tại sao? (Lua behaves weird on PowerPC/LynxOS platform, why?)

PowerPC 彙編中的位置相關、獨立代碼和全局變量 (Position Dependent, Independent Code, and Global Variables in PowerPC Assembly)

為什麼 U-Boot (DENX) 停留在引導循環並給出“程序檢查異常”? (Why U-Boot (DENX) stays in boot loop and gives "Program Check Exception"?)

如何在 AIX/powerpc 上實現原子分配? (how to implement an atomic assignment on AIX/powerpc?)

'無法啟動 Java JAR 文件“NetC.jar”。' ('The Java JAR file "NetC.jar" could not be launched.')

用於在 PowerPC 中執行系統調用的通用 C/C++ 函數 (Generic C/C++ function for execution system calls in PowerPC)

(模擬的)PPC64 Linux 上的 backtrace() 段錯誤 (backtrace() segfaults on (emulated) PPC64 Linux)

在 PowerPC (ppc64le) 架構上找不到版本“GLIBCXX_3.4.21” (version `GLIBCXX_3.4.21' not found on PowerPC (ppc64le) architecture)







留言討論