diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-05-13 14:24:10 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-05-13 14:24:10 -0300 |
commit | 49c42f3615bd876657bf697e3bf040ce796ae238 (patch) | |
tree | bb2268fbcd525045b5e9ed523b5dab8a67fc7fe1 /luaconf.h | |
parent | d881325c2fcbb6d2c434ec403b0bbe51ac200c7b (diff) | |
download | lua-49c42f3615bd876657bf697e3bf040ce796ae238.tar.gz lua-49c42f3615bd876657bf697e3bf040ce796ae238.tar.bz2 lua-49c42f3615bd876657bf697e3bf040ce796ae238.zip |
Some improvements in 'luaconf.h'
Added '#if !defined' in some definitions to allow external definitions;
more comments; other small changes.
Diffstat (limited to 'luaconf.h')
-rw-r--r-- | luaconf.h | 88 |
1 files changed, 57 insertions, 31 deletions
@@ -14,6 +14,16 @@ | |||
14 | 14 | ||
15 | /* | 15 | /* |
16 | ** =================================================================== | 16 | ** =================================================================== |
17 | ** General Configuration File for Lua | ||
18 | ** | ||
19 | ** Some definitions here can be changed externally, through the | ||
20 | ** compiler (e.g., with '-D' options). Those are protected by | ||
21 | ** '#if !defined' guards. However, several other definitions should | ||
22 | ** be changed directly here, either because they affect the Lua | ||
23 | ** ABI (by making the changes here, you ensure that all software | ||
24 | ** connected to Lua, such as C libraries, will be compiled with the | ||
25 | ** same configuration); or because they are seldom changed. | ||
26 | ** | ||
17 | ** Search for "@@" to find all configurable definitions. | 27 | ** Search for "@@" to find all configurable definitions. |
18 | ** =================================================================== | 28 | ** =================================================================== |
19 | */ | 29 | */ |
@@ -22,8 +32,7 @@ | |||
22 | /* | 32 | /* |
23 | ** {==================================================================== | 33 | ** {==================================================================== |
24 | ** System Configuration: macros to adapt (if needed) Lua to some | 34 | ** System Configuration: macros to adapt (if needed) Lua to some |
25 | ** particular platform, for instance compiling it with 32-bit numbers or | 35 | ** particular platform, for instance restricting it to C89. |
26 | ** restricting it to C89. | ||
27 | ** ===================================================================== | 36 | ** ===================================================================== |
28 | */ | 37 | */ |
29 | 38 | ||
@@ -43,15 +52,6 @@ | |||
43 | 52 | ||
44 | 53 | ||
45 | /* | 54 | /* |
46 | @@ LUA_32BITS enables Lua with 32-bit integers and 32-bit floats. You | ||
47 | ** can also define LUA_32BITS in the make file, but changing here you | ||
48 | ** ensure that all software connected to Lua will be compiled with the | ||
49 | ** same configuration. | ||
50 | */ | ||
51 | /* #define LUA_32BITS */ | ||
52 | |||
53 | |||
54 | /* | ||
55 | @@ LUA_USE_C89 controls the use of non-ISO-C89 features. | 55 | @@ LUA_USE_C89 controls the use of non-ISO-C89 features. |
56 | ** Define it if you want Lua to avoid the use of a few C99 features | 56 | ** Define it if you want Lua to avoid the use of a few C99 features |
57 | ** or Windows-specific features on Windows. | 57 | ** or Windows-specific features on Windows. |
@@ -86,33 +86,42 @@ | |||
86 | 86 | ||
87 | 87 | ||
88 | /* | 88 | /* |
89 | @@ LUA_C89_NUMBERS ensures that Lua uses the largest types available for | 89 | @@ LUAI_IS32INT is true iff 'int' has (at least) 32 bits. |
90 | ** C89 ('long' and 'double'); Windows always has '__int64', so it does | 90 | ** (the use of two shifts avoids undefined shifts) |
91 | ** not need to use this case. | ||
92 | */ | 91 | */ |
93 | #if defined(LUA_USE_C89) && !defined(LUA_USE_WINDOWS) | 92 | #define LUAI_IS32INT (((UINT_MAX >> 15) >> 15) >= 3) |
94 | #define LUA_C89_NUMBERS | 93 | |
95 | #endif | 94 | /* }================================================================== */ |
96 | 95 | ||
97 | 96 | ||
98 | 97 | ||
99 | /* | 98 | /* |
100 | @@ LUAI_BITSINT defines the (minimum) number of bits in an 'int'. | 99 | ** {================================================================== |
100 | ** Configuration for Number types. | ||
101 | ** =================================================================== | ||
101 | */ | 102 | */ |
102 | /* avoid undefined shifts */ | 103 | |
103 | #if ((INT_MAX >> 15) >> 15) >= 1 | 104 | /* |
104 | #define LUAI_BITSINT 32 | 105 | @@ LUA_32BITS enables Lua with 32-bit integers and 32-bit floats. |
105 | #else | 106 | */ |
106 | /* 'int' always must have at least 16 bits */ | 107 | /* #define LUA_32BITS */ |
107 | #define LUAI_BITSINT 16 | 108 | |
109 | |||
110 | /* | ||
111 | @@ LUA_C89_NUMBERS ensures that Lua uses the largest types available for | ||
112 | ** C89 ('long' and 'double'); Windows always has '__int64', so it does | ||
113 | ** not need to use this case. | ||
114 | */ | ||
115 | #if defined(LUA_USE_C89) && !defined(LUA_USE_WINDOWS) | ||
116 | #define LUA_C89_NUMBERS | ||
108 | #endif | 117 | #endif |
109 | 118 | ||
110 | 119 | ||
111 | /* | 120 | /* |
112 | @@ LUA_INT_TYPE defines the type for Lua integers. | 121 | @@ LUA_INT_TYPE defines the type for Lua integers. |
113 | @@ LUA_FLOAT_TYPE defines the type for Lua floats. | 122 | @@ LUA_FLOAT_TYPE defines the type for Lua floats. |
114 | ** Lua should work fine with any mix of these options (if supported | 123 | ** Lua should work fine with any mix of these options supported |
115 | ** by your C compiler). The usual configurations are 64-bit integers | 124 | ** by your C compiler. The usual configurations are 64-bit integers |
116 | ** and 'double' (the default), 32-bit integers and 'float' (for | 125 | ** and 'double' (the default), 32-bit integers and 'float' (for |
117 | ** restricted platforms), and 'long'/'double' (for C compilers not | 126 | ** restricted platforms), and 'long'/'double' (for C compilers not |
118 | ** compliant with C99, which may not have support for 'long long'). | 127 | ** compliant with C99, which may not have support for 'long long'). |
@@ -132,7 +141,7 @@ | |||
132 | /* | 141 | /* |
133 | ** 32-bit integers and 'float' | 142 | ** 32-bit integers and 'float' |
134 | */ | 143 | */ |
135 | #if LUAI_BITSINT >= 32 /* use 'int' if big enough */ | 144 | #if LUAI_IS32INT /* use 'int' if big enough */ |
136 | #define LUA_INT_TYPE LUA_INT_INT | 145 | #define LUA_INT_TYPE LUA_INT_INT |
137 | #else /* otherwise use 'long' */ | 146 | #else /* otherwise use 'long' */ |
138 | #define LUA_INT_TYPE LUA_INT_LONG | 147 | #define LUA_INT_TYPE LUA_INT_LONG |
@@ -164,7 +173,6 @@ | |||
164 | 173 | ||
165 | 174 | ||
166 | 175 | ||
167 | |||
168 | /* | 176 | /* |
169 | ** {================================================================== | 177 | ** {================================================================== |
170 | ** Configuration for Paths. | 178 | ** Configuration for Paths. |
@@ -192,6 +200,7 @@ | |||
192 | ** hierarchy or if you want to install your libraries in | 200 | ** hierarchy or if you want to install your libraries in |
193 | ** non-conventional directories. | 201 | ** non-conventional directories. |
194 | */ | 202 | */ |
203 | |||
195 | #define LUA_VDIR LUA_VERSION_MAJOR "." LUA_VERSION_MINOR | 204 | #define LUA_VDIR LUA_VERSION_MAJOR "." LUA_VERSION_MINOR |
196 | #if defined(_WIN32) /* { */ | 205 | #if defined(_WIN32) /* { */ |
197 | /* | 206 | /* |
@@ -201,27 +210,40 @@ | |||
201 | #define LUA_LDIR "!\\lua\\" | 210 | #define LUA_LDIR "!\\lua\\" |
202 | #define LUA_CDIR "!\\" | 211 | #define LUA_CDIR "!\\" |
203 | #define LUA_SHRDIR "!\\..\\share\\lua\\" LUA_VDIR "\\" | 212 | #define LUA_SHRDIR "!\\..\\share\\lua\\" LUA_VDIR "\\" |
213 | |||
214 | #if !defined(LUA_PATH_DEFAULT) | ||
204 | #define LUA_PATH_DEFAULT \ | 215 | #define LUA_PATH_DEFAULT \ |
205 | LUA_LDIR"?.lua;" LUA_LDIR"?\\init.lua;" \ | 216 | LUA_LDIR"?.lua;" LUA_LDIR"?\\init.lua;" \ |
206 | LUA_CDIR"?.lua;" LUA_CDIR"?\\init.lua;" \ | 217 | LUA_CDIR"?.lua;" LUA_CDIR"?\\init.lua;" \ |
207 | LUA_SHRDIR"?.lua;" LUA_SHRDIR"?\\init.lua;" \ | 218 | LUA_SHRDIR"?.lua;" LUA_SHRDIR"?\\init.lua;" \ |
208 | ".\\?.lua;" ".\\?\\init.lua" | 219 | ".\\?.lua;" ".\\?\\init.lua" |
220 | #endif | ||
221 | |||
222 | #if !defined(LUA_CPATH_DEFAULT) | ||
209 | #define LUA_CPATH_DEFAULT \ | 223 | #define LUA_CPATH_DEFAULT \ |
210 | LUA_CDIR"?.dll;" \ | 224 | LUA_CDIR"?.dll;" \ |
211 | LUA_CDIR"..\\lib\\lua\\" LUA_VDIR "\\?.dll;" \ | 225 | LUA_CDIR"..\\lib\\lua\\" LUA_VDIR "\\?.dll;" \ |
212 | LUA_CDIR"loadall.dll;" ".\\?.dll" | 226 | LUA_CDIR"loadall.dll;" ".\\?.dll" |
227 | #endif | ||
213 | 228 | ||
214 | #else /* }{ */ | 229 | #else /* }{ */ |
215 | 230 | ||
216 | #define LUA_ROOT "/usr/local/" | 231 | #define LUA_ROOT "/usr/local/" |
217 | #define LUA_LDIR LUA_ROOT "share/lua/" LUA_VDIR "/" | 232 | #define LUA_LDIR LUA_ROOT "share/lua/" LUA_VDIR "/" |
218 | #define LUA_CDIR LUA_ROOT "lib/lua/" LUA_VDIR "/" | 233 | #define LUA_CDIR LUA_ROOT "lib/lua/" LUA_VDIR "/" |
234 | |||
235 | #if !defined(LUA_PATH_DEFAULT) | ||
219 | #define LUA_PATH_DEFAULT \ | 236 | #define LUA_PATH_DEFAULT \ |
220 | LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \ | 237 | LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \ |
221 | LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua;" \ | 238 | LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua;" \ |
222 | "./?.lua;" "./?/init.lua" | 239 | "./?.lua;" "./?/init.lua" |
240 | #endif | ||
241 | |||
242 | #if !defined(LUA_CPATH_DEFAULT) | ||
223 | #define LUA_CPATH_DEFAULT \ | 243 | #define LUA_CPATH_DEFAULT \ |
224 | LUA_CDIR"?.so;" LUA_CDIR"loadall.so;" "./?.so" | 244 | LUA_CDIR"?.so;" LUA_CDIR"loadall.so;" "./?.so" |
245 | #endif | ||
246 | |||
225 | #endif /* } */ | 247 | #endif /* } */ |
226 | 248 | ||
227 | 249 | ||
@@ -230,12 +252,16 @@ | |||
230 | ** CHANGE it if your machine does not use "/" as the directory separator | 252 | ** CHANGE it if your machine does not use "/" as the directory separator |
231 | ** and is not Windows. (On Windows Lua automatically uses "\".) | 253 | ** and is not Windows. (On Windows Lua automatically uses "\".) |
232 | */ | 254 | */ |
255 | #if !defined(LUA_DIRSEP) | ||
256 | |||
233 | #if defined(_WIN32) | 257 | #if defined(_WIN32) |
234 | #define LUA_DIRSEP "\\" | 258 | #define LUA_DIRSEP "\\" |
235 | #else | 259 | #else |
236 | #define LUA_DIRSEP "/" | 260 | #define LUA_DIRSEP "/" |
237 | #endif | 261 | #endif |
238 | 262 | ||
263 | #endif | ||
264 | |||
239 | /* }================================================================== */ | 265 | /* }================================================================== */ |
240 | 266 | ||
241 | 267 | ||
@@ -632,7 +658,7 @@ | |||
632 | /* | 658 | /* |
633 | @@ lua_getlocaledecpoint gets the locale "radix character" (decimal point). | 659 | @@ lua_getlocaledecpoint gets the locale "radix character" (decimal point). |
634 | ** Change that if you do not want to use C locales. (Code using this | 660 | ** Change that if you do not want to use C locales. (Code using this |
635 | ** macro must include header 'locale.h'.) | 661 | ** macro must include the header 'locale.h'.) |
636 | */ | 662 | */ |
637 | #if !defined(lua_getlocaledecpoint) | 663 | #if !defined(lua_getlocaledecpoint) |
638 | #define lua_getlocaledecpoint() (localeconv()->decimal_point[0]) | 664 | #define lua_getlocaledecpoint() (localeconv()->decimal_point[0]) |
@@ -673,7 +699,7 @@ | |||
673 | ** {================================================================== | 699 | ** {================================================================== |
674 | ** Macros that affect the API and must be stable (that is, must be the | 700 | ** Macros that affect the API and must be stable (that is, must be the |
675 | ** same when you compile Lua and when you compile code that links to | 701 | ** same when you compile Lua and when you compile code that links to |
676 | ** Lua). You probably do not want/need to change them. | 702 | ** Lua). |
677 | ** ===================================================================== | 703 | ** ===================================================================== |
678 | */ | 704 | */ |
679 | 705 | ||
@@ -684,7 +710,7 @@ | |||
684 | ** space (and to reserve some numbers for pseudo-indices). | 710 | ** space (and to reserve some numbers for pseudo-indices). |
685 | ** (It must fit into max(size_t)/32.) | 711 | ** (It must fit into max(size_t)/32.) |
686 | */ | 712 | */ |
687 | #if LUAI_BITSINT >= 32 | 713 | #if LUAI_IS32INT |
688 | #define LUAI_MAXSTACK 1000000 | 714 | #define LUAI_MAXSTACK 1000000 |
689 | #else | 715 | #else |
690 | #define LUAI_MAXSTACK 15000 | 716 | #define LUAI_MAXSTACK 15000 |