Re: 64-bit integration - best practice

  • From: Justin Cormack <justin@xxxxxxxxxxxxxxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Mon, 15 Apr 2013 15:16:28 +0100

On 15 Apr 2013 15:09, "Stefan Hett" <stefan@xxxxxxxxxxx> wrote:
>
> Hi,
>
> I'm wondering what the suggested approach for us would be to add
64-bit-value support to Lua.
>
> The requirements/situation are/is as follows:
> - 64-support must be available for a 32-bit Windows application
> - we use integer as well as floating point values in Lua
> - we would like to make use of arithmetical calculations on 64-bit values
> - we would like to support signed/unsigned values (64-bit and 32-bit)
> - we currently do not use FFI
> - the project is close to release and consists of a lot of Lua bindings
making use of lua_pushinteger() / lua_tointeger() to pass along values
>
> I'm aware of approaches for us we could go:
> 1. use FFI to pass around 64-bit values
> 2. create our own user-data-object to pass around 64-bit data
> 3. try to patch LuaJIT to make direct use of 64-bit values (not sure if
this is possible at all)
> 4. pass along the 64-bit values as two 32-bit values via
lua_pushinteger()/lua_tointeger() and add custom functions to support the
arithmetical operations.
>
> What'd be the suggested approach?
>
> Regards,
> Stefan
>

I would use ffi. Second best option is 2 but it is probably more work in
the end if you want to use the values extensively in Lua as LuaJIT already
understands ffi integers.

Justin

Other related posts: