Make bit module handle 32/64bit integer configs.

This commit is contained in:
Johny Mattsson 2021-08-25 18:58:53 +10:00
parent cd585ae91c
commit 0690a7d181
3 changed files with 9 additions and 5 deletions

View File

@ -169,7 +169,7 @@
/* Changed to long for use with integral Lua numbers. */
#if !defined LUA_NUMBER_INTEGRAL
#define LUA_INTEGER ptrdiff_t
#define LUA_INTEGER int
#else
#if !defined LUA_INTEGRAL_LONGLONG
#define LUA_INTEGER int

View File

@ -10,9 +10,11 @@
#include "lauxlib.h"
/* FIXME: Assume size_t is an unsigned lua_Integer */
typedef size_t lua_UInteger;
#define LUA_UINTEGER_MAX SIZE_MAX
#if defined(LUA_UNSIGNED)
typedef LUA_UNSIGNED lua_UInteger;
#else
typedef unsigned LUA_INTEGER lua_UInteger;
#endif
/* Define TOBIT to get a bit value */
#define TOBIT(L, n) \

View File

@ -4,7 +4,9 @@
| 2014-12-24 | [https://github.com/LuaDist/bitlib](https://github.com/LuaDist/bitlib), [Zeroday](https://github.com/funshine) | [Zeroday](https://github.com/funshine) | [bit.c](../../components/modules/bit.c)|
Bit manipulation support, on 32bit integers.
Bit manipulation support, on the integer type used by the Lua VM. On 5.1 this
will be 32bit, whereas on 5.3 it may be either 32bit (default) or 64bit if
configured for 64bit integers.
## bit.arshift()
Arithmetic right shift a number equivalent to `value >> shift` in C.