Determines the bitness of Lua
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.appveyor
.travis
rockspecs
src
test
.travis.yml
LICENSE
README.md
appveyor.yml

README.md

bitness

Build Status Build status License

Determines the bitness of Lua.

Ever wanted to answer the question "Is this Lua installation I'm running on 32 or 64 bits?". Well, bitness gives you the answer.

local arch = require("bitness")()
print("Lua has been compiled as "..arch.." bits")

How it works?

Under PUC Lua, it inspects the bytecode to get the size of size_t. On LuaJIT it calls ffi.abi to get the architecture.

The module exports a single function that when called will return 32, 64 or throw an error if it can't determine the bitness.

Where does it work?

Automated tests are run with Lua 5.1, 5,2 and 5.3 and LuaJIT 2.0.4, 2.1 on both x86 and x64 platforms.

It won't work on your ZX Spectrum or your old trusty 80286. Tests probably won't run out of the box on ARM. Patches welcome.

How do I install it?

You can just use LuaRocks:

luarocks install bitness

or just copy the file bitness.lua into Lua's path.

License

bitness is available under the MIT license.