/*
 * This is a machine-generated file. Please do not edit it by hand.
 * (As of sbcl-0.8.14, it came from WRITE-CONFIG-H in genesis.lisp.)
 *
 * 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
#define THREAD_HEADER_SLOTS 0

#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_OS_KERNEL_TID_OFFSET 64
#define THREAD_ALIEN_STACK_START_OFFSET 68
#define THREAD_BINDING_STACK_START_OFFSET 72
#define THREAD_CONTROL_STACK_START_OFFSET 76
#define THREAD_CONTROL_STACK_END_OFFSET 80
#define THREAD_THIS_OFFSET 84
#define THREAD_PREV_OFFSET 88
#define THREAD_NEXT_OFFSET 92
#define THREAD_STATE_WORD_OFFSET 96
#define THREAD_SPROF_DATA_OFFSET 100
#define THREAD_ARENA_OFFSET 104
#define THREAD_SYMBOL_TLAB_OFFSET 108
#define THREAD_SYS_MIXED_TLAB_OFFSET 120
#define THREAD_SYS_CONS_TLAB_OFFSET 132
#define THREAD_TOT_BYTES_ALLOC_BOXED_OFFSET 144
#define THREAD_TOT_BYTES_ALLOC_UNBOXED_OFFSET 148
#define THREAD_SLOW_PATH_ALLOCS_OFFSET 152
#define THREAD_ET_ALLOCATOR_MUTEX_ACQ_OFFSET 156
#define THREAD_ET_FIND_FREEISH_PAGE_OFFSET 160
#define THREAD_ET_BZEROING_OFFSET 164
#define THREAD_ALLOCATOR_HISTOGRAM_OFFSET 168
#define THREAD_LISP_THREAD_OFFSET 552
#define THREAD_SIZE 139

#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_thread;
    lispobj uw_control_stack_start;
    lispobj uw_control_stack_end;
    lispobj startup_info;
    lispobj _visible;
    lispobj interruptions;
    lispobj interruptions_lock;
    lispobj uw_observed_internal_real_time_delta_sec;
    lispobj sw_observed_internal_real_time_delta_millisec;
    lispobj internal_real_time;
    lispobj uw_max_stw_pause;
    lispobj uw_sum_stw_pause;
    lispobj uw_ct_stw_pauses;
    lispobj result;
    lispobj semaphore;
    lispobj waiting_for;
};
struct mutex {
    lispobj header; // = word_0_
    lispobj _layout;
    lispobj name;
    lispobj _owner;
};
#include "gencgc-alloc-region.h"

#define N_HISTOGRAM_BINS_LARGE 32
#define N_HISTOGRAM_BINS_SMALL 32
typedef lispobj size_histogram[2*N_HISTOGRAM_BINS_LARGE+N_HISTOGRAM_BINS_SMALL];

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 sprof_enable; // statistical CPU profiler switch
  char state;
  char user_thread_p; // opposite of lisp's ephemeral-p

};
#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 os_kernel_tid;
    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 arena;
    struct alloc_region symbol_tlab;
    struct alloc_region sys_mixed_tlab;
    struct alloc_region sys_cons_tlab;
    lispobj tot_bytes_alloc_boxed;
    lispobj tot_bytes_alloc_unboxed;
    lispobj slow_path_allocs;
    lispobj et_allocator_mutex_acq;
    lispobj et_find_freeish_page;
    lispobj et_bzeroing;
    size_histogram allocator_histogram;
    lispobj lisp_thread;
};

#endif /* __ASSEMBLER__ */
#endif
