/elua/elua-git-20110610-5cb72c0595bbcc1e919d-patches/lua-remove-dump.patch

https://code.google.com/p/mizar32/ · Patch · 195 lines · 173 code · 22 blank · 0 comment · 0 complexity · 7e38d1d510d2e2589cb2e53269d589e2 MD5 · raw file

  1. Index: elua/src/lua/lapi.c
  2. ===================================================================
  3. --- elua.orig/src/lua/lapi.c 2011-06-03 19:06:16.754074015 +0200
  4. +++ elua/src/lua/lapi.c 2011-06-25 04:40:23.808035679 +0200
  5. @@ -915,6 +915,7 @@
  6. }
  7. +#ifndef NO_DUMP
  8. LUA_API int lua_dump (lua_State *L, lua_Writer writer, void *data) {
  9. int status;
  10. TValue *o;
  11. @@ -928,6 +929,7 @@
  12. lua_unlock(L);
  13. return status;
  14. }
  15. +#endif
  16. LUA_API int lua_status (lua_State *L) {
  17. Index: elua/src/lua/ldo.c
  18. ===================================================================
  19. --- elua.orig/src/lua/ldo.c 2011-06-25 04:40:23.756035421 +0200
  20. +++ elua/src/lua/ldo.c 2011-06-25 04:40:23.808035679 +0200
  21. @@ -525,11 +525,17 @@
  22. Proto *tf;
  23. Closure *cl;
  24. struct SParser *p = cast(struct SParser *, ud);
  25. +#ifndef NO_UNDUMP
  26. int c = luaZ_lookahead(p->z);
  27. +#endif
  28. luaC_checkGC(L);
  29. set_block_gc(L); /* stop collector during parsing */
  30. +#ifndef NO_UNDUMP
  31. tf = ((c == LUA_SIGNATURE[0]) ? luaU_undump : luaY_parser)(L, p->z,
  32. &p->buff, p->name);
  33. +#else
  34. + tf = luaY_parser(L, p->z, &p->buff, p->name);
  35. +#endif
  36. cl = luaF_newLclosure(L, tf->nups, hvalue(gt(L)));
  37. cl->l.p = tf;
  38. for (i = 0; i < tf->nups; i++) /* initialize eventual upvalues */
  39. Index: elua/src/lua/ldump.c
  40. ===================================================================
  41. --- elua.orig/src/lua/ldump.c 2011-06-24 13:56:09.754078683 +0200
  42. +++ elua/src/lua/ldump.c 2011-06-25 04:40:23.808035679 +0200
  43. @@ -13,6 +13,10 @@
  44. #include "lua.h"
  45. +
  46. +#ifndef NO_DUMP
  47. +
  48. +
  49. #include "lobject.h"
  50. #include "lstate.h"
  51. #include "lundump.h"
  52. @@ -308,3 +312,6 @@
  53. target.is_arm_fpa=0;
  54. return luaU_dump_crosscompile(L,f,w,data,strip,target);
  55. }
  56. +
  57. +
  58. +#endif // NO_DUMP
  59. Index: elua/src/lua/lstrlib.c
  60. ===================================================================
  61. --- elua.orig/src/lua/lstrlib.c 2011-06-25 04:40:23.684035062 +0200
  62. +++ elua/src/lua/lstrlib.c 2011-06-25 04:40:23.808035679 +0200
  63. @@ -137,6 +137,7 @@
  64. }
  65. +#ifndef NO_DUMP
  66. static int writer (lua_State *L, const void* b, size_t size, void* B) {
  67. (void)L;
  68. luaL_addlstring((luaL_Buffer*) B, (const char *)b, size);
  69. @@ -154,6 +155,7 @@
  70. luaL_pushresult(&b);
  71. return 1;
  72. }
  73. +#endif // NO_DUMP
  74. @@ -832,7 +834,9 @@
  75. const LUA_REG_TYPE strlib[] = {
  76. {LSTRKEY("byte"), LFUNCVAL(str_byte)},
  77. {LSTRKEY("char"), LFUNCVAL(str_char)},
  78. +#ifndef NO_DUMP
  79. {LSTRKEY("dump"), LFUNCVAL(str_dump)},
  80. +#endif
  81. {LSTRKEY("find"), LFUNCVAL(str_find)},
  82. {LSTRKEY("format"), LFUNCVAL(str_format)},
  83. #if LUA_OPTIMIZE_MEMORY > 0 && defined(LUA_COMPAT_GFIND)
  84. Index: elua/src/lua/lundump.c
  85. ===================================================================
  86. --- elua.orig/src/lua/lundump.c 2011-06-03 19:06:16.766074070 +0200
  87. +++ elua/src/lua/lundump.c 2011-06-25 04:40:23.808035679 +0200
  88. @@ -20,6 +20,10 @@
  89. #include "lundump.h"
  90. #include "lzio.h"
  91. +
  92. +#ifndef NO_UNDUMP
  93. +
  94. +
  95. typedef struct {
  96. lua_State* L;
  97. ZIO* Z;
  98. @@ -305,3 +309,6 @@
  99. *h++=(char)sizeof(lua_Number);
  100. *h++=(char)(((lua_Number)0.5)==0); /* is lua_Number integral? */
  101. }
  102. +
  103. +
  104. +#endif // NO_UNDUMP
  105. Index: elua/src/lua/lundump.h
  106. ===================================================================
  107. --- elua.orig/src/lua/lundump.h 2011-06-03 19:06:16.838074425 +0200
  108. +++ elua/src/lua/lundump.h 2011-06-25 04:40:23.808035679 +0200
  109. @@ -12,6 +12,7 @@
  110. #include "lobject.h"
  111. #include "lzio.h"
  112. +
  113. typedef uint32_t strsize_t;
  114. /* info about target machine for cross-compilation */
  115. @@ -24,11 +25,15 @@
  116. int is_arm_fpa;
  117. } DumpTargetInfo;
  118. +#ifndef NO_UNDUMP
  119. /* load one chunk; from lundump.c */
  120. LUAI_FUNC Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name);
  121. /* make header; from lundump.c */
  122. LUAI_FUNC void luaU_header (char* h);
  123. +#endif
  124. +
  125. +#ifndef NO_DUMP
  126. /* dump one chunk to a different target; from ldump.c */
  127. int luaU_dump_crosscompile (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip, DumpTargetInfo target);
  128. @@ -41,6 +46,8 @@
  129. LUAI_FUNC void luaU_print (const Proto* f, int full);
  130. #endif
  131. +#endif // NO_DUMP
  132. +
  133. /* for header of binary files -- this is Lua 5.1 */
  134. #define LUAC_VERSION 0x51
  135. Index: elua/src/lua/luaconf.h
  136. ===================================================================
  137. --- elua.orig/src/lua/luaconf.h 2011-06-25 04:40:23.792035600 +0200
  138. +++ elua/src/lua/luaconf.h 2011-06-25 04:40:23.812035704 +0200
  139. @@ -36,6 +36,17 @@
  140. */
  141. #define NO_GETENV
  142. +/*
  143. +@@ Defining NO_DUMP removes the dump mechanism, but it is always needed when
  144. +** compiling the corss-compiler
  145. +@@ Defining NO_UNDUMP removes the undump nechanism, which is needed to be able
  146. +** to load compiled bytecode from *.lc files.
  147. +*/
  148. +#ifndef LUA_CROSS_COMPILER
  149. +# define NO_DUMP
  150. +#endif
  151. +#define NO_UNDUMP
  152. +
  153. /*
  154. @@ NO_SIGNAL removes all calls to signal() since embedded platforms don't
  155. Index: elua/src/main.c
  156. ===================================================================
  157. --- elua.orig/src/main.c 2011-06-03 19:06:16.738073936 +0200
  158. +++ elua/src/main.c 2011-06-25 04:40:23.812035704 +0200
  159. @@ -30,11 +30,15 @@
  160. char *boot_order[] = {
  161. #if defined(BUILD_MMCFS)
  162. "/mmc/autorun.lua",
  163. +# ifndef NO_UNDUMP
  164. "/mmc/autorun.lc",
  165. +# endif
  166. #endif
  167. #if defined(BUILD_ROMFS)
  168. "/rom/autorun.lua",
  169. +# ifndef NO_UNDUMP
  170. "/rom/autorun.lc",
  171. +# endif
  172. #endif
  173. };