/*
 * 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 4
#define THREAD_BINDING_STACK_POINTER_OFFSET 8
#define THREAD_ALIEN_STACK_POINTER_OFFSET 12
#define THREAD_PROFILE_DATA_OFFSET 16
#define THREAD_BOXED_TLAB_OFFSET 20
#define THREAD_CONS_TLAB_OFFSET 32
#define THREAD_MIXED_TLAB_OFFSET 44
#define THREAD_OS_ADDRESS_OFFSET 56
#define THREAD_OS_THREAD_OFFSET 60
#define THREAD_ALIEN_STACK_START_OFFSET 64
#define THREAD_BINDING_STACK_START_OFFSET 68
#define THREAD_CONTROL_STACK_START_OFFSET 72
#define THREAD_CONTROL_STACK_END_OFFSET 76
#define THREAD_THIS_OFFSET 80
#define THREAD_PREV_OFFSET 84
#define THREAD_NEXT_OFFSET 88
#define THREAD_STATE_WORD_OFFSET 92
#define THREAD_SPROF_DATA_OFFSET 100
#define THREAD_SPROF_ENABLE_OFFSET 104
#define THREAD_ARENA_OFFSET 108
#define THREAD_BREAKPOINT_MISC_OFFSET 112
#define THREAD_SYMBOL_TLAB_OFFSET 116
#define THREAD_SYS_MIXED_TLAB_OFFSET 128
#define THREAD_SYS_CONS_TLAB_OFFSET 140
#define THREAD_REMSET_OFFSET 152
#define THREAD_SLOW_PATH_ALLOCS_OFFSET 156
#define THREAD_ET_FIND_FREEISH_PAGE_OFFSET 160
#define THREAD_ET_BZEROING_OFFSET 164
#define THREAD_LISP_THREAD_OFFSET 168
#define THREAD_SIZE 43

#else /* __ASSEMBLER__ */

#include "lispobj.h"
struct thread_instance {
    lispobj header; // = word_0_
    lispobj _layout;
    lispobj _name;
    lispobj ephemeral_p;
    lispobj uw_primitive_thread;
    lispobj uw_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 uw_observed_internal_real_time_delta_sec;
    lispobj sw_observed_internal_real_time_delta_millisec;
    lispobj internal_real_time;
    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 name;
    lispobj _owner;
};
#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)

extern struct thread *all_threads;
struct thread {
    lispobj no_tls_value_marker;
    lispobj stepping;
    lispobj * binding_stack_pointer;
    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;
    lispobj 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;
    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
