Fix attach_thread to allocate a TLS index for *gc-inhibit* if needed
[sbcl.git] / src / runtime / gencgc.c
index f4cbcc7..f4ffd2f 100644 (file)
@@ -597,7 +597,7 @@ report_heap_exhaustion(long available, long requested, struct thread *th)
 }
 \f
 
-#if defined(LISP_FEATURE_X86) || defined(LISP_FEATURE_X86_64)
+#if defined(LISP_FEATURE_X86)
 void fast_bzero(void*, size_t); /* in <arch>-assem.S */
 #endif
 
@@ -4303,13 +4303,26 @@ general_alloc(sword_t nbytes, int page_type_flag)
     }
 }
 
-lispobj *
+lispobj AMD64_SYSV_ABI *
 alloc(long nbytes)
 {
-#if !(defined(LISP_FEATURE_WIN32) && defined(LISP_FEATURE_SB_THREAD))
+#ifdef LISP_FEATURE_SB_SAFEPOINT_STRICTLY
+    struct thread *self = arch_os_get_current_thread();
+    int was_pseudo_atomic = get_pseudo_atomic_atomic(self);
+    if (!was_pseudo_atomic)
+        set_pseudo_atomic_atomic(self);
+#else
     gc_assert(get_pseudo_atomic_atomic(arch_os_get_current_thread()));
 #endif
-    return general_alloc(nbytes, BOXED_PAGE_FLAG);
+
+    lispobj *result = general_alloc(nbytes, BOXED_PAGE_FLAG);
+
+#ifdef LISP_FEATURE_SB_SAFEPOINT_STRICTLY
+    if (!was_pseudo_atomic)
+        clear_pseudo_atomic_atomic(self);
+#endif
+
+    return result;
 }
 \f
 /*
@@ -4419,8 +4432,12 @@ void gc_alloc_update_all_page_tables(void)
 {
     /* Flush the alloc regions updating the tables. */
     struct thread *th;
-    for_each_thread(th)
+    for_each_thread(th) {
         gc_alloc_update_page_tables(BOXED_PAGE_FLAG, &th->alloc_region);
+#if defined(LISP_FEATURE_SB_SAFEPOINT_STRICTLY) && !defined(LISP_FEATURE_WIN32)
+        gc_alloc_update_page_tables(BOXED_PAGE_FLAG, &th->sprof_alloc_region);
+#endif
+    }
     gc_alloc_update_page_tables(UNBOXED_PAGE_FLAG, &unboxed_region);
     gc_alloc_update_page_tables(BOXED_PAGE_FLAG, &boxed_region);
 }