lua-users home
lua-l archive

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



On 12 Aug 2008, at 02:38, Tim Maxwell wrote:

Hi,

Attached are modified versions of ldump.c, lundump.h, and luac.c to allow for cross-compilation. They should work as drop-in replacements. I've done some basic testing, but I only have access to one architecture so I can't test endianness.

This code lets you specify:
* the endianness of the target platform
* the size of int as 8, 16, or 32 (no 64-bit support right now)
* lua_Number as an int (8, 16, or 32 bits) or a float (32 or 64 bits)

ldump.c exports a new function called "luaU_dump_crosscompile" that works like luaU_dump except that it takes a DumpTargetInfo structure.

luaU_dump_crosscompile supports different sizes of size_t but luac does not allow it to be set from the command line. Are there any targets where sizeof(int) is different from sizeof(size_t)?

Plenty.

Almost every C compiler for processors where a 16-bit int made sense (PDP, MC68000, Intel) had a 16-bit int and a 32-bit size_t. Some C compilers for 64-bit processors have 32-bit int and 64-bit size_t. Quite possibly some embedded ARMs have compiler modes where int is 16- bit because it fits better with an external RAM bus and it feels more "embedded".

All the world's a VAX.


This code assumes that 'float' is a standard 32-bit float and 'double' is a standard 64-bit double. It will trip a lua_assert if lua_Number is not integer but sizeof(lua_Number) is not 32 or 64. Is that portable enough?

Probably.  For now.

drj