Discussion:
problems with Lua
Andreas K. Foerster
2013-07-19 19:48:31 UTC
Permalink
Hello,

my project is Lua-AKFAvatar[1]. That is an unusual graphical user
interface which can be scripted with Lua[2].

Since I try to keep everything small and portable, I thought it would
be a good idea if it could be compiled with dietlibc for embedded
Linux systems with a framebuffer.

To my own surprise I could get it working to some extend. The GUI stuff
runs. But also to my surprise, now it is Lua which seems to make trouble.

It seems to have trouble with numbers. Lua uses double for numbers.
And often I get a NaN instead of a simple number. That is at least
one problem, maybe there are others.

So has anyone here experience with Lua and dietlibc? Any hints?


I use Lua-5.2.2. I compiled it with
make ansi CC="diet gcc -m32"
If you want to test AKFAvatar for the Linux framebuffer you have to get
it from the GIT repository[3]. Put liblua.a for dietlibc in that directory.
Eventually put the header files there too, if they aren't already
in the usual places. Then build it with
./configure --host=x86 CC="diet gcc -std=gnu99"
make lua-akfavatar-linuxfb
Note: configure still requires SDL-1.2, but that isn't used in this case.
So you should have it installed, but it needn't be compiled for dietlibc.
It's all still experimental...



[1] http://akfavatar.nongnu.org
[2] http://www.lua.org
[3] git clone git://git.sv.nongnu.org/akfavatar.git
--
AKFoerster <http://AKFoerster.de/>
Felix von Leitner
2013-07-19 19:52:30 UTC
Permalink
Post by Andreas K. Foerster
my project is Lua-AKFAvatar[1]. That is an unusual graphical user
interface which can be scripted with Lua[2].
Since I try to keep everything small and portable, I thought it would
be a good idea if it could be compiled with dietlibc for embedded
Linux systems with a framebuffer.
To my own surprise I could get it working to some extend. The GUI stuff
runs. But also to my surprise, now it is Lua which seems to make trouble.
It seems to have trouble with numbers. Lua uses double for numbers.
And often I get a NaN instead of a simple number. That is at least
one problem, maybe there are others.
So has anyone here experience with Lua and dietlibc? Any hints?
The floating point input and output routines are pretty buggy,
unfortunately. Input and output of floating point numbers is harder
than it looks, it turns out :-)

Felix
Andreas K. Foerster
2013-07-19 21:50:09 UTC
Permalink
Post by Felix von Leitner
The floating point input and output routines are pretty buggy,
unfortunately. Input and output of floating point numbers is harder
than it looks, it turns out :-)
Thanks for confirming that that is the problem.
I am aware that floating points are not ideal. I avoid them in my own
code whenever I can.

It seems to be possible to compile Lua without floating points.
But it's not only a configuration option. I'm going to have a
look at it...
--
AKFoerster <http://AKFoerster.de/>
Andreas K. Foerster
2013-07-20 13:34:40 UTC
Permalink
Post by Andreas K. Foerster
I use Lua-5.2.2. I compiled it with
make ansi CC="diet gcc -m32"
Someone asked me offlist if I could write a small test
that triggers the bug.
For this test you need Lua compiled for x86 as shown above.
(My project is not needed.)

Here is a little Lua script:

----
t = {0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF}

for k,v in pairs(t) do
print(k,v)
end
----

I get the output:
----
0 65535
2 65535
3 65535
4 65535
5 65535
6 65535
7 nan
8 nan
---

Note: the first number should be 1, not 0.
And there should be no "nan".
Works fine with other libc's.
--
AKFoerster <http://AKFoerster.de/>
Lorenzo
2013-07-20 15:25:36 UTC
Permalink
Post by Andreas K. Foerster
Post by Andreas K. Foerster
I use Lua-5.2.2. I compiled it with
make ansi CC="diet gcc -m32"
Someone asked me offlist if I could write a small test
that triggers the bug.
For this test you need Lua compiled for x86 as shown above.
(My project is not needed.)
My mistake, sorry.

Loading...