Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/torch/torch7.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/init.c
diff options
context:
space:
mode:
authorTim Harley <tim.harley.uk@gmail.com>2014-03-14 18:01:08 +0400
committerTim Harley <tim.harley.uk@gmail.com>2014-03-14 21:07:54 +0400
commit7504955cc8fd207dfa0d362199a286331bc03347 (patch)
treec056e407852437bce54c3504ab1fa441d71afc80 /init.c
parentc75931dd08d48790df8f08c64bde361fe1b972df (diff)
Thread local callback and state for THError. Copied from github:koraykv/torch
Diffstat (limited to 'init.c')
-rw-r--r--init.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/init.c b/init.c
index 46ec2fd..0f6213e 100644
--- a/init.c
+++ b/init.c
@@ -35,24 +35,24 @@ extern void torch_DoubleTensorOperator_init(lua_State *L);
extern void torch_TensorMath_init(lua_State *L);
-static lua_State *globalL;
-static void luaTorchErrorHandlerFunction(const char *msg)
+static void luaTorchErrorHandlerFunction(const char *msg, void *data)
{
- luaL_error(globalL, msg);
+ lua_State *L = data;
+ luaL_error(L, msg);
}
-static void luaTorchArgErrorHandlerFunction(int argNumber, const char *msg)
+static void luaTorchArgErrorHandlerFunction(int argNumber, const char *msg, void *data)
{
- luaL_argcheck(globalL, 0, argNumber, msg);
+ lua_State *L = data;
+ luaL_argcheck(L, 0, argNumber, msg);
}
LUA_EXTERNC DLL_EXPORT int luaopen_libtorch(lua_State *L);
int luaopen_libtorch(lua_State *L)
{
- globalL = L;
- THSetErrorHandler(luaTorchErrorHandlerFunction);
- THSetArgErrorHandler(luaTorchArgErrorHandlerFunction);
+ THSetErrorHandler(luaTorchErrorHandlerFunction, L);
+ THSetArgErrorHandler(luaTorchArgErrorHandlerFunction, L);
lua_newtable(L);
lua_pushvalue(L, -1);