diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2015-03-02 13:59:01 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2015-03-02 13:59:01 -0300 |
commit | 951b562cf847a1ed660ac7f682a197b6b8f5967b (patch) | |
tree | 3780541f900c76fb8b1cc154ab63028124510731 /luaconf.h | |
parent | 6408bc0b7f23b580cb51b591277b82eac58f6e2e (diff) | |
download | lua-951b562cf847a1ed660ac7f682a197b6b8f5967b.tar.gz lua-951b562cf847a1ed660ac7f682a197b6b8f5967b.tar.bz2 lua-951b562cf847a1ed660ac7f682a197b6b8f5967b.zip |
configuration for numerical types through only one #define for
each type
Diffstat (limited to 'luaconf.h')
-rw-r--r-- | luaconf.h | 48 |
1 files changed, 28 insertions, 20 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: luaconf.h,v 1.245 2015/02/05 17:15:33 roberto Exp roberto $ | 2 | ** $Id: luaconf.h,v 1.246 2015/02/28 19:22:31 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 | */ |
@@ -96,10 +96,8 @@ | |||
96 | 96 | ||
97 | 97 | ||
98 | /* | 98 | /* |
99 | @@ LUA_INT_INT / LUA_INT_LONG / LUA_INT_LONGLONG defines the type for | 99 | @@ LUA_INT_TYPE defines the type for Lua integers. |
100 | ** Lua integers. | 100 | @@ LUA_REAL_TYPE defines the type for Lua floats. |
101 | @@ LUA_REAL_FLOAT / LUA_REAL_DOUBLE / LUA_REAL_LONGDOUBLE defines | ||
102 | ** the type for Lua floats. | ||
103 | ** Lua should work fine with any mix of these options (if supported | 101 | ** Lua should work fine with any mix of these options (if supported |
104 | ** by your C compiler). The usual configurations are 64-bit integers | 102 | ** by your C compiler). The usual configurations are 64-bit integers |
105 | ** and 'double' (the default), 32-bit integers and 'float' (for | 103 | ** and 'double' (the default), 32-bit integers and 'float' (for |
@@ -107,30 +105,40 @@ | |||
107 | ** compliant with C99, which may not have support for 'long long'). | 105 | ** compliant with C99, which may not have support for 'long long'). |
108 | */ | 106 | */ |
109 | 107 | ||
108 | /* predefined options for LUA_INT_TYPE */ | ||
109 | #define LUA_INT_INT 1 | ||
110 | #define LUA_INT_LONG 2 | ||
111 | #define LUA_INT_LONGLONG 3 | ||
112 | |||
113 | /* predefined options for LUA_REAL_TYPE */ | ||
114 | #define LUA_REAL_FLOAT 1 | ||
115 | #define LUA_REAL_DOUBLE 2 | ||
116 | #define LUA_REAL_LONGDOUBLE 3 | ||
117 | |||
110 | #if defined(LUA_32BITS) /* { */ | 118 | #if defined(LUA_32BITS) /* { */ |
111 | /* | 119 | /* |
112 | ** 32-bit integers and 'float' | 120 | ** 32-bit integers and 'float' |
113 | */ | 121 | */ |
114 | #if LUAI_BITSINT >= 32 /* use 'int' if big enough */ | 122 | #if LUAI_BITSINT >= 32 /* use 'int' if big enough */ |
115 | #define LUA_INT_INT | 123 | #define LUA_INT_TYPE LUA_INT_INT |
116 | #else /* otherwise use 'long' */ | 124 | #else /* otherwise use 'long' */ |
117 | #define LUA_INT_LONG | 125 | #define LUA_INT_TYPE LUA_INT_LONG |
118 | #endif | 126 | #endif |
119 | #define LUA_REAL_FLOAT | 127 | #define LUA_REAL_TYPE LUA_REAL_FLOAT |
120 | 128 | ||
121 | #elif defined(LUA_C89_NUMBERS) /* }{ */ | 129 | #elif defined(LUA_C89_NUMBERS) /* }{ */ |
122 | /* | 130 | /* |
123 | ** largest types available for C89 ('long' and 'double') | 131 | ** largest types available for C89 ('long' and 'double') |
124 | */ | 132 | */ |
125 | #define LUA_INT_LONG | 133 | #define LUA_INT_TYPE LUA_INT_LONG |
126 | #define LUA_REAL_DOUBLE | 134 | #define LUA_REAL_TYPE LUA_REAL_DOUBLE |
127 | 135 | ||
128 | #else /* }{ */ | 136 | #else /* }{ */ |
129 | /* | 137 | /* |
130 | ** default configuration for 64-bit Lua ('long long' and 'double') | 138 | ** default configuration for 64-bit Lua ('long long' and 'double') |
131 | */ | 139 | */ |
132 | #define LUA_INT_LONGLONG | 140 | #define LUA_INT_TYPE LUA_INT_LONGLONG |
133 | #define LUA_REAL_DOUBLE | 141 | #define LUA_REAL_TYPE LUA_REAL_DOUBLE |
134 | 142 | ||
135 | #endif /* } */ | 143 | #endif /* } */ |
136 | 144 | ||
@@ -155,7 +163,7 @@ | |||
155 | ** non-conventional directories. | 163 | ** non-conventional directories. |
156 | */ | 164 | */ |
157 | #define LUA_VDIR LUA_VERSION_MAJOR "." LUA_VERSION_MINOR | 165 | #define LUA_VDIR LUA_VERSION_MAJOR "." LUA_VERSION_MINOR |
158 | #if defined(_WIN32) /* { */ | 166 | #if defined(_WIN32) /* { */ |
159 | /* | 167 | /* |
160 | ** In Windows, any exclamation mark ('!') in the path is replaced by the | 168 | ** In Windows, any exclamation mark ('!') in the path is replaced by the |
161 | ** path of the directory of the executable file of the current process. | 169 | ** path of the directory of the executable file of the current process. |
@@ -404,7 +412,7 @@ | |||
404 | @@ lua_str2number converts a decimal numeric string to a number. | 412 | @@ lua_str2number converts a decimal numeric string to a number. |
405 | */ | 413 | */ |
406 | 414 | ||
407 | #if defined(LUA_REAL_FLOAT) /* { single float */ | 415 | #if LUA_REAL_TYPE == LUA_REAL_FLOAT /* { single float */ |
408 | 416 | ||
409 | #define LUA_NUMBER float | 417 | #define LUA_NUMBER float |
410 | 418 | ||
@@ -418,7 +426,7 @@ | |||
418 | #define lua_str2number(s,p) strtof((s), (p)) | 426 | #define lua_str2number(s,p) strtof((s), (p)) |
419 | 427 | ||
420 | 428 | ||
421 | #elif defined(LUA_REAL_LONGDOUBLE) /* }{ long double */ | 429 | #elif LUA_REAL_TYPE == LUA_REAL_LONGDOUBLE /* }{ long double */ |
422 | 430 | ||
423 | #define LUA_NUMBER long double | 431 | #define LUA_NUMBER long double |
424 | 432 | ||
@@ -431,7 +439,7 @@ | |||
431 | 439 | ||
432 | #define lua_str2number(s,p) strtold((s), (p)) | 440 | #define lua_str2number(s,p) strtold((s), (p)) |
433 | 441 | ||
434 | #elif defined(LUA_REAL_DOUBLE) /* }{ double */ | 442 | #elif LUA_REAL_TYPE == LUA_REAL_DOUBLE /* }{ double */ |
435 | 443 | ||
436 | #define LUA_NUMBER double | 444 | #define LUA_NUMBER double |
437 | 445 | ||
@@ -444,7 +452,7 @@ | |||
444 | 452 | ||
445 | #define lua_str2number(s,p) strtod((s), (p)) | 453 | #define lua_str2number(s,p) strtod((s), (p)) |
446 | 454 | ||
447 | #else /* }{ */ | 455 | #else /* }{ */ |
448 | 456 | ||
449 | #error "numeric real type not defined" | 457 | #error "numeric real type not defined" |
450 | 458 | ||
@@ -502,7 +510,7 @@ | |||
502 | 510 | ||
503 | /* now the variable definitions */ | 511 | /* now the variable definitions */ |
504 | 512 | ||
505 | #if defined(LUA_INT_INT) /* { int */ | 513 | #if LUA_INT_TYPE == LUA_INT_INT /* { int */ |
506 | 514 | ||
507 | #define LUA_INTEGER int | 515 | #define LUA_INTEGER int |
508 | #define LUA_INTEGER_FRMLEN "" | 516 | #define LUA_INTEGER_FRMLEN "" |
@@ -510,7 +518,7 @@ | |||
510 | #define LUA_MAXINTEGER INT_MAX | 518 | #define LUA_MAXINTEGER INT_MAX |
511 | #define LUA_MININTEGER INT_MIN | 519 | #define LUA_MININTEGER INT_MIN |
512 | 520 | ||
513 | #elif defined(LUA_INT_LONG) /* }{ long */ | 521 | #elif LUA_INT_TYPE == LUA_INT_LONG /* }{ long */ |
514 | 522 | ||
515 | #define LUA_INTEGER long | 523 | #define LUA_INTEGER long |
516 | #define LUA_INTEGER_FRMLEN "l" | 524 | #define LUA_INTEGER_FRMLEN "l" |
@@ -518,7 +526,7 @@ | |||
518 | #define LUA_MAXINTEGER LONG_MAX | 526 | #define LUA_MAXINTEGER LONG_MAX |
519 | #define LUA_MININTEGER LONG_MIN | 527 | #define LUA_MININTEGER LONG_MIN |
520 | 528 | ||
521 | #elif defined(LUA_INT_LONGLONG) /* }{ long long */ | 529 | #elif LUA_INT_TYPE == LUA_INT_LONGLONG /* }{ long long */ |
522 | 530 | ||
523 | #if defined(LLONG_MAX) /* { */ | 531 | #if defined(LLONG_MAX) /* { */ |
524 | /* use ISO C99 stuff */ | 532 | /* use ISO C99 stuff */ |