aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWaldemar Celes <celes@tecgraf.puc-rio.br>1995-01-27 15:19:06 -0200
committerWaldemar Celes <celes@tecgraf.puc-rio.br>1995-01-27 15:19:06 -0200
commit8795aab83ed89f6a93d71d36c8cc37a4887581b2 (patch)
tree87e6e2f0a2c2ad76557a6148d4eb1e6a2558884f
parentf83db16cabdd3e83986e5f3a74c822baa688649e (diff)
downloadlua-8795aab83ed89f6a93d71d36c8cc37a4887581b2.tar.gz
lua-8795aab83ed89f6a93d71d36c8cc37a4887581b2.tar.bz2
lua-8795aab83ed89f6a93d71d36c8cc37a4887581b2.zip
new API function lua_pushlocked & lua_checkstack is a macro
-rw-r--r--opcode.c39
1 files changed, 23 insertions, 16 deletions
diff --git a/opcode.c b/opcode.c
index d7b82c50..4f488bb0 100644
--- a/opcode.c
+++ b/opcode.c
@@ -3,7 +3,7 @@
3** TecCGraf - PUC-Rio 3** TecCGraf - PUC-Rio
4*/ 4*/
5 5
6char *rcs_opcode="$Id: opcode.c,v 3.30 1994/12/28 12:55:47 roberto Exp roberto $"; 6char *rcs_opcode="$Id: opcode.c,v 3.31 1994/12/30 17:45:11 roberto Exp celes $";
7 7
8#include <setjmp.h> 8#include <setjmp.h>
9#include <stdio.h> 9#include <stdio.h>
@@ -96,22 +96,21 @@ static void lua_initstack (void)
96/* 96/*
97** Check stack overflow and, if necessary, realloc vector 97** Check stack overflow and, if necessary, realloc vector
98*/ 98*/
99static void lua_checkstack (StkId n) 99#define lua_checkstack(n) if ((Long)(n) > maxstack) checkstack(n)
100
101static void checkstack (StkId n)
100{ 102{
101 if ((Long)n > maxstack) 103 StkId t;
102 { 104 if (stack == NULL)
103 StkId t; 105 lua_initstack();
104 if (stack == NULL) 106 if (maxstack >= MAX_INT)
105 lua_initstack(); 107 lua_error("stack size overflow");
106 if (maxstack >= MAX_INT) 108 t = top-stack;
107 lua_error("stack size overflow"); 109 maxstack *= 2;
108 t = top-stack; 110 if (maxstack >= MAX_INT)
109 maxstack *= 2; 111 maxstack = MAX_INT;
110 if (maxstack >= MAX_INT) 112 stack = growvector(stack, maxstack, Object);
111 maxstack = MAX_INT; 113 top = stack + t;
112 stack = growvector(stack, maxstack, Object);
113 top = stack + t;
114 }
115} 114}
116 115
117 116
@@ -565,6 +564,14 @@ lua_Object lua_getlocked (int ref)
565} 564}
566 565
567 566
567void lua_pushlocked (int ref)
568{
569 lua_checkstack(top-stack+1);
570 *top = *luaI_getlocked(ref);
571 top++;
572}
573
574
568int lua_lock (void) 575int lua_lock (void)
569{ 576{
570 adjustC(1); 577 adjustC(1);