mirror of
https://github.com/lua/lua
synced 2024-11-22 12:51:30 +03:00
new macro 'ispow2'
This commit is contained in:
parent
aedcfb9414
commit
06127927ff
@ -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
|
||||
*/
|
||||
@ -59,6 +59,12 @@ typedef signed char ls_byte;
|
||||
#define log2maxs(t) (sizeof(t) * 8 - 2)
|
||||
|
||||
|
||||
/*
|
||||
** 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
|
||||
|
Loading…
Reference in New Issue
Block a user