Hi, I found a reproducible bug in LuaJIT 2.0.0 as well as git HEAD (f772bed). Here's the test case. Only tested on 64-bit LuaJIT running on OS X 10.8.2. $ cat bug.lua local ffi = require 'ffi' ffi.cdef [[ struct timespec { int tv_sec; long tv_nsec; } int nanosleep(const struct timespec *req, struct timespec *rem); ]] local ret = ffi.C.nanosleep(ffi.new('struct timespec'), nil) print(type(ret), ret) $ luajit bug.lua cdata cdata<struct timespec>: 0x0004bb90 I expected ffi.C.nanosleep to return int, not a struct timespec. Anders