lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


-- LuaJIT tag
--
-- commit bcd459aa0e5ab8e6df4a89c75c4f9f00ec7d0176
-- Author: Mike Pall <mike>
-- Date:   Fri Mar 30 01:36:55 2012 +0200
--
--    MIPS: Integrate and enable JIT compiler.
--

assert( jit and jit.os == "Windows" and jit.arch == "x86", "The bug happens only on Windows/x86" )
local ffi = require( "ffi" )
local C = ffi.C
local K = ffi.load( "KERNEL32" )
local U = ffi.load( "USER32" )

print()

ffi.cdef( 'uint32_t GetTickCount()' )
print( '1 C Works ', C.GetTickCount() )
print( '1 K Works ', K.GetTickCount() )
--print( '1 U should not work', U.GetTickCount() ) -- ERRORS OUT NORMALLY AS IT SHOULD

ffi.cdef( 'uint32_t __stdcall GetTickCount()' )
print( '2 C Works ', C.GetTickCount() )
print( '2 K Works ', K.GetTickCount() )
--print( '2 U should not work', U.GetTickCount() ) -- ERRORS OUT NORMALLY AS IT SHOULD

ffi.cdef( 'uint32_t winGetTickCount() asm("GetTickCount")' )
print( '3 C Works ', C.winGetTickCount() )
print( '3 K Works ', K.GetTickCount() )
print( '3 U Works ', U.GetTickCount() )  -- HANGS HERE!
print( '3 Never comes here (it hangs). Comment the previous line and it would come' )

ffi.cdef( 'uint32_t __stdcall winGetTickCount() asm("GetTickCount")' )
print( 'Works ', C.winGetTickCount() )
print( '4 C Works ', C.winGetTickCount() )
print( '4 K Works ', K.GetTickCount() )
print( '4 U Works ', U.GetTickCount() )  -- HANGS HERE!
print( '4 Never comes here (it hangs). Comment the previous line and it would come' )

--[[ - Never goes out of the loop
#if LJ_TARGET_X86 && LJ_ABI_WIN
/* Compute argument size for fastcall/stdcall functions. */
static CTSize clib_func_argsize(CTState *cts, CType *ct)
{
  CTSize n = 0;
  while (ct->sib) {
    CType *d;
    ct = ctype_get(cts, ct->sib);
    lua_assert(ctype_isfield(ct->info));
    d = ctype_rawchild(cts, ct);
    n += ((d->size + 3) & ~3);
  }
  return n;
}
#endif
--]]