lua-users home
lua-l archive

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


On Sun, Mar 7, 2010 at 7:06 PM, Mike Pall <mikelu-1003@mike.de> wrote:
> LuaJIT builds out-of-the-box on most x86 or x64 operating systems
> (Linux, Windows, OSX etc.).

Running the msvcbuild included in beta3 from a Visual Studio 2008 x64
command prompt on Vista x64 yields:
j_err.c(636) : error C2061: syntax error : identifier 'PEXCEPTION_ROUTINE'
It then proceeds with further errors, but they are likely just results
of the above:
lj_err.c(638) : error C2061: syntax error : identifier 'HistoryTable'
lj_err.c(638) : error C2059: syntax error : ';'
lj_err.c(641) : error C2059: syntax error : '}'
lj_err.c(657) : error C2143: syntax error : missing ')' before '*'
lj_err.c(657) : error C2081: 'UndocumentedDispatcherContext' : name in formal pa
rameter list illegal
lj_err.c(657) : error C2143: syntax error : missing '{' before '*'
lj_err.c(657) : error C2059: syntax error : ')'
lj_err.c(658) : error C2054: expected '(' to follow 'dispatch'
This is followed by numerous "unresolved external symbol" linker
errors, again likely all due to lj_err.c not compiling.

Giving it a definition for PEXCEPTION_ROUTINE causes similar errors
about PUNWIND_HISTORY_TABLE. After also giving it a definition for
PUNWIND_HISTORY_TABLE, it warns about RtlUnwindEx being undefined.
All-in-all, adding the following definitions around line 627 caused
compilation to succeed: (I'm not confident that any of the definitions
are correct though)

typedef EXCEPTION_DISPOSITION (*PEXCEPTION_ROUTINE) (
  struct _EXCEPTION_RECORD *ExceptionRecord,
  PVOID EstablisherFrame,
  struct _CONTEXT *ContextRecord,
  PVOID DispatcherContext
);
#define UNWIND_HISTORY_TABLE_SIZE 12
typedef struct _UNWIND_HISTORY_TABLE_ENTRY {
  ULONG64 ImageBase;
  PRUNTIME_FUNCTION FunctionEntry;
} UNWIND_HISTORY_TABLE_ENTRY, *PUNWIND_HISTORY_TABLE_ENTRY;
typedef struct _UNWIND_HISTORY_TABLE {
  ULONG Count;
  UCHAR Search;
  ULONG64 LowAddress;
  ULONG64 HighAddress;
  UNWIND_HISTORY_TABLE_ENTRY Entry[UNWIND_HISTORY_TABLE_SIZE];
} UNWIND_HISTORY_TABLE, *PUNWIND_HISTORY_TABLE;
VOID NTAPI RtlUnwindEx(
  PVOID TargetFrame,
  PVOID TargetIp,
  PEXCEPTION_RECORD ExceptionRecord,
  PVOID ReturnValue,
  PCONTEXT OriginalContext,
  PUNWIND_HISTORY_TABLE HistoryTable
);

The resulting DLL then worked as a drop-in replacement for a 64-bit
compilation of the standard Lua DLL, with only one minor change to the
application source code (which is ~30K lines of Lua, ~20K lines of
C/C++). The change was regarding the standard io.lines function - I
read the manual as saying that io.lines returns an iterator function,
which just happens to work in the generic for loop, which is how the
standard implementation works. The LuaJIT implementation of io.lines
returns an iterator function and an iterator state, which again just
happens to work in the generic for loop, but doesn't work with code
expecting just a single function return value.