RetroBSD

2.11BSD operating system for microcontrollers
It is currently Tue Jan 18, 2022 8:21 am

All times are UTC




Post new topic Reply to topic  [ 16 posts ] 
Author Message
 Post subject: Lua 5.3.2 Latest Version
PostPosted: Sat Jan 09, 2016 1:46 pm 
User avatar

Joined: Fri Mar 06, 2015 9:13 pm
Posts: 37
Location: Barcelona, SP
Maybe Interesting working from swap and without FPU at the moment.

http://www.lua.org/download.html

But something for code also in place....

If are ok maybe ibara is possible to add to the pkg list....


Attachments:
File comment: Extract files
lua / bisect.lua

lua.zip [385.6 KiB]
Downloaded 869 times

_________________
Dennis MacAlistair Ritchie (Sep.09.1941 - Oct.12.2011)
Top
 Profile  
 
PostPosted: Sat Jan 09, 2016 4:31 pm 
Contributor
User avatar

Joined: Sun Oct 20, 2013 3:15 am
Posts: 322
Cool! Your example bisect.lua program works here.
I created a package and uploaded it to the package repo.
https://devio.us/~bcallah/pub/LiteBSD/packages/

It has the following information in its plist. Let me know if your email address is correct.
Code:
Powerful, fast, lightweight, embeddable scripting language.
Maintainer: mferrera@cssiberica.com
License: MIT
###
bin/lua
share/examples/lua-5.3.2/bisect.lua


Also, do you have the code you built it from? We can add it to the ports repository on GitHub.

_________________
@__briancallahan on Twitter


Top
 Profile  
 
PostPosted: Sat Jan 09, 2016 6:48 pm 
Contributor
User avatar

Joined: Sun Oct 20, 2013 3:15 am
Posts: 322
Oh also do you have liblua.a? That would be extremely important to add to the package.

_________________
@__briancallahan on Twitter


Top
 Profile  
 
PostPosted: Sat Jan 09, 2016 8:50 pm 
User avatar

Joined: Fri Mar 06, 2015 9:13 pm
Posts: 37
Location: Barcelona, SP
ibara wrote:
Cool! Your example bisect.lua program works here.
I created a package and uploaded it to the package repo.
https://devio.us/~bcallah/pub/LiteBSD/packages/

It has the following information in its plist. Let me know if your email address is correct.
Code:
Powerful, fast, lightweight, embeddable scripting language.
Maintainer: mferrera@cssiberica.com
License: MIT
###
bin/lua
share/examples/lua-5.3.2/bisect.lua


Also, do you have the code you built it from? We can add it to the ports repository on GitHub.


The e-mail is ok, the project i used for compile it's here
http://whitecatboard.org/websvn/listing.php?repname=Whitecat&path=%2FLiteBSD%2Fapps%2Flua%2F
It's a Netbeans project like all other ones, it's more comfortable to me to work on this way but easy to port to bmake.

Also can be downloaded from http://www.lua.org/download.html it compiles out of the box with some CFLAGS

On the nbproject folder can see the makefiles with the flags used for compile the binary. Remove luac.c from compilation because has also main() method i attached this utility i forgot before on this post too.

