aboutsummaryrefslogtreecommitdiff
path: root/src/lanes.c
diff options
context:
space:
mode:
authorBenoit Germain <bnt period germain arrobase gmail period com>2014-01-06 10:40:14 +0100
committerBenoit Germain <bnt period germain arrobase gmail period com>2014-01-06 10:40:14 +0100
commitb335cbcc9f07dc71999b885ffa2962c0ec00f5eb (patch)
treead6398a6f7e5ef155631b984bd41d07d535ea1f9 /src/lanes.c
parent132e85cb40f3a88efdb66a6344061bade628fcda (diff)
downloadlanes-b335cbcc9f07dc71999b885ffa2962c0ec00f5eb.tar.gz
lanes-b335cbcc9f07dc71999b885ffa2962c0ec00f5eb.tar.bz2
lanes-b335cbcc9f07dc71999b885ffa2962c0ec00f5eb.zip
fix on_state_create circular logic issue
* if config.on_state_create() is a C function, call it by direct C closure reconstruction in newly created states * bumped version to 3.7.6
Diffstat (limited to 'src/lanes.c')
-rw-r--r--src/lanes.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/src/lanes.c b/src/lanes.c
index e66342d..3ccf915 100644
--- a/src/lanes.c
+++ b/src/lanes.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * LANES.C Copyright (c) 2007-08, Asko Kauppi 2 * LANES.C Copyright (c) 2007-08, Asko Kauppi
3 * Copyright (C) 2009-13, Benoit Germain 3 * Copyright (C) 2009-14, Benoit Germain
4 * 4 *
5 * Multithreading in Lua. 5 * Multithreading in Lua.
6 * 6 *
@@ -52,13 +52,13 @@
52 * ... 52 * ...
53 */ 53 */
54 54
55char const* VERSION = "3.7.5"; 55char const* VERSION = "3.7.6";
56 56
57/* 57/*
58=============================================================================== 58===============================================================================
59 59
60Copyright (C) 2007-10 Asko Kauppi <akauppi@gmail.com> 60Copyright (C) 2007-10 Asko Kauppi <akauppi@gmail.com>
61 2011-13 Benoit Germain <bnt.germain@gmail.com> 61 2011-14 Benoit Germain <bnt.germain@gmail.com>
62 62
63Permission is hereby granted, free of charge, to any person obtaining a copy 63Permission is hereby granted, free of charge, to any person obtaining a copy
64of this software and associated documentation files (the "Software"), to deal 64of this software and associated documentation files (the "Software"), to deal
@@ -1987,14 +1987,13 @@ LUAG_FUNC( thread_new)
1987 struct s_lane** ud; 1987 struct s_lane** ud;
1988 1988
1989 char const* libs = lua_tostring( L, 2); 1989 char const* libs = lua_tostring( L, 2);
1990 int const on_state_create = lua_isfunction( L, 3) ? 3 : 0; 1990 uint_t cs = luaG_optunsigned( L, 3, 0);
1991 uint_t cs = luaG_optunsigned( L, 4, 0); 1991 int const prio = (int) luaL_optinteger( L, 4, 0);
1992 int const prio = (int) luaL_optinteger( L, 5, 0); 1992 uint_t glob = lua_isnoneornil( L, 5) ? 0 : 5;
1993 uint_t glob = lua_isnoneornil( L, 6) ? 0 : 6; 1993 uint_t package = lua_isnoneornil( L, 6) ? 0 : 6;
1994 uint_t package = lua_isnoneornil( L,7) ? 0 : 7; 1994 uint_t required = lua_isnoneornil( L, 7) ? 0 : 7;
1995 uint_t required = lua_isnoneornil( L, 8) ? 0 : 8; 1995
1996 1996#define FIXED_ARGS 7
1997#define FIXED_ARGS 8
1998 uint_t args = lua_gettop(L) - FIXED_ARGS; 1997 uint_t args = lua_gettop(L) - FIXED_ARGS;
1999 1998
2000 // public Lanes API accepts a generic range -3/+3 1999 // public Lanes API accepts a generic range -3/+3
@@ -2011,7 +2010,7 @@ LUAG_FUNC( thread_new)
2011 2010
2012 // populate with selected libraries at the same time 2011 // populate with selected libraries at the same time
2013 // 2012 //
2014 L2 = luaG_newstate( L, on_state_create, libs); 2013 L2 = luaG_newstate( L, libs);
2015 2014
2016 STACK_GROW( L, 2); 2015 STACK_GROW( L, 2);
2017 STACK_GROW( L2, 3); 2016 STACK_GROW( L2, 3);
@@ -2727,6 +2726,8 @@ static const struct luaL_Reg lanes_functions [] = {
2727*/ 2726*/
2728static void init_once_LOCKED( lua_State* L) 2727static void init_once_LOCKED( lua_State* L)
2729{ 2728{
2729 initialize_on_state_create( L);
2730
2730 STACK_CHECK( L); 2731 STACK_CHECK( L);
2731 2732
2732 lua_getfield( L, 1, "verbose_errors"); 2733 lua_getfield( L, 1, "verbose_errors");