diff options
-rw-r--r-- | llimits.h | 49 | ||||
-rw-r--r-- | lobject.c | 5 | ||||
-rw-r--r-- | luaconf.h | 42 | ||||
-rw-r--r-- | lvm.c | 3 |
4 files changed, 53 insertions, 46 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: llimits.h,v 1.128 2015/01/16 15:41:03 roberto Exp roberto $ | 2 | ** $Id: llimits.h,v 1.129 2015/01/16 17:15:52 roberto Exp roberto $ |
3 | ** Limits, basic types, and some other 'installation-dependent' definitions | 3 | ** Limits, basic types, and some other 'installation-dependent' definitions |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -243,6 +243,53 @@ typedef unsigned long Instruction; | |||
243 | 243 | ||
244 | 244 | ||
245 | /* | 245 | /* |
246 | ** The luai_num* macros define the primitive operations over numbers. | ||
247 | */ | ||
248 | |||
249 | /* floor division (defined as 'floor(a/b)') */ | ||
250 | #if !defined(luai_numidiv) | ||
251 | #define luai_numidiv(L,a,b) ((void)L, l_mathop(floor)(luai_numdiv(L,a,b))) | ||
252 | #endif | ||
253 | |||
254 | /* float division */ | ||
255 | #if !defined(luai_numdiv) | ||
256 | #define luai_numdiv(L,a,b) ((a)/(b)) | ||
257 | #endif | ||
258 | |||
259 | /* | ||
260 | ** module: defined as 'a - floor(a/b)*b'; the previous definition gives | ||
261 | ** NaN when 'b' is huge, but the result should be 'a'. 'fmod' gives the | ||
262 | ** result of 'a - trunc(a/b)*b', and therefore must be corrected when | ||
263 | ** 'trunc(a/b) ~= floor(a/b)'. That happens when the division has a | ||
264 | ** non-integer negative result, which is equivalent to the test below | ||
265 | */ | ||
266 | #if !defined(luai_nummod) | ||
267 | #define luai_nummod(L,a,b,m) \ | ||
268 | { (m) = l_mathop(fmod)(a,b); if ((m)*(b) < 0) (m) += (b); } | ||
269 | #endif | ||
270 | |||
271 | /* exponentiation */ | ||
272 | #if !defined(luai_numpow) | ||
273 | #define luai_numpow(L,a,b) ((void)L, l_mathop(pow)(a,b)) | ||
274 | #endif | ||
275 | |||
276 | /* the others are quite standard operations */ | ||
277 | #if !defined(luai_numadd) | ||
278 | #define luai_numadd(L,a,b) ((a)+(b)) | ||
279 | #define luai_numsub(L,a,b) ((a)-(b)) | ||
280 | #define luai_nummul(L,a,b) ((a)*(b)) | ||
281 | #define luai_numunm(L,a) (-(a)) | ||
282 | #define luai_numeq(a,b) ((a)==(b)) | ||
283 | #define luai_numlt(a,b) ((a)<(b)) | ||
284 | #define luai_numle(a,b) ((a)<=(b)) | ||
285 | #define luai_numisnan(a) (!luai_numeq((a), (a))) | ||
286 | #endif | ||
287 | |||
288 | |||
289 | |||
290 | |||
291 | |||
292 | /* | ||
246 | ** macro to control inclusion of some hard tests on stack reallocation | 293 | ** macro to control inclusion of some hard tests on stack reallocation |
247 | */ | 294 | */ |
248 | #if !defined(HARDSTACKTESTS) | 295 | #if !defined(HARDSTACKTESTS) |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lobject.c,v 2.100 2014/11/21 12:15:57 roberto Exp roberto $ | 2 | ** $Id: lobject.c,v 2.101 2014/12/26 14:43:45 roberto Exp roberto $ |
3 | ** Some generic functions over Lua objects | 3 | ** Some generic functions over Lua objects |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -10,6 +10,7 @@ | |||
10 | #include "lprefix.h" | 10 | #include "lprefix.h" |
11 | 11 | ||
12 | 12 | ||
13 | #include <math.h> | ||
13 | #include <stdarg.h> | 14 | #include <stdarg.h> |
14 | #include <stdio.h> | 15 | #include <stdio.h> |
15 | #include <stdlib.h> | 16 | #include <stdlib.h> |
@@ -174,8 +175,6 @@ static int isneg (const char **s) { | |||
174 | */ | 175 | */ |
175 | #if !defined(lua_strx2number) | 176 | #if !defined(lua_strx2number) |
176 | 177 | ||
177 | #include <math.h> | ||
178 | |||
179 | /* maximum number of significant digits to read (to avoid overflows | 178 | /* maximum number of significant digits to read (to avoid overflows |
180 | even with single floats) */ | 179 | even with single floats) */ |
181 | #define MAXSIGDIG 30 | 180 | #define MAXSIGDIG 30 |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: luaconf.h,v 1.243 2015/02/04 12:52:57 roberto Exp roberto $ | 2 | ** $Id: luaconf.h,v 1.244 2015/02/05 16:53:34 roberto Exp roberto $ |
3 | ** Configuration file for Lua | 3 | ** Configuration file for Lua |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -466,46 +466,6 @@ | |||
466 | (*(p) = (LUA_INTEGER)(n), 1)) | 466 | (*(p) = (LUA_INTEGER)(n), 1)) |
467 | 467 | ||
468 | 468 | ||
469 | /* | ||
470 | @@ The luai_num* macros define the primitive operations over numbers. | ||
471 | ** They should work for any size of floating numbers. | ||
472 | */ | ||
473 | |||
474 | /* the following operations need the math library */ | ||
475 | #if defined(lobject_c) || defined(lvm_c) | ||
476 | #include <math.h> | ||
477 | |||
478 | /* floor division (defined as 'floor(a/b)') */ | ||
479 | #define luai_numidiv(L,a,b) ((void)L, l_mathop(floor)(luai_numdiv(L,a,b))) | ||
480 | |||
481 | /* | ||
482 | ** module: defined as 'a - floor(a/b)*b'; the previous definition gives | ||
483 | ** NaN when 'b' is huge, but the result should be 'a'. 'fmod' gives the | ||
484 | ** result of 'a - trunc(a/b)*b', and therefore must be corrected when | ||
485 | ** 'trunc(a/b) ~= floor(a/b)'. That happens when the division has a | ||
486 | ** non-integer negative result, which is equivalent to the test below | ||
487 | */ | ||
488 | #define luai_nummod(L,a,b,m) \ | ||
489 | { (m) = l_mathop(fmod)(a,b); if ((m)*(b) < 0) (m) += (b); } | ||
490 | |||
491 | /* exponentiation */ | ||
492 | #define luai_numpow(L,a,b) ((void)L, l_mathop(pow)(a,b)) | ||
493 | |||
494 | #endif | ||
495 | |||
496 | /* these are quite standard operations */ | ||
497 | #if defined(LUA_CORE) | ||
498 | #define luai_numadd(L,a,b) ((a)+(b)) | ||
499 | #define luai_numsub(L,a,b) ((a)-(b)) | ||
500 | #define luai_nummul(L,a,b) ((a)*(b)) | ||
501 | #define luai_numdiv(L,a,b) ((a)/(b)) | ||
502 | #define luai_numunm(L,a) (-(a)) | ||
503 | #define luai_numeq(a,b) ((a)==(b)) | ||
504 | #define luai_numlt(a,b) ((a)<(b)) | ||
505 | #define luai_numle(a,b) ((a)<=(b)) | ||
506 | #define luai_numisnan(a) (!luai_numeq((a), (a))) | ||
507 | #endif | ||
508 | |||
509 | 469 | ||
510 | /* | 470 | /* |
511 | @@ LUA_INTEGER is the integer type used by Lua. | 471 | @@ LUA_INTEGER is the integer type used by Lua. |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lvm.c,v 2.232 2014/12/27 20:30:38 roberto Exp roberto $ | 2 | ** $Id: lvm.c,v 2.233 2015/01/16 16:54:37 roberto Exp roberto $ |
3 | ** Lua virtual machine | 3 | ** Lua virtual machine |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -11,6 +11,7 @@ | |||
11 | 11 | ||
12 | 12 | ||
13 | #include <limits.h> | 13 | #include <limits.h> |
14 | #include <math.h> | ||
14 | #include <stdio.h> | 15 | #include <stdio.h> |
15 | #include <stdlib.h> | 16 | #include <stdlib.h> |
16 | #include <string.h> | 17 | #include <string.h> |