diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-12-10 09:56:55 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-12-10 09:56:55 -0200 |
commit | bd8ce7e33188502fe8d42d3dcf29e52eb164fcf6 (patch) | |
tree | bff4e13b3a141e975847fe65e274a8180c0d363f /luaconf.h | |
parent | 5c519a69d3e25f5c210a858f0abf721cd7a2fdab (diff) | |
download | lua-bd8ce7e33188502fe8d42d3dcf29e52eb164fcf6.tar.gz lua-bd8ce7e33188502fe8d42d3dcf29e52eb164fcf6.tar.bz2 lua-bd8ce7e33188502fe8d42d3dcf29e52eb164fcf6.zip |
macro 'LUA_C89_NUMBERS' makes a little easier to use C89 numerical types
Diffstat (limited to 'luaconf.h')
-rw-r--r-- | luaconf.h | 62 |
1 files changed, 25 insertions, 37 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: luaconf.h,v 1.229 2014/11/21 12:15:00 roberto Exp roberto $ | 2 | ** $Id: luaconf.h,v 1.230 2014/11/25 18:21: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 | */ |
@@ -72,6 +72,16 @@ | |||
72 | #endif | 72 | #endif |
73 | 73 | ||
74 | 74 | ||
75 | /* | ||
76 | @@ LUA_C89_NUMBERS ensures that Lua uses the largest types available for | ||
77 | ** C89 ('long' and 'double'); Windows has '__int64', so it does not need | ||
78 | ** to use this case. | ||
79 | */ | ||
80 | #if defined(LUA_USE_C89) && !defined(LUA_USE_WINDOWS) | ||
81 | #define LUA_C89_NUMBERS | ||
82 | #endif | ||
83 | |||
84 | |||
75 | 85 | ||
76 | /* | 86 | /* |
77 | @@ LUAI_BITSINT defines the (minimum) number of bits in an 'int'. | 87 | @@ LUAI_BITSINT defines the (minimum) number of bits in an 'int'. |
@@ -90,17 +100,16 @@ | |||
90 | ** Lua integers. | 100 | ** Lua integers. |
91 | @@ LUA_REAL_FLOAT / LUA_REAL_DOUBLE / LUA_REAL_LONGDOUBLE defines | 101 | @@ LUA_REAL_FLOAT / LUA_REAL_DOUBLE / LUA_REAL_LONGDOUBLE defines |
92 | ** the type for Lua floats. | 102 | ** the type for Lua floats. |
93 | ** Lua should work fine with any mix of these options (if supported by | 103 | ** Lua should work fine with any mix of these options (if supported |
94 | ** your C compiler). The usual configurations are 64-bit integers and | 104 | ** by your C compiler). The usual configurations are 64-bit integers |
95 | ** 'double' (the default) and 32-bit integers and 'float' (Small Lua, | 105 | ** and 'double' (the default), 32-bit integers and 'float' (Small Lua, |
96 | ** for restricted platforms). C compilers not compliant with C99 may | 106 | ** for restricted platforms), and 'long'/'double' (for C compilers not |
97 | ** not have support for 'long long', so the default in that case is | 107 | ** compliant with C99, which may not have support for 'long long'). |
98 | ** 'long'/'double'. | ||
99 | */ | 108 | */ |
100 | 109 | ||
101 | #if defined(LUA_32BITS) /* { */ | 110 | #if defined(LUA_32BITS) /* { */ |
102 | /* | 111 | /* |
103 | ** Small Lua | 112 | ** Small Lua (32-bit integers and 'float') |
104 | */ | 113 | */ |
105 | #if LUAI_BITSINT >= 32 /* use 'int' if big enough */ | 114 | #if LUAI_BITSINT >= 32 /* use 'int' if big enough */ |
106 | #define LUA_INT_INT | 115 | #define LUA_INT_INT |
@@ -109,15 +118,14 @@ | |||
109 | #endif | 118 | #endif |
110 | #define LUA_REAL_FLOAT | 119 | #define LUA_REAL_FLOAT |
111 | 120 | ||
112 | #elif defined(LUA_USE_C89) && !defined(LUA_USE_WINDOWS) /* }{ */ | 121 | #elif defined(LUA_C89_NUMBERS) /* }{ */ |
113 | /* | 122 | /* |
114 | ** use largest types available for C89 ('long' and 'double'); | 123 | ** largest types available for C89 ('long' and 'double') |
115 | ** Windows has '__int64', so does not need to use this case | ||
116 | */ | 124 | */ |
117 | #define LUA_INT_LONG | 125 | #define LUA_INT_LONG |
118 | #define LUA_REAL_DOUBLE | 126 | #define LUA_REAL_DOUBLE |
119 | 127 | ||
120 | #else /* }{ */ | 128 | #else /* }{ */ |
121 | /* | 129 | /* |
122 | ** default configuration for 64-bit Lua ('long long' and 'double'); | 130 | ** default configuration for 64-bit Lua ('long long' and 'double'); |
123 | ** Windows will use '__int64' | 131 | ** Windows will use '__int64' |
@@ -557,7 +565,7 @@ | |||
557 | 565 | ||
558 | #elif defined(LUA_INT_LONGLONG) /* }{ long long */ | 566 | #elif defined(LUA_INT_LONGLONG) /* }{ long long */ |
559 | 567 | ||
560 | #if defined(LUA_USE_WINDOWS) | 568 | #if defined(LUA_USE_WINDOWS) /* { */ |
561 | 569 | ||
562 | #define LUA_INTEGER __int64 | 570 | #define LUA_INTEGER __int64 |
563 | #define LUA_INTEGER_FRMLEN "I64" | 571 | #define LUA_INTEGER_FRMLEN "I64" |
@@ -565,11 +573,11 @@ | |||
565 | #define LUA_MAXINTEGER _I64_MAX | 573 | #define LUA_MAXINTEGER _I64_MAX |
566 | #define LUA_MININTEGER _I64_MIN | 574 | #define LUA_MININTEGER _I64_MIN |
567 | 575 | ||
568 | #else | 576 | #else /* }{ */ |
569 | 577 | ||
570 | #if !defined(LLONG_MAX) | 578 | #if !defined(LLONG_MAX) |
571 | #error "Compiler does not support 'long long'. Use option '-DLUA_32BITS' \ | 579 | #error "Compiler does not support 'long long'. Use option '-DLUA_32BITS' \ |
572 | or '-DLUA_USE_C89' (see file 'luaconf.h' for details)" | 580 | or '-DLUA_C89_NUMBERS' (see file 'luaconf.h' for details)" |
573 | #endif | 581 | #endif |
574 | 582 | ||
575 | #define LUA_INTEGER long long | 583 | #define LUA_INTEGER long long |
@@ -578,27 +586,7 @@ | |||
578 | #define LUA_MAXINTEGER LLONG_MAX | 586 | #define LUA_MAXINTEGER LLONG_MAX |
579 | #define LUA_MININTEGER LLONG_MIN | 587 | #define LUA_MININTEGER LLONG_MIN |
580 | 588 | ||
581 | #endif | 589 | #endif /* } */ |
582 | |||
583 | #elif defined(LUA_INT_SHORT) /* }{ short int */ | ||
584 | /* | ||
585 | ** this option is for internal tests only; it is not particularly useful | ||
586 | ** and it does not pass the test suit. | ||
587 | */ | ||
588 | |||
589 | #define LUA_INTEGER short int | ||
590 | #define LUA_INTEGER_FRMLEN "" | ||
591 | |||
592 | #define LUA_MAXINTEGER SHRT_MAX | ||
593 | #define LUA_MININTEGER SHRT_MIN | ||
594 | |||
595 | #undef LUAI_UACINT | ||
596 | #define LUAI_UACINT int | ||
597 | |||
598 | #undef LUAI_BITSINT | ||
599 | #define LUAI_BITSINT 16 | ||
600 | |||
601 | #define l_castS2U(x) ((LUA_UNSIGNED)(unsigned short)(x)) | ||
602 | 590 | ||
603 | #else /* }{ */ | 591 | #else /* }{ */ |
604 | 592 | ||