lua-users home
lua-l archive

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


My first guess is conflicting function prototypes. This happens in embedded development a lot when a library is built

softfloat_double baz(softfloat_double x);

Except that you don't see the conflict because softfloat_double is spelled "double" when compiling with -msoft-float or whatever the compiler option is. Compiling with a mix of flags gets you a mix of declarations, and weird behavior.

The calling conventions of many (most?) machines place hardfloat arguments and return values in FP registers instead of general purpose ones. By definition, softfloat code doesn't alter FP registers so you often get the previous hardfloat function's return value instead.

People with pure stack-based calling conventions won't notice, but they're on slow or expensive processors.

I really wish C was only taught on I32LP64 big-endian MIPS or something. Actually, a protected-mode i286 would be ideal, since that will teach you not to do pointer arithmetic with values outside an array....

On Apr 3, 2013 5:47 PM, "dcharno" <dcharno@comcast.net> wrote:
I've been using it on a PPC 450gx with now problems either.  But it looks like he has some problem though.

On Apr 3, 2013, at 5:33 PM, Eric Wing <ewmailing@gmail.com> wrote:

> On 4/2/13, Li, Samuel <samuel.li@spx.com> wrote:
>> I choose Lua 5.1 as my application's embedded scripting language, but when I
>> port the application to a legacy platform runs LynxOS 3.1 on PowerPC,
>> things seems going wrong.
>> I get following code run up on 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(;;);
>> }
>> 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.
>
> I used Lua for years on PowerPC based Macs and never noticed any
> problems. I never had to setup anything special for PowerPC. I just
> used the Mac makefile target which I don't think does anything special
> because it works for both PowerPC and Intel. Lua tends to be pure ANSI
> C everywhere which means no #if clauses for platform specific things
> like endianess.
>
>
> -Eric
> --
> Beginning iPhone Games Development
> http://playcontrol.net/iphonegamebook/
>