]> git.lizzy.rs Git - metalua.git/commitdiff
added 64 bits and openBSD compatibility
authorFabien Fleutot <fabien@macfabien.local>
Thu, 14 Feb 2008 21:09:04 +0000 (22:09 +0100)
committerFabien Fleutot <fabien@macfabien.local>
Thu, 14 Feb 2008 21:09:04 +0000 (22:09 +0100)
src/binlibs/pluto/pluto.c
src/binlibs/pluto/pluto.h
src/compiler/ldump.lua
src/config

index 4d3be53bf0f55fe763b1f306e5a9e86749e19b61..b0aec283d143eac485c70788f97b247eb4a2042d 100644 (file)
@@ -1530,7 +1530,7 @@ static luaL_reg pluto_reg[] = {
        { NULL, NULL }
 };
 
-int luaopen_pluto(lua_State *L) {
+LUALIB_API int luaopen_pluto(lua_State *L) {
        luaL_openlib(L, "pluto", pluto_reg, 0);
        return 1;
 }
index 7da4e1611fb4d9bdf51610c7d3d47e1ee516d810..e42f4bbe39848619db8ef2161093b36ac5decd20 100644 (file)
@@ -22,4 +22,4 @@ void pluto_persist(lua_State *L, lua_Chunkwriter writer, void *ud);
 
 void pluto_unpersist(lua_State *L, lua_Chunkreader reader, void *ud);
 
-int luaopen_pluto(lua_State *L);
+LUALIB_API int luaopen_pluto(lua_State *L);
index f2ef5da4e8094686eb9f0a51199b225708949d52..6299c4e8cfda6a9209d1ed47376673bab19f5577 100644 (file)
 
 module("bytecode", package.seeall)
 
-local cfg = { }
-cfg.little_endian, cfg.int_size, 
-cfg.size_t_size,   cfg.instr_size, 
-cfg.number_size,   cfg.integral = 
-   string.dump(function()end):byte(7, 12)
+format = { }
+format.header = string.dump(function()end):sub(1, 12)
+format.little_endian, format.int_size, 
+format.size_t_size,   format.instr_size, 
+format.number_size,   format.integral = 
+   format.header:byte(7, 12)
 
---for k, v in pairs(cfg) do
---   printf("%s:\t%i", k, v)
---end
-
-assert(cfg.number_size==8, "Number format not supported by dumper")
-assert(cfg.little_endian==1, "Big endian architectures not supported by dumper")
+assert(format.number_size==8, "Number format not supported by dumper")
+assert(format.little_endian==1, "Big endian architectures not supported by dumper")
 
 --requires luaP
 luaU = {}
@@ -234,14 +231,14 @@ end
 -- dumps a 32-bit signed integer (for int)
 ------------------------------------------------------------------------
 function luaU:DumpInt(x, D)
-  self:DumpBlock(self:from_int(x, cfg.int_size), D)
+  self:DumpBlock(self:from_int(x, format.int_size), D)
 end
 
 ------------------------------------------------------------------------
 -- dumps a 32-bit unsigned integer (for size_t)
 ------------------------------------------------------------------------
 function luaU:DumpSize(x, D)
-  self:DumpBlock(self:from_int(x, cfg.size_t_size), D)
+  self:DumpBlock(self:from_int(x, format.size_t_size), D)
 end
 
 ------------------------------------------------------------------------
@@ -393,15 +390,7 @@ end
 --FF: updated for version 5.1
 ------------------------------------------------------------------------
 function luaU:DumpHeader(D)
-  self:DumpLiteral(self.LUA_SIGNATURE, D)
-  self:DumpByte(self.VERSION, D)
-  self:DumpByte(self.FORMAT_VERSION, D)
-  self:DumpByte(self:endianness(), D)
-  self:DumpByte(4, D)  -- sizeof(int)
-  self:DumpByte(4, D)  -- sizeof(size_t)
-  self:DumpByte(4, D)  -- sizeof(Instruction)
-  self:DumpByte(8, D)  -- sizeof lua_Number
-  self:DumpByte(0, D)  -- integral flag
+  self:DumpLiteral(format.header, D)
 end
 
 ------------------------------------------------------------------------
@@ -436,11 +425,11 @@ function dump_string (proto)
 end
 
 -- FIXME: [make_setS] sucks, perform synchronous file writing
+-- Now unused
 function dump_file (proto, filename)
    local writer, buff = luaU:make_setS()
    luaU:dump (proto, writer, buff)
    local file = io.open (filename, "wb")
-   file:write (UNIX_SHARPBANG or "")
    file:write (buff.data)
    io.close(file)
    if UNIX_SHARPBANG then os.execute ("chmod a+x "..filename) end
index 5406a00c84a847afc626fef147aee1b6d56ca394..588ae32499307f516e4540e748c85391aeb0eebe 100644 (file)
@@ -5,7 +5,7 @@
 # Feel welcome to contribute additional ones! :)
 
 PLATFORM  = macosx
-PLATFORMS = macosx mingw linux
+PLATFORMS = macosx mingw linux bsd
 
 
 #########################################################
@@ -56,7 +56,15 @@ endif
 ifeq ($(PLATFORM), linux)
   LIBEXT        = so
   MKLIB         = gcc -shared
-  LDFLAGS      = -L../$(LUA_VM_DIR) -llua
+  LDFLAGS              = -L../$(LUA_VM_DIR) -llua
+  LUA_BINARIES  = $(COMPILE) $(RUN)
+endif
+
+ifeq ($(PLATFORM), bsd)
+  LIBEXT        = so
+  MKLIB         = gcc -shared
+  CFLAGS       += -fPIC
+  LDFLAGS              = -fPIC
   LUA_BINARIES  = $(COMPILE) $(RUN)
 endif