Better initialization of ir2-component-constants on x86-64.
[sbcl.git] / src / runtime / dynbind.c
index 1d62ee0..8d8da8c 100644 (file)
@@ -24,7 +24,6 @@
 #include "pseudo-atomic.h"
 #include "genesis/symbol.h"
 #include "genesis/binding.h"
-#include "genesis/thread.h"
 #include "genesis/static-symbols.h"
 
 void bind_variable(lispobj symbol, lispobj value, void *th)
@@ -41,12 +40,11 @@ void bind_variable(lispobj symbol, lispobj value, void *th)
                 &((struct symbol *)native_pointer(TLS_INDEX_LOCK))->value;
             FSHOW_SIGNAL((stderr, "entering dynbind tls alloc\n"));
             set_pseudo_atomic_atomic(thread);
-            get_spinlock(tls_index_lock,(long)th);
+            get_spinlock(tls_index_lock,(uword_t)th);
             if(!sym->tls_index) {
                 sym->tls_index=SymbolValue(FREE_TLS_INDEX,0);
-                SetSymbolValue(FREE_TLS_INDEX,
-                               make_fixnum(fixnum_value(sym->tls_index)+1),0);
-                if(fixnum_value(sym->tls_index)>=TLS_SIZE) {
+                SetSymbolValue(FREE_TLS_INDEX, sym->tls_index+N_WORD_BYTES, 0);
+                if((sym->tls_index)>=(TLS_SIZE << WORD_SHIFT)) {
                     lose("Thread local storage exhausted.");
                 }
             }
@@ -83,6 +81,28 @@ unbind(void *th)
 }
 
 void
+unbind_variable(lispobj name, void *th)
+{
+    struct thread *thread=(struct thread *)th;
+    struct binding *binding;
+    lispobj symbol;
+
+    binding = ((struct binding *)get_binding_stack_pointer(thread)) - 1;
+
+    symbol = binding->symbol;
+
+    if (symbol != name)
+      lose("unbind_variable, 0x%p != 0x%p", symbol, name);
+
+    SetTlSymbolValue(symbol, binding->value,thread);
+
+    binding->symbol = 0;
+    binding->value = 0;
+
+    set_binding_stack_pointer(thread,binding);
+}
+
+void
 unbind_to_here(lispobj *bsp,void *th)
 {
     struct thread *thread=(struct thread *)th;