From 2cf954b8ae08a9094354551ee3733f4ff8078443 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Tue, 8 Nov 1994 17:56:39 -0200 Subject: [PATCH] lock mechanism --- fallback.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++- fallback.h | 6 ++++- lua.h | 6 ++++- opcode.c | 14 ++++++++++-- 4 files changed, 88 insertions(+), 5 deletions(-) diff --git a/fallback.c b/fallback.c index 023d11c3..68d052b3 100644 --- a/fallback.c +++ b/fallback.c @@ -3,11 +3,13 @@ ** TecCGraf - PUC-Rio */ -char *rcs_fallback="$Id: $"; +char *rcs_fallback="$Id: fallback.c,v 1.1 1994/11/07 15:20:56 roberto Exp roberto $"; #include +#include #include "fallback.h" +#include "opcode.h" #include "lua.h" @@ -49,3 +51,66 @@ void luaI_orderFB (void) lua_error("unexpected type at comparison"); } + +/* +** Lock routines +*/ + +static Object *lockArray = NULL; +static int lockSize = 0; + +int lua_lock (lua_Object object) +{ + int i; + int oldSize; + if (lua_isnil(object)) + return -1; + for (i=0; i #include @@ -545,14 +545,24 @@ void *lua_getuserdata (lua_Object object) else return (uvalue(Address(object))); } + +lua_Object lua_getlocked (int ref) +{ + adjustC(0); + *(top++) = *luaI_getlocked(ref); + CBase++; /* incorporate object in the stack */ + return Ref(top-1); +} + /* ** Get a global object. Return the object handle or NULL on error. */ lua_Object lua_getglobal (char *name) { int n = lua_findsymbol(name); - if (n < 0) return 0; + adjustC(0); *(top++) = s_object(n); + CBase++; /* incorporate object in the stack */ return Ref(top-1); }