Skip to content

Commit

Permalink
lua_Unsigned uses 64-bit ints again, fixing many bugs (closes #7)
Browse files Browse the repository at this point in the history
  • Loading branch information
MCJack123 committed Feb 19, 2024
1 parent 43c3746 commit 89dcba9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion include/luaconf.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include <limits.h>
#include <stddef.h>
#include <stdint.h>


/*
Expand Down Expand Up @@ -462,7 +463,7 @@
@@ LUA_UNSIGNED is the integral type used by lua_pushunsigned/lua_tounsigned.
** It must have at least 32 bits.
*/
#define LUA_UNSIGNED unsigned LUA_INT32
#define LUA_UNSIGNED uintptr_t



Expand Down
2 changes: 1 addition & 1 deletion src/lbitlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ static int b_arshift (lua_State *L) {
else { /* arithmetic shift for 'negative' number */
if (i >= LUA_NBITS) r = ALLONES;
else
r = trim((r >> i) | ~(~(b_uint)0 >> i)); /* add signal bit */
r = trim((r >> i) | ~(ALLONES >> i)); /* add signal bit */
lua_pushunsigned(L, r);
return 1;
}
Expand Down
3 changes: 2 additions & 1 deletion src/luaconf.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include <limits.h>
#include <stddef.h>
#include <stdint.h>


/*
Expand Down Expand Up @@ -462,7 +463,7 @@
@@ LUA_UNSIGNED is the integral type used by lua_pushunsigned/lua_tounsigned.
** It must have at least 32 bits.
*/
#define LUA_UNSIGNED unsigned LUA_INT32
#define LUA_UNSIGNED uintptr_t



Expand Down

0 comments on commit 89dcba9

Please sign in to comment.