1
0
mirror of https://github.com/lua/lua.git synced 2025-01-28 06:03:00 +08:00

better ways to test lock mechanism

This commit is contained in:
Roberto Ierusalimschy 1999-11-10 13:41:11 -02:00
parent 0c725b2492
commit a4628a02cf

View File

@ -1,5 +1,5 @@
/* /*
** $Id: lbuiltin.c,v 1.69 1999/10/26 10:53:40 roberto Exp roberto $ ** $Id: lbuiltin.c,v 1.70 1999/11/04 17:22:26 roberto Exp roberto $
** Built-in functions ** Built-in functions
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -696,7 +696,6 @@ static void testC (void) {
#define getnum(s) ((*s++) - '0') #define getnum(s) ((*s++) - '0')
#define getname(s) (nome[0] = *s++, nome) #define getname(s) (nome[0] = *s++, nome)
static int locks[10];
lua_Object reg[10]; lua_Object reg[10];
char nome[2]; char nome[2];
const char *s = luaL_check_string(1); const char *s = luaL_check_string(1);
@ -719,10 +718,14 @@ static void testC (void) {
reg[n] = lua_rawgetglobal(getname(s)); reg[n] = lua_rawgetglobal(getname(s));
break; break;
} }
case 'l': locks[getnum(s)] = lua_ref(1); break; case 'l': lua_pushnumber(lua_ref(1)); reg[getnum(s)] = lua_pop(); break;
case 'L': locks[getnum(s)] = lua_ref(0); break; case 'L': lua_pushnumber(lua_ref(0)); reg[getnum(s)] = lua_pop(); break;
case 'r': { int n=getnum(s); reg[n]=lua_getref(locks[getnum(s)]); break; } case 'r': { int n=getnum(s);
case 'u': lua_unref(locks[getnum(s)]); break; reg[n]=lua_getref((int)lua_getnumber(reg[getnum(s)]));
break;
}
case 'u': lua_unref((int)lua_getnumber(reg[getnum(s)]));
break;
case 'p': { int n = getnum(s); reg[n] = lua_getparam(getnum(s)); break; } case 'p': { int n = getnum(s); reg[n] = lua_getparam(getnum(s)); break; }
case '=': lua_setglobal(getname(s)); break; case '=': lua_setglobal(getname(s)); break;
case 's': lua_pushstring(getname(s)); break; case 's': lua_pushstring(getname(s)); break;