(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-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>
* Makefile.in: Change the way that -f options are appended to CFLAGS,
#include "sync.h"
#include "cygerrno.h"
#include "sigproc.h"
+#include "thread.h"
+#include "cygtls.h"
#undef CloseHandle
DWORD WINAPI
cygthread::stub (VOID *arg)
{
- DECLARE_TLS_STORAGE;
+ _threadinfo::call (stub2, arg);
+ return 0;
+}
+
+void
+cygthread::stub2 (void *arg, void *)
+{
exception_list except_entry;
/* Initialize this thread's ability to respond to things like
SIGSEGV or SIGFPE. */
init_exceptions (&except_entry);
+
cygthread *info = (cygthread *) arg;
if (info->arg == cygself)
{
DWORD WINAPI
cygthread::simplestub (VOID *arg)
{
- DECLARE_TLS_STORAGE;
+ _threadinfo::call (simplestub2, arg);
+ return 0;
+}
+
+void
+cygthread::simplestub2 (void *arg, void *)
+{
exception_list except_entry;
/* Initialize this thread's ability to respond to things like
bool is_freerange;
static bool exiting;
static DWORD WINAPI stub (VOID *);
+ static void stub2 (void *, void *);
static DWORD WINAPI simplestub (VOID *);
+ static void simplestub2 (void *, void *);
void terminate_thread ();
public:
static DWORD main_thread_id;
int sig;
__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 push (__stack_t, bool = false);
__stack_t pop ();
static void
dll_crt0_1 ()
{
- __uint64_t padding[CYGTLS_PADSIZE];
- _main_tls = _my_tls.init (padding);
+ char padding[CYGTLS_PADSIZE];
+ _main_tls = &_my_tls;
+ _main_tls->init (padding);
/* According to onno@stack.urc.tue.nl, the exception handler record must
be on the stack. */
extern "C" void __stdcall
_dll_crt0 ()
{
- DECLARE_TLS_STORAGE;
initial_env ();
char zeros[sizeof (fork_info->zero)] = {0};
static NO_COPY STARTUPINFO si;
void
dll_crt0 (per_process *uptr)
{
- DECLARE_TLS_STORAGE;
/* Set the local copy of the pointer into the user space. */
if (uptr && uptr != user_data)
{
}
}
-_threadinfo *
-_threadinfo::init (void *, void *thread)
+void
+_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));
stackptr = stack;
_last_thread = this;
set_state (false);
errno_addr = &errno;
- return this;
}
void
_clib = &var;
};
-/* Pthreads */
-void *
-pthread::thread_init_wrapper (void *_arg)
+void
+pthread::thread_init_wrapper2 (void *arg, void *)
{
- // Setup the local/global storage of this thread
- __uint64_t padding[CYGTLS_PADSIZE];
- pthread *thread = (pthread *) _arg;
- thread->cygtls = _my_tls.init (padding, &thread);
+ pthread *thread = (pthread *) arg;
_my_tls.tid = thread;
exception_list cygwin_except_entry;
system_printf ("local storage for thread isn't setup correctly");
#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);
// call the user's thread
thread->exit (ret);
}
+/* Pthreads */
+void
+pthread::thread_init_wrapper (void *arg)
+{
+ // calls thread_init_wrapper2. Never returns.
+ _threadinfo::call (thread_init_wrapper2, arg);
+}
+
bool
pthread::is_good_object (pthread_t const *thread)
{
virtual void pop_cleanup_handler (int const execute);
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();
#define InterlockedExchange ilockexch
#undef InterlockedCompareExchange
#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*/