diff options
Diffstat (limited to 'src/lanes.cpp')
-rw-r--r-- | src/lanes.cpp | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/src/lanes.cpp b/src/lanes.cpp index d907fcd..e150eea 100644 --- a/src/lanes.cpp +++ b/src/lanes.cpp | |||
@@ -556,7 +556,7 @@ static void selfdestruct_add(Lane* lane_) | |||
556 | if (lane != SELFDESTRUCT_END) | 556 | if (lane != SELFDESTRUCT_END) |
557 | { | 557 | { |
558 | // this causes a leak because we don't call U's destructor (which could be bad if the still running lanes are accessing it) | 558 | // this causes a leak because we don't call U's destructor (which could be bad if the still running lanes are accessing it) |
559 | luaL_error(L, "Zombie thread %s refuses to die!", lane->debug_name); // doesn't return | 559 | raise_luaL_error(L, "Zombie thread %s refuses to die!", lane->debug_name); |
560 | } | 560 | } |
561 | } | 561 | } |
562 | 562 | ||
@@ -600,16 +600,16 @@ LUAG_FUNC( set_singlethreaded) | |||
600 | #ifdef _UTILBINDTHREADTOCPU | 600 | #ifdef _UTILBINDTHREADTOCPU |
601 | if (cores > 1) | 601 | if (cores > 1) |
602 | { | 602 | { |
603 | return luaL_error(L, "Limiting to N>1 cores not possible"); | 603 | raise_luaL_error(L, "Limiting to N>1 cores not possible"); |
604 | } | 604 | } |
605 | // requires 'chudInitialize()' | 605 | // requires 'chudInitialize()' |
606 | utilBindThreadToCPU(0); // # of CPU to run on (we cannot limit to 2..N CPUs?) | 606 | utilBindThreadToCPU(0); // # of CPU to run on (we cannot limit to 2..N CPUs?) |
607 | return 0; | 607 | return 0; |
608 | #else | 608 | #else |
609 | return luaL_error(L, "Not available: compile with _UTILBINDTHREADTOCPU"); | 609 | raise_luaL_error(L, "Not available: compile with _UTILBINDTHREADTOCPU"); |
610 | #endif | 610 | #endif |
611 | #else | 611 | #else |
612 | return luaL_error(L, "not implemented"); | 612 | raise_luaL_error(L, "not implemented"); |
613 | #endif | 613 | #endif |
614 | } | 614 | } |
615 | 615 | ||
@@ -645,7 +645,7 @@ LUAG_FUNC( set_error_reporting) | |||
645 | bool const basic{ strcmp(mode, "basic") == 0 }; | 645 | bool const basic{ strcmp(mode, "basic") == 0 }; |
646 | if (!extended && !basic) | 646 | if (!extended && !basic) |
647 | { | 647 | { |
648 | return luaL_error(L, "unsupported error reporting model %s", mode); | 648 | raise_luaL_error(L, "unsupported error reporting model %s", mode); |
649 | } | 649 | } |
650 | 650 | ||
651 | kExtendedStackTraceRegKey.setValue(L, [extended](lua_State* L) { lua_pushboolean(L, extended ? 1 : 0); }); | 651 | kExtendedStackTraceRegKey.setValue(L, [extended](lua_State* L) { lua_pushboolean(L, extended ? 1 : 0); }); |
@@ -769,7 +769,7 @@ LUAG_FUNC(set_thread_priority) | |||
769 | // On some platforms, -3 is equivalent to -2 and +3 to +2 | 769 | // On some platforms, -3 is equivalent to -2 and +3 to +2 |
770 | if (prio < kThreadPrioMin || prio > kThreadPrioMax) | 770 | if (prio < kThreadPrioMin || prio > kThreadPrioMax) |
771 | { | 771 | { |
772 | return luaL_error(L, "priority out of range: %d..+%d (%d)", kThreadPrioMin, kThreadPrioMax, prio); | 772 | raise_luaL_error(L, "priority out of range: %d..+%d (%d)", kThreadPrioMin, kThreadPrioMax, prio); |
773 | } | 773 | } |
774 | THREAD_SET_PRIORITY(static_cast<int>(prio), universe_get(L)->m_sudo); | 774 | THREAD_SET_PRIORITY(static_cast<int>(prio), universe_get(L)->m_sudo); |
775 | return 0; | 775 | return 0; |
@@ -782,7 +782,7 @@ LUAG_FUNC(set_thread_affinity) | |||
782 | lua_Integer const affinity{ luaL_checkinteger(L, 1) }; | 782 | lua_Integer const affinity{ luaL_checkinteger(L, 1) }; |
783 | if (affinity <= 0) | 783 | if (affinity <= 0) |
784 | { | 784 | { |
785 | return luaL_error(L, "invalid affinity (%d)", affinity); | 785 | raise_luaL_error(L, "invalid affinity (%d)", affinity); |
786 | } | 786 | } |
787 | THREAD_SET_AFFINITY( static_cast<unsigned int>(affinity)); | 787 | THREAD_SET_AFFINITY( static_cast<unsigned int>(affinity)); |
788 | return 0; | 788 | return 0; |
@@ -994,7 +994,7 @@ LUAG_FUNC(lane_new) | |||
994 | // On some platforms, -3 is equivalent to -2 and +3 to +2 | 994 | // On some platforms, -3 is equivalent to -2 and +3 to +2 |
995 | if (have_priority && (priority < kThreadPrioMin || priority > kThreadPrioMax)) | 995 | if (have_priority && (priority < kThreadPrioMin || priority > kThreadPrioMax)) |
996 | { | 996 | { |
997 | return luaL_error(L, "Priority out of range: %d..+%d (%d)", kThreadPrioMin, kThreadPrioMax, priority); | 997 | raise_luaL_error(L, "Priority out of range: %d..+%d (%d)", kThreadPrioMin, kThreadPrioMax, priority); |
998 | } | 998 | } |
999 | 999 | ||
1000 | /* --- Create and prepare the sub state --- */ | 1000 | /* --- Create and prepare the sub state --- */ |
@@ -1007,7 +1007,7 @@ LUAG_FUNC(lane_new) | |||
1007 | Lane* const lane{ new (U) Lane{ U, L2 } }; | 1007 | Lane* const lane{ new (U) Lane{ U, L2 } }; |
1008 | if (lane == nullptr) | 1008 | if (lane == nullptr) |
1009 | { | 1009 | { |
1010 | return luaL_error(L, "could not create lane: out of memory"); | 1010 | raise_luaL_error(L, "could not create lane: out of memory"); |
1011 | } | 1011 | } |
1012 | 1012 | ||
1013 | class OnExit | 1013 | class OnExit |
@@ -1125,7 +1125,7 @@ LUAG_FUNC(lane_new) | |||
1125 | // should not happen, was checked in lanes.lua before calling lane_new() | 1125 | // should not happen, was checked in lanes.lua before calling lane_new() |
1126 | if (lua_type(L, required_idx) != LUA_TTABLE) | 1126 | if (lua_type(L, required_idx) != LUA_TTABLE) |
1127 | { | 1127 | { |
1128 | luaL_error(L, "expected required module list as a table, got %s", luaL_typename(L, required_idx)); // doesn't return | 1128 | raise_luaL_error(L, "expected required module list as a table, got %s", luaL_typename(L, required_idx)); |
1129 | } | 1129 | } |
1130 | 1130 | ||
1131 | lua_pushnil(L); // func libs priority globals package required gc_cb [... args ...] nil | 1131 | lua_pushnil(L); // func libs priority globals package required gc_cb [... args ...] nil |
@@ -1133,7 +1133,7 @@ LUAG_FUNC(lane_new) | |||
1133 | { | 1133 | { |
1134 | if (lua_type(L, -1) != LUA_TSTRING || lua_type(L, -2) != LUA_TNUMBER || lua_tonumber(L, -2) != nbRequired) | 1134 | if (lua_type(L, -1) != LUA_TSTRING || lua_type(L, -2) != LUA_TNUMBER || lua_tonumber(L, -2) != nbRequired) |
1135 | { | 1135 | { |
1136 | luaL_error(L, "required module list should be a list of strings"); // doesn't return | 1136 | raise_luaL_error(L, "required module list should be a list of strings"); |
1137 | } | 1137 | } |
1138 | else | 1138 | else |
1139 | { | 1139 | { |
@@ -1147,7 +1147,7 @@ LUAG_FUNC(lane_new) | |||
1147 | if (lua_isnil( L2, -1)) | 1147 | if (lua_isnil( L2, -1)) |
1148 | { | 1148 | { |
1149 | lua_pop( L2, 1); // | 1149 | lua_pop( L2, 1); // |
1150 | luaL_error(L, "cannot pre-require modules without loading 'package' library first"); // doesn't return | 1150 | raise_luaL_error(L, "cannot pre-require modules without loading 'package' library first"); |
1151 | } | 1151 | } |
1152 | else | 1152 | else |
1153 | { | 1153 | { |
@@ -1179,7 +1179,7 @@ LUAG_FUNC(lane_new) | |||
1179 | DEBUGSPEW_CODE( fprintf( stderr, INDENT_BEGIN "lane_new: transfer globals\n" INDENT_END)); | 1179 | DEBUGSPEW_CODE( fprintf( stderr, INDENT_BEGIN "lane_new: transfer globals\n" INDENT_END)); |
1180 | if (!lua_istable(L, globals_idx)) | 1180 | if (!lua_istable(L, globals_idx)) |
1181 | { | 1181 | { |
1182 | luaL_error(L, "Expected table, got %s", luaL_typename(L, globals_idx)); // doesn't return | 1182 | raise_luaL_error(L, "Expected table, got %s", luaL_typename(L, globals_idx)); |
1183 | } | 1183 | } |
1184 | 1184 | ||
1185 | DEBUGSPEW_CODE(DebugSpewIndentScope scope{ U }); | 1185 | DEBUGSPEW_CODE(DebugSpewIndentScope scope{ U }); |
@@ -1210,7 +1210,7 @@ LUAG_FUNC(lane_new) | |||
1210 | InterCopyResult const res{ c.inter_move(1) }; // func libs priority globals package required gc_cb [... args ...] // func | 1210 | InterCopyResult const res{ c.inter_move(1) }; // func libs priority globals package required gc_cb [... args ...] // func |
1211 | if (res != InterCopyResult::Success) | 1211 | if (res != InterCopyResult::Success) |
1212 | { | 1212 | { |
1213 | luaL_error(L, "tried to copy unsupported types"); // doesn't return | 1213 | raise_luaL_error(L, "tried to copy unsupported types"); |
1214 | } | 1214 | } |
1215 | } | 1215 | } |
1216 | else if (func_type == LuaType::STRING) | 1216 | else if (func_type == LuaType::STRING) |
@@ -1219,12 +1219,12 @@ LUAG_FUNC(lane_new) | |||
1219 | // compile the string | 1219 | // compile the string |
1220 | if (luaL_loadstring(L2, lua_tostring(L, 1)) != 0) // func | 1220 | if (luaL_loadstring(L2, lua_tostring(L, 1)) != 0) // func |
1221 | { | 1221 | { |
1222 | luaL_error(L, "error when parsing lane function code"); // doesn't return | 1222 | raise_luaL_error(L, "error when parsing lane function code"); |
1223 | } | 1223 | } |
1224 | } | 1224 | } |
1225 | else | 1225 | else |
1226 | { | 1226 | { |
1227 | luaL_error(L, "Expected function, got %s", lua_typename(L, func_type)); // doesn't return | 1227 | raise_luaL_error(L, "Expected function, got %s", lua_typename(L, func_type)); |
1228 | } | 1228 | } |
1229 | STACK_CHECK(L, 0); | 1229 | STACK_CHECK(L, 0); |
1230 | STACK_CHECK(L2, 1); | 1230 | STACK_CHECK(L2, 1); |
@@ -1239,7 +1239,7 @@ LUAG_FUNC(lane_new) | |||
1239 | InterCopyResult const res{ c.inter_move(nargs) }; // func libs priority globals package required gc_cb // func [... args ...] | 1239 | InterCopyResult const res{ c.inter_move(nargs) }; // func libs priority globals package required gc_cb // func [... args ...] |
1240 | if (res != InterCopyResult::Success) | 1240 | if (res != InterCopyResult::Success) |
1241 | { | 1241 | { |
1242 | luaL_error(L, "tried to copy unsupported types"); // doesn't return | 1242 | raise_luaL_error(L, "tried to copy unsupported types"); |
1243 | } | 1243 | } |
1244 | } | 1244 | } |
1245 | STACK_CHECK(L, -nargs); | 1245 | STACK_CHECK(L, -nargs); |
@@ -1405,7 +1405,7 @@ LUAG_FUNC(thread_join) | |||
1405 | (InterCopyContext{ U, DestState{ L }, SourceState{ L2 }, {}, {}, {}, {}, {} }.inter_move(n) != InterCopyResult::Success) | 1405 | (InterCopyContext{ U, DestState{ L }, SourceState{ L2 }, {}, {}, {}, {}, {} }.inter_move(n) != InterCopyResult::Success) |
1406 | ) | 1406 | ) |
1407 | { | 1407 | { |
1408 | luaL_error(L, "tried to copy unsupported types"); // doesn't return | 1408 | raise_luaL_error(L, "tried to copy unsupported types"); |
1409 | } | 1409 | } |
1410 | ret = n; | 1410 | ret = n; |
1411 | } | 1411 | } |
@@ -1420,7 +1420,7 @@ LUAG_FUNC(thread_join) | |||
1420 | InterCopyContext c{ U, DestState{ L }, SourceState{ L2 }, {}, {}, {}, {}, {} }; | 1420 | InterCopyContext c{ U, DestState{ L }, SourceState{ L2 }, {}, {}, {}, {}, {} }; |
1421 | if (c.inter_move(n) != InterCopyResult::Success) // nil "err" [trace] | 1421 | if (c.inter_move(n) != InterCopyResult::Success) // nil "err" [trace] |
1422 | { | 1422 | { |
1423 | luaL_error(L, "tried to copy unsupported types: %s", lua_tostring(L, -n)); // doesn't return | 1423 | raise_luaL_error(L, "tried to copy unsupported types: %s", lua_tostring(L, -n)); |
1424 | } | 1424 | } |
1425 | ret = 1 + n; | 1425 | ret = 1 + n; |
1426 | } | 1426 | } |
@@ -1580,7 +1580,7 @@ LUAG_FUNC(thread_index) | |||
1580 | // only "cancel" and "join" are registered as functions, any other string will raise an error | 1580 | // only "cancel" and "join" are registered as functions, any other string will raise an error |
1581 | if (!lua_iscfunction(L, -1)) | 1581 | if (!lua_iscfunction(L, -1)) |
1582 | { | 1582 | { |
1583 | luaL_error(L, "can't index a lane with '%s'", keystr); // doesn't return | 1583 | raise_luaL_error(L, "can't index a lane with '%s'", keystr); |
1584 | } | 1584 | } |
1585 | return 1; | 1585 | return 1; |
1586 | } | 1586 | } |
@@ -1818,7 +1818,7 @@ LUAG_FUNC(configure) | |||
1818 | char const* errmsg{ DeepFactory::PushDeepProxy(DestState{ L }, U->timer_deep, 0, LookupMode::LaneBody) }; // settings M timer_deep | 1818 | char const* errmsg{ DeepFactory::PushDeepProxy(DestState{ L }, U->timer_deep, 0, LookupMode::LaneBody) }; // settings M timer_deep |
1819 | if (errmsg != nullptr) | 1819 | if (errmsg != nullptr) |
1820 | { | 1820 | { |
1821 | return luaL_error(L, errmsg); | 1821 | raise_luaL_error(L, errmsg); |
1822 | } | 1822 | } |
1823 | lua_setfield(L, -2, "timer_gateway"); // settings M | 1823 | lua_setfield(L, -2, "timer_gateway"); // settings M |
1824 | } | 1824 | } |
@@ -1975,10 +1975,10 @@ LANES_API int luaopen_lanes_core( lua_State* L) | |||
1975 | lua_getglobal(L, "jit"); // {jit?} | 1975 | lua_getglobal(L, "jit"); // {jit?} |
1976 | #if LUAJIT_FLAVOR() == 0 | 1976 | #if LUAJIT_FLAVOR() == 0 |
1977 | if (!lua_isnil(L, -1)) | 1977 | if (!lua_isnil(L, -1)) |
1978 | return luaL_error(L, "Lanes is built for PUC-Lua, don't run from LuaJIT"); | 1978 | raise_luaL_error(L, "Lanes is built for PUC-Lua, don't run from LuaJIT"); |
1979 | #else | 1979 | #else |
1980 | if (lua_isnil(L, -1)) | 1980 | if (lua_isnil(L, -1)) |
1981 | return luaL_error(L, "Lanes is built for LuaJIT, don't run from PUC-Lua"); | 1981 | raise_luaL_error(L, "Lanes is built for LuaJIT, don't run from PUC-Lua"); |
1982 | #endif | 1982 | #endif |
1983 | lua_pop(L, 1); // | 1983 | lua_pop(L, 1); // |
1984 | STACK_CHECK(L, 0); | 1984 | STACK_CHECK(L, 0); |
@@ -2012,7 +2012,7 @@ LANES_API int luaopen_lanes_core( lua_State* L) | |||
2012 | int const rc{ luaL_loadfile(L, "lanes.lua") || lua_pcall(L, 0, 1, 0) }; | 2012 | int const rc{ luaL_loadfile(L, "lanes.lua") || lua_pcall(L, 0, 1, 0) }; |
2013 | if (rc != LUA_OK) | 2013 | if (rc != LUA_OK) |
2014 | { | 2014 | { |
2015 | return luaL_error(L, "failed to initialize embedded Lanes"); | 2015 | raise_luaL_error(L, "failed to initialize embedded Lanes"); |
2016 | } | 2016 | } |
2017 | return 1; | 2017 | return 1; |
2018 | } | 2018 | } |