aboutsummaryrefslogtreecommitdiff
path: root/src/lanes.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/lanes.cpp')
-rw-r--r--src/lanes.cpp25
1 files changed, 13 insertions, 12 deletions
diff --git a/src/lanes.cpp b/src/lanes.cpp
index fa69656..126f65c 100644
--- a/src/lanes.cpp
+++ b/src/lanes.cpp
@@ -128,7 +128,7 @@ static void securize_debug_threadname( lua_State* L, Lane* s)
128#if ERROR_FULL_STACK 128#if ERROR_FULL_STACK
129static int lane_error( lua_State* L); 129static int lane_error( lua_State* L);
130// crc64/we of string "STACKTRACE_REGKEY" generated at http://www.nitrxgen.net/hashgen/ 130// crc64/we of string "STACKTRACE_REGKEY" generated at http://www.nitrxgen.net/hashgen/
131static DECLARE_CONST_UNIQUE_KEY( STACKTRACE_REGKEY, 0x534af7d3226a429f); 131static constexpr UniqueKey STACKTRACE_REGKEY{ 0x534af7d3226a429full };
132#endif // ERROR_FULL_STACK 132#endif // ERROR_FULL_STACK
133 133
134/* 134/*
@@ -140,7 +140,7 @@ static DECLARE_CONST_UNIQUE_KEY( STACKTRACE_REGKEY, 0x534af7d3226a429f);
140* anyways complicate that approach. 140* anyways complicate that approach.
141*/ 141*/
142// crc64/we of string "FINALIZER_REGKEY" generated at http://www.nitrxgen.net/hashgen/ 142// crc64/we of string "FINALIZER_REGKEY" generated at http://www.nitrxgen.net/hashgen/
143static DECLARE_CONST_UNIQUE_KEY( FINALIZER_REGKEY, 0x188fccb8bf348e09); 143static constexpr UniqueKey FINALIZER_REGKEY{ 0x188fccb8bf348e09ull };
144 144
145struct s_Linda; 145struct s_Linda;
146 146
@@ -649,7 +649,7 @@ LUAG_FUNC( set_singlethreaded)
649#if ERROR_FULL_STACK 649#if ERROR_FULL_STACK
650 650
651// crc64/we of string "EXTENDED_STACKTRACE_REGKEY" generated at http://www.nitrxgen.net/hashgen/ 651// crc64/we of string "EXTENDED_STACKTRACE_REGKEY" generated at http://www.nitrxgen.net/hashgen/
652static DECLARE_CONST_UNIQUE_KEY( EXTENDED_STACKTRACE_REGKEY, 0x2357c69a7c92c936); // used as registry key 652static constexpr UniqueKey EXTENDED_STACKTRACE_REGKEY{ 0x2357c69a7c92c936ull }; // used as registry key
653 653
654LUAG_FUNC( set_error_reporting) 654LUAG_FUNC( set_error_reporting)
655{ 655{
@@ -683,7 +683,7 @@ static int lane_error( lua_State* L)
683 683
684 // Don't do stack survey for cancelled lanes. 684 // Don't do stack survey for cancelled lanes.
685 // 685 //
686 if( equal_unique_key( L, 1, CANCEL_ERROR)) 686 if (CANCEL_ERROR.equals(L, 1))
687 { 687 {
688 return 1; // just pass on 688 return 1; // just pass on
689 } 689 }
@@ -769,7 +769,7 @@ static void push_stack_trace( lua_State* L, int rc_, int stk_base_)
769 769
770 // For cancellation the error message is CANCEL_ERROR, and a stack trace isn't placed 770 // For cancellation the error message is CANCEL_ERROR, and a stack trace isn't placed
771 // For other errors, the message can be whatever was thrown, and we should have a stack trace table 771 // For other errors, the message can be whatever was thrown, and we should have a stack trace table
772 ASSERT_L( lua_type( L, 1 + stk_base_) == (equal_unique_key( L, stk_base_, CANCEL_ERROR) ? LUA_TNIL : LUA_TTABLE)); 772 ASSERT_L(lua_type(L, 1 + stk_base_) == (CANCEL_ERROR.equals(L, stk_base_) ? LUA_TNIL : LUA_TTABLE));
773 // Just leaving the stack trace table on the stack is enough to get it through to the master. 773 // Just leaving the stack trace table on the stack is enough to get it through to the master.
774 break; 774 break;
775 } 775 }
@@ -779,14 +779,15 @@ static void push_stack_trace( lua_State* L, int rc_, int stk_base_)
779 case LUA_ERRERR: // error while running the error handler (if any, for example an out-of-memory condition) 779 case LUA_ERRERR: // error while running the error handler (if any, for example an out-of-memory condition)
780 default: 780 default:
781 // we should have a single value which is either a string (the error message) or CANCEL_ERROR 781 // we should have a single value which is either a string (the error message) or CANCEL_ERROR
782 ASSERT_L( (lua_gettop( L) == stk_base_) && ((lua_type( L, stk_base_) == LUA_TSTRING) || equal_unique_key( L, stk_base_, CANCEL_ERROR))); 782 ASSERT_L((lua_gettop(L) == stk_base_) && ((lua_type(L, stk_base_) == LUA_TSTRING) || CANCEL_ERROR.equals(L, stk_base_)));
783 break; 783 break;
784 } 784 }
785} 785}
786 786
787LUAG_FUNC( set_debug_threadname) 787LUAG_FUNC( set_debug_threadname)
788{ 788{
789 DECLARE_CONST_UNIQUE_KEY( hidden_regkey, LG_set_debug_threadname); 789 // fnv164 of string "debug_threadname" generated at https://www.pelock.com/products/hash-calculator
790 constexpr UniqueKey hidden_regkey{ 0x79C0669AAAE04440ull };
790 // C s_lane structure is a light userdata upvalue 791 // C s_lane structure is a light userdata upvalue
791 Lane* s = (Lane*) lua_touserdata( L, lua_upvalueindex( 1)); 792 Lane* s = (Lane*) lua_touserdata( L, lua_upvalueindex( 1));
792 luaL_checktype( L, -1, LUA_TSTRING); // "name" 793 luaL_checktype( L, -1, LUA_TSTRING); // "name"
@@ -959,7 +960,7 @@ static THREAD_RETURN_T THREAD_CALLCONV lane_main( void* vs)
959 { 960 {
960 // leave results (1..top) or error message + stack trace (1..2) on the stack - master will copy them 961 // leave results (1..top) or error message + stack trace (1..2) on the stack - master will copy them
961 962
962 enum e_status st = (rc == 0) ? DONE : equal_unique_key( L, 1, CANCEL_ERROR) ? CANCELLED : ERROR_ST; 963 enum e_status st = (rc == 0) ? DONE : CANCEL_ERROR.equals(L, 1) ? CANCELLED : ERROR_ST;
963 964
964 // Posix no PTHREAD_TIMEDJOIN: 965 // Posix no PTHREAD_TIMEDJOIN:
965 // 'done_lock' protects the -> DONE|ERROR_ST|CANCELLED state change 966 // 'done_lock' protects the -> DONE|ERROR_ST|CANCELLED state change
@@ -1024,7 +1025,7 @@ LUAG_FUNC( register)
1024} 1025}
1025 1026
1026// crc64/we of string "GCCB_KEY" generated at http://www.nitrxgen.net/hashgen/ 1027// crc64/we of string "GCCB_KEY" generated at http://www.nitrxgen.net/hashgen/
1027static DECLARE_CONST_UNIQUE_KEY( GCCB_KEY, 0xcfb1f046ef074e88); 1028static constexpr UniqueKey GCCB_KEY{ 0xcfb1f046ef074e88ull };
1028 1029
1029//--- 1030//---
1030// lane_ud = lane_new( function 1031// lane_ud = lane_new( function
@@ -1267,7 +1268,7 @@ LUAG_FUNC( lane_new)
1267 // Store the gc_cb callback in the uservalue 1268 // Store the gc_cb callback in the uservalue
1268 if( gc_cb_idx > 0) 1269 if( gc_cb_idx > 0)
1269 { 1270 {
1270 push_unique_key( L, GCCB_KEY); // func libs priority globals package required gc_cb lane uv k 1271 GCCB_KEY.push(L); // func libs priority globals package required gc_cb lane uv k
1271 lua_pushvalue( L, gc_cb_idx); // func libs priority globals package required gc_cb lane uv k gc_cb 1272 lua_pushvalue( L, gc_cb_idx); // func libs priority globals package required gc_cb lane uv k gc_cb
1272 lua_rawset( L, -3); // func libs priority globals package required gc_cb lane uv 1273 lua_rawset( L, -3); // func libs priority globals package required gc_cb lane uv
1273 } 1274 }
@@ -1307,7 +1308,7 @@ LUAG_FUNC( thread_gc)
1307 1308
1308 // if there a gc callback? 1309 // if there a gc callback?
1309 lua_getiuservalue( L, 1, 1); // ud uservalue 1310 lua_getiuservalue( L, 1, 1); // ud uservalue
1310 push_unique_key( L, GCCB_KEY); // ud uservalue __gc 1311 GCCB_KEY.push(L); // ud uservalue __gc
1311 lua_rawget( L, -2); // ud uservalue gc_cb|nil 1312 lua_rawget( L, -2); // ud uservalue gc_cb|nil
1312 if( !lua_isnil( L, -1)) 1313 if( !lua_isnil( L, -1))
1313 { 1314 {
@@ -1986,7 +1987,7 @@ LUAG_FUNC( configure)
1986 lua_pushinteger(L, THREAD_PRIO_MAX); // settings M THREAD_PRIO_MAX 1987 lua_pushinteger(L, THREAD_PRIO_MAX); // settings M THREAD_PRIO_MAX
1987 lua_setfield( L, -2, "max_prio"); // settings M 1988 lua_setfield( L, -2, "max_prio"); // settings M
1988 1989
1989 push_unique_key( L, CANCEL_ERROR); // settings M CANCEL_ERROR 1990 CANCEL_ERROR.push(L); // settings M CANCEL_ERROR
1990 lua_setfield( L, -2, "cancel_error"); // settings M 1991 lua_setfield( L, -2, "cancel_error"); // settings M
1991 1992
1992 STACK_MID( L, 2); // reference stack contains only the function argument 'settings' 1993 STACK_MID( L, 2); // reference stack contains only the function argument 'settings'