diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2017-06-01 16:16:34 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2017-06-01 16:16:34 -0300 |
| commit | 4bc33d64de9bb2c1cd96240337ba8486300759da (patch) | |
| tree | 6f7c8b0a644ebb33fab416a6aecc8b3b8acbd150 /llimits.h | |
| parent | 882174684147b2fbc3f3a740c463b199978d9286 (diff) | |
| download | lua-4bc33d64de9bb2c1cd96240337ba8486300759da.tar.gz lua-4bc33d64de9bb2c1cd96240337ba8486300759da.tar.bz2 lua-4bc33d64de9bb2c1cd96240337ba8486300759da.zip | |
avoid overflows in computation of step size
Diffstat (limited to 'llimits.h')
| -rw-r--r-- | llimits.h | 9 |
1 files changed, 8 insertions, 1 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: llimits.h,v 1.141 2015/11/19 19:16:22 roberto Exp roberto $ | 2 | ** $Id: llimits.h,v 1.142 2017/04/24 18:06:12 roberto Exp roberto $ |
| 3 | ** Limits, basic types, and some other 'installation-dependent' definitions | 3 | ** Limits, basic types, and some other 'installation-dependent' definitions |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -52,6 +52,13 @@ typedef unsigned char lu_byte; | |||
| 52 | 52 | ||
| 53 | 53 | ||
| 54 | /* | 54 | /* |
| 55 | ** floor of the log2 of the maximum signed value for integral type 't'. | ||
| 56 | ** (That is, maximum 'n' such that '2^n' fits in the given signed type.) | ||
| 57 | */ | ||
| 58 | #define log2maxs(t) (sizeof(t) * 8 - 2) | ||
| 59 | |||
| 60 | |||
| 61 | /* | ||
| 55 | ** conversion of pointer to unsigned integer: | 62 | ** conversion of pointer to unsigned integer: |
| 56 | ** this is for hashing only; there is no problem if the integer | 63 | ** this is for hashing only; there is no problem if the integer |
| 57 | ** cannot hold the whole pointer value | 64 | ** cannot hold the whole pointer value |
