diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2005-11-08 17:45:58 -0200 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2005-11-08 17:45:58 -0200 |
| commit | cbbde11a8ab1cda25fa36533739e4ca1efd1916c (patch) | |
| tree | a60f074eca3a3bbcd8d40f0597430668f27deff4 | |
| parent | 7b89cf3aeba7e256c5546cbed7b2b3f004c524dc (diff) | |
| download | lua-cbbde11a8ab1cda25fa36533739e4ca1efd1916c.tar.gz lua-cbbde11a8ab1cda25fa36533739e4ca1efd1916c.tar.bz2 lua-cbbde11a8ab1cda25fa36533739e4ca1efd1916c.zip | |
better position for lua_number2int (it is related to lua_Number)
| -rw-r--r-- | luaconf.h | 52 |
1 files changed, 26 insertions, 26 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: luaconf.h,v 1.70 2005/10/24 17:39:21 roberto Exp $ | 2 | ** $Id: luaconf.h,v 1.71 2005/10/25 13:36:28 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 | */ |
| @@ -483,31 +483,6 @@ | |||
| 483 | 483 | ||
| 484 | 484 | ||
| 485 | 485 | ||
| 486 | /* | ||
| 487 | @@ lua_number2int is a macro to convert lua_Number to int. | ||
| 488 | @@ lua_number2integer is a macro to convert lua_Number to lua_Integer. | ||
| 489 | ** CHANGE them if you know a faster way to convert a lua_Number to | ||
| 490 | ** int (with any rounding method and without throwing errors) in your | ||
| 491 | ** system. In Pentium machines, a naive typecast from double to int | ||
| 492 | ** in C is extremely slow, so any alternative is worth trying. | ||
| 493 | */ | ||
| 494 | |||
| 495 | /* On a Pentium, resort to a trick */ | ||
| 496 | #if !defined(LUA_ANSI) && !defined(__SSE2__) && \ | ||
| 497 | (defined(__i386) || defined (_M_IX86)) | ||
| 498 | union luai_Cast { double l_d; long l_l; }; | ||
| 499 | #define lua_number2int(i,d) \ | ||
| 500 | { volatile union luai_Cast u; u.l_d = (d) + 6755399441055744.0; (i) = u.l_l; } | ||
| 501 | #define lua_number2integer(i,n) lua_number2int(i, n) | ||
| 502 | |||
| 503 | /* this option always works, but may be slow */ | ||
| 504 | #else | ||
| 505 | #define lua_number2int(i,d) ((i)=(int)(d)) | ||
| 506 | #define lua_number2integer(i,d) ((i)=(lua_Integer)(d)) | ||
| 507 | |||
| 508 | #endif | ||
| 509 | |||
| 510 | |||
| 511 | 486 | ||
| 512 | /* | 487 | /* |
| 513 | ** {================================================================== | 488 | ** {================================================================== |
| @@ -558,6 +533,31 @@ union luai_Cast { double l_d; long l_l; }; | |||
| 558 | #define luai_numle(a,b) ((a)<=(b)) | 533 | #define luai_numle(a,b) ((a)<=(b)) |
| 559 | #endif | 534 | #endif |
| 560 | 535 | ||
| 536 | |||
| 537 | /* | ||
| 538 | @@ lua_number2int is a macro to convert lua_Number to int. | ||
| 539 | @@ lua_number2integer is a macro to convert lua_Number to lua_Integer. | ||
| 540 | ** CHANGE them if you know a faster way to convert a lua_Number to | ||
| 541 | ** int (with any rounding method and without throwing errors) in your | ||
| 542 | ** system. In Pentium machines, a naive typecast from double to int | ||
| 543 | ** in C is extremely slow, so any alternative is worth trying. | ||
| 544 | */ | ||
| 545 | |||
| 546 | /* On a Pentium, resort to a trick */ | ||
| 547 | #if !defined(LUA_ANSI) && !defined(__SSE2__) && \ | ||
| 548 | (defined(__i386) || defined (_M_IX86)) | ||
| 549 | union luai_Cast { double l_d; long l_l; }; | ||
| 550 | #define lua_number2int(i,d) \ | ||
| 551 | { volatile union luai_Cast u; u.l_d = (d) + 6755399441055744.0; (i) = u.l_l; } | ||
| 552 | #define lua_number2integer(i,n) lua_number2int(i, n) | ||
| 553 | |||
| 554 | /* this option always works, but may be slow */ | ||
| 555 | #else | ||
| 556 | #define lua_number2int(i,d) ((i)=(int)(d)) | ||
| 557 | #define lua_number2integer(i,d) ((i)=(lua_Integer)(d)) | ||
| 558 | |||
| 559 | #endif | ||
| 560 | |||
| 561 | /* }================================================================== */ | 561 | /* }================================================================== */ |
| 562 | 562 | ||
| 563 | 563 | ||
