aboutsummaryrefslogtreecommitdiff
path: root/src/lanes.c
diff options
context:
space:
mode:
authorBenoit Germain <bnt.germain@gmail.com>2013-01-28 19:44:43 +0100
committerBenoit Germain <bnt.germain@gmail.com>2013-01-28 19:44:43 +0100
commit3377b95704e611a288791fee6a7bc59c5ecebf2d (patch)
tree35deabd01dc7c7095c3a11bef5f09456ffb503aa /src/lanes.c
parentfb0c67b1c95b6a595c0cd34a66136af6193b4d1b (diff)
downloadlanes-3377b95704e611a288791fee6a7bc59c5ecebf2d.tar.gz
lanes-3377b95704e611a288791fee6a7bc59c5ecebf2d.tar.bz2
lanes-3377b95704e611a288791fee6a7bc59c5ecebf2d.zip
* More detailed DEBUG_SPEW logs
* A bit of code cosmetics
Diffstat (limited to 'src/lanes.c')
-rw-r--r--src/lanes.c151
1 files changed, 91 insertions, 60 deletions
diff --git a/src/lanes.c b/src/lanes.c
index 62d56c1..80f5b15 100644
--- a/src/lanes.c
+++ b/src/lanes.c
@@ -403,11 +403,11 @@ LUAG_FUNC( linda_send)
403 STACK_GROW(L, 1); 403 STACK_GROW(L, 1);
404 { 404 {
405 struct s_Keeper *K = keeper_acquire( linda); 405 struct s_Keeper *K = keeper_acquire( linda);
406 lua_State*KL = K->L; // need to do this for 'STACK_CHECK' 406 lua_State *KL = K->L; // need to do this for 'STACK_CHECK'
407 STACK_CHECK( KL) 407 STACK_CHECK( KL);
408 for( ;;) 408 for( ;;)
409 { 409 {
410 STACK_MID(KL, 0) 410 STACK_MID( KL, 0);
411 pushed = keeper_call( KL, KEEPER_API( send), L, linda, key_i); 411 pushed = keeper_call( KL, KEEPER_API( send), L, linda, key_i);
412 if( pushed < 0) 412 if( pushed < 0)
413 { 413 {
@@ -444,12 +444,12 @@ LUAG_FUNC( linda_send)
444 enum e_status prev_status = ERROR_ST; // prevent 'might be used uninitialized' warnings 444 enum e_status prev_status = ERROR_ST; // prevent 'might be used uninitialized' warnings
445 STACK_GROW(L, 1); 445 STACK_GROW(L, 1);
446 446
447 STACK_CHECK(L) 447 STACK_CHECK( L);
448 lua_pushlightuserdata( L, CANCEL_TEST_KEY); 448 lua_pushlightuserdata( L, CANCEL_TEST_KEY);
449 lua_rawget( L, LUA_REGISTRYINDEX); 449 lua_rawget( L, LUA_REGISTRYINDEX);
450 s = lua_touserdata( L, -1); // lightuserdata (true 's_lane' pointer) or nil if in the main Lua state 450 s = lua_touserdata( L, -1); // lightuserdata (true 's_lane' pointer) or nil if in the main Lua state
451 lua_pop(L, 1); 451 lua_pop(L, 1);
452 STACK_END(L,0) 452 STACK_END( L, 0);
453 if( s) 453 if( s)
454 { 454 {
455 prev_status = s->status; // RUNNING, most likely 455 prev_status = s->status; // RUNNING, most likely
@@ -475,7 +475,7 @@ LUAG_FUNC( linda_send)
475 } 475 }
476 } 476 }
477 } 477 }
478 STACK_END( KL, 0) 478 STACK_END( KL, 0);
479 keeper_release( K); 479 keeper_release( K);
480 } 480 }
481 481
@@ -602,12 +602,12 @@ LUAG_FUNC( linda_receive)
602 enum e_status prev_status = ERROR_ST; // prevent 'might be used uninitialized' warnings 602 enum e_status prev_status = ERROR_ST; // prevent 'might be used uninitialized' warnings
603 STACK_GROW(L,1); 603 STACK_GROW(L,1);
604 604
605 STACK_CHECK(L) 605 STACK_CHECK( L);
606 lua_pushlightuserdata( L, CANCEL_TEST_KEY); 606 lua_pushlightuserdata( L, CANCEL_TEST_KEY);
607 lua_rawget( L, LUA_REGISTRYINDEX); 607 lua_rawget( L, LUA_REGISTRYINDEX);
608 s = lua_touserdata( L, -1); // lightuserdata (true 's_lane' pointer) or nil if in the main Lua state 608 s = lua_touserdata( L, -1); // lightuserdata (true 's_lane' pointer) or nil if in the main Lua state
609 lua_pop(L, 1); 609 lua_pop( L, 1);
610 STACK_END(L, 0) 610 STACK_END( L, 0);
611 if( s) 611 if( s)
612 { 612 {
613 prev_status = s->status; // RUNNING, most likely 613 prev_status = s->status; // RUNNING, most likely
@@ -959,7 +959,7 @@ static void linda_id( lua_State*L, char const * const which)
959 else if (strcmp( which, "metatable" )==0) 959 else if (strcmp( which, "metatable" )==0)
960 { 960 {
961 961
962 STACK_CHECK(L) 962 STACK_CHECK( L);
963 lua_newtable(L); 963 lua_newtable(L);
964 // metatable is its own index 964 // metatable is its own index
965 lua_pushvalue( L, -1); 965 lua_pushvalue( L, -1);
@@ -1008,7 +1008,7 @@ static void linda_id( lua_State*L, char const * const which)
1008 lua_pushliteral( L, BATCH_SENTINEL); 1008 lua_pushliteral( L, BATCH_SENTINEL);
1009 lua_setfield(L, -2, "batched"); 1009 lua_setfield(L, -2, "batched");
1010 1010
1011 STACK_END(L,1) 1011 STACK_END( L, 1);
1012 } 1012 }
1013 else if( strcmp( which, "module") == 0) 1013 else if( strcmp( which, "module") == 0)
1014 { 1014 {
@@ -1441,12 +1441,12 @@ static bool_t cancel_test( lua_State*L ) {
1441 1441
1442 STACK_GROW(L,1); 1442 STACK_GROW(L,1);
1443 1443
1444 STACK_CHECK(L) 1444 STACK_CHECK( L);
1445 lua_pushlightuserdata( L, CANCEL_TEST_KEY ); 1445 lua_pushlightuserdata( L, CANCEL_TEST_KEY );
1446 lua_rawget( L, LUA_REGISTRYINDEX ); 1446 lua_rawget( L, LUA_REGISTRYINDEX );
1447 s= lua_touserdata( L, -1 ); // lightuserdata (true 's_lane' pointer) / nil 1447 s= lua_touserdata( L, -1 ); // lightuserdata (true 's_lane' pointer) / nil
1448 lua_pop(L,1); 1448 lua_pop(L,1);
1449 STACK_END(L,0) 1449 STACK_END( L, 0);
1450 1450
1451 // 's' is NULL for the original main state (no-one can cancel that) 1451 // 's' is NULL for the original main state (no-one can cancel that)
1452 // 1452 //
@@ -1773,12 +1773,12 @@ static THREAD_RETURN_T THREAD_CALLCONV lane_main( void *vs)
1773 // LUA_ERRMEM(4): memory allocation error 1773 // LUA_ERRMEM(4): memory allocation error
1774#endif 1774#endif
1775 1775
1776 DEBUGSPEW_CODE( fprintf( stderr, "Lane %p body: %s\n", L, get_errcode_name( rc))); 1776 DEBUGSPEW_CODE( fprintf( stderr, INDENT_BEGIN "Lane %p body: %s\n" INDENT_END, L, get_errcode_name( rc)));
1777 //STACK_DUMP(L); 1777 //STACK_DUMP(L);
1778 // Call finalizers, if the script has set them up. 1778 // Call finalizers, if the script has set them up.
1779 // 1779 //
1780 rc2 = run_finalizers( L, rc); 1780 rc2 = run_finalizers( L, rc);
1781 DEBUGSPEW_CODE( fprintf( stderr, "Lane %p finalizer: %s\n", L, get_errcode_name( rc2))); 1781 DEBUGSPEW_CODE( fprintf( stderr, INDENT_BEGIN "Lane %p finalizer: %s\n" INDENT_END, L, get_errcode_name( rc2)));
1782 if( rc2 != LUA_OK) 1782 if( rc2 != LUA_OK)
1783 { 1783 {
1784 // Error within a finalizer! 1784 // Error within a finalizer!
@@ -1857,7 +1857,9 @@ static void require_one_module( lua_State* L, lua_State* L2, bool_t _fatal)
1857 { 1857 {
1858 lua_pop( L2, 1); 1858 lua_pop( L2, 1);
1859 if( _fatal) 1859 if( _fatal)
1860 {
1860 luaL_error( L, "cannot pre-require modules without loading 'package' library first"); 1861 luaL_error( L, "cannot pre-require modules without loading 'package' library first");
1862 }
1861 } 1863 }
1862 else 1864 else
1863 { 1865 {
@@ -1868,11 +1870,11 @@ static void require_one_module( lua_State* L, lua_State* L2, bool_t _fatal)
1868 } 1870 }
1869} 1871}
1870 1872
1871LUAG_FUNC( thread_new ) 1873LUAG_FUNC( thread_new)
1872{ 1874{
1873 lua_State*L2; 1875 lua_State* L2;
1874 struct s_lane *s; 1876 struct s_lane* s;
1875 struct s_lane **ud; 1877 struct s_lane** ud;
1876 1878
1877 char const* libs = lua_tostring( L, 2); 1879 char const* libs = lua_tostring( L, 2);
1878 lua_CFunction on_state_create = lua_iscfunction( L, 3) ? lua_tocfunction( L, 3) : NULL; 1880 lua_CFunction on_state_create = lua_iscfunction( L, 3) ? lua_tocfunction( L, 3) : NULL;
@@ -1891,6 +1893,8 @@ LUAG_FUNC( thread_new )
1891 } 1893 }
1892 1894
1893 /* --- Create and prepare the sub state --- */ 1895 /* --- Create and prepare the sub state --- */
1896 DEBUGSPEW_CODE( fprintf( stderr, INDENT_BEGIN "thread_new: setup\n" INDENT_END));
1897 DEBUGSPEW_CODE( ++ debugspew_indent_depth);
1894 1898
1895 // populate with selected libraries at the same time 1899 // populate with selected libraries at the same time
1896 // 1900 //
@@ -1905,6 +1909,7 @@ LUAG_FUNC( thread_new )
1905 1909
1906 ASSERT_L( lua_gettop(L2) == 0); 1910 ASSERT_L( lua_gettop(L2) == 0);
1907 1911
1912 DEBUGSPEW_CODE( fprintf( stderr, INDENT_BEGIN "thread_new: update 'package'\n" INDENT_END));
1908 // package 1913 // package
1909 if( package) 1914 if( package)
1910 { 1915 {
@@ -1913,21 +1918,24 @@ LUAG_FUNC( thread_new )
1913 1918
1914 // modules to require in the target lane *before* the function is transfered! 1919 // modules to require in the target lane *before* the function is transfered!
1915 1920
1921 DEBUGSPEW_CODE( fprintf( stderr, INDENT_BEGIN "thread_new: require 'lanes.core'\n" INDENT_END));
1916 //start by requiring lanes.core, since it is a bit special 1922 //start by requiring lanes.core, since it is a bit special
1917 // it is not fatal if 'require' isn't loaded, just ignore (may cause function transfer errors later on if the lane pulls the lanes module itself) 1923 // it is not fatal if 'require' isn't loaded, just ignore (may cause function transfer errors later on if the lane pulls the lanes module itself)
1918 STACK_CHECK(L) 1924 STACK_CHECK( L);
1919 STACK_CHECK(L2) 1925 STACK_CHECK( L2);
1920 lua_pushliteral( L, "lanes.core"); 1926 lua_pushliteral( L, "lanes.core");
1921 require_one_module( L, L2, FALSE); 1927 require_one_module( L, L2, FALSE);
1922 lua_pop( L, 1); 1928 lua_pop( L, 1);
1923 STACK_END(L2,0) 1929 STACK_END( L2, 0);
1924 STACK_END(L,0) 1930 STACK_END (L, 0);
1925 1931
1926 STACK_CHECK(L) 1932 STACK_CHECK( L);
1927 STACK_CHECK(L2) 1933 STACK_CHECK( L2);
1928 if( required) 1934 if( required)
1929 { 1935 {
1930 int nbRequired = 1; 1936 int nbRequired = 1;
1937 DEBUGSPEW_CODE( fprintf( stderr, INDENT_BEGIN "thread_new: require 'required' list\n" INDENT_END));
1938 DEBUGSPEW_CODE( ++ debugspew_indent_depth);
1931 // should not happen, was checked in lanes.lua before calling thread_new() 1939 // should not happen, was checked in lanes.lua before calling thread_new()
1932 if( lua_type( L, required) != LUA_TTABLE) 1940 if( lua_type( L, required) != LUA_TTABLE)
1933 { 1941 {
@@ -1947,22 +1955,25 @@ LUAG_FUNC( thread_new )
1947 lua_pop( L, 1); 1955 lua_pop( L, 1);
1948 ++ nbRequired; 1956 ++ nbRequired;
1949 } 1957 }
1958 DEBUGSPEW_CODE( -- debugspew_indent_depth);
1950 } 1959 }
1951 STACK_END(L2,0) 1960 STACK_END( L2, 0);
1952 STACK_END(L,0) 1961 STACK_END( L, 0);
1953 1962
1954 // Appending the specified globals to the global environment 1963 // Appending the specified globals to the global environment
1955 // *after* stdlibs have been loaded and modules required, in case we transfer references to native functions they exposed... 1964 // *after* stdlibs have been loaded and modules required, in case we transfer references to native functions they exposed...
1956 // 1965 //
1957 if( glob != 0) 1966 if( glob != 0)
1958 { 1967 {
1959 STACK_CHECK(L) 1968 DEBUGSPEW_CODE( fprintf( stderr, INDENT_BEGIN "thread_new: transfer globals\n" INDENT_END));
1960 STACK_CHECK(L2) 1969 STACK_CHECK( L);
1970 STACK_CHECK( L2);
1961 if( !lua_istable( L, glob)) 1971 if( !lua_istable( L, glob))
1962 { 1972 {
1963 return luaL_error( L, "Expected table, got %s", luaL_typename( L, glob)); 1973 return luaL_error( L, "Expected table, got %s", luaL_typename( L, glob));
1964 } 1974 }
1965 1975
1976 DEBUGSPEW_CODE( ++ debugspew_indent_depth);
1966 lua_pushnil( L); 1977 lua_pushnil( L);
1967 lua_pushglobaltable( L2); // Lua 5.2 wants us to push the globals table on the stack 1978 lua_pushglobaltable( L2); // Lua 5.2 wants us to push the globals table on the stack
1968 while( lua_next( L, glob)) 1979 while( lua_next( L, glob))
@@ -1974,23 +1985,29 @@ LUAG_FUNC( thread_new )
1974 } 1985 }
1975 lua_pop( L2, 1); 1986 lua_pop( L2, 1);
1976 1987
1977 STACK_END(L2, 0) 1988 STACK_END( L2, 0);
1978 STACK_END(L, 0) 1989 STACK_END( L, 0);
1990 DEBUGSPEW_CODE( -- debugspew_indent_depth);
1979 } 1991 }
1980 1992
1981 ASSERT_L( lua_gettop(L2) == 0); 1993 ASSERT_L( lua_gettop( L2) == 0);
1982 1994
1983 // Lane main function 1995 // Lane main function
1984 // 1996 //
1985 STACK_CHECK(L) 1997 STACK_CHECK( L);
1986 if( lua_type( L, 1) == LUA_TFUNCTION) 1998 if( lua_type( L, 1) == LUA_TFUNCTION)
1987 { 1999 {
2000 int res;
2001 DEBUGSPEW_CODE( fprintf( stderr, INDENT_BEGIN "thread_new: transfer lane body\n" INDENT_END));
2002 DEBUGSPEW_CODE( ++ debugspew_indent_depth);
1988 lua_pushvalue( L, 1); 2003 lua_pushvalue( L, 1);
1989 if( luaG_inter_move( L, L2, 1) != 0) // L->L2 2004 res = luaG_inter_move( L, L2, 1); // L->L2
2005 DEBUGSPEW_CODE( -- debugspew_indent_depth);
2006 if( res != 0)
1990 { 2007 {
1991 return luaL_error( L, "tried to copy unsupported types"); 2008 return luaL_error( L, "tried to copy unsupported types");
1992 } 2009 }
1993 STACK_MID(L,0) 2010 STACK_MID( L, 0);
1994 } 2011 }
1995 else if( lua_type( L, 1) == LUA_TSTRING) 2012 else if( lua_type( L, 1) == LUA_TSTRING)
1996 { 2013 {
@@ -2001,28 +2018,34 @@ LUAG_FUNC( thread_new )
2001 } 2018 }
2002 } 2019 }
2003 2020
2004 ASSERT_L( lua_gettop(L2) == 1); 2021 ASSERT_L( lua_gettop( L2) == 1);
2005 ASSERT_L( lua_isfunction(L2,1)); 2022 ASSERT_L( lua_isfunction( L2, 1));
2006 2023
2007 // revive arguments 2024 // revive arguments
2008 // 2025 //
2009 if( (args > 0) && (luaG_inter_copy( L, L2, args) != 0)) // L->L2 2026 if( args > 0)
2010 { 2027 {
2011 return luaL_error( L, "tried to copy unsupported types"); 2028 int res;
2029 DEBUGSPEW_CODE( fprintf( stderr, INDENT_BEGIN "thread_new: transfer lane arguments\n" INDENT_END));
2030 DEBUGSPEW_CODE( ++ debugspew_indent_depth);
2031 res = luaG_inter_copy( L, L2, args); // L->L2
2032 DEBUGSPEW_CODE( -- debugspew_indent_depth);
2033 if( res != 0)
2034 return luaL_error( L, "tried to copy unsupported types");
2012 } 2035 }
2013 STACK_MID(L,0) 2036 STACK_MID( L, 0);
2014 2037
2015 ASSERT_L( (uint_t)lua_gettop(L2) == 1+args ); 2038 ASSERT_L( (uint_t)lua_gettop( L2) == 1+args);
2016 ASSERT_L( lua_isfunction(L2,1) ); 2039 ASSERT_L( lua_isfunction( L2, 1));
2017 2040
2018 // 's' is allocated from heap, not Lua, since its life span may surpass 2041 // 's' is allocated from heap, not Lua, since its life span may surpass
2019 // the handle's (if free running thread) 2042 // the handle's (if free running thread)
2020 // 2043 //
2021 ud= lua_newuserdata( L, sizeof(struct s_lane*) ); 2044 ud = lua_newuserdata( L, sizeof( struct s_lane*));
2022 ASSERT_L(ud); 2045 ASSERT_L( ud);
2023 2046
2024 s= *ud= malloc( sizeof(struct s_lane) ); 2047 s = *ud = malloc( sizeof( struct s_lane));
2025 ASSERT_L(s); 2048 ASSERT_L( s);
2026 2049
2027 //memset( s, 0, sizeof(struct s_lane) ); 2050 //memset( s, 0, sizeof(struct s_lane) );
2028 s->L= L2; 2051 s->L= L2;
@@ -2045,7 +2068,7 @@ LUAG_FUNC( thread_new )
2045 // 2068 //
2046 lua_pushvalue( L, lua_upvalueindex(1) ); 2069 lua_pushvalue( L, lua_upvalueindex(1) );
2047 lua_setmetatable( L, -2 ); 2070 lua_setmetatable( L, -2 );
2048 STACK_MID(L,1) 2071 STACK_MID( L, 1);
2049 2072
2050 // Clear environment for the userdata 2073 // Clear environment for the userdata
2051 // 2074 //
@@ -2064,8 +2087,11 @@ LUAG_FUNC( thread_new )
2064 lua_sethook( L2, cancel_hook, LUA_MASKCOUNT, cs ); 2087 lua_sethook( L2, cancel_hook, LUA_MASKCOUNT, cs );
2065 } 2088 }
2066 2089
2090 DEBUGSPEW_CODE( fprintf( stderr, INDENT_BEGIN "thread_new: launching thread\n" INDENT_END));
2067 THREAD_CREATE( &s->thread, lane_main, s, prio ); 2091 THREAD_CREATE( &s->thread, lane_main, s, prio );
2068 STACK_END(L,1) 2092 STACK_END( L, 1);
2093
2094 DEBUGSPEW_CODE( -- debugspew_indent_depth);
2069 2095
2070 return 1; 2096 return 1;
2071} 2097}
@@ -2503,7 +2529,7 @@ LUAG_FUNC( wakeup_conv )
2503 // .yday (day of the year) 2529 // .yday (day of the year)
2504 // .isdst (daylight saving on/off) 2530 // .isdst (daylight saving on/off)
2505 2531
2506 STACK_CHECK(L) 2532 STACK_CHECK( L);
2507 lua_getfield( L, 1, "year" ); year= (int)lua_tointeger(L,-1); lua_pop(L,1); 2533 lua_getfield( L, 1, "year" ); year= (int)lua_tointeger(L,-1); lua_pop(L,1);
2508 lua_getfield( L, 1, "month" ); month= (int)lua_tointeger(L,-1); lua_pop(L,1); 2534 lua_getfield( L, 1, "month" ); month= (int)lua_tointeger(L,-1); lua_pop(L,1);
2509 lua_getfield( L, 1, "day" ); day= (int)lua_tointeger(L,-1); lua_pop(L,1); 2535 lua_getfield( L, 1, "day" ); day= (int)lua_tointeger(L,-1); lua_pop(L,1);
@@ -2517,7 +2543,7 @@ LUAG_FUNC( wakeup_conv )
2517 lua_getfield( L, 1, "isdst" ); 2543 lua_getfield( L, 1, "isdst" );
2518 isdst= lua_isboolean(L,-1) ? lua_toboolean(L,-1) : -1; 2544 isdst= lua_isboolean(L,-1) ? lua_toboolean(L,-1) : -1;
2519 lua_pop(L,1); 2545 lua_pop(L,1);
2520 STACK_END(L,0) 2546 STACK_END( L, 0);
2521 2547
2522 t.tm_year= year-1900; 2548 t.tm_year= year-1900;
2523 t.tm_mon= month-1; // 0..11 2549 t.tm_mon= month-1; // 0..11
@@ -2619,13 +2645,13 @@ static void init_once_LOCKED( lua_State* L, int const nbKeepers, lua_CFunction _
2619 // 2645 //
2620 ASSERT_L( timer_deep == NULL); 2646 ASSERT_L( timer_deep == NULL);
2621 2647
2622 STACK_CHECK(L) 2648 STACK_CHECK( L);
2623 { 2649 {
2624 // proxy_ud= deep_userdata( idfunc ) 2650 // proxy_ud= deep_userdata( idfunc )
2625 // 2651 //
2626 lua_pushliteral( L, "lanes-timer"); // push a name for debug purposes 2652 lua_pushliteral( L, "lanes-timer"); // push a name for debug purposes
2627 luaG_deep_userdata( L, linda_id); 2653 luaG_deep_userdata( L, linda_id);
2628 STACK_MID( L, 2) 2654 STACK_MID( L, 2);
2629 lua_remove( L, -2); // remove the name as we no longer need it 2655 lua_remove( L, -2); // remove the name as we no longer need it
2630 2656
2631 ASSERT_L( lua_isuserdata(L,-1) ); 2657 ASSERT_L( lua_isuserdata(L,-1) );
@@ -2653,7 +2679,7 @@ static void init_once_LOCKED( lua_State* L, int const nbKeepers, lua_CFunction _
2653 lua_rawset( L, LUA_REGISTRYINDEX); 2679 lua_rawset( L, LUA_REGISTRYINDEX);
2654 2680
2655 } 2681 }
2656 STACK_END(L,0) 2682 STACK_END( L, 0);
2657} 2683}
2658 2684
2659static volatile long s_initCount = 0; 2685static volatile long s_initCount = 0;
@@ -2669,7 +2695,10 @@ LUAG_FUNC( configure)
2669 lua_Number shutdown_timeout = lua_tonumber( L, 3); 2695 lua_Number shutdown_timeout = lua_tonumber( L, 3);
2670 bool_t track_lanes = lua_toboolean( L, 4); 2696 bool_t track_lanes = lua_toboolean( L, 4);
2671 2697
2672 STACK_CHECK( L) 2698 DEBUGSPEW_CODE( fprintf( stderr, INDENT_BEGIN "%p: lanes.configure() BEGIN\n" INDENT_END, L));
2699 DEBUGSPEW_CODE( ++ debugspew_indent_depth);
2700 STACK_CHECK( L);
2701
2673 // Create main module interface table 2702 // Create main module interface table
2674 lua_pushvalue( L, lua_upvalueindex( 2)); // ... M 2703 lua_pushvalue( L, lua_upvalueindex( 2)); // ... M
2675 // remove configure() (this function) from the module interface 2704 // remove configure() (this function) from the module interface
@@ -2677,7 +2706,7 @@ LUAG_FUNC( configure)
2677 lua_setfield( L, -2, "configure"); // ... M 2706 lua_setfield( L, -2, "configure"); // ... M
2678 // add functions to the module's table 2707 // add functions to the module's table
2679 luaG_registerlibfuncs( L, lanes_functions); 2708 luaG_registerlibfuncs( L, lanes_functions);
2680 STACK_MID( L, 1) 2709 STACK_MID( L, 1);
2681 2710
2682 // metatable for threads 2711 // metatable for threads
2683 // contains keys: { __gc, __index, cached_error, cached_tostring, cancel, join } 2712 // contains keys: { __gc, __index, cached_error, cached_tostring, cancel, join }
@@ -2723,7 +2752,7 @@ LUAG_FUNC( configure)
2723 populate_func_lookup_table( L, -1, NULL); 2752 populate_func_lookup_table( L, -1, NULL);
2724 lua_pop( L, 1); // ... M 2753 lua_pop( L, 1); // ... M
2725 2754
2726 STACK_MID( L, 1) 2755 STACK_MID( L, 1);
2727 /* 2756 /*
2728 * Making one-time initializations. 2757 * Making one-time initializations.
2729 * 2758 *
@@ -2765,14 +2794,16 @@ LUAG_FUNC( configure)
2765 } 2794 }
2766#endif // THREADAPI == THREADAPI_PTHREAD 2795#endif // THREADAPI == THREADAPI_PTHREAD
2767 assert( timer_deep != NULL); 2796 assert( timer_deep != NULL);
2768 STACK_MID( L, 1) 2797 STACK_MID( L, 1);
2769 2798
2770 // init_once_LOCKED initializes timer_deep, so we must do this after, of course 2799 // init_once_LOCKED initializes timer_deep, so we must do this after, of course
2771 luaG_push_proxy( L, linda_id, (DEEP_PRELUDE*) timer_deep); // ... M timer_deep 2800 luaG_push_proxy( L, linda_id, (DEEP_PRELUDE*) timer_deep); // ... M timer_deep
2772 lua_setfield( L, -2, "timer_gateway"); // ... M 2801 lua_setfield( L, -2, "timer_gateway"); // ... M
2773 2802
2774 lua_pop( L, 1); // ... 2803 lua_pop( L, 1); // ...
2775 STACK_END( L, 0) 2804 STACK_END( L, 0);
2805 DEBUGSPEW_CODE( fprintf( stderr, INDENT_BEGIN "%p: lanes.configure() END\n" INDENT_END, L));
2806 DEBUGSPEW_CODE( -- debugspew_indent_depth);
2776 // Return nothing 2807 // Return nothing
2777 return 0; 2808 return 0;
2778} 2809}
@@ -2810,7 +2841,7 @@ luaopen_lanes_core( lua_State* L)
2810 EnableCrashingOnCrashes(); 2841 EnableCrashingOnCrashes();
2811 2842
2812 STACK_GROW( L, 3); 2843 STACK_GROW( L, 3);
2813 STACK_CHECK( L) 2844 STACK_CHECK( L);
2814 2845
2815 // sanity check: let's see if _"VERSION" matches what we we built against 2846 // sanity check: let's see if _"VERSION" matches what we we built against
2816 lua_getglobal( L, "_VERSION"); 2847 lua_getglobal( L, "_VERSION");
@@ -2838,6 +2869,6 @@ luaopen_lanes_core( lua_State* L)
2838 lua_call( L, 2, 0); 2869 lua_call( L, 2, 0);
2839 } 2870 }
2840 2871
2841 STACK_END( L, 1) 2872 STACK_END( L, 1);
2842 return 1; 2873 return 1;
2843} 2874}