aboutsummaryrefslogtreecommitdiff
path: root/llimits.h
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2018-06-15 11:13:45 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2018-06-15 11:13:45 -0300
commit06127927ffb4eb8459523f6c07bf8f22390c31b9 (patch)
tree869ace438c1b8a0687efbff989614068bdcd220a /llimits.h
parentaedcfb94144b173a5af52c05c590e9af12b6632b (diff)
downloadlua-06127927ffb4eb8459523f6c07bf8f22390c31b9.tar.gz
lua-06127927ffb4eb8459523f6c07bf8f22390c31b9.tar.bz2
lua-06127927ffb4eb8459523f6c07bf8f22390c31b9.zip
new macro 'ispow2'
Diffstat (limited to 'llimits.h')
-rw-r--r--llimits.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/llimits.h b/llimits.h
index 725d7c8b..715d55b8 100644
--- a/llimits.h
+++ b/llimits.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: llimits.h,v 1.149 2018/01/28 15:13:26 roberto Exp roberto $ 2** $Id: llimits.h,v 1.150 2018/05/30 14:25:52 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*/
@@ -60,6 +60,12 @@ typedef signed char ls_byte;
60 60
61 61
62/* 62/*
63** test whether an unsigned value is a power of 2 (or zero)
64*/
65#define ispow2(x) (((x) & ((x) - 1)) == 0)
66
67
68/*
63** conversion of pointer to unsigned integer: 69** conversion of pointer to unsigned integer:
64** this is for hashing only; there is no problem if the integer 70** this is for hashing only; there is no problem if the integer
65** cannot hold the whole pointer value 71** cannot hold the whole pointer value