Use of luac
Code:
# ls -l
total 44
-rw-rw-r--  1 root  wheel    699 Jan  1 13:06 .cshrc
-rw-rw-r--  1 root  wheel     62 Jan  1 13:06 .klogin
-rw-rw-r--  1 root  wheel    193 Jan  1 13:06 .login
-rw-rw-r--  1 root  wheel  15442 Jan  1 13:10 .mkshrc
-rw-rw-r--  1 root  wheel    396 Jan  4 18:57 .profile
-rw-rw-r--  1 root  wheel     28 Jan  1 13:06 .rhosts
-rw-r--r--  1 root  wheel    659 Jan  4 20:05 bisect.lua
-rwxr-xr-x  1 root  wheel    102 Jan  4 19:07 mqtt
# luac bisect.lua
# ls -l
total 48
-rw-rw-r--  1 root  wheel    699 Jan  1 13:06 .cshrc
-rw-rw-r--  1 root  wheel     62 Jan  1 13:06 .klogin
-rw-rw-r--  1 root  wheel    193 Jan  1 13:06 .login
-rw-rw-r--  1 root  wheel  15442 Jan  1 13:10 .mkshrc
-rw-rw-r--  1 root  wheel    396 Jan  4 18:57 .profile
-rw-rw-r--  1 root  wheel     28 Jan  1 13:06 .rhosts
-rw-r--r--  1 root  wheel    659 Jan  4 20:05 bisect.lua
-rw-r--r--  1 root  wheel   1368 Jan  4 21:15 luac.out
-rwxr-xr-x  1 root  wheel    102 Jan  4 19:07 mqtt
# lua luac.out
0 c=1.5 a=1 b=2
1 c=1.25 a=1 b=1.5
2 c=1.375 a=1.25 b=1.5
3 c=1.3125 a=1.25 b=1.375
4 c=1.34375 a=1.3125 b=1.375
5 c=1.328125 a=1.3125 b=1.34375
6 c=1.3203125 a=1.3125 b=1.328125
7 c=1.32421875 a=1.3203125 b=1.328125
8 c=1.326171875 a=1.32421875 b=1.328125
9 c=1.3251953125 a=1.32421875 b=1.326171875
10 c=1.32470703125 a=1.32421875 b=1.3251953125
11 c=1.324951171875 a=1.32470703125 b=1.3251953125
12 c=1.3248291015625 a=1.32470703125 b=1.324951171875
13 c=1.3247680664062 a=1.32470703125 b=1.3248291015625
14 c=1.3247375488281 a=1.32470703125 b=1.3247680664062
15 c=1.3247222900391 a=1.32470703125 b=1.3247375488281
16 c=1.3247146606445 a=1.32470703125 b=1.3247222900391
17 c=1.3247184753418 a=1.3247146606445 b=1.3247222900391
18 c=1.3247165679932 a=1.3247146606445 b=1.3247184753418
19 c=1.3247175216675 a=1.3247165679932 b=1.3247184753418
20 c=1.3247179985046 a=1.3247175216675 b=1.3247184753418
after 20 steps, root is 1.3247179985046387 with error 9.5e-07, f=1.8e-07
#


BTW Ibara it's possible to use the httpsrv project on the same svn repo up in apps i got e-mail from his creator and the license is ok, the good thing about this http server is very easy and simple and fast too. I will manage to modify the code to implement shell scripts stdout to the http response.


Attachments:
File comment: luac Lua compiler to generate bytecode for the Lua interpreter
luac.zip [386.3 KiB]
Downloaded 887 times

_________________
Dennis MacAlistair Ritchie (Sep.09.1941 - Oct.12.2011)
Top
 Profile  
 
PostPosted: Sun Jan 10, 2016 4:40 am 
Contributor
User avatar

Joined: Sun Oct 20, 2013 3:15 am
Posts: 322
liblua53.a is also really important: a lot of projects embed Lua and then link to the library for scripting support. Do you have that too (with headers)? Then we'd have a more-or-less complete lua-5.3.2 package.

Mikeloto wrote:
BTW Ibara it's possible to use the httpsrv project on the same svn repo up in apps i got e-mail from his creator and the license is ok, the good thing about this http server is very easy and simple and fast too. I will manage to modify the code to implement shell scripts stdout to the http response.

Sure. Do you have binaries or do I need to make one for the package?

_________________
@__briancallahan on Twitter


Top
 Profile  
 
PostPosted: Sun Jan 10, 2016 11:14 am 
Contributor
User avatar

Joined: Thu Nov 08, 2012 7:04 am
Posts: 2401
Location: Rapa Nui
Cool!
Code:
# time ./luac bisect.lua
    0m-1.175s real     0m-1.155s user     0m-1.102s system
