diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2015-10-21 16:17:40 -0200 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2015-10-21 16:17:40 -0200 |
| commit | 48098c42ff69154811f234c1446b4fcbf2f15e94 (patch) | |
| tree | 7a0ba652295134cce51257b439cd59ec487fb7ac | |
| parent | 3ad55386c4ed4bf1255e5a15ef439431184a025f (diff) | |
| download | lua-48098c42ff69154811f234c1446b4fcbf2f15e94.tar.gz lua-48098c42ff69154811f234c1446b4fcbf2f15e94.tar.bz2 lua-48098c42ff69154811f234c1446b4fcbf2f15e94.zip | |
generic definitions for float types moved to before variable definitions
(so that specific cases can redefine these generic definitions if
needed)
| -rw-r--r-- | luaconf.h | 46 |
1 files changed, 26 insertions, 20 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: luaconf.h,v 1.252 2015/06/18 14:26:05 roberto Exp roberto $ | 2 | ** $Id: luaconf.h,v 1.253 2015/06/24 18:23:57 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 | */ |
| @@ -412,9 +412,33 @@ | |||
| 412 | @@ LUA_NUMBER_FMT is the format for writing floats. | 412 | @@ LUA_NUMBER_FMT is the format for writing floats. |
| 413 | @@ lua_number2str converts a float to a string. | 413 | @@ lua_number2str converts a float to a string. |
| 414 | @@ l_mathop allows the addition of an 'l' or 'f' to all math operations. | 414 | @@ l_mathop allows the addition of an 'l' or 'f' to all math operations. |
| 415 | @@ l_floor takes the floor of a float. | ||
| 415 | @@ lua_str2number converts a decimal numeric string to a number. | 416 | @@ lua_str2number converts a decimal numeric string to a number. |
| 416 | */ | 417 | */ |
| 417 | 418 | ||
| 419 | |||
| 420 | /* The following definitions are good for most cases here */ | ||
| 421 | |||
| 422 | #define l_floor(x) (l_mathop(floor)(x)) | ||
| 423 | |||
| 424 | #define lua_number2str(s,sz,n) l_sprintf((s), sz, LUA_NUMBER_FMT, (n)) | ||
| 425 | |||
| 426 | /* | ||
| 427 | @@ lua_numbertointeger converts a float number to an integer, or | ||
| 428 | ** returns 0 if float is not within the range of a lua_Integer. | ||
| 429 | ** (The range comparisons are tricky because of rounding. The tests | ||
| 430 | ** here assume a two-complement representation, where MININTEGER always | ||
| 431 | ** has an exact representation as a float; MAXINTEGER may not have one, | ||
| 432 | ** and therefore its conversion to float may have an ill-defined value.) | ||
| 433 | */ | ||
| 434 | #define lua_numbertointeger(n,p) \ | ||
| 435 | ((n) >= (LUA_NUMBER)(LUA_MININTEGER) && \ | ||
| 436 | (n) < -(LUA_NUMBER)(LUA_MININTEGER) && \ | ||
| 437 | (*(p) = (LUA_INTEGER)(n), 1)) | ||
| 438 | |||
| 439 | |||
| 440 | /* now the variable definitions */ | ||
| 441 | |||
| 418 | #if LUA_FLOAT_TYPE == LUA_FLOAT_FLOAT /* { single float */ | 442 | #if LUA_FLOAT_TYPE == LUA_FLOAT_FLOAT /* { single float */ |
| 419 | 443 | ||
| 420 | #define LUA_NUMBER float | 444 | #define LUA_NUMBER float |
| @@ -468,25 +492,6 @@ | |||
| 468 | #endif /* } */ | 492 | #endif /* } */ |
| 469 | 493 | ||
| 470 | 494 | ||
| 471 | #define l_floor(x) (l_mathop(floor)(x)) | ||
| 472 | |||
| 473 | #define lua_number2str(s,sz,n) l_sprintf((s), sz, LUA_NUMBER_FMT, (n)) | ||
| 474 | |||
| 475 | |||
| 476 | /* | ||
| 477 | @@ lua_numbertointeger converts a float number to an integer, or | ||
| 478 | ** returns 0 if float is not within the range of a lua_Integer. | ||
| 479 | ** (The range comparisons are tricky because of rounding. The tests | ||
| 480 | ** here assume a two-complement representation, where MININTEGER always | ||
| 481 | ** has an exact representation as a float; MAXINTEGER may not have one, | ||
| 482 | ** and therefore its conversion to float may have an ill-defined value.) | ||
| 483 | */ | ||
| 484 | #define lua_numbertointeger(n,p) \ | ||
| 485 | ((n) >= (LUA_NUMBER)(LUA_MININTEGER) && \ | ||
| 486 | (n) < -(LUA_NUMBER)(LUA_MININTEGER) && \ | ||
| 487 | (*(p) = (LUA_INTEGER)(n), 1)) | ||
| 488 | |||
| 489 | |||
| 490 | 495 | ||
| 491 | /* | 496 | /* |
| 492 | @@ LUA_INTEGER is the integer type used by Lua. | 497 | @@ LUA_INTEGER is the integer type used by Lua. |
| @@ -537,6 +542,7 @@ | |||
| 537 | 542 | ||
| 538 | #elif LUA_INT_TYPE == LUA_INT_LONGLONG /* }{ long long */ | 543 | #elif LUA_INT_TYPE == LUA_INT_LONGLONG /* }{ long long */ |
| 539 | 544 | ||
| 545 | /* use presence of macro LLONG_MAX as proxy for C99 compliance */ | ||
| 540 | #if defined(LLONG_MAX) /* { */ | 546 | #if defined(LLONG_MAX) /* { */ |
| 541 | /* use ISO C99 stuff */ | 547 | /* use ISO C99 stuff */ |
| 542 | 548 | ||
