diff options
Diffstat (limited to 'luaconf.h')
-rw-r--r-- | luaconf.h | 50 |
1 files changed, 30 insertions, 20 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: luaconf.h,v 1.104 2009/03/26 12:57:01 roberto Exp roberto $ | 2 | ** $Id: luaconf.h,v 1.105 2009/06/18 18:19:36 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 | */ |
@@ -142,14 +142,6 @@ | |||
142 | 142 | ||
143 | 143 | ||
144 | /* | 144 | /* |
145 | @@ LUA_INTEGER is the integral type used by lua_pushinteger/lua_tointeger. | ||
146 | ** CHANGE that if ptrdiff_t is not adequate on your machine. (On most | ||
147 | ** machines, ptrdiff_t gives a good choice between int or long.) | ||
148 | */ | ||
149 | #define LUA_INTEGER ptrdiff_t | ||
150 | |||
151 | |||
152 | /* | ||
153 | @@ LUA_API is a mark for all core API functions. | 145 | @@ LUA_API is a mark for all core API functions. |
154 | @@ LUALIB_API is a mark for all standard library functions. | 146 | @@ LUALIB_API is a mark for all standard library functions. |
155 | ** CHANGE them if you need to define those functions in some special way. | 147 | ** CHANGE them if you need to define those functions in some special way. |
@@ -403,24 +395,22 @@ | |||
403 | 395 | ||
404 | 396 | ||
405 | /* | 397 | /* |
406 | @@ LUAI_UINT32 is an unsigned integer with at least 32 bits. | 398 | @@ LUA_INT32 is an signed integer with exactly 32 bits. |
407 | @@ LUAI_INT32 is an signed integer with at least 32 bits. | ||
408 | @@ LUAI_UMEM is an unsigned integer big enough to count the total | 399 | @@ LUAI_UMEM is an unsigned integer big enough to count the total |
409 | @* memory used by Lua. | 400 | @* memory used by Lua. |
410 | @@ LUAI_MEM is a signed integer big enough to count the total memory | 401 | @@ LUAI_MEM is a signed integer big enough to count the total memory |
411 | @* used by Lua. | 402 | @* used by Lua. |
412 | ** CHANGE here if for some weird reason the default definitions are not | 403 | ** CHANGE here if for some weird reason the default definitions are not |
413 | ** good enough for your machine. (The definitions in the 'else' | 404 | ** good enough for your machine. Probably you do not need to change |
414 | ** part always works, but may waste space on machines with 64-bit | 405 | ** this. |
415 | ** longs.) Probably you do not need to change this. | ||
416 | */ | 406 | */ |
417 | #if LUAI_BITSINT >= 32 | 407 | #if LUAI_BITSINT >= 32 |
418 | #define LUAI_UINT32 unsigned int | 408 | #define LUA_INT32 int |
419 | #define LUAI_UMEM size_t | 409 | #define LUAI_UMEM size_t |
420 | #define LUAI_MEM ptrdiff_t | 410 | #define LUAI_MEM ptrdiff_t |
421 | #else | 411 | #else |
422 | /* 16-bit ints */ | 412 | /* 16-bit ints */ |
423 | #define LUAI_UINT32 unsigned long | 413 | #define LUA_INT32 long |
424 | #define LUAI_UMEM unsigned long | 414 | #define LUAI_UMEM unsigned long |
425 | #define LUAI_MEM long | 415 | #define LUAI_MEM long |
426 | #endif | 416 | #endif |
@@ -553,8 +543,20 @@ | |||
553 | 543 | ||
554 | 544 | ||
555 | /* | 545 | /* |
546 | @@ LUA_INTEGER is the integral type used by lua_pushinteger/lua_tointeger. | ||
547 | ** CHANGE that if ptrdiff_t is not adequate on your machine. (On most | ||
548 | ** machines, ptrdiff_t gives a good choice between int or long.) | ||
549 | */ | ||
550 | #define LUA_INTEGER ptrdiff_t | ||
551 | |||
552 | |||
553 | /* | ||
556 | @@ lua_number2int is a macro to convert lua_Number to int. | 554 | @@ lua_number2int is a macro to convert lua_Number to int. |
557 | @@ lua_number2integer is a macro to convert lua_Number to lua_Integer. | 555 | @@ lua_number2integer is a macro to convert lua_Number to lUA_INTEGER. |
556 | @@ lua_number2uint is a macro to convert a lua_Number to an unsigned | ||
557 | @* LUA_INT32. | ||
558 | @@ lua_uint2number is a macro to convert an unsigned LUA_INT32 | ||
559 | @* to a lua_Number. | ||
558 | ** CHANGE them if you know a faster way to convert a lua_Number to | 560 | ** CHANGE them if you know a faster way to convert a lua_Number to |
559 | ** int (with any rounding method and without throwing errors) in your | 561 | ** int (with any rounding method and without throwing errors) in your |
560 | ** system. In Pentium machines, a naive typecast from double to int | 562 | ** system. In Pentium machines, a naive typecast from double to int |
@@ -571,25 +573,33 @@ | |||
571 | #define lua_number2int(i,d) __asm fld d __asm fistp i | 573 | #define lua_number2int(i,d) __asm fld d __asm fistp i |
572 | #define lua_number2integer(i,n) lua_number2int(i, n) | 574 | #define lua_number2integer(i,n) lua_number2int(i, n) |
573 | 575 | ||
576 | #else | ||
574 | /* the next trick should work on any Pentium, but sometimes clashes | 577 | /* the next trick should work on any Pentium, but sometimes clashes |
575 | with a DirectX idiosyncrasy */ | 578 | with a DirectX idiosyncrasy */ |
576 | #else | ||
577 | 579 | ||
578 | union luai_Cast { double l_d; long l_l; }; | 580 | union luai_Cast { double l_d; long l_l; }; |
579 | #define lua_number2int(i,d) \ | 581 | #define lua_number2int(i,d) \ |
580 | { volatile union luai_Cast u; u.l_d = (d) + 6755399441055744.0; (i) = u.l_l; } | 582 | { volatile union luai_Cast u; u.l_d = (d) + 6755399441055744.0; (i) = u.l_l; } |
581 | #define lua_number2integer(i,n) lua_number2int(i, n) | 583 | #define lua_number2integer(i,n) lua_number2int(i, n) |
584 | #define lua_number2uint(i,n) lua_number2int(i, n) | ||
582 | 585 | ||
583 | #endif | 586 | #endif |
584 | 587 | ||
585 | 588 | ||
586 | /* this option always works, but may be slow */ | ||
587 | #else | 589 | #else |
590 | /* this option always works, but may be slow */ | ||
588 | #define lua_number2int(i,d) ((i)=(int)(d)) | 591 | #define lua_number2int(i,d) ((i)=(int)(d)) |
589 | #define lua_number2integer(i,d) ((i)=(lua_Integer)(d)) | 592 | #define lua_number2integer(i,d) ((i)=(LUA_INTEGER)(d)) |
593 | #define lua_number2uint(i,d) ((i)=(unsigned LUA_INT32)(d)) | ||
590 | 594 | ||
591 | #endif | 595 | #endif |
592 | 596 | ||
597 | |||
598 | /* on several machines, coercion from unsigned to double is too slow, | ||
599 | so avoid that if possible */ | ||
600 | #define lua_uint2number(u) \ | ||
601 | ((LUA_INT32)(u) < 0 ? (lua_Number)(u) : (lua_Number)(LUA_INT32)(u)) | ||
602 | |||
593 | /* }================================================================== */ | 603 | /* }================================================================== */ |
594 | 604 | ||
595 | 605 | ||