* cygthread.cc (cygthread::stub): Properly establish _threadinfo environment.
(cygthread::stub2): New function. (cygthread::simplestub): Ditto. (cygthread::simplestub2): New function. * cygthread.h (cygthread::stub2): Declare new function. (cygthread::simplestub2): Ditto. * cygtls.h (_threadinfo::call): Declare new function. (_threadinfo::call2): Ditto. * dcrt0.cc (dll_crt0_1): Accommodate new _threadinfo::init which doesn't return pointer to tls. (_dll_crt0): Remove obsolete DECLARE_TLS_STORAGE. (dll_crt0): Ditto. * exceptions.cc (_threadinfo::call): New function. (_threadinfo::call2): Ditto. (_threadinfo::init): Don't return pointer. * thread.cc (pthread::thread_init_wrapper): Properly establish _threadinfo environment. (pthread::thread_init_wrapper2): New function. * thread.h (pthread::thread_init_wrapper): Remove noreturn attribute (pthread::thread_init_wrapper2): Declare new function. * winbase.h: Remove obsolete code.
This commit is contained in:
parent
af9ef8abb2
commit
d1eb7a4615
@ -1,3 +1,28 @@
|
|||||||
|
2003-12-03 Christopher Faylor <cgf@redhat.com>
|
||||||
|
|
||||||
|
* cygthread.cc (cygthread::stub): Properly establish _threadinfo
|
||||||
|
environment.
|
||||||
|
(cygthread::stub2): New function.
|
||||||
|
(cygthread::simplestub): Ditto.
|
||||||
|
(cygthread::simplestub2): New function.
|
||||||
|
* cygthread.h (cygthread::stub2): Declare new function.
|
||||||
|
(cygthread::simplestub2): Ditto.
|
||||||
|
* cygtls.h (_threadinfo::call): Declare new function.
|
||||||
|
(_threadinfo::call2): Ditto.
|
||||||
|
* dcrt0.cc (dll_crt0_1): Accommodate new _threadinfo::init which
|
||||||
|
doesn't return pointer to tls.
|
||||||
|
(_dll_crt0): Remove obsolete DECLARE_TLS_STORAGE.
|
||||||
|
(dll_crt0): Ditto.
|
||||||
|
* exceptions.cc (_threadinfo::call): New function.
|
||||||
|
(_threadinfo::call2): Ditto.
|
||||||
|
(_threadinfo::init): Don't return pointer.
|
||||||
|
* thread.cc (pthread::thread_init_wrapper): Properly establish
|
||||||
|
_threadinfo environment.
|
||||||
|
(pthread::thread_init_wrapper2): New function.
|
||||||
|
* thread.h (pthread::thread_init_wrapper): Remove noreturn attribute
|
||||||
|
(pthread::thread_init_wrapper2): Declare new function.
|
||||||
|
* winbase.h: Remove obsolete code.
|
||||||
|
|
||||||
2003-12-02 Christopher Faylor <cgf@redhat.com>
|
2003-12-02 Christopher Faylor <cgf@redhat.com>
|
||||||
|
|
||||||
* Makefile.in: Change the way that -f options are appended to CFLAGS,
|
* Makefile.in: Change the way that -f options are appended to CFLAGS,
|
||||||
|
@ -15,6 +15,8 @@ details. */
|
|||||||
#include "sync.h"
|
#include "sync.h"
|
||||||
#include "cygerrno.h"
|
#include "cygerrno.h"
|
||||||
#include "sigproc.h"
|
#include "sigproc.h"
|
||||||
|
#include "thread.h"
|
||||||
|
#include "cygtls.h"
|
||||||
|
|
||||||
#undef CloseHandle
|
#undef CloseHandle
|
||||||
|
|
||||||
@ -30,13 +32,20 @@ bool NO_COPY cygthread::exiting;
|
|||||||
DWORD WINAPI
|
DWORD WINAPI
|
||||||
cygthread::stub (VOID *arg)
|
cygthread::stub (VOID *arg)
|
||||||
{
|
{
|
||||||
DECLARE_TLS_STORAGE;
|
_threadinfo::call (stub2, arg);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cygthread::stub2 (void *arg, void *)
|
||||||
|
{
|
||||||
exception_list except_entry;
|
exception_list except_entry;
|
||||||
|
|
||||||
/* Initialize this thread's ability to respond to things like
|
/* Initialize this thread's ability to respond to things like
|
||||||
SIGSEGV or SIGFPE. */
|
SIGSEGV or SIGFPE. */
|
||||||
init_exceptions (&except_entry);
|
init_exceptions (&except_entry);
|
||||||
|
|
||||||
|
|
||||||
cygthread *info = (cygthread *) arg;
|
cygthread *info = (cygthread *) arg;
|
||||||
if (info->arg == cygself)
|
if (info->arg == cygself)
|
||||||
{
|
{
|
||||||
@ -91,7 +100,13 @@ cygthread::stub (VOID *arg)
|
|||||||
DWORD WINAPI
|
DWORD WINAPI
|
||||||
cygthread::simplestub (VOID *arg)
|
cygthread::simplestub (VOID *arg)
|
||||||
{
|
{
|
||||||
DECLARE_TLS_STORAGE;
|
_threadinfo::call (simplestub2, arg);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
cygthread::simplestub2 (void *arg, void *)
|
||||||
|
{
|
||||||
exception_list except_entry;
|
exception_list except_entry;
|
||||||
|
|
||||||
/* Initialize this thread's ability to respond to things like
|
/* Initialize this thread's ability to respond to things like
|
||||||
|
@ -20,7 +20,9 @@ class cygthread
|
|||||||
bool is_freerange;
|
bool is_freerange;
|
||||||
static bool exiting;
|
static bool exiting;
|
||||||
static DWORD WINAPI stub (VOID *);
|
static DWORD WINAPI stub (VOID *);
|
||||||
|
static void stub2 (void *, void *);
|
||||||
static DWORD WINAPI simplestub (VOID *);
|
static DWORD WINAPI simplestub (VOID *);
|
||||||
|
static void simplestub2 (void *, void *);
|
||||||
void terminate_thread ();
|
void terminate_thread ();
|
||||||
public:
|
public:
|
||||||
static DWORD main_thread_id;
|
static DWORD main_thread_id;
|
||||||
|
@ -40,7 +40,9 @@ struct _threadinfo
|
|||||||
int sig;
|
int sig;
|
||||||
__stack_t *stackptr;
|
__stack_t *stackptr;
|
||||||
|
|
||||||
struct _threadinfo *init (void *, void * = NULL);
|
void init (void *);
|
||||||
|
static void call (void (*) (void *, void *), void *);
|
||||||
|
void call2 (void (*) (void *, void *), void *, void *);
|
||||||
void remove ();
|
void remove ();
|
||||||
void push (__stack_t, bool = false);
|
void push (__stack_t, bool = false);
|
||||||
__stack_t pop ();
|
__stack_t pop ();
|
||||||
|
@ -532,8 +532,9 @@ _threadinfo NO_COPY *_main_tls;
|
|||||||
static void
|
static void
|
||||||
dll_crt0_1 ()
|
dll_crt0_1 ()
|
||||||
{
|
{
|
||||||
__uint64_t padding[CYGTLS_PADSIZE];
|
char padding[CYGTLS_PADSIZE];
|
||||||
_main_tls = _my_tls.init (padding);
|
_main_tls = &_my_tls;
|
||||||
|
_main_tls->init (padding);
|
||||||
|
|
||||||
/* According to onno@stack.urc.tue.nl, the exception handler record must
|
/* According to onno@stack.urc.tue.nl, the exception handler record must
|
||||||
be on the stack. */
|
be on the stack. */
|
||||||
@ -838,7 +839,6 @@ initial_env ()
|
|||||||
extern "C" void __stdcall
|
extern "C" void __stdcall
|
||||||
_dll_crt0 ()
|
_dll_crt0 ()
|
||||||
{
|
{
|
||||||
DECLARE_TLS_STORAGE;
|
|
||||||
initial_env ();
|
initial_env ();
|
||||||
char zeros[sizeof (fork_info->zero)] = {0};
|
char zeros[sizeof (fork_info->zero)] = {0};
|
||||||
static NO_COPY STARTUPINFO si;
|
static NO_COPY STARTUPINFO si;
|
||||||
@ -907,7 +907,6 @@ _dll_crt0 ()
|
|||||||
void
|
void
|
||||||
dll_crt0 (per_process *uptr)
|
dll_crt0 (per_process *uptr)
|
||||||
{
|
{
|
||||||
DECLARE_TLS_STORAGE;
|
|
||||||
/* Set the local copy of the pointer into the user space. */
|
/* Set the local copy of the pointer into the user space. */
|
||||||
if (uptr && uptr != user_data)
|
if (uptr && uptr != user_data)
|
||||||
{
|
{
|
||||||
|
@ -147,8 +147,22 @@ _threadinfo::reset_exception ()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_threadinfo *
|
void
|
||||||
_threadinfo::init (void *, void *thread)
|
_threadinfo::call (void (*func) (void *, void *), void *arg)
|
||||||
|
{
|
||||||
|
char buf[CYGTLS_PADSIZE];
|
||||||
|
_my_tls.call2 (func, arg, buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_threadinfo::call2 (void (*func) (void *, void *), void *arg, void *buf)
|
||||||
|
{
|
||||||
|
init (buf);
|
||||||
|
func (arg, buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_threadinfo::init (void *)
|
||||||
{
|
{
|
||||||
memset (this, 0, sizeof (*this));
|
memset (this, 0, sizeof (*this));
|
||||||
stackptr = stack;
|
stackptr = stack;
|
||||||
@ -157,7 +171,6 @@ _threadinfo::init (void *, void *thread)
|
|||||||
_last_thread = this;
|
_last_thread = this;
|
||||||
set_state (false);
|
set_state (false);
|
||||||
errno_addr = &errno;
|
errno_addr = &errno;
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -1885,14 +1885,10 @@ __reent_t::init_clib (struct _reent& var)
|
|||||||
_clib = &var;
|
_clib = &var;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Pthreads */
|
void
|
||||||
void *
|
pthread::thread_init_wrapper2 (void *arg, void *)
|
||||||
pthread::thread_init_wrapper (void *_arg)
|
|
||||||
{
|
{
|
||||||
// Setup the local/global storage of this thread
|
pthread *thread = (pthread *) arg;
|
||||||
__uint64_t padding[CYGTLS_PADSIZE];
|
|
||||||
pthread *thread = (pthread *) _arg;
|
|
||||||
thread->cygtls = _my_tls.init (padding, &thread);
|
|
||||||
_my_tls.tid = thread;
|
_my_tls.tid = thread;
|
||||||
|
|
||||||
exception_list cygwin_except_entry;
|
exception_list cygwin_except_entry;
|
||||||
@ -1923,7 +1919,7 @@ pthread::thread_init_wrapper (void *_arg)
|
|||||||
system_printf ("local storage for thread isn't setup correctly");
|
system_printf ("local storage for thread isn't setup correctly");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
thread_printf ("started thread %p %p %p %p %p %p", _arg, &local_clib,
|
thread_printf ("started thread %p %p %p %p %p %p", arg, &local_clib,
|
||||||
_impure_ptr, thread, thread->function, thread->arg);
|
_impure_ptr, thread, thread->function, thread->arg);
|
||||||
|
|
||||||
// call the user's thread
|
// call the user's thread
|
||||||
@ -1932,6 +1928,14 @@ pthread::thread_init_wrapper (void *_arg)
|
|||||||
thread->exit (ret);
|
thread->exit (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Pthreads */
|
||||||
|
void
|
||||||
|
pthread::thread_init_wrapper (void *arg)
|
||||||
|
{
|
||||||
|
// calls thread_init_wrapper2. Never returns.
|
||||||
|
_threadinfo::call (thread_init_wrapper2, arg);
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
pthread::is_good_object (pthread_t const *thread)
|
pthread::is_good_object (pthread_t const *thread)
|
||||||
{
|
{
|
||||||
|
@ -502,7 +502,8 @@ public:
|
|||||||
virtual void pop_cleanup_handler (int const execute);
|
virtual void pop_cleanup_handler (int const execute);
|
||||||
|
|
||||||
static pthread* self ();
|
static pthread* self ();
|
||||||
static void *thread_init_wrapper (void *) __attribute__ ((noreturn));
|
static void thread_init_wrapper (void *);
|
||||||
|
static void thread_init_wrapper2 (void *, void *);
|
||||||
|
|
||||||
virtual unsigned long getsequence_np();
|
virtual unsigned long getsequence_np();
|
||||||
|
|
||||||
|
@ -56,49 +56,4 @@ ilockcmpexch (long *t, long v, long c)
|
|||||||
#define InterlockedExchange ilockexch
|
#define InterlockedExchange ilockexch
|
||||||
#undef InterlockedCompareExchange
|
#undef InterlockedCompareExchange
|
||||||
#define InterlockedCompareExchange ilockcmpexch
|
#define InterlockedCompareExchange ilockcmpexch
|
||||||
|
|
||||||
// extern char * volatile *__stackbase __asm__ ("%fs:4");
|
|
||||||
#ifndef EXPCGf
|
|
||||||
#define DECLARE_TLS_STORAGE do {} while (0)
|
|
||||||
#else
|
|
||||||
#define DECLARE_TLS_STORAGE char **tls[4096] __attribute__ ((unused))
|
|
||||||
extern long tls_ix;
|
|
||||||
|
|
||||||
extern __inline__ DWORD
|
|
||||||
my_tlsalloc ()
|
|
||||||
{
|
|
||||||
DWORD n = ilockdecr (&tls_ix);
|
|
||||||
__stackbase[tls_ix] = NULL;
|
|
||||||
return n;
|
|
||||||
}
|
|
||||||
|
|
||||||
extern __inline__ BOOL
|
|
||||||
my_tlssetvalue (DWORD ix, void *val)
|
|
||||||
{
|
|
||||||
__stackbase[ix] = (char *) val;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
extern __inline__ void *
|
|
||||||
my_tlsgetvalue (DWORD ix)
|
|
||||||
{
|
|
||||||
return __stackbase[ix];
|
|
||||||
}
|
|
||||||
|
|
||||||
extern __inline__ BOOL
|
|
||||||
my_tlsfree (DWORD ix)
|
|
||||||
{
|
|
||||||
/* nothing for now */
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
#undef TlsAlloc
|
|
||||||
#define TlsAlloc my_tlsalloc
|
|
||||||
#undef TlsGetValue
|
|
||||||
#define TlsGetValue my_tlsgetvalue
|
|
||||||
#undef TlsSetValue
|
|
||||||
#define TlsSetValue my_tlssetvalue
|
|
||||||
#undef TlsFree
|
|
||||||
#define TlsFree my_tlsfree
|
|
||||||
#endif /*EXPCGF*/
|
|
||||||
#endif /*_WINBASE2_H*/
|
#endif /*_WINBASE2_H*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user