# ls -l
total 1904
-rw-r--r--  1 root  wheel     659 Jan  9 05:20 bisect.lua
-rw-r--r--  1 root  wheel    3040 Apr 25  2014 bmp.h
-rwxr-xr-x  1 root  wheel  944556 Jan  9 06:32 lua
-rwxr-xr-x  1 root  wheel  948144 Jan  9 13:46 luac
-rw-r--r--  1 root  wheel    1368 Jan  1 04:47 luac.out
-rw-r--r--  1 root  wheel    2781 Dec  9 16:11 mandel.c
-rw-r--r--  1 root  wheel    9644 Jan  1 03:06 mandel.s
-rw-r--r--  1 root  wheel    3007 Dec 30 04:50 rc4.c
-rw-r--r--  1 root  wheel    9290 Jan  1 04:33 rc4.s
# time ./lua luac.out
0 c=1.5 a=1 b=2
1 c=1.25 a=1 b=1.5
2 c=1.375 a=1.25 b=1.5
3 c=1.3125 a=1.25 b=1.375
4 c=1.34375 a=1.3125 b=1.375
5 c=1.328125 a=1.3125 b=1.34375
6 c=1.3203125 a=1.3125 b=1.328125
7 c=1.32421875 a=1.3203125 b=1.328125
8 c=1.326171875 a=1.32421875 b=1.328125
9 c=1.3251953125 a=1.32421875 b=1.326171875
10 c=1.32470703125 a=1.32421875 b=1.3251953125
11 c=1.324951171875 a=1.32470703125 b=1.3251953125
12 c=1.3248291015625 a=1.32470703125 b=1.324951171875
13 c=1.3247680664062 a=1.32470703125 b=1.3248291015625
14 c=1.3247375488281 a=1.32470703125 b=1.3247680664062
15 c=1.3247222900391 a=1.32470703125 b=1.3247375488281
16 c=1.3247146606445 a=1.32470703125 b=1.3247222900391
17 c=1.3247184753418 a=1.3247146606445 b=1.3247222900391
18 c=1.3247165679932 a=1.3247146606445 b=1.3247184753418
19 c=1.3247175216675 a=1.3247165679932 b=1.3247184753418
20 c=1.3247179985046 a=1.3247175216675 b=1.3247184753418
after 20 steps, root is 1.3247179985046387 with error 9.5e-07, f=1.8e-07
    0m3.141s real     0m3.42s user     0m-1.102s system
#

_________________
Pukao Hats Cleaning Services Ltd.


Top
 Profile  
 
PostPosted: Sun Jan 10, 2016 6:26 pm 
Contributor
User avatar

