/[cmucl]/src/lisp/dynbind.c
ViewVC logotype

Contents of /src/lisp/dynbind.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations)
Tue Jan 21 00:28:13 1997 UTC (17 years, 2 months ago) by ram
Branch: MAIN
CVS Tags: RELEASE_18d, snapshot-2003-10, release-18e-base, remove_negative_zero_not_zero, snapshot-2004-05, dynamic-extent-base, LINKAGE_TABLE, PRE_LINKAGE_TABLE, mod-arith-base, sparc_gencgc_merge, RELEASE_18a, RELEASE_18b, RELEASE_18c, amd64-merge-start, release-18e-pre2, cold-pcl-base, snapshot-2003-11, release-19a-base, sparc_gencgc, snapshot-2003-12, release-19a-pre1, release-19a-pre3, release-19a-pre2, release-19a, UNICODE-BASE, release-18e, snapshot-2004-04, lisp-executable-base, release-18e-pre1
Branch point for: mod-arith-branch, sparc_gencgc_branch, RELENG_18, dynamic-extent, UNICODE-BRANCH, lisp-executable, release-18e-branch, cold-pcl, release-19a-branch
Changes since 1.1: +2 -2 lines
File MIME type: text/plain
source kit 1.03.7
1 wlott 1.1 /*
2 ram 1.2 * $Header: /tiger/var/lib/cvsroots/cmucl/src/lisp/dynbind.c,v 1.2 1997/01/21 00:28:13 ram Exp $
3 wlott 1.1 *
4     * Support for dynamic binding from C.
5     */
6    
7     #include "lisp.h"
8     #include "internals.h"
9     #include "globals.h"
10     #include "dynbind.h"
11    
12 ram 1.2 #if defined(ibmrt) || defined(i386)
13 wlott 1.1 #define GetBSP() ((struct binding *)SymbolValue(BINDING_STACK_POINTER))
14     #define SetBSP(value) SetSymbolValue(BINDING_STACK_POINTER, (lispobj)(value))
15     #else
16     #define GetBSP() ((struct binding *)current_binding_stack_pointer)
17     #define SetBSP(value) (current_binding_stack_pointer=(lispobj *)(value))
18     #endif
19    
20     void bind_variable(lispobj symbol, lispobj value)
21     {
22     lispobj old_value;
23     struct binding *binding;
24    
25     old_value = SymbolValue(symbol);
26     binding = GetBSP();
27     SetBSP(binding+1);
28    
29     binding->value = old_value;
30     binding->symbol = symbol;
31     SetSymbolValue(symbol, value);
32     }
33    
34     void unbind(void)
35     {
36     struct binding *binding;
37     lispobj symbol;
38    
39     binding = GetBSP() - 1;
40    
41     symbol = binding->symbol;
42    
43     SetSymbolValue(symbol, binding->value);
44    
45     binding->symbol = 0;
46    
47     SetBSP(binding);
48     }
49    
50     void unbind_to_here(lispobj *bsp)
51     {
52     struct binding *target = (struct binding *)bsp;
53     struct binding *binding = GetBSP();
54     lispobj symbol;
55    
56     while (target < binding) {
57     binding--;
58    
59     symbol = binding->symbol;
60    
61     if (symbol) {
62     SetSymbolValue(symbol, binding->value);
63     binding->symbol = 0;
64     }
65    
66     }
67     SetBSP(binding);
68     }

  ViewVC Help
Powered by ViewVC 1.1.5