Generating 32 bit byte code on 64 bit platform (lua 5.1)
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Generating 32 bit byte code on 64 bit platform (lua 5.1)
- From: Eliot Blennerhassett <ewblen@...>
- Date: 2016年2月18日 11:29:50 +1300
Greetings,
I develop for a system that embeds stripped down 32 bit lua 5.1
The system doesn't support compilation, so this is done on a host PC.
This was fine when the host was 32 bit (same endian), but doesn't work
with 64 bit host (becoming the norm these days)
So, I finally bit the bullet and modified the 64-bit (linux x86) host
Lua implementation to emit the same bytecode as 32-bit one.
Despite my fear this would be difficult, the change is almost trivial:
I added this to lundump.h:
/* default */
/* #define LUAC_STR_SIZE_TYPE size_t */
/* for 32 bit compatible bytecode */
#define LUAC_STR_SIZE_TYPE int
and replaced the use of size_t with LUAC_STR_SIZE_TYPE in ldump.c and
lundump.c
It is only used in string dump and load function, and in the bytecode
header.
There may be various caveats, but it works for me...
--
Eliot