1diff -ur -x lbitlib.c LuaJIT-2.0.3.orig/src/Makefile LuaJIT-2.0.3/src/Makefile 2--- LuaJIT-2.0.3.orig/src/Makefile 2014-03-12 13:10:00.000000000 +0100 3+++ LuaJIT-2.0.3/src/Makefile 2014-03-14 09:15:50.000000000 +0100 4@@ -100,7 +100,7 @@ 5 # enabled by default. Some other features that *might* break some existing 6 # code (e.g. __pairs or os.execute() return values) can be enabled here. 7 # Note: this does not provide full compatibility with Lua 5.2 at this time. 8-#XCFLAGS+= -DLUAJIT_ENABLE_LUA52COMPAT 9+XCFLAGS+= -DLUAJIT_ENABLE_LUA52COMPAT 10 # 11 # Disable the JIT compiler, i.e. turn LuaJIT into a pure interpreter. 12 #XCFLAGS+= -DLUAJIT_DISABLE_JIT 13@@ -450,7 +450,7 @@ 14 LJVM_BOUT= $(LJVM_S) 15 LJVM_MODE= elfasm 16 17-LJLIB_O= lib_base.o lib_math.o lib_bit.o lib_string.o lib_table.o \ 18+LJLIB_O= lib_base.o lib_math.o lbitlib.o lib_bit.o lib_string.o lib_table.o \ 19 lib_io.o lib_os.o lib_package.o lib_debug.o lib_jit.o lib_ffi.o 20 LJLIB_C= $(LJLIB_O:.o=.c) 21 22diff -ur -x lbitlib.c LuaJIT-2.0.3.orig/src/Makefile.dep LuaJIT-2.0.3/src/Makefile.dep 23--- LuaJIT-2.0.3.orig/src/Makefile.dep 2014-03-12 13:10:00.000000000 +0100 24+++ LuaJIT-2.0.3/src/Makefile.dep 2014-03-14 09:15:50.000000000 +0100 25@@ -6,6 +6,7 @@ 26 lj_tab.h lj_meta.h lj_state.h lj_ctype.h lj_cconv.h lj_bc.h lj_ff.h \ 27 lj_ffdef.h lj_dispatch.h lj_jit.h lj_ir.h lj_char.h lj_strscan.h \ 28 lj_lib.h lj_libdef.h 29+lbitlib.o: lbitlib.c lua.h luaconf.h lauxlib.h lualib.h 30 lib_bit.o: lib_bit.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h lj_def.h \ 31 lj_arch.h lj_err.h lj_errmsg.h lj_str.h lj_lib.h lj_libdef.h 32 lib_debug.o: lib_debug.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h \ 33diff -ur -x lbitlib.c LuaJIT-2.0.3.orig/src/lauxlib.h LuaJIT-2.0.3/src/lauxlib.h 34--- LuaJIT-2.0.3.orig/src/lauxlib.h 2014-03-12 13:10:00.000000000 +0100 35+++ LuaJIT-2.0.3/src/lauxlib.h 2014-03-14 09:15:50.000000000 +0100 36@@ -86,6 +86,32 @@ 37 int level); 38 39 40+ 41+/* 42+** {====================================================== 43+** File handles for IO library 44+** ======================================================= 45+*/ 46+ 47+/* 48+** A file handle is a userdata with metatable 'LUA_FILEHANDLE' and 49+** initial structure 'luaL_Stream' (it may contain other fields 50+** after that initial structure). 51+*/ 52+ 53+#define LUA_FILEHANDLE "FILE*" 54+ 55+ 56+typedef struct luaL_Stream { 57+ FILE *f; /* stream (NULL for incompletely created streams) */ 58+ lua_CFunction closef; /* to close stream (NULL for closed streams) */ 59+} luaL_Stream; 60+ 61+/* }====================================================== */ 62+ 63+ 64+ 65+ 66 /* 67 ** =============================================================== 68 ** some useful macros 69diff -ur -x lbitlib.c LuaJIT-2.0.3.orig/src/lib_init.c LuaJIT-2.0.3/src/lib_init.c 70--- LuaJIT-2.0.3.orig/src/lib_init.c 2014-03-12 13:10:00.000000000 +0100 71+++ LuaJIT-2.0.3/src/lib_init.c 2014-03-14 09:15:50.000000000 +0100 72@@ -26,6 +26,7 @@ 73 { LUA_DBLIBNAME, luaopen_debug }, 74 { LUA_BITLIBNAME, luaopen_bit }, 75 { LUA_JITLIBNAME, luaopen_jit }, 76+ { LUA_BITLIBNAME_32, luaopen_bit32 }, 77 { NULL, NULL } 78 }; 79 80diff -ur -x lbitlib.c LuaJIT-2.0.3.orig/src/lib_package.c LuaJIT-2.0.3/src/lib_package.c 81--- LuaJIT-2.0.3.orig/src/lib_package.c 2014-03-12 13:10:00.000000000 +0100 82+++ LuaJIT-2.0.3/src/lib_package.c 2014-03-14 09:15:50.000000000 +0100 83@@ -354,6 +354,29 @@ 84 return 1; /* library loaded successfully */ 85 } 86 87+#define LUA_POF "luaopen_" 88+#define LUA_OFSEP "_" 89+#define POF LUA_POF 90+ 91+static const char *mkfuncname (lua_State *L, const char *modname) { 92+ const char *funcname; 93+ const char *mark = strchr(modname, *LUA_IGMARK); 94+ if (mark) modname = mark + 1; 95+ funcname = luaL_gsub(L, modname, ".", LUA_OFSEP); 96+ funcname = lua_pushfstring(L, POF"%s", funcname); 97+ lua_remove(L, -2); /* remove 'gsub' result */ 98+ return funcname; 99+} 100+ 101+ 102+int loader_C_luatex (lua_State *L, const char *name, const char *filename) { 103+ const char *funcname; 104+ funcname = mkfuncname(L, name); 105+ if (ll_loadfunc(L, filename, funcname,0) != 0) 106+ loaderror(L, filename); 107+ return 1; /* library loaded successfully */ 108+} 109+ 110 static int lj_cf_package_loader_croot(lua_State *L) 111 { 112 const char *filename; 113@@ -373,6 +396,21 @@ 114 return 1; 115 } 116 117+int loader_Call_luatex (lua_State *L, const char *name, const char *filename) { 118+ const char *funcname; 119+ int stat; 120+ if (filename == NULL) return 1; /* root not found */ 121+ funcname = mkfuncname(L, name); 122+ if ((stat = ll_loadfunc(L, filename, funcname,0)) != 0) { 123+ if (stat != PACKAGE_ERR_FUNC) loaderror(L, filename); /* real error */ 124+ lua_pushfstring(L, "\n\tno module " LUA_QS " in file " LUA_QS, 125+ name, filename); 126+ return 1; /* function not found */ 127+ } 128+ return 1; /* library loaded successfully */ 129+} 130+ 131+ 132 static int lj_cf_package_loader_preload(lua_State *L) 133 { 134 const char *name = luaL_checkstring(L, 1); 135diff -ur -x lbitlib.c LuaJIT-2.0.3.orig/src/lua.h LuaJIT-2.0.3/src/lua.h 136--- LuaJIT-2.0.3.orig/src/lua.h 2014-03-12 13:10:00.000000000 +0100 137+++ LuaJIT-2.0.3/src/lua.h 2014-03-14 09:15:50.000000000 +0100 138@@ -348,6 +348,16 @@ 139 const char *chunkname, const char *mode); 140 141 142+#define LUA_OPEQ 0 143+#define LUA_OPLT 1 144+#define LUA_OPLE 2 145+#define LUA_OK 0 146+ 147+/* see http://comments.gmane.org/gmane.comp.programming.swig/18673 */ 148+# define lua_rawlen lua_objlen 149+ 150+ 151+ 152 struct lua_Debug { 153 int event; 154 const char *name; /* (n) */ 155diff -ur -x lbitlib.c LuaJIT-2.0.3.orig/src/lualib.h LuaJIT-2.0.3/src/lualib.h 156--- LuaJIT-2.0.3.orig/src/lualib.h 2014-03-12 13:10:00.000000000 +0100 157+++ LuaJIT-2.0.3/src/lualib.h 2014-03-14 09:15:50.000000000 +0100 158@@ -22,6 +22,8 @@ 159 #define LUA_JITLIBNAME "jit" 160 #define LUA_FFILIBNAME "ffi" 161 162+#define LUA_BITLIBNAME_32 "bit32" 163+ 164 LUALIB_API int luaopen_base(lua_State *L); 165 LUALIB_API int luaopen_math(lua_State *L); 166 LUALIB_API int luaopen_string(lua_State *L); 167@@ -34,6 +36,8 @@ 168 LUALIB_API int luaopen_jit(lua_State *L); 169 LUALIB_API int luaopen_ffi(lua_State *L); 170 171+LUALIB_API int luaopen_bit32(lua_State *L); 172+ 173 LUALIB_API void luaL_openlibs(lua_State *L); 174 175 #ifndef lua_assert 176