diff options
Diffstat (limited to 'luaconf.h')
-rw-r--r-- | luaconf.h | 107 |
1 files changed, 8 insertions, 99 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: luaconf.h,v 1.147 2010/10/29 11:13:21 roberto Exp roberto $ | 2 | ** $Id: luaconf.h,v 1.148 2010/10/29 17:52:46 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 | */ |
@@ -348,27 +348,13 @@ | |||
348 | 348 | ||
349 | 349 | ||
350 | 350 | ||
351 | /* | ||
352 | ** {================================================================== | ||
353 | ** CHANGE (to smaller values) the following definitions if your system | ||
354 | ** has a small C stack. (Or you may want to change them to larger | ||
355 | ** values if your system has a large C stack and these limits are | ||
356 | ** too rigid for you.) Some of these constants control the size of | ||
357 | ** stack-allocated arrays used by the compiler or the interpreter, while | ||
358 | ** others limit the maximum number of recursive calls that the compiler | ||
359 | ** or the interpreter can perform. Values too large may cause a C stack | ||
360 | ** overflow for some forms of deep constructs. | ||
361 | ** =================================================================== | ||
362 | */ | ||
363 | |||
364 | 351 | ||
365 | /* | 352 | /* |
366 | @@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system. | 353 | @@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system. |
354 | ** CHANGE it if it uses too much C-stack space. | ||
367 | */ | 355 | */ |
368 | #define LUAL_BUFFERSIZE BUFSIZ | 356 | #define LUAL_BUFFERSIZE BUFSIZ |
369 | 357 | ||
370 | /* }================================================================== */ | ||
371 | |||
372 | 358 | ||
373 | 359 | ||
374 | 360 | ||
@@ -445,32 +431,21 @@ | |||
445 | #define LUA_UNSIGNED unsigned LUA_INT32 | 431 | #define LUA_UNSIGNED unsigned LUA_INT32 |
446 | 432 | ||
447 | 433 | ||
448 | /* | ||
449 | @@ lua_number2int is a macro to convert lua_Number to int. | ||
450 | @@ lua_number2integer is a macro to convert lua_Number to LUA_INTEGER. | ||
451 | @@ lua_number2uint is a macro to convert a lua_Number to a LUA_UNSIGNED. | ||
452 | @@ lua_uint2number is a macro to convert a LUA_UNSIGNED to a lua_Number. | ||
453 | */ | ||
454 | |||
455 | #if defined(LUA_CORE) /* { */ | 434 | #if defined(LUA_CORE) /* { */ |
456 | 435 | ||
457 | #if defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI) && \ | 436 | #if defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI) /* { */ |
458 | !defined(LUA_NOIEEE754TRICK) /* { */ | ||
459 | 437 | ||
460 | /* On a Microsoft compiler on a Pentium, use assembler to avoid clashes | 438 | /* On a Microsoft compiler on a Pentium, use assembler to avoid clashes |
461 | with a DirectX idiosyncrasy */ | 439 | with a DirectX idiosyncrasy */ |
462 | #if defined(_MSC_VER) && defined(M_IX86) /* { */ | 440 | #if defined(_MSC_VER) && defined(M_IX86) /* { */ |
463 | 441 | ||
464 | #define lua_number2int(i,n) __asm {__asm fld n __asm fistp i} | 442 | #define MS_ASMTRICK |
465 | #define lua_number2integer(i,n) lua_number2int(i, n) | ||
466 | #define lua_number2uint(i,n) \ | ||
467 | {__int64 l; __asm {__asm fld n __asm fistp l} i = (unsigned int)l;} | ||
468 | 443 | ||
469 | #else /* }{ */ | 444 | #else /* }{ */ |
470 | /* the next trick should work on any machine using IEEE754 with | 445 | /* the next definition uses a trick that should work on any machine |
471 | a 32-bit integer type */ | 446 | using IEEE754 with a 32-bit integer type */ |
472 | 447 | ||
473 | union luai_Cast { double l_d; LUA_INT32 l_p[2]; }; | 448 | #define LUA_IEEE754TRICK |
474 | 449 | ||
475 | /* | 450 | /* |
476 | @@ LUA_IEEEENDIAN is the endianness of doubles in your machine | 451 | @@ LUA_IEEEENDIAN is the endianness of doubles in your machine |
@@ -485,77 +460,11 @@ union luai_Cast { double l_d; LUA_INT32 l_p[2]; }; | |||
485 | #define LUA_IEEEENDIAN 1 | 460 | #define LUA_IEEEENDIAN 1 |
486 | #endif | 461 | #endif |
487 | 462 | ||
488 | #if !defined(LUA_IEEEENDIAN) /* { */ | ||
489 | #define LUAI_EXTRAIEEE \ | ||
490 | static const union luai_Cast ieeeendian = {-(33.0 + 6755399441055744.0)}; | ||
491 | #define LUA_IEEEENDIAN (ieeeendian.l_p[1] == 33) | ||
492 | #else | ||
493 | #define LUAI_EXTRAIEEE /* empty */ | ||
494 | #endif /* } */ | ||
495 | |||
496 | #define lua_number2int32(i,n,t) \ | ||
497 | { LUAI_EXTRAIEEE \ | ||
498 | volatile union luai_Cast u; u.l_d = (n) + 6755399441055744.0; \ | ||
499 | (i) = (t)u.l_p[LUA_IEEEENDIAN]; } | ||
500 | |||
501 | #define lua_number2int(i,n) lua_number2int32(i, n, int) | ||
502 | #define lua_number2integer(i,n) lua_number2int32(i, n, LUA_INTEGER) | ||
503 | #define lua_number2uint(i,n) lua_number2int32(i, n, LUA_UNSIGNED) | ||
504 | |||
505 | #endif /* } */ | 463 | #endif /* } */ |
506 | 464 | ||
507 | |||
508 | #endif /* } */ | 465 | #endif /* } */ |
509 | 466 | ||
510 | 467 | #endif /* } */ | |
511 | /* the following definitions always work, but may be slow */ | ||
512 | |||
513 | #if !defined(lua_number2int) | ||
514 | #define lua_number2int(i,n) ((i)=(int)(n)) | ||
515 | #endif | ||
516 | |||
517 | #if !defined(lua_number2integer) | ||
518 | #define lua_number2integer(i,n) ((i)=(LUA_INTEGER)(n)) | ||
519 | #endif | ||
520 | |||
521 | #if !defined(lua_number2uint) && (defined(lapi_c) || defined(luaall_c)) /* { */ | ||
522 | /* the following definition assures proper modulo behavior */ | ||
523 | #if defined(LUA_NUMBER_DOUBLE) | ||
524 | #include <math.h> | ||
525 | #define lua_number2uint(i,n) \ | ||
526 | ((i)=(LUA_UNSIGNED)((n) - floor((n)/4294967296.0)*4294967296.0)) | ||
527 | #else | ||
528 | #define lua_number2uint(i,n) ((i)=(LUA_UNSIGNED)(n)) | ||
529 | #endif | ||
530 | #endif /* } */ | ||
531 | |||
532 | #if !defined(lua_uint2number) | ||
533 | /* on several machines, coercion from unsigned to double is slow, | ||
534 | so it may be worth to avoid */ | ||
535 | #define lua_uint2number(u) \ | ||
536 | ((LUA_INT32)(u) < 0 ? (lua_Number)(u) : (lua_Number)(LUA_INT32)(u)) | ||
537 | #endif | ||
538 | |||
539 | #endif /* } */ | ||
540 | |||
541 | |||
542 | /* | ||
543 | @@ luai_hashnum is a macro do hash a lua_Number value into an integer. | ||
544 | @* The hash must be deterministic and give reasonable values for | ||
545 | @* both small and large values (outside the range of integers). | ||
546 | @* It is used only in ltable.c. | ||
547 | */ | ||
548 | |||
549 | #if defined(ltable_c) || defined(luaall_c) | ||
550 | |||
551 | #include <float.h> | ||
552 | #include <math.h> | ||
553 | |||
554 | #define luai_hashnum(i,n) { int e; \ | ||
555 | n = frexp(n, &e) * (lua_Number)(INT_MAX - DBL_MAX_EXP); \ | ||
556 | lua_number2int(i, n); i += e; } | ||
557 | |||
558 | #endif /* ltable_c */ | ||
559 | 468 | ||
560 | /* }================================================================== */ | 469 | /* }================================================================== */ |
561 | 470 | ||