diff options
-rw-r--r-- | src/keeper.cpp | 4 | ||||
-rw-r--r-- | src/lanes.cpp | 20 | ||||
-rw-r--r-- | src/tools.cpp | 6 | ||||
-rw-r--r-- | src/uniquekey.h | 6 | ||||
-rw-r--r-- | src/universe.h | 2 |
5 files changed, 16 insertions, 22 deletions
diff --git a/src/keeper.cpp b/src/keeper.cpp index 8f762e5..244cb6a 100644 --- a/src/keeper.cpp +++ b/src/keeper.cpp | |||
@@ -61,10 +61,10 @@ class keeper_fifo | |||
61 | int limit{ -1 }; | 61 | int limit{ -1 }; |
62 | 62 | ||
63 | // a fifo full userdata has one uservalue, the table that holds the actual fifo contents | 63 | // a fifo full userdata has one uservalue, the table that holds the actual fifo contents |
64 | static void* operator new(size_t size_, lua_State* L) noexcept { return lua_newuserdatauv<keeper_fifo>(L, 1); } | 64 | static void* operator new([[maybe_unused]] size_t size_, lua_State* L) noexcept { return lua_newuserdatauv<keeper_fifo>(L, 1); } |
65 | // always embedded somewhere else or "in-place constructed" as a full userdata | 65 | // always embedded somewhere else or "in-place constructed" as a full userdata |
66 | // can't actually delete the operator because the compiler generates stack unwinding code that could call it in case of exception | 66 | // can't actually delete the operator because the compiler generates stack unwinding code that could call it in case of exception |
67 | static void operator delete(void* p_, lua_State* L) { ASSERT_L(!"should never be called") }; | 67 | static void operator delete([[maybe_unused]] void* p_, lua_State* L) { ASSERT_L(!"should never be called") }; |
68 | 68 | ||
69 | static keeper_fifo* getPtr(lua_State* L, int idx_) | 69 | static keeper_fifo* getPtr(lua_State* L, int idx_) |
70 | { | 70 | { |
diff --git a/src/lanes.cpp b/src/lanes.cpp index 472b501..47ca79a 100644 --- a/src/lanes.cpp +++ b/src/lanes.cpp | |||
@@ -655,22 +655,16 @@ static constexpr UniqueKey EXTENDED_STACKTRACE_REGKEY{ 0x2357c69a7c92c936ull }; | |||
655 | LUAG_FUNC( set_error_reporting) | 655 | LUAG_FUNC( set_error_reporting) |
656 | { | 656 | { |
657 | luaL_checktype(L, 1, LUA_TSTRING); | 657 | luaL_checktype(L, 1, LUA_TSTRING); |
658 | char const* mode{ lua_tostring(L, 1) }; | ||
658 | lua_pushliteral(L, "extended"); | 659 | lua_pushliteral(L, "extended"); |
659 | int equal = lua_rawequal(L, -1, 1); | 660 | bool const extended{ strcmp(mode, "extended") == 0 }; |
660 | lua_pop(L, 1); | 661 | bool const basic{ strcmp(mode, "basic") == 0 }; |
661 | if (equal) | 662 | if (!extended && !basic) |
662 | { | 663 | { |
663 | goto done; | 664 | return luaL_error(L, "unsupported error reporting model %s", mode); |
664 | } | 665 | } |
665 | lua_pushliteral(L, "basic"); | 666 | |
666 | equal = !lua_rawequal(L, -1, 1); | 667 | EXTENDED_STACKTRACE_REGKEY.setValue(L, [extended](lua_State* L) { lua_pushboolean(L, extended ? 1 : 0); }); |
667 | lua_pop(L, 1); | ||
668 | if (equal) | ||
669 | { | ||
670 | return luaL_error(L, "unsupported error reporting model"); | ||
671 | } | ||
672 | done: | ||
673 | EXTENDED_STACKTRACE_REGKEY.setValue(L, [equal](lua_State* L) { lua_pushboolean(L, equal); }); | ||
674 | return 0; | 668 | return 0; |
675 | } | 669 | } |
676 | 670 | ||
diff --git a/src/tools.cpp b/src/tools.cpp index 103122e..df7602e 100644 --- a/src/tools.cpp +++ b/src/tools.cpp | |||
@@ -156,7 +156,7 @@ void luaG_dump( lua_State* L) | |||
156 | // ################################################################################################ | 156 | // ################################################################################################ |
157 | 157 | ||
158 | // same as PUC-Lua l_alloc | 158 | // same as PUC-Lua l_alloc |
159 | extern "C" static void* libc_lua_Alloc([[maybe_unused]] void* ud, [[maybe_unused]] void* ptr_, size_t osize_, size_t nsize_) | 159 | extern "C" static void* libc_lua_Alloc([[maybe_unused]] void* ud, [[maybe_unused]] void* ptr_, [[maybe_unused]] size_t osize_, size_t nsize_) |
160 | { | 160 | { |
161 | if (nsize_ == 0) | 161 | if (nsize_ == 0) |
162 | { | 162 | { |
@@ -175,7 +175,7 @@ static int luaG_provide_protected_allocator(lua_State* L) | |||
175 | { | 175 | { |
176 | Universe* const U{ universe_get(L) }; | 176 | Universe* const U{ universe_get(L) }; |
177 | // push a new full userdata on the stack, giving access to the universe's protected allocator | 177 | // push a new full userdata on the stack, giving access to the universe's protected allocator |
178 | AllocatorDefinition* const def{ new (L) AllocatorDefinition{ U->protected_allocator.makeDefinition() } }; | 178 | [[maybe_unused]] AllocatorDefinition* const def{ new (L) AllocatorDefinition{ U->protected_allocator.makeDefinition() } }; |
179 | return 1; | 179 | return 1; |
180 | } | 180 | } |
181 | 181 | ||
@@ -229,7 +229,7 @@ void initialize_allocator_function(Universe* U, lua_State* L) | |||
229 | { | 229 | { |
230 | U->internal_allocator = AllocatorDefinition{ libc_lua_Alloc, nullptr }; | 230 | U->internal_allocator = AllocatorDefinition{ libc_lua_Alloc, nullptr }; |
231 | } | 231 | } |
232 | else if (U->provide_allocator = luaG_provide_protected_allocator) | 232 | else if (U->provide_allocator == luaG_provide_protected_allocator) |
233 | { | 233 | { |
234 | // user wants mutex protection on the state's allocator. Use protection for our own allocations too, just in case. | 234 | // user wants mutex protection on the state's allocator. Use protection for our own allocations too, just in case. |
235 | U->internal_allocator = U->protected_allocator.makeDefinition(); | 235 | U->internal_allocator = U->protected_allocator.makeDefinition(); |
diff --git a/src/uniquekey.h b/src/uniquekey.h index bd3b61f..e592f0a 100644 --- a/src/uniquekey.h +++ b/src/uniquekey.h | |||
@@ -13,11 +13,11 @@ class UniqueKey | |||
13 | 13 | ||
14 | public: | 14 | public: |
15 | 15 | ||
16 | constexpr UniqueKey(uintptr_t val_) | 16 | constexpr UniqueKey(uint64_t val_) |
17 | #if LUAJIT_FLAVOR() == 64 // building against LuaJIT headers for 64 bits, light userdata is restricted to 47 significant bits, because LuaJIT uses the other bits for internal optimizations | 17 | #if LUAJIT_FLAVOR() == 64 // building against LuaJIT headers for 64 bits, light userdata is restricted to 47 significant bits, because LuaJIT uses the other bits for internal optimizations |
18 | : m_storage{ val_ & 0x7fffffffffffull } | 18 | : m_storage{ static_cast<uintptr_t>(val_ & 0x7fffffffffffull) } |
19 | #else // LUAJIT_FLAVOR() | 19 | #else // LUAJIT_FLAVOR() |
20 | : m_storage{ val_ } | 20 | : m_storage{ static_cast<uintptr_t>(val_) } |
21 | #endif // LUAJIT_FLAVOR() | 21 | #endif // LUAJIT_FLAVOR() |
22 | { | 22 | { |
23 | } | 23 | } |
diff --git a/src/universe.h b/src/universe.h index 3ee0868..6a65888 100644 --- a/src/universe.h +++ b/src/universe.h | |||
@@ -38,7 +38,7 @@ class AllocatorDefinition | |||
38 | static void* operator new(size_t size_, lua_State* L) noexcept { return lua_newuserdatauv(L, size_, 0); } | 38 | static void* operator new(size_t size_, lua_State* L) noexcept { return lua_newuserdatauv(L, size_, 0); } |
39 | // always embedded somewhere else or "in-place constructed" as a full userdata | 39 | // always embedded somewhere else or "in-place constructed" as a full userdata |
40 | // can't actually delete the operator because the compiler generates stack unwinding code that could call it in case of exception | 40 | // can't actually delete the operator because the compiler generates stack unwinding code that could call it in case of exception |
41 | static void operator delete(void* p_, lua_State* L) { ASSERT_L(!"should never be called") }; | 41 | static void operator delete([[maybe_unused]] void* p_, lua_State* L) { ASSERT_L(!"should never be called") }; |
42 | 42 | ||
43 | AllocatorDefinition(lua_Alloc allocF_, void* allocUD_) noexcept | 43 | AllocatorDefinition(lua_Alloc allocF_, void* allocUD_) noexcept |
44 | : m_allocF{ allocF_ } | 44 | : m_allocF{ allocF_ } |