Forked from
redox-os / gcc
200345 commits behind, 60702 commits ahead of the upstream repository.
-
hboehm authored
* mach_dep.c (GC_generic_push_regs): Prevent tail call optimization. * misc.c (GC_init_inner): Call GC_thr_init for win32. (GC_set_warn_proc): Add assertion. * win32_threads.c: Import 6.3alpha2 version. * include/private/gc_priv.h: Add support for EMPTY_GETENV_RESULTS. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@72074 138bc75d-0d04-0410-961f-82ee72b054a4
hboehm authored* mach_dep.c (GC_generic_push_regs): Prevent tail call optimization. * misc.c (GC_init_inner): Call GC_thr_init for win32. (GC_set_warn_proc): Add assertion. * win32_threads.c: Import 6.3alpha2 version. * include/private/gc_priv.h: Add support for EMPTY_GETENV_RESULTS. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@72074 138bc75d-0d04-0410-961f-82ee72b054a4
win32_threads.c 22.21 KiB
#if defined(GC_WIN32_THREADS)
#include "private/gc_priv.h"
#include <windows.h>
#ifdef CYGWIN32
# include <errno.h>
/* Cygwin-specific forward decls */
# undef pthread_create
# undef pthread_sigmask
# undef pthread_join
# undef dlopen
# define DEBUG_CYGWIN_THREADS 0
void * GC_start_routine(void * arg);
void GC_thread_exit_proc(void *arg);
#endif
/* The type of the first argument to InterlockedExchange. */
/* Documented to be LONG volatile *, but at least gcc likes */
/* this better. */
typedef LONG * IE_t;
#ifndef MAX_THREADS
# define MAX_THREADS 256
/* FIXME: */
/* Things may get quite slow for large numbers of threads, */
/* since we look them up with sequential search. */
#endif
GC_bool GC_thr_initialized = FALSE;
DWORD GC_main_thread = 0;
struct GC_thread_Rep {
LONG in_use; /* Updated without lock. */
/* We assert that unused */
/* entries have invalid ids of */
/* zero and zero stack fields. */
DWORD id;
HANDLE handle;
ptr_t stack_base; /* The cold end of the stack. */
/* 0 ==> entry not valid. */
/* !in_use ==> stack_base == 0 */
GC_bool suspended;
# ifdef CYGWIN32
void *status; /* hold exit value until join in case it's a pointer */
pthread_t pthread_id;
short flags; /* Protected by GC lock. */
# define FINISHED 1 /* Thread has exited. */
# define DETACHED 2 /* Thread is intended to be detached. */
# endif
};
typedef volatile struct GC_thread_Rep * GC_thread;
/*
* We generally assume that volatile ==> memory ordering, at least among
* volatiles.
*/
volatile GC_bool GC_please_stop = FALSE;
volatile struct GC_thread_Rep thread_table[MAX_THREADS];
volatile LONG GC_max_thread_index = 0; /* Largest index in thread_table */