Re: How to create another lua_State in pthread?

  • From: Wolfgang Pupp <wolfgang.pupp@xxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Wed, 23 Jan 2013 23:17:50 +0100

I never realized that thread-creation can be done via FFI-only... Cool.

Henk Boom wrote:
> I couldn't find a way to get the returned callback through the lua API

I used lua_tointeger for this (not completely sure if it'd work with a
LuaJIT x64 build).

Ran into some (surprising to me) quirks though:
    print(ffi.cast('ptrdiff_t', 5))      --> cdata<int>: 0x...
    print('ptrdiff_t[1]', 5)[0]) --> 5
    print('ptrdiff_t', 5)+0)     --> 5LL

I can understand why the cast would give me a boxed int instead of a
number-- I asked for it, after all, and the documentation says that
C->Lua type conversions only happen with return values from FFI-function
calls (or when dereferencing, thus case 2).

But I don't understand why I'm getting a different result for the third
case (a boxed int64). Can someone explain?

(32bit-LuaJIT build, GIT HEAD afaik, mingw-compiled on win7/64)

Other related posts: