summaryrefslogtreecommitdiffstats
path: root/meta-oe/recipes-devtools/lua
diff options
context:
space:
mode:
authorKoen Kooi <koen@dominion.thruhere.net>2011-03-23 16:26:43 +0100
committerKoen Kooi <koen@dominion.thruhere.net>2011-03-23 16:26:43 +0100
commitd011ac80a04ca5ea49a59c272236a1cbde4901b4 (patch)
treeffbe1e59097cd97ea1da960af6ce5fa373951de9 /meta-oe/recipes-devtools/lua
parent073805a1cd1794d95c9dacea4e9c5be366530798 (diff)
downloadmeta-openembedded-d011ac80a04ca5ea49a59c272236a1cbde4901b4.tar.gz
lua: import from meta-shr
Signed-off-by: Koen Kooi <koen@dominion.thruhere.net>
Diffstat (limited to 'meta-oe/recipes-devtools/lua')
-rw-r--r--meta-oe/recipes-devtools/lua/lua5.1/bitwise_operators.patch620
-rw-r--r--meta-oe/recipes-devtools/lua/lua5.1/lua5.1.pc11
-rw-r--r--meta-oe/recipes-devtools/lua/lua5.1/uclibc-pthread.patch13
-rw-r--r--meta-oe/recipes-devtools/lua/lua5.1_5.1.4.bb45
4 files changed, 689 insertions, 0 deletions
diff --git a/meta-oe/recipes-devtools/lua/lua5.1/bitwise_operators.patch b/meta-oe/recipes-devtools/lua/lua5.1/bitwise_operators.patch
new file mode 100644
index 000000000..138a2bd54
--- /dev/null
+++ b/meta-oe/recipes-devtools/lua/lua5.1/bitwise_operators.patch
@@ -0,0 +1,620 @@
1Index: lua-5.1.4/src/lcode.c
2===================================================================
3--- lua-5.1.4.orig/src/lcode.c 2007-12-28 16:32:23.000000000 +0100
4+++ lua-5.1.4/src/lcode.c 2009-01-27 21:15:39.000000000 +0100
5@@ -650,6 +650,17 @@
6 case OP_POW: r = luai_numpow(v1, v2); break;
7 case OP_UNM: r = luai_numunm(v1); break;
8 case OP_LEN: return 0; /* no constant folding for 'len' */
9+#if defined(LUA_BITWISE_OPERATORS)
10+ case OP_BOR: luai_logor(r, v1, v2); break;
11+ case OP_BAND: luai_logand(r, v1, v2); break;
12+ case OP_BXOR: luai_logxor(r, v1, v2); break;
13+ case OP_BLSHFT: luai_loglshft(r, v1, v2); break;
14+ case OP_BRSHFT: luai_logrshft(r, v1, v2); break;
15+ case OP_BNOT: luai_lognot(r, v1); break;
16+ case OP_INTDIV:
17+ if (v2 == 0) return 0; /* do not attempt to divide by 0 */
18+ r = luai_numintdiv(v1, v2); break;
19+#endif
20 default: lua_assert(0); r = 0; break;
21 }
22 if (luai_numisnan(r)) return 0; /* do not attempt to produce NaN */
23@@ -662,7 +673,11 @@
24 if (constfolding(op, e1, e2))
25 return;
26 else {
27+#if defined(LUA_BITWISE_OPERATORS)
28+ int o2 = (op != OP_UNM && op != OP_LEN && op != OP_BNOT) ? luaK_exp2RK(fs, e2) : 0;
29+#else
30 int o2 = (op != OP_UNM && op != OP_LEN) ? luaK_exp2RK(fs, e2) : 0;
31+#endif
32 int o1 = luaK_exp2RK(fs, e1);
33 if (o1 > o2) {
34 freeexp(fs, e1);
35@@ -698,6 +713,14 @@
36 expdesc e2;
37 e2.t = e2.f = NO_JUMP; e2.k = VKNUM; e2.u.nval = 0;
38 switch (op) {
39+#if defined(LUA_BITWISE_OPERATORS)
40+ case OPR_BNOT: {
41+ if (e->k == VK)
42+ luaK_exp2anyreg(fs, e); /* cannot operate on non-numeric constants */
43+ codearith(fs, OP_BNOT, e, &e2);
44+ break;
45+ }
46+#endif
47 case OPR_MINUS: {
48 if (!isnumeral(e))
49 luaK_exp2anyreg(fs, e); /* cannot operate on non-numeric constants */
50@@ -778,6 +801,14 @@
51 case OPR_DIV: codearith(fs, OP_DIV, e1, e2); break;
52 case OPR_MOD: codearith(fs, OP_MOD, e1, e2); break;
53 case OPR_POW: codearith(fs, OP_POW, e1, e2); break;
54+#if defined(LUA_BITWISE_OPERATORS)
55+ case OPR_BOR: codearith(fs, OP_BOR, e1, e2); break;
56+ case OPR_BAND: codearith(fs, OP_BAND, e1, e2); break;
57+ case OPR_BXOR: codearith(fs, OP_BXOR, e1, e2); break;
58+ case OPR_BLSHFT: codearith(fs, OP_BLSHFT, e1, e2); break;
59+ case OPR_BRSHFT: codearith(fs, OP_BRSHFT, e1, e2); break;
60+ case OPR_INTDIV: codearith(fs, OP_INTDIV, e1, e2); break;
61+#endif
62 case OPR_EQ: codecomp(fs, OP_EQ, 1, e1, e2); break;
63 case OPR_NE: codecomp(fs, OP_EQ, 0, e1, e2); break;
64 case OPR_LT: codecomp(fs, OP_LT, 1, e1, e2); break;
65Index: lua-5.1.4/src/lcode.h
66===================================================================
67--- lua-5.1.4.orig/src/lcode.h 2007-12-27 14:02:25.000000000 +0100
68+++ lua-5.1.4/src/lcode.h 2009-01-27 21:15:39.000000000 +0100
69@@ -25,6 +25,9 @@
70 */
71 typedef enum BinOpr {
72 OPR_ADD, OPR_SUB, OPR_MUL, OPR_DIV, OPR_MOD, OPR_POW,
73+#if defined(LUA_BITWISE_OPERATORS)
74+ OPR_BOR, OPR_BAND, OPR_BXOR, OPR_BLSHFT, OPR_BRSHFT, OPR_INTDIV,
75+#endif
76 OPR_CONCAT,
77 OPR_NE, OPR_EQ,
78 OPR_LT, OPR_LE, OPR_GT, OPR_GE,
79@@ -33,8 +36,11 @@
80 } BinOpr;
81
82
83+#if defined(LUA_BITWISE_OPERATORS)
84+typedef enum UnOpr { OPR_BNOT, OPR_MINUS, OPR_NOT, OPR_LEN, OPR_NOUNOPR } UnOpr;
85+#else
86 typedef enum UnOpr { OPR_MINUS, OPR_NOT, OPR_LEN, OPR_NOUNOPR } UnOpr;
87-
88+#endif
89
90 #define getcode(fs,e) ((fs)->f->code[(e)->u.s.info])
91
92Index: lua-5.1.4/src/ldebug.c
93===================================================================
94--- lua-5.1.4.orig/src/ldebug.c 2008-05-08 18:56:26.000000000 +0200
95+++ lua-5.1.4/src/ldebug.c 2009-01-27 21:15:39.000000000 +0100
96@@ -592,6 +592,16 @@
97 luaG_typeerror(L, p2, "perform arithmetic on");
98 }
99
100+#if defined (LUA_BITWISE_OPERATORS)
101+void luaG_logicerror (lua_State *L, const TValue *p1, const TValue *p2) {
102+ TValue temp;
103+ if (luaV_tonumber(p1, &temp) == NULL)
104+ p2 = p1; /* first operand is wrong */
105+ luaG_typeerror(L, p2, "perform bitwise operation on");
106+}
107+#endif
108+
109+
110
111 int luaG_ordererror (lua_State *L, const TValue *p1, const TValue *p2) {
112 const char *t1 = luaT_typenames[ttype(p1)];
113Index: lua-5.1.4/src/ldebug.h
114===================================================================
115--- lua-5.1.4.orig/src/ldebug.h 2007-12-27 14:02:25.000000000 +0100
116+++ lua-5.1.4/src/ldebug.h 2009-01-27 21:15:39.000000000 +0100
117@@ -30,4 +30,9 @@
118 LUAI_FUNC int luaG_checkcode (const Proto *pt);
119 LUAI_FUNC int luaG_checkopenop (Instruction i);
120
121+#if defined (LUA_BITWISE_OPERATORS)
122+LUAI_FUNC void luaG_logicerror (lua_State *L, const TValue *p1,
123+ const TValue *p2);
124+#endif
125+
126 #endif
127Index: lua-5.1.4/src/llex.c
128===================================================================
129--- lua-5.1.4.orig/src/llex.c 2007-12-27 14:02:25.000000000 +0100
130+++ lua-5.1.4/src/llex.c 2009-01-27 21:15:39.000000000 +0100
131@@ -39,7 +39,11 @@
132 "end", "false", "for", "function", "if",
133 "in", "local", "nil", "not", "or", "repeat",
134 "return", "then", "true", "until", "while",
135+#if defined(LUA_BITWISE_OPERATORS)
136+ "..", "...", "==", ">=", ">>", "<=", "<<", "^^", "~=", "!="
137+#else
138 "..", "...", "==", ">=", "<=", "~=",
139+#endif
140 "<number>", "<name>", "<string>", "<eof>",
141 NULL
142 };
143@@ -371,6 +375,30 @@
144 if (ls->current != '=') return '=';
145 else { next(ls); return TK_EQ; }
146 }
147+#if defined(LUA_BITWISE_OPERATORS)
148+ case '<': {
149+ next(ls);
150+ if (ls->current == '=') { next(ls); return TK_LE; }
151+ else if (ls->current == '<') { next(ls); return TK_LSHFT; }
152+ else return '<';
153+ }
154+ case '>': {
155+ next(ls);
156+ if (ls->current == '=') { next(ls); return TK_GE; }
157+ else if (ls->current == '>') { next(ls); return TK_RSHFT; }
158+ else return '>';
159+ }
160+ case '^': {
161+ next(ls);
162+ if (ls->current != '^') return '^';
163+ else { next(ls); return TK_XOR; }
164+ }
165+ case '!': {
166+ next(ls);
167+ if (ls->current != '=') return '!';
168+ else { next(ls); return TK_NE; }
169+ }
170+#else
171 case '<': {
172 next(ls);
173 if (ls->current != '=') return '<';
174@@ -379,8 +407,9 @@
175 case '>': {
176 next(ls);
177 if (ls->current != '=') return '>';
178- else { next(ls); return TK_GE; }
179+ else { next(ls); return TK_GE; }
180 }
181+#endif
182 case '~': {
183 next(ls);
184 if (ls->current != '=') return '~';
185Index: lua-5.1.4/src/llex.h
186===================================================================
187--- lua-5.1.4.orig/src/llex.h 2007-12-27 14:02:25.000000000 +0100
188+++ lua-5.1.4/src/llex.h 2009-01-27 21:15:39.000000000 +0100
189@@ -28,7 +28,11 @@
190 TK_IF, TK_IN, TK_LOCAL, TK_NIL, TK_NOT, TK_OR, TK_REPEAT,
191 TK_RETURN, TK_THEN, TK_TRUE, TK_UNTIL, TK_WHILE,
192 /* other terminal symbols */
193+#if defined(LUA_BITWISE_OPERATORS)
194+ TK_CONCAT, TK_DOTS, TK_EQ, TK_GE, TK_LSHFT, TK_LE, TK_RSHFT, TK_XOR, TK_NE, TK_CNE, TK_NUMBER,
195+#else
196 TK_CONCAT, TK_DOTS, TK_EQ, TK_GE, TK_LE, TK_NE, TK_NUMBER,
197+#endif
198 TK_NAME, TK_STRING, TK_EOS
199 };
200
201Index: lua-5.1.4/src/lopcodes.c
202===================================================================
203--- lua-5.1.4.orig/src/lopcodes.c 2007-12-27 14:02:25.000000000 +0100
204+++ lua-5.1.4/src/lopcodes.c 2009-01-27 21:15:39.000000000 +0100
205@@ -32,6 +32,15 @@
206 "DIV",
207 "MOD",
208 "POW",
209+#if defined(LUA_BITWISE_OPERATORS)
210+ "BOR",
211+ "BAND",
212+ "OP_BXOR"
213+ "BLSHFT",
214+ "BRSHFT",
215+ "BNOT",
216+ "INTDIV",
217+#endif
218 "UNM",
219 "NOT",
220 "LEN",
221@@ -78,6 +87,15 @@
222 ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_DIV */
223 ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_MOD */
224 ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_POW */
225+#if defined(LUA_BITWISE_OPERATORS)
226+ ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_BOR */
227+ ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_BAND */
228+ ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_BXOR */
229+ ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_BLSHFT */
230+ ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_BRSHFT */
231+ ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_BNOT */
232+ ,opmode(0, 1, OpArgK, OpArgK, iABC) /* OP_INTDIV */
233+#endif
234 ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_UNM */
235 ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_NOT */
236 ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_LEN */
237Index: lua-5.1.4/src/lopcodes.h
238===================================================================
239--- lua-5.1.4.orig/src/lopcodes.h 2007-12-27 14:02:25.000000000 +0100
240+++ lua-5.1.4/src/lopcodes.h 2009-01-27 21:15:39.000000000 +0100
241@@ -174,10 +174,20 @@
242 OP_DIV,/* A B C R(A) := RK(B) / RK(C) */
243 OP_MOD,/* A B C R(A) := RK(B) % RK(C) */
244 OP_POW,/* A B C R(A) := RK(B) ^ RK(C) */
245+#if defined(LUA_BITWISE_OPERATORS)
246+OP_BOR,/* A B C R(A) := RK(B) | RK(C) */
247+OP_BAND,/* A B C R(A) := RK(B) & RK(C) */
248+OP_BXOR,/* A B C R(A) := RK(B) ^| RK(C) */
249+OP_BLSHFT,/* A B C R(A) := RK(B) << RK(C) */
250+OP_BRSHFT,/* A B C R(A) := RK(B) >> RK(C) */
251+OP_BNOT,/* A B R(A) := ~ R(B) */
252+OP_INTDIV,/* A B C R(A) := RK(B) \ RK(C) */
253+#endif
254 OP_UNM,/* A B R(A) := -R(B) */
255 OP_NOT,/* A B R(A) := not R(B) */
256 OP_LEN,/* A B R(A) := length of R(B) */
257
258+
259 OP_CONCAT,/* A B C R(A) := R(B).. ... ..R(C) */
260
261 OP_JMP,/* sBx pc+=sBx */
262@@ -186,8 +196,8 @@
263 OP_LT,/* A B C if ((RK(B) < RK(C)) ~= A) then pc++ */
264 OP_LE,/* A B C if ((RK(B) <= RK(C)) ~= A) then pc++ */
265
266-OP_TEST,/* A C if not (R(A) <=> C) then pc++ */
267-OP_TESTSET,/* A B C if (R(B) <=> C) then R(A) := R(B) else pc++ */
268+OP_TEST,/* A C if not (R(A) <=> C) then pc++ */
269+OP_TESTSET,/* A B C if (R(B) <=> C) then R(A) := R(B) else pc++ */
270
271 OP_CALL,/* A B C R(A), ... ,R(A+C-2) := R(A)(R(A+1), ... ,R(A+B-1)) */
272 OP_TAILCALL,/* A B C return R(A)(R(A+1), ... ,R(A+B-1)) */
273@@ -197,8 +207,8 @@
274 if R(A) <?= R(A+1) then { pc+=sBx; R(A+3)=R(A) }*/
275 OP_FORPREP,/* A sBx R(A)-=R(A+2); pc+=sBx */
276
277-OP_TFORLOOP,/* A C R(A+3), ... ,R(A+2+C) := R(A)(R(A+1), R(A+2));
278- if R(A+3) ~= nil then R(A+2)=R(A+3) else pc++ */
279+OP_TFORLOOP,/* A C R(A+3), ... ,R(A+2+C) := R(A)(R(A+1), R(A+2));
280+ if R(A+3) ~= nil then R(A+2)=R(A+3) else pc++ */
281 OP_SETLIST,/* A B C R(A)[(C-1)*FPF+i] := R(A+i), 1 <= i <= B */
282
283 OP_CLOSE,/* A close all variables in the stack up to (>=) R(A)*/
284Index: lua-5.1.4/src/lparser.c
285===================================================================
286--- lua-5.1.4.orig/src/lparser.c 2007-12-28 16:32:23.000000000 +0100
287+++ lua-5.1.4/src/lparser.c 2009-01-27 21:15:39.000000000 +0100
288@@ -780,6 +780,9 @@
289 case TK_NOT: return OPR_NOT;
290 case '-': return OPR_MINUS;
291 case '#': return OPR_LEN;
292+#if defined(LUA_BITWISE_OPERATORS)
293+ case '~': return OPR_BNOT;
294+#endif
295 default: return OPR_NOUNOPR;
296 }
297 }
298@@ -793,6 +796,14 @@
299 case '/': return OPR_DIV;
300 case '%': return OPR_MOD;
301 case '^': return OPR_POW;
302+#if defined(LUA_BITWISE_OPERATORS)
303+ case '|': return OPR_BOR;
304+ case '&': return OPR_BAND;
305+ case TK_XOR: return OPR_BXOR;
306+ case TK_LSHFT: return OPR_BLSHFT;
307+ case TK_RSHFT: return OPR_BRSHFT;
308+ case '\\': return OPR_INTDIV;
309+#endif
310 case TK_CONCAT: return OPR_CONCAT;
311 case TK_NE: return OPR_NE;
312 case TK_EQ: return OPR_EQ;
313@@ -812,6 +823,9 @@
314 lu_byte right; /* right priority */
315 } priority[] = { /* ORDER OPR */
316 {6, 6}, {6, 6}, {7, 7}, {7, 7}, {7, 7}, /* `+' `-' `/' `%' */
317+#if defined(LUA_BITWISE_OPERATORS)
318+ {6, 6}, {6, 6}, {6, 6}, {7, 7}, {7, 7}, {7, 7}, /* `|' `&' `!' `<<' `>>' `\' */
319+#endif
320 {10, 9}, {5, 4}, /* power and concat (right associative) */
321 {3, 3}, {3, 3}, /* equality and inequality */
322 {3, 3}, {3, 3}, {3, 3}, {3, 3}, /* order */
323Index: lua-5.1.4/src/ltm.c
324===================================================================
325--- lua-5.1.4.orig/src/ltm.c 2007-12-27 14:02:25.000000000 +0100
326+++ lua-5.1.4/src/ltm.c 2009-01-27 21:15:39.000000000 +0100
327@@ -34,6 +34,9 @@
328 "__add", "__sub", "__mul", "__div", "__mod",
329 "__pow", "__unm", "__len", "__lt", "__le",
330 "__concat", "__call"
331+#if defined(LUA_BITWISE_OPERATORS)
332+ ,"__or", "__and", "__xor", "__shl", "__shr", "__not", "__intdiv"
333+#endif
334 };
335 int i;
336 for (i=0; i<TM_N; i++) {
337Index: lua-5.1.4/src/ltm.h
338===================================================================
339--- lua-5.1.4.orig/src/ltm.h 2007-12-27 14:02:25.000000000 +0100
340+++ lua-5.1.4/src/ltm.h 2009-01-27 21:15:39.000000000 +0100
341@@ -33,6 +33,15 @@
342 TM_LE,
343 TM_CONCAT,
344 TM_CALL,
345+#if defined(LUA_BITWISE_OPERATORS)
346+ TM_BOR,
347+ TM_BAND,
348+ TM_BXOR,
349+ TM_BLSHFT,
350+ TM_BRSHFT,
351+ TM_BNOT,
352+ TM_INTDIV,
353+#endif
354 TM_N /* number of elements in the enum */
355 } TMS;
356
357Index: lua-5.1.4/src/lua.h
358===================================================================
359--- lua-5.1.4.orig/src/lua.h 2008-08-06 15:30:12.000000000 +0200
360+++ lua-5.1.4/src/lua.h 2009-01-27 21:16:39.000000000 +0100
361@@ -17,7 +17,7 @@
362
363
364 #define LUA_VERSION "Lua 5.1"
365-#define LUA_RELEASE "Lua 5.1.4"
366+#define LUA_RELEASE "Lua 5.1.4+bitwiseops"
367 #define LUA_VERSION_NUM 501
368 #define LUA_COPYRIGHT "Copyright (C) 1994-2008 Lua.org, PUC-Rio"
369 #define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo & W. Celes"
370Index: lua-5.1.4/src/luaconf.h
371===================================================================
372--- lua-5.1.4.orig/src/luaconf.h 2008-02-11 17:25:08.000000000 +0100
373+++ lua-5.1.4/src/luaconf.h 2009-01-27 21:15:39.000000000 +0100
374@@ -2,6 +2,7 @@
375 ** $Id: luaconf.h,v 1.82.1.7 2008/02/11 16:25:08 roberto Exp $
376 ** Configuration file for Lua
377 ** See Copyright Notice in lua.h
378+** Added logic operators : & | ^^ (xor) << >> ~, arithmetic operator \ (integer division) and != as an alternative to ~=
379 */
380
381
382@@ -209,6 +210,12 @@
383 */
384 #define LUA_IDSIZE 60
385
386+/*
387+@@ LUA_BITWISE_OPERATORS enable logical operators | & ^| >> << ~ on lua_Number
388+@* but also arithmetic operator \ (integer division) and != as an alernative to ~=
389+*/
390+#define LUA_BITWISE_OPERATORS
391+
392
393 /*
394 ** {==================================================================
395@@ -216,6 +223,7 @@
396 ** ===================================================================
397 */
398
399+
400 #if defined(lua_c) || defined(luaall_c)
401
402 /*
403@@ -526,25 +534,6 @@
404
405
406 /*
407-@@ The luai_num* macros define the primitive operations over numbers.
408-*/
409-#if defined(LUA_CORE)
410-#include <math.h>
411-#define luai_numadd(a,b) ((a)+(b))
412-#define luai_numsub(a,b) ((a)-(b))
413-#define luai_nummul(a,b) ((a)*(b))
414-#define luai_numdiv(a,b) ((a)/(b))
415-#define luai_nummod(a,b) ((a) - floor((a)/(b))*(b))
416-#define luai_numpow(a,b) (pow(a,b))
417-#define luai_numunm(a) (-(a))
418-#define luai_numeq(a,b) ((a)==(b))
419-#define luai_numlt(a,b) ((a)<(b))
420-#define luai_numle(a,b) ((a)<=(b))
421-#define luai_numisnan(a) (!luai_numeq((a), (a)))
422-#endif
423-
424-
425-/*
426 @@ lua_number2int is a macro to convert lua_Number to int.
427 @@ lua_number2integer is a macro to convert lua_Number to lua_Integer.
428 ** CHANGE them if you know a faster way to convert a lua_Number to
429@@ -560,7 +549,7 @@
430 /* On a Microsoft compiler, use assembler */
431 #if defined(_MSC_VER)
432
433-#define lua_number2int(i,d) __asm fld d __asm fistp i
434+#define lua_number2int(i,d) { __asm fld d __asm fistp i }
435 #define lua_number2integer(i,n) lua_number2int(i, n)
436
437 /* the next trick should work on any Pentium, but sometimes clashes
438@@ -582,6 +571,38 @@
439
440 #endif
441
442+
443+/*
444+@@ The luai_num* macros define the primitive operations over numbers.
445+*/
446+#if defined(LUA_CORE)
447+#include <math.h>
448+#define luai_numadd(a,b) ((a)+(b))
449+#define luai_numsub(a,b) ((a)-(b))
450+#define luai_nummul(a,b) ((a)*(b))
451+#define luai_numdiv(a,b) ((a)/(b))
452+#ifdef LUA_BITWISE_OPERATORS
453+#define luai_numintdiv(a,b) (floor((a)/(b)))
454+#endif
455+#define luai_nummod(a,b) ((a) - floor((a)/(b))*(b))
456+#define luai_numpow(a,b) (pow(a,b))
457+#define luai_numunm(a) (-(a))
458+#define luai_numeq(a,b) ((a)==(b))
459+#define luai_numlt(a,b) ((a)<(b))
460+#define luai_numle(a,b) ((a)<=(b))
461+#define luai_numisnan(a) (!luai_numeq((a), (a)))
462+
463+#if defined(LUA_BITWISE_OPERATORS)
464+#define luai_logor(r, a, b) { lua_Integer ai,bi; lua_number2int(ai,a); lua_number2int(bi,b); r = ai|bi; }
465+#define luai_logand(r, a,b) { lua_Integer ai,bi; lua_number2int(ai,a); lua_number2int(bi,b); r = ai&bi; }
466+#define luai_logxor(r, a,b) { lua_Integer ai,bi; lua_number2int(ai,a); lua_number2int(bi,b); r = ai^bi; }
467+#define luai_lognot(r,a) { lua_Integer ai; lua_number2int(ai,a); r = ~ai; }
468+#define luai_loglshft(r, a,b) { lua_Integer ai,bi; lua_number2int(ai,a); lua_number2int(bi,b); r = ai<<bi; }
469+#define luai_logrshft(r, a,b) { lua_Integer ai,bi; lua_number2int(ai,a); lua_number2int(bi,b); r = ai>>bi; }
470+#endif
471+
472+#endif
473+
474 /* }================================================================== */
475
476
477Index: lua-5.1.4/src/lvm.c
478===================================================================
479--- lua-5.1.4.orig/src/lvm.c 2007-12-28 16:32:23.000000000 +0100
480+++ lua-5.1.4/src/lvm.c 2009-01-27 21:15:39.000000000 +0100
481@@ -325,6 +325,9 @@
482 case TM_MOD: setnvalue(ra, luai_nummod(nb, nc)); break;
483 case TM_POW: setnvalue(ra, luai_numpow(nb, nc)); break;
484 case TM_UNM: setnvalue(ra, luai_numunm(nb)); break;
485+#if defined(LUA_BITWISE_OPERATORS)
486+ case TM_INTDIV: setnvalue(ra, luai_numintdiv(nb, nc)); break;
487+#endif
488 default: lua_assert(0); break;
489 }
490 }
491@@ -332,7 +335,30 @@
492 luaG_aritherror(L, rb, rc);
493 }
494
495-
496+#if defined(LUA_BITWISE_OPERATORS)
497+static void Logic (lua_State *L, StkId ra, const TValue *rb,
498+ const TValue *rc, TMS op) {
499+ TValue tempb, tempc;
500+ const TValue *b, *c;
501+ if ((b = luaV_tonumber(rb, &tempb)) != NULL &&
502+ (c = luaV_tonumber(rc, &tempc)) != NULL) {
503+ lua_Number nb = nvalue(b), nc = nvalue(c);
504+ lua_Integer r;
505+ switch (op) {
506+ case TM_BLSHFT: luai_loglshft(r, nb, nc); break;
507+ case TM_BRSHFT: luai_logrshft(r, nb, nc); break;
508+ case TM_BOR: luai_logor(r, nb, nc); break;
509+ case TM_BAND: luai_logand(r, nb, nc); break;
510+ case TM_BXOR: luai_logxor(r, nb, nc); break;
511+ case TM_BNOT: luai_lognot(r, nb); break;
512+ default: lua_assert(0); r = 0; break;
513+ }
514+ setnvalue(ra, r);
515+ }
516+ else if (!call_binTM(L, rb, rc, ra, op))
517+ luaG_logicerror(L, rb, rc);
518+}
519+#endif
520
521 /*
522 ** some macros for common tasks in `luaV_execute'
523@@ -369,6 +395,22 @@
524 }
525
526
527+#if defined(LUA_BITWISE_OPERATORS)
528+#define logic_op(op,tm) { \
529+ TValue *rb = RKB(i); \
530+ TValue *rc = RKC(i); \
531+ if (ttisnumber(rb) && ttisnumber(rc)) { \
532+ lua_Integer r; \
533+ lua_Number nb = nvalue(rb), nc = nvalue(rc); \
534+ op(r, nb, nc); \
535+ setnvalue(ra, r); \
536+ } \
537+ else \
538+ Protect(Logic(L, ra, rb, rc, tm)); \
539+ }
540+#endif
541+
542+
543
544 void luaV_execute (lua_State *L, int nexeccalls) {
545 LClosure *cl;
546@@ -502,6 +544,45 @@
547 }
548 continue;
549 }
550+#if defined(LUA_BITWISE_OPERATORS)
551+ case OP_BOR: {
552+ logic_op(luai_logor, TM_BOR);
553+ continue;
554+ }
555+ case OP_BAND: {
556+ logic_op(luai_logand, TM_BAND);
557+ continue;
558+ }
559+ case OP_BXOR: {
560+ logic_op(luai_logxor, TM_BXOR);
561+ continue;
562+ }
563+ case OP_BLSHFT: {
564+ logic_op(luai_loglshft, TM_BLSHFT);
565+ continue;
566+ }
567+ case OP_BRSHFT: {
568+ logic_op(luai_logrshft, TM_BRSHFT);
569+ continue;
570+ }
571+ case OP_BNOT: {
572+ TValue *rb = RB(i);
573+ if (ttisnumber(rb)) {
574+ lua_Integer r;
575+ lua_Number nb = nvalue(rb);
576+ luai_lognot(r, nb);
577+ setnvalue(ra, r);
578+ }
579+ else {
580+ Protect(Logic(L, ra, rb, rb, TM_BNOT));
581+ }
582+ continue;
583+ }
584+ case OP_INTDIV: {
585+ arith_op(luai_numintdiv, TM_DIV);
586+ continue;
587+ }
588+#endif
589 case OP_NOT: {
590 int res = l_isfalse(RB(i)); /* next assignment may change this value */
591 setbvalue(ra, res);
592Index: lua-5.1.4/test/bitwisepatchtest.lua
593===================================================================
594--- /dev/null 1970-01-01 00:00:00.000000000 +0000
595+++ lua-5.1.4/test/bitwisepatchtest.lua 2009-01-27 21:15:39.000000000 +0100
596@@ -0,0 +1,24 @@
597+hex=function (i) return "0x"..string.format("%X", i) end
598+print(hex(0x54|0x55))
599+print(hex(0x54&0x66))
600+print(hex(0x54^|0x66))
601+print(hex(~0x54))
602+print(hex(0xF<< 4))
603+print(hex(0xF0>> 4))
604+a,b=0x54,0x55
605+print(hex(a),"|",hex(b), "=",hex(a|b))
606+print(hex(a),"|","0x55", "=",hex(a|0x55))
607+print(hex(a),"|","0x5|0x50 (", hex(0x5|0x50), ") =",hex(a|(0x5|0x50)))
608+a,b=0x54,0x66
609+print(hex(a),"&",hex(b), "=",hex(a&b))
610+print(hex(a),"&","0x66", "=",hex(a&0x66))
611+print(hex(a),"^|",hex(b), "=",hex(a^|b))
612+print(hex(a),"^|","0x66", "=",hex(a^|0x66))
613+print("~"..hex(a),"=",hex(~a))
614+a,b=0xF,0xF0
615+print(hex(a).."<<4","=",hex(a<<4))
616+print(hex(b)..">>4","=",hex(b>>4))
617+a,b=0xF,4
618+print(hex(a).."<<"..b,"=",hex(a<<b))
619+a,b=0xF0,4
620+print(hex(a)..">>"..b,"=",hex(a>>b))
diff --git a/meta-oe/recipes-devtools/lua/lua5.1/lua5.1.pc b/meta-oe/recipes-devtools/lua/lua5.1/lua5.1.pc
new file mode 100644
index 000000000..41d580123
--- /dev/null
+++ b/meta-oe/recipes-devtools/lua/lua5.1/lua5.1.pc
@@ -0,0 +1,11 @@
1prefix=/usr
2libdir=${prefix}/lib
3includedir=${prefix}/include
4
5Name: Lua
6Description: Lua language engine
7Version: 5.1.4
8Requires:
9Libs: -L${libdir} -llua
10Libs.private: -lm
11Cflags: -I${includedir}
diff --git a/meta-oe/recipes-devtools/lua/lua5.1/uclibc-pthread.patch b/meta-oe/recipes-devtools/lua/lua5.1/uclibc-pthread.patch
new file mode 100644
index 000000000..0555e81b1
--- /dev/null
+++ b/meta-oe/recipes-devtools/lua/lua5.1/uclibc-pthread.patch
@@ -0,0 +1,13 @@
1Index: lua-5.1.4/src/Makefile
2===================================================================
3--- lua-5.1.4.orig/src/Makefile 2010-10-16 09:51:52.000000000 +0200
4+++ lua-5.1.4/src/Makefile 2010-10-16 09:52:15.000000000 +0200
5@@ -12,7 +12,7 @@
6 AR= ar rcu
7 RANLIB= ranlib
8 RM= rm -f
9-LIBS= -lm $(MYLIBS)
10+LIBS= -lm -lpthread $(MYLIBS)
11
12 MYCFLAGS=
13 MYLDFLAGS=
diff --git a/meta-oe/recipes-devtools/lua/lua5.1_5.1.4.bb b/meta-oe/recipes-devtools/lua/lua5.1_5.1.4.bb
new file mode 100644
index 000000000..06c800496
--- /dev/null
+++ b/meta-oe/recipes-devtools/lua/lua5.1_5.1.4.bb
@@ -0,0 +1,45 @@
1DESCRIPTION = "Lua is a powerful light-weight programming language designed \
2for extending applications."
3LICENSE = "MIT"
4HOMEPAGE = "http://www.lua.org/"
5
6DEPENDS += "readline"
7PR = "r10"
8SRC_URI = "http://www.lua.org/ftp/lua-${PV}.tar.gz \
9 file://bitwise_operators.patch \
10 file://lua5.1.pc \
11 "
12S = "${WORKDIR}/lua-${PV}"
13
14inherit pkgconfig binconfig
15
16UCLIBC_PATCHES += "file://uclibc-pthread.patch"
17SRC_URI_append_libc-uclibc = "${UCLIBC_PATCHES}"
18
19TARGET_CC_ARCH += " -fPIC ${LDFLAGS}"
20EXTRA_OEMAKE = "'CC=${CC} -fPIC' 'MYCFLAGS=${CFLAGS} -DLUA_USE_LINUX -fPIC' MYLDFLAGS='${LDFLAGS}'"
21
22do_configure_prepend() {
23 sed -i -e s:/usr/local:${prefix}:g src/luaconf.h
24}
25
26do_compile () {
27 oe_runmake linux
28}
29
30do_install () {
31 oe_runmake \
32 'INSTALL_TOP=${D}${prefix}' \
33 'INSTALL_BIN=${D}${bindir}' \
34 'INSTALL_INC=${D}${includedir}/' \
35 'INSTALL_MAN=${D}${mandir}/man1' \
36 'INSTALL_SHARE=${D}${datadir}/lua' \
37 install
38 install -d ${D}${libdir}/pkgconfig
39 install -m 0644 ${WORKDIR}/lua5.1.pc ${D}${libdir}/pkgconfig/lua5.1.pc
40}
41NATIVE_INSTALL_WORKS = 1
42BBCLASSEXTEND = "native"
43
44SRC_URI[md5sum] = "d0870f2de55d59c1c8419f36e8fac150"
45SRC_URI[sha256sum] = "b038e225eaf2a5b57c9bcc35cd13aa8c6c8288ef493d52970c9545074098af3a"