lua

A copy of the Lua development repository
Log | Files | Refs | README

commit 06127927ffb4eb8459523f6c07bf8f22390c31b9
parent aedcfb94144b173a5af52c05c590e9af12b6632b
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date:   Fri, 15 Jun 2018 11:13:18 -0300

new macro 'ispow2'

Diffstat:
Mllimits.h | 8+++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/llimits.h b/llimits.h @@ -1,5 +1,5 @@ /* -** $Id: llimits.h,v 1.149 2018/01/28 15:13:26 roberto Exp roberto $ +** $Id: llimits.h,v 1.150 2018/05/30 14:25:52 roberto Exp roberto $ ** Limits, basic types, and some other 'installation-dependent' definitions ** See Copyright Notice in lua.h */ @@ -60,6 +60,12 @@ typedef signed char ls_byte; /* +** test whether an unsigned value is a power of 2 (or zero) +*/ +#define ispow2(x) (((x) & ((x) - 1)) == 0) + + +/* ** conversion of pointer to unsigned integer: ** this is for hashing only; there is no problem if the integer ** cannot hold the whole pointer value