/*
 * This is a machine-generated file. Please do not edit it by hand.
 *
 * This file contains low-level information about the
 * internals of a particular version and configuration
 * of SBCL. It is used by the C compiler to create a runtime
 * support environment, an executable program in the host
 * operating system's native format, which can then be used to
 * load and run 'core' files, which are basically programs
 * in SBCL's own format.
 */
#ifndef SBCL_GENESIS_THREAD
#define SBCL_GENESIS_THREAD

#ifdef __ASSEMBLER__

/* These offsets are SLOT-OFFSET * N-WORD-BYTES - LOWTAG
 * so they work directly on tagged addresses. */

#define THREAD_NO_TLS_VALUE_MARKER_OFFSET 0
#define THREAD_STEPPING_OFFSET 8
#define THREAD_BINDING_STACK_POINTER_OFFSET 16
#define THREAD_CURRENT_CATCH_BLOCK_OFFSET 24
#define THREAD_CURRENT_UNWIND_PROTECT_BLOCK_OFFSET 32
#define THREAD_PSEUDO_ATOMIC_BITS_OFFSET 40
#define THREAD_ALIEN_STACK_POINTER_OFFSET 48
#define THREAD_PROFILE_DATA_OFFSET 56
#define THREAD_BOXED_TLAB_OFFSET 64
#define THREAD_CONS_TLAB_OFFSET 88
#define THREAD_MIXED_TLAB_OFFSET 112
#define THREAD_OS_ADDRESS_OFFSET 136
#define THREAD_OS_THREAD_OFFSET 144
#define THREAD_ALIEN_STACK_START_OFFSET 152
#define THREAD_BINDING_STACK_START_OFFSET 160
#define THREAD_CONTROL_STACK_START_OFFSET 168
#define THREAD_CONTROL_STACK_END_OFFSET 176
#define THREAD_THIS_OFFSET 184
#define THREAD_PREV_OFFSET 192
#define THREAD_NEXT_OFFSET 200
#define THREAD_STATE_WORD_OFFSET 208
#define THREAD_SPROF_DATA_OFFSET 216
#define THREAD_SPROF_ENABLE_OFFSET 224
#define THREAD_ARENA_OFFSET 232
#define THREAD_BREAKPOINT_MISC_OFFSET 240
#define THREAD_TLS_SIZE_OFFSET 248
#define THREAD_CONTROL_FRAME_POINTER_OFFSET 256
#define THREAD_CONTROL_STACK_POINTER_OFFSET 264
#define THREAD_SYMBOL_TLAB_OFFSET 272
#define THREAD_SYS_MIXED_TLAB_OFFSET 296
#define THREAD_SYS_CONS_TLAB_OFFSET 320
#define THREAD_REMSET_OFFSET 344
#define THREAD_SLOW_PATH_ALLOCS_OFFSET 352
#define THREAD_ET_FIND_FREEISH_PAGE_OFFSET 360
#define THREAD_ET_BZEROING_OFFSET 368
#define THREAD_LISP_THREAD_OFFSET 376
#define THREAD_SIZE 48

#else /* __ASSEMBLER__ */

#include "lispobj.h"
struct thread_instance {
    lispobj header; // = word_0_
    lispobj _layout;
    lispobj _name;
    lispobj ephemeral_p;
    lispobj uw_primitive_thread;
    lispobj os_tid;
    lispobj uw_os_thread;
    lispobj uw_control_stack_start;
    lispobj uw_control_stack_end;
    lispobj startup_info;
    lispobj _visible;
    lispobj interruptions;
    lispobj storage_lock;
    lispobj alloc_histogram;
    lispobj uw_tot_bytes_alloc_boxed;
    lispobj uw_tot_bytes_alloc_unboxed;
    lispobj uw_max_stw_pause;
    lispobj uw_sum_stw_pause;
    lispobj uw_ct_stw_pauses;
    lispobj uw_gc_virtual_time;
    lispobj result;
    lispobj semaphore;
    lispobj waiting_for;
};
struct lispmutex {
    lispobj header; // = word_0_
    lispobj _layout;
    lispobj uw__state;
    lispobj name;
    lispobj uw_induced_wait;
};
#include <pthread.h>
#include "gencgc-alloc-region.h"

#define ALLOC_HISTOGRAM_WORDS 96

struct thread_state_word {
  // - control_stack_guard_page_protected is referenced from
  //   hand-written assembly code. (grep 'THREAD_STATE_WORD_OFFSET')
  // - sprof_enable is referenced with SAPs.
  //   (grep 'sb-vm:thread-state-word-slot')
  char control_stack_guard_page_protected;
  char unused;
  char state;
  char user_thread_p; // opposite of lisp's ephemeral-p
  char alien_stack_guard_page_protected;
  char binding_stack_guard_page_protected;
  char padding[2];
};
#define INIT_THREAD_REGIONS(x) \
 gc_init_region(&x->boxed_tlab),\
 gc_init_region(&x->cons_tlab),\
 gc_init_region(&x->mixed_tlab),\
 gc_init_region(&x->symbol_tlab),\
 gc_init_region(&x->sys_mixed_tlab),\
 gc_init_region(&x->sys_cons_tlab)

#define HAVE_THREAD_PSEUDO_ATOMIC_BITS_SLOT 1

typedef lispobj pa_bits_t;

extern struct thread *all_threads;
struct thread {
    lispobj no_tls_value_marker;
    lispobj stepping;
    lispobj * binding_stack_pointer;
    lispobj current_catch_block;
    lispobj current_unwind_protect_block;
    pa_bits_t pseudo_atomic_bits;
    lispobj * alien_stack_pointer;
    uword_t * profile_data;
    struct alloc_region boxed_tlab;
    struct alloc_region cons_tlab;
    struct alloc_region mixed_tlab;
    void * os_address;
    pthread_t os_thread;
    lispobj * alien_stack_start;
    lispobj * binding_stack_start;
    lispobj * control_stack_start;
    lispobj * control_stack_end;
    struct thread * this;
    struct thread * prev;
    struct thread * next;
    struct thread_state_word state_word;
    lispobj sprof_data;
    lispobj sprof_enable;
    lispobj arena;
    void * breakpoint_misc;
    lispobj tls_size;
    lispobj * control_frame_pointer;
    lispobj * control_stack_pointer;
    struct alloc_region symbol_tlab;
    struct alloc_region sys_mixed_tlab;
    struct alloc_region sys_cons_tlab;
    lispobj remset;
    lispobj slow_path_allocs;
    lispobj et_find_freeish_page;
    lispobj et_bzeroing;
    lispobj lisp_thread;
};

#endif /* __ASSEMBLER__ */
#endif
