diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-10-27 14:59:31 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-10-27 14:59:31 -0200 |
commit | 4b2521cd9e7cb052a04abb90557c9cfed42300df (patch) | |
tree | 4828c29ed470f8e0f8413d2c09f1fcaf2849ceaf /luaconf.h | |
parent | 491103708e5516c94fa3e1af0af3a52065c40959 (diff) | |
download | lua-4b2521cd9e7cb052a04abb90557c9cfed42300df.tar.gz lua-4b2521cd9e7cb052a04abb90557c9cfed42300df.tar.bz2 lua-4b2521cd9e7cb052a04abb90557c9cfed42300df.zip |
better (and safer?) way to test native size of type 'int'
Diffstat (limited to 'luaconf.h')
-rw-r--r-- | luaconf.h | 20 |
1 files changed, 9 insertions, 11 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: luaconf.h,v 1.220 2014/10/21 14:38:46 roberto Exp roberto $ | 2 | ** $Id: luaconf.h,v 1.221 2014/10/24 11:42:47 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 | */ |
@@ -417,23 +417,21 @@ | |||
417 | 417 | ||
418 | 418 | ||
419 | /* | 419 | /* |
420 | @@ LUAI_BITSINT defines the number of bits in an int. | 420 | @@ LUAI_BITSINT defines the (minimum) number of bits in an int. |
421 | ** CHANGE here if Lua cannot automatically detect the number of bits of | 421 | ** CHANGE here if Lua cannot automatically detect the number of bits of |
422 | ** your machine. Probably you do not need to change this. | 422 | ** your machine. Probably you do not need to change this. |
423 | */ | 423 | */ |
424 | /* avoid overflows in comparison */ | 424 | /* avoid undefined shifts */ |
425 | #if INT_MAX-20 < 32760 /* { */ | 425 | #if ((INT_MAX >> 15) >> 15) >= 1 |
426 | #define LUAI_BITSINT 16 | ||
427 | #elif INT_MAX > 2147483640L /* }{ */ | ||
428 | /* int has at least 32 bits */ | ||
429 | #define LUAI_BITSINT 32 | 426 | #define LUAI_BITSINT 32 |
430 | #else /* }{ */ | 427 | #else |
431 | #error "you must define LUA_BITSINT with number of bits in an integer" | 428 | /* 'int' always must have at least 16 bits */ |
432 | #endif /* } */ | 429 | #define LUAI_BITSINT 16 |
430 | #endif | ||
433 | 431 | ||
434 | 432 | ||
435 | /* | 433 | /* |
436 | @@ LUA_INT32 is an signed integer with exactly 32 bits. | 434 | @@ LUA_INT32 is a signed integer with at least 32 bits. |
437 | @@ LUAI_UMEM is an unsigned integer big enough to count the total | 435 | @@ LUAI_UMEM is an unsigned integer big enough to count the total |
438 | @@ memory used by Lua. | 436 | @@ memory used by Lua. |
439 | @@ LUAI_MEM is a signed integer big enough to count the total memory | 437 | @@ LUAI_MEM is a signed integer big enough to count the total memory |