Joined: Thu Nov 08, 2012 7:04 am
Posts: 2401
Location: Rapa Nui
@Mikeloto: Long time back I messed with pic32lua and afaik the resulting binary was something around 250kBytes (standalone Lua 5.1.4 plus pic32mx enhancements, compiled with mchp's C32). http://www.askrprojects.net/software/pi ... index.html
Why is yours 4x larger?
PS: From my v0.4b map file:
Code:
         Total Program Memory used  :     0x3e37c      254844  47.9% of 0x81e00
        --------------------------------------------------------------------------

_________________
Pukao Hats Cleaning Services Ltd.


Top
 Profile  
 
PostPosted: Wed Jan 13, 2016 11:46 am 
User avatar

Joined: Fri Mar 06, 2015 9:13 pm
Posts: 37
Location: Barcelona, SP
Pito wrote:
@Mikeloto: Long time back I messed with pic32lua and afaik the resulting binary was something around 250kBytes (standalone Lua 5.1.4 plus pic32mx enhancements, compiled with mchp's C32). http://www.askrprojects.net/software/pi ... index.html
Why is yours 4x larger?
PS: From my v0.4b map file:
Code:
         Total Program Memory used  :     0x3e37c      254844  47.9% of 0x81e00
        --------------------------------------------------------------------------


This is full featured Lua from it's source this means do you have exactly the same lua you can find on the desktop, with all the libs, math, etc.....

Our project LuaOS_V1 is more optimized you can look at,
https://github.com/whitecatboard/LuaOS_V1

My idea here is just to check "big" program out of the box.

_________________
Dennis MacAlistair Ritchie (Sep.09.1941 - Oct.12.2011)


Top
 Profile  
 
PostPosted: Sat Jan 23, 2016 6:23 am 
Contributor
User avatar

Joined: Sun Oct 20, 2013 3:15 am
Posts: 322
Hi team --

I've gone ahead and made a branch that imports Lua 5.3.2 into the base system (as lib/liblua and usr.bin/lua -- which contains lua(1) and luac(1)): https://github.com/sergev/LiteBSD/tree/lua

I think there's a lot of benefits to having lua in base:
1. An accessible scripting language is a positive selling point for LiteBSD. Perl is huge, so it's not really an option, and Python has a non-standard license. Lua is MIT licensed which makes it perfectly acceptable for base. (Note that I don't consider shell scripting "accessible.")
2. Scripting languages in base are not uncommon in the *BSD world. OpenBSD and NetBSD both include Perl, and NetBSD even includes Lua itself as a kernel scripting language (I don't advocate we do anything like lua(4) though, mind you).
3. The ability to prototype new utilities. Things like adduser(1) are Perl scripts on half of the BSDs. No reason we can't replicate that with Lua. Lua can also be called from C, which is a nice bonus the other scripting languages can't do all that well.
4. Finding and fixing bugs. One has already been reported, the #! not working properly: https://github.com/sergev/LiteBSD/issues/43 -- I've found others as well, such as 64-bit numbers not working properly (yes I'm aware that 4.4BSD-Lite2 was released before long long was added to the standard, but that doesn't mean it should never be supported).
5. It really is tiny! The whole liblua.a is only around 150K. I think that fits with the spirit of LiteBSD.

For those looking to see how 64-bit numbers are broken, here's a lua program to demonstrate (save it as factorial.lua):
Code:
function factorial(n)
  if (n == 0) then
    return 1
  else
    return n * factorial(n - 1)
  end
end

for n = 0, 16 do
  io.write(n, "! = ", factorial(n), "\n")
end

Then run it as
Code:
$ lua factorial.lua

You'll notice that from 13! onward (i.e. when the result is larger than UINT_MAX), the results are wrong.

_________________
@__briancallahan on Twitter


Top
 Profile  
 
PostPosted: Sun Jan 24, 2016 8:52 am 
Committer
User avatar

Joined: Wed Oct 10, 2012 11:01 pm
Posts: 1081
Location: Sunnyvale, CA
Pico-C is another good alternative as a scripting language to consider.


Top
 Profile  
 
PostPosted: Sun Jan 24, 2016 10:12 am 
Contributor
User avatar

Joined: Thu Nov 08, 2012 7:04 am
Posts: 2401
Location: Rapa Nui
Mind the Lua type is 64bit double precision float.
There is none integer type. The integer math uses a mantissa (or significand of the float) only, which is maybe 52 bits. I've seen somewhere the newest Lua introduces integer as a type, not sure this one does.

_________________
Pukao Hats Cleaning Services Ltd.


Top
 Profile  
 
PostPosted: Sun Jan 24, 2016 10:22 am 
Committer
User avatar

Joined: Wed Oct 10, 2012 11:01 pm
Posts: 1081
Location: Sunnyvale, CA
It is possible to build Lua with basic number type defined as 32bit float. See parameter LUA_FLOAT_TYPE in luaconf.h.


Top
 Profile  
 
PostPosted: Sun Jan 24, 2016 10:37 am 
Contributor
User avatar

Joined: Thu Nov 08, 2012 7:04 am
Posts: 2401
Location: Rapa Nui
You can build Lua with basic number type defined as 32bit integer..

_________________
Pukao Hats Cleaning Services Ltd.


Top
 Profile  
 
PostPosted: Sun Jan 24, 2016 5:19 pm 
Contributor
User avatar

Joined: Sun Oct 20, 2013 3:15 am
Posts: 322
Yes I know. But I think both are undesirable options. No one writes Lua with those assumptions any more. Plus, it lets someone who's motivated enough to add those features/fix those bugs.

_________________
@__briancallahan on Twitter


Top
 Profile  
 
PostPosted: Mon Jan 25, 2016 8:18 pm 
Contributor
User avatar

Joined: Thu Nov 08, 2012 7:04 am
Posts: 2401
Location: Rapa Nui
5.3.2 has got (in addition to double float) the long long integer type.. The conversion to/from double float is automatic as required from context..

_________________
Pukao Hats Cleaning Services Ltd.


Top
 Profile  
 
PostPosted: Thu Jun 23, 2016 4:46 pm 
Contributor
User avatar

Joined: Sun Oct 20, 2013 3:15 am
Posts: 322
I've updated Lua to 5.3.3--it's just a small bugfix release but it's nice to keep things up-to-date.

_________________
@__briancallahan on Twitter


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 16 posts ] 

All times are UTC


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
cron




Powered by phpBB® Forum Software © phpBB Group

BSD Daemon used with permission