![](https://secure.gravatar.com/avatar/62c54476729274ddfefd6b1f53e311dc.jpg?s=120&d=mm&r=g)
Luigi, this looks very promising!!! I've been able to run a simple document with my publisher with it. Great. Just a question: there seems to be a new bit library included, right? Is this documented anywhere? Is the library itself documented? It has these functions: bit = { ["rol"] = "function: builtin#71" ["rshift"] = "function: builtin#69" ["ror"] = "function: builtin#72" ["bswap"] = "function: builtin#67" ["bxor"] = "function: builtin#75" ["bor"] = "function: builtin#74" ["arshift"] = "function: builtin#70" ["bnot"] = "function: builtin#66" ["tobit"] = "function: builtin#65" ["lshift"] = "function: builtin#68" ["tohex"] = "function: builtin#76" ["band"] = "function: builtin#73" } Patrick
![](https://secure.gravatar.com/avatar/c4f0c6e51c7e20868aeb1c84fd05f61f.jpg?s=120&d=mm&r=g)
On Thu, Jan 10, 2013 at 11:26 PM, Patrick Gundlach
Luigi,
this looks very promising!!! I've been able to run a simple document with my publisher with it. Great.
Just a question: there seems to be a new bit library included, right? Is this documented anywhere? Is the library itself documented?
It has these functions:
bit = { ["rol"] = "function: builtin#71" ["rshift"] = "function: builtin#69" ["ror"] = "function: builtin#72" ["bswap"] = "function: builtin#67" ["bxor"] = "function: builtin#75" ["bor"] = "function: builtin#74" ["arshift"] = "function: builtin#70" ["bnot"] = "function: builtin#66" ["tobit"] = "function: builtin#65" ["lshift"] = "function: builtin#68" ["tohex"] = "function: builtin#76" ["band"] = "function: builtin#73" }
![](https://secure.gravatar.com/avatar/62c54476729274ddfefd6b1f53e311dc.jpg?s=120&d=mm&r=g)
![](https://secure.gravatar.com/avatar/386a116d129cdc597f2bb6210bbaff7a.jpg?s=120&d=mm&r=g)
On Thu, Jan 10, 2013 at 4:30 PM, minux
On Thu, Jan 10, 2013 at 11:26 PM, Patrick Gundlach
wrote: Luigi,
this looks very promising!!! I've been able to run a simple document with my publisher with it. Great.
Just a question: there seems to be a new bit library included, right? Is this documented anywhere? Is the library itself documented?
It has these functions:
bit = { ["rol"] = "function: builtin#71" ["rshift"] = "function: builtin#69" ["ror"] = "function: builtin#72" ["bswap"] = "function: builtin#67" ["bxor"] = "function: builtin#75" ["bor"] = "function: builtin#74" ["arshift"] = "function: builtin#70" ["bnot"] = "function: builtin#66" ["tobit"] = "function: builtin#65" ["lshift"] = "function: builtin#68" ["tohex"] = "function: builtin#76" ["band"] = "function: builtin#73" }
This is the standard bit library of luajit but there is also bit32 Why two bit library ? bit32 is the bit lib of lua5.2, so it helps the programmer You can check bit32 with the following code (from H. Hagen). Please, note that I've not checked that the bit gives the same results -- but I would like to know, of course. print("testing bitwise operations") assert(bit32.band() == bit32.bnot(0)) assert(bit32.btest() == true) assert(bit32.bor() == 0) assert(bit32.bxor() == 0) assert(bit32.band() == bit32.band(0xffffffff)) assert(bit32.band(1,2) == 0) -- out-of-range numbers assert(bit32.band(-1) == 0xffffffff) assert(bit32.band(2^33 - 1) == 0xffffffff) assert(bit32.band(-2^33 - 1) == 0xffffffff) assert(bit32.band(2^33 + 1) == 1) assert(bit32.band(-2^33 + 1) == 1) assert(bit32.band(-2^40) == 0) assert(bit32.band(2^40) == 0) assert(bit32.band(-2^40 - 2) == 0xfffffffe) assert(bit32.band(2^40 - 4) == 0xfffffffc) assert(bit32.lrotate(0, -1) == 0) assert(bit32.lrotate(0, 7) == 0) assert(bit32.lrotate(0x12345678, 4) == 0x23456781) assert(bit32.rrotate(0x12345678, -4) == 0x23456781) assert(bit32.lrotate(0x12345678, -8) == 0x78123456) assert(bit32.rrotate(0x12345678, 8) == 0x78123456) assert(bit32.lrotate(0xaaaaaaaa, 2) == 0xaaaaaaaa) assert(bit32.lrotate(0xaaaaaaaa, -2) == 0xaaaaaaaa) for i = -50, 50 do assert(bit32.lrotate(0x89abcdef, i) == bit32.lrotate(0x89abcdef, i%32)) end assert(bit32.lshift(0x12345678, 4) == 0x23456780) assert(bit32.lshift(0x12345678, 8) == 0x34567800) assert(bit32.lshift(0x12345678, -4) == 0x01234567) assert(bit32.lshift(0x12345678, -8) == 0x00123456) assert(bit32.lshift(0x12345678, 32) == 0) assert(bit32.lshift(0x12345678, -32) == 0) assert(bit32.rshift(0x12345678, 4) == 0x01234567) assert(bit32.rshift(0x12345678, 8) == 0x00123456) assert(bit32.rshift(0x12345678, 32) == 0) assert(bit32.rshift(0x12345678, -32) == 0) assert(bit32.arshift(0x12345678, 0) == 0x12345678) assert(bit32.arshift(0x12345678, 1) == 0x12345678 / 2) assert(bit32.arshift(0x12345678, -1) == 0x12345678 * 2) assert(bit32.arshift(-1, 1) == 0xffffffff) assert(bit32.arshift(-1, 24) == 0xffffffff) assert(bit32.arshift(-1, 32) == 0xffffffff) assert(bit32.arshift(-1, -1) == (-1 * 2) % 2^32) print("+") -- some special cases local c = {0, 1, 2, 3, 10, 0x80000000, 0xaaaaaaaa, 0x55555555, 0xffffffff, 0x7fffffff} for _, b in pairs(c) do assert(bit32.band(b) == b) assert(bit32.band(b, b) == b) assert(bit32.btest(b, b) == (b ~= 0)) assert(bit32.band(b, b, b) == b) assert(bit32.btest(b, b, b) == (b ~= 0)) assert(bit32.band(b, bit32.bnot(b)) == 0) assert(bit32.bor(b, bit32.bnot(b)) == bit32.bnot(0)) assert(bit32.bor(b) == b) assert(bit32.bor(b, b) == b) assert(bit32.bor(b, b, b) == b) assert(bit32.bxor(b) == b) assert(bit32.bxor(b, b) == 0) assert(bit32.bxor(b, 0) == b) assert(bit32.bnot(b) ~= b) assert(bit32.bnot(bit32.bnot(b)) == b) assert(bit32.bnot(b) == 2^32 - 1 - b) assert(bit32.lrotate(b, 32) == b) assert(bit32.rrotate(b, 32) == b) assert(bit32.lshift(bit32.lshift(b, -4), 4) == bit32.band(b, bit32.bnot(0xf))) assert(bit32.rshift(bit32.rshift(b, 4), -4) == bit32.band(b, bit32.bnot(0xf))) for i = -40, 40 do assert(bit32.lshift(b, i) == math.floor((b * 2^i) % 2^32)) end end assert(not pcall(bit32.band, {})) assert(not pcall(bit32.bnot, "a")) assert(not pcall(bit32.lshift, 45)) assert(not pcall(bit32.lshift, 45, print)) assert(not pcall(bit32.rshift, 45, print)) print("+") -- testing extract/replace assert(bit32.extract(0x12345678, 0, 4) == 8) assert(bit32.extract(0x12345678, 4, 4) == 7) assert(bit32.extract(0xa0001111, 28, 4) == 0xa) assert(bit32.extract(0xa0001111, 31, 1) == 1) assert(bit32.extract(0x50000111, 31, 1) == 0) assert(bit32.extract(0xf2345679, 0, 32) == 0xf2345679) assert(not pcall(bit32.extract, 0, -1)) assert(not pcall(bit32.extract, 0, 32)) assert(not pcall(bit32.extract, 0, 0, 33)) assert(not pcall(bit32.extract, 0, 31, 2)) assert(bit32.replace(0x12345678, 5, 28, 4) == 0x52345678) assert(bit32.replace(0x12345678, 0x87654321, 0, 32) == 0x87654321) assert(bit32.replace(0, 1, 2) == 2^2) assert(bit32.replace(0, -1, 4) == 2^4) assert(bit32.replace(-1, 0, 31) == 2^31 - 1) assert(bit32.replace(-1, 0, 1, 2) == 2^32 - 7) print'OK' -- luigi
![](https://secure.gravatar.com/avatar/49e63acb01f2ca80efce7eed08310ce8.jpg?s=120&d=mm&r=g)
On 1/10/2013 4:26 PM, Patrick Gundlach wrote:
Luigi,
this looks very promising!!! I've been able to run a simple document with my publisher with it. Great.
Just a question: there seems to be a new bit library included, right? Is this documented anywhere? Is the library itself documented?
It has these functions:
bit = { ["rol"] = "function: builtin#71" ["rshift"] = "function: builtin#69" ["ror"] = "function: builtin#72" ["bswap"] = "function: builtin#67" ["bxor"] = "function: builtin#75" ["bor"] = "function: builtin#74" ["arshift"] = "function: builtin#70" ["bnot"] = "function: builtin#66" ["tobit"] = "function: builtin#65" ["lshift"] = "function: builtin#68" ["tohex"] = "function: builtin#76" ["band"] = "function: builtin#73" }
that one is different from the stock lua 5.2 bit32 library so we decided to add bit32 to luajittex as well as that is the standard (bit32 is documented in the 5.2 manual, and bit on the luajit website) some functions can be mapped onto the jit bit library (jit will optimize build in functions) Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
![](https://secure.gravatar.com/avatar/386a116d129cdc597f2bb6210bbaff7a.jpg?s=120&d=mm&r=g)
On Thu, Jan 10, 2013 at 5:20 PM, Hans Hagen
On 1/10/2013 4:26 PM, Patrick Gundlach wrote:
Luigi,
this looks very promising!!! I've been able to run a simple document with my publisher with it. Great.
Are you using clang or gcc ? Did you checked some C module -- i.e. the binding for libxml ? Remember that it's lua5.1 !!!
PS the really fun for you is the ffi module... -- luigi
![](https://secure.gravatar.com/avatar/62c54476729274ddfefd6b1f53e311dc.jpg?s=120&d=mm&r=g)
Am 10.01.2013 um 18:22 schrieb luigi scarso
On Thu, Jan 10, 2013 at 5:20 PM, Hans Hagen
wrote: On 1/10/2013 4:26 PM, Patrick Gundlach wrote:
Luigi,
this looks very promising!!! I've been able to run a simple document with my publisher with it. Great.
Are you using clang or gcc ?
Neither, I use Mac. (Seriously: I have no idea - I guess I use gcc :) $ type gcc gcc is /usr/bin/gcc $ type clang clang is /usr/bin/clang no mentioning of "clang" in ./buildjit.sh output
Did you checked some C module -- i.e. the binding for libxml ?
not yet. I will need to make my publisher run with luajittex smoothly first. But I am lying in bed and unable to do serious work.
the really fun for you is the ffi module...
I've seen that :) Patrick
![](https://secure.gravatar.com/avatar/386a116d129cdc597f2bb6210bbaff7a.jpg?s=120&d=mm&r=g)
On Thu, Jan 10, 2013 at 8:08 PM, Patrick Gundlach
not yet. I will need to make my publisher run with luajittex smoothly first. But I am lying in bed and unable to do serious work. sorry to stress you.. I've added a check of Darwin X86_64, so that the export LDFLAGS=.. should be not needed anymore.. can you check ? (It assumes the gcc compiler)
-- luigi
![](https://secure.gravatar.com/avatar/386a116d129cdc597f2bb6210bbaff7a.jpg?s=120&d=mm&r=g)
I've added the script buildjit-clang.sh I've checked under linux 64bit, and it works even if there are some warnings on luajit. The performances are slightly different vs gcc (gcc is better) but nothing of important. I've not compiled the MacOS X Intel x86_64, but there should be no warnings on luajit. So we have buildjit.sh: Linux and Mac, gcc compiler. Under linux is better to use this one. buildjit-clang.sh:Linux and Mac, clang compiler. Under MaCOS could the default choice. -- luigi
![](https://secure.gravatar.com/avatar/49e63acb01f2ca80efce7eed08310ce8.jpg?s=120&d=mm&r=g)
On 1/11/2013 6:29 PM, luigi scarso wrote:
I've added the script buildjit-clang.sh
I've checked under linux 64bit, and it works even if there are some warnings on luajit. The performances are slightly different vs gcc (gcc is better) but nothing of important.
btw, we measured just a few % slower processing on our benchmarks so it's neglectable, but then: using -O3 on gcc is also faster so speed is hard to define Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
participants (4)
-
Hans Hagen
-
luigi scarso
-
minux
-
Patrick Gundlach