diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2013-06-25 16:04:40 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2013-06-25 16:04:40 -0300 |
commit | 2b4975dca710510a7b94f1f9bef97814d1349f95 (patch) | |
tree | f1669be4bac09beadea854165a1c06c111785753 | |
parent | e39da66c8c23ede187df14fef6314052d124dad3 (diff) | |
download | lua-2b4975dca710510a7b94f1f9bef97814d1349f95.tar.gz lua-2b4975dca710510a7b94f1f9bef97814d1349f95.tar.bz2 lua-2b4975dca710510a7b94f1f9bef97814d1349f95.zip |
LUA_SMALL_* changed to LUA_*SIZE + added support for long double + better
support for ANSI systems
-rw-r--r-- | luaconf.h | 64 |
1 files changed, 40 insertions, 24 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: luaconf.h,v 1.183 2013/06/20 15:02:49 roberto Exp roberto $ | 2 | ** $Id: luaconf.h,v 1.184 2013/06/21 17:42: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 | */ |
@@ -384,11 +384,12 @@ | |||
384 | */ | 384 | */ |
385 | 385 | ||
386 | /* | 386 | /* |
387 | @@ LUA_SMALL_INT true makes Lua use a 32-bit integer type | 387 | @@ LUA_INTSIZE defines size for Lua integer: 1=int, 2=long, 3=long long |
388 | @@ LUA_SMALL_FLOAT true makes Lua use a 32-bit float type | 388 | @@ LUA_FLOATSIZE defines size for Lua float: 1=float, 2=double, 3=long double |
389 | ** Default is long long + double | ||
389 | */ | 390 | */ |
390 | #define LUA_SMALL_FLOAT 0 | 391 | #define LUA_INTSIZE 3 |
391 | #define LUA_SMALL_INT 0 | 392 | #define LUA_FLOATSIZE 2 |
392 | 393 | ||
393 | 394 | ||
394 | /* | 395 | /* |
@@ -405,14 +406,9 @@ | |||
405 | @@ l_mathop allows the addition of an 'l' or 'f' to all math operations | 406 | @@ l_mathop allows the addition of an 'l' or 'f' to all math operations |
406 | ** | 407 | ** |
407 | @@ lua_str2number converts a decimal numeric string to a number. | 408 | @@ lua_str2number converts a decimal numeric string to a number. |
408 | @@ lua_strx2number converts an hexadecimal numeric string to a number. | ||
409 | ** In C99, 'strtod' does both conversions. C89, however, has no function | ||
410 | ** to convert floating hexadecimal strings to numbers. For these | ||
411 | ** systems, you can leave 'lua_strx2number' undefined and Lua will | ||
412 | ** provide its own implementation. | ||
413 | */ | 409 | */ |
414 | 410 | ||
415 | #if LUA_SMALL_FLOAT /* { */ | 411 | #if LUA_FLOATSIZE == 1 /* { single float */ |
416 | 412 | ||
417 | #define LUA_NUMBER float | 413 | #define LUA_NUMBER float |
418 | 414 | ||
@@ -423,13 +419,26 @@ | |||
423 | #define LUA_NUMBER_FMT "%.7g" | 419 | #define LUA_NUMBER_FMT "%.7g" |
424 | 420 | ||
425 | #define l_mathop(op) op##f | 421 | #define l_mathop(op) op##f |
426 | #define l_floor(x) (floorf(x)) | ||
427 | 422 | ||
428 | #define lua_str2number(s,p) strtof((s), (p)) | 423 | #define lua_str2number(s,p) strtof((s), (p)) |
429 | 424 | ||
430 | #else /* }{ */ | ||
431 | 425 | ||
432 | #define LUA_NUMBER_DOUBLE | 426 | #elif LUA_FLOATSIZE == 3 /* }{ long double */ |
427 | |||
428 | #define LUA_NUMBER long double | ||
429 | |||
430 | #define LUAI_UACNUMBER long double | ||
431 | |||
432 | #define LUA_NUMBER_FRMLEN "L" | ||
433 | #define LUA_NUMBER_SCAN "%Lf" | ||
434 | #define LUA_NUMBER_FMT "%.19Lg" | ||
435 | |||
436 | #define l_mathop(op) op##l | ||
437 | |||
438 | #define lua_str2number(s,p) strtold((s), (p)) | ||
439 | |||
440 | #else /* }{ default: double */ | ||
441 | |||
433 | #define LUA_NUMBER double | 442 | #define LUA_NUMBER double |
434 | 443 | ||
435 | #define LUAI_UACNUMBER double | 444 | #define LUAI_UACNUMBER double |
@@ -439,18 +448,28 @@ | |||
439 | #define LUA_NUMBER_FMT "%.14g" | 448 | #define LUA_NUMBER_FMT "%.14g" |
440 | 449 | ||
441 | #define l_mathop(op) op | 450 | #define l_mathop(op) op |
442 | #define l_floor(x) (floor(x)) | ||
443 | 451 | ||
444 | #define lua_str2number(s,p) strtod((s), (p)) | 452 | #define lua_str2number(s,p) strtod((s), (p)) |
445 | 453 | ||
446 | #endif /* } */ | 454 | #endif /* } */ |
447 | 455 | ||
448 | 456 | ||
449 | #if defined(LUA_USE_STRTODHEX) | 457 | #if defined(LUA_ANSI) |
450 | #define lua_strx2number(s,p) lua_str2number(s,p) | 458 | /* C89 does not support 'opf' variants for math functions */ |
459 | #undef l_mathop | ||
460 | #define l_mathop(op) (lua_Number)op | ||
451 | #endif | 461 | #endif |
452 | 462 | ||
453 | 463 | ||
464 | #if defined(LUA_ANSI) || defined(_WIN32) | ||
465 | /* C89 and Windows do not support 'strtof'... */ | ||
466 | #undef lua_str2number | ||
467 | #define lua_str2number(s,p) ((lua_Number)strtod((s), (p))) | ||
468 | #endif | ||
469 | |||
470 | |||
471 | #define l_floor(x) (l_mathop(floor)(x)) | ||
472 | |||
454 | #define lua_number2str(s,n) sprintf((s), LUA_NUMBER_FMT, (n)) | 473 | #define lua_number2str(s,n) sprintf((s), LUA_NUMBER_FMT, (n)) |
455 | 474 | ||
456 | 475 | ||
@@ -492,27 +511,24 @@ | |||
492 | @@ lua_integer2str converts an integer to a string. | 511 | @@ lua_integer2str converts an integer to a string. |
493 | */ | 512 | */ |
494 | 513 | ||
495 | #if LUA_SMALL_INT /* { */ | 514 | #if LUA_INTSIZE == 1 /* { int */ |
496 | |||
497 | #if LUAI_BITSINT >= 32 | ||
498 | 515 | ||
499 | #define LUA_INTEGER int | 516 | #define LUA_INTEGER int |
500 | #define LUA_INTEGER_FRMLEN "" | 517 | #define LUA_INTEGER_FRMLEN "" |
501 | 518 | ||
502 | #else | 519 | #elif LUA_INTSIZE == 2 /* }{ long */ |
503 | 520 | ||
504 | #define LUA_INTEGER long | 521 | #define LUA_INTEGER long |
505 | #define LUA_INTEGER_FRMLEN "l" | 522 | #define LUA_INTEGER_FRMLEN "l" |
506 | 523 | ||
507 | #endif | 524 | #else /* }{ default: long long */ |
508 | |||
509 | #else /* }{ */ | ||
510 | 525 | ||
511 | #define LUA_INTEGER long long | 526 | #define LUA_INTEGER long long |
512 | #define LUA_INTEGER_FRMLEN "ll" | 527 | #define LUA_INTEGER_FRMLEN "ll" |
513 | 528 | ||
514 | #endif /* } */ | 529 | #endif /* } */ |
515 | 530 | ||
531 | |||
516 | #define LUA_INTEGER_SCAN "%" LUA_INTEGER_FRMLEN "d" | 532 | #define LUA_INTEGER_SCAN "%" LUA_INTEGER_FRMLEN "d" |
517 | #define LUA_INTEGER_FMT "%" LUA_INTEGER_FRMLEN "d" | 533 | #define LUA_INTEGER_FMT "%" LUA_INTEGER_FRMLEN "d" |
518 | #define lua_integer2str(s,n) sprintf((s), LUA_INTEGER_FMT, (n)) | 534 | #define lua_integer2str(s,n) sprintf((s), LUA_INTEGER_FMT, (n)) |