4
0
mirror of git://sourceware.org/git/newlib-cygwin.git synced 2025-01-18 12:29:32 +08:00
Christopher Faylor b9874a0c14 * cygthread.cc (cygthread::create): Fix incorrect use of name rather than
__name.
* cygthread.h (cygthread::cygthread): Create versions which eliminate 'n'
parameter.
* dcrt0.cc (dll_crt0_1): Remove check for threadfunc_ix.  Remove obsolete
comments.  Set process_state to active here.
* fhandler_netdrive.cc (create_thread_and_wait): Use shortened cygthread
constructor.
* timer.cc (timer_tracker::settime): Ditto.
* window.cc (HWND): Ditto.
* fhandler_tty.cc: Use shortened cygthread constructor, where appropriate,
throughout.
* select.cc: Ditto.
* fork.cc (frok::child): Remove wait_for_sigthread.
(fork): Reformat if for slightly better clarity.
* init.cc (dll_finished_loading): New variable.
(dll_entry): Use dll_finished_loading to determine when we should call
merge_threadfunc.
* sigproc.cc (no_signals_available): Simplify by using my_readsig.
(wait_sig_inited): Delete.
(wait_sig): Define as void function.
(pending_signals): Accommodate change to wait_sig definition.
(wait_for_sigthread): Delete definition.
(sigproc_init): Initialize signal pipe here, before wait_sig thread is created.
Use void form of cygthread creation.
(init_sig_pipe): Delete.
(wait_sig): Return void rather than DWORD.  Assume previous initialization of
signal pipe.  Set my_sendsig to NULL when exiting.
* sigproc.h (wait_for_sigthread): Delete declaration.
2010-09-01 18:24:11 +00:00

90 lines
2.7 KiB
C++

/* cygthread.h
Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2010
Red Hat, Inc.
This software is a copyrighted work licensed under the terms of the
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */
#ifndef _CYGTHREAD_H
#define _CYGTHREAD_H
typedef void WINAPI (*LPVOID_THREAD_START_ROUTINE) (void *) __attribute__((noreturn)); // Input queue thread
class cygthread
{
LONG inuse;
DWORD id;
HANDLE h;
HANDLE ev;
HANDLE thread_sync;
void *stack_ptr;
const char *__name;
#ifdef DEBUGGING
const char *__oldname;
bool terminated;
#endif
LPTHREAD_START_ROUTINE func;
unsigned arglen;
VOID *arg;
bool is_freerange;
static bool exiting;
HANDLE notify_detached;
bool standalone;
void create () __attribute__ ((regparm(2)));
public:
bool terminate_thread ();
static DWORD WINAPI stub (VOID *);
static DWORD WINAPI simplestub (VOID *);
static DWORD main_thread_id;
static const char * name (DWORD = 0);
void callfunc (bool) __attribute__ ((noinline, regparm (2)));
void auto_release () {func = NULL;}
void release (bool);
cygthread (LPTHREAD_START_ROUTINE start, unsigned n, LPVOID param, const char *name, HANDLE notify = NULL)
: __name (name), func (start), arglen (n), arg (param), notify_detached (notify), standalone (false)
{
create ();
}
cygthread (LPVOID_THREAD_START_ROUTINE start, LPVOID param, const char *name, HANDLE notify = NULL)
: __name (name), func ((LPTHREAD_START_ROUTINE) start), arglen (0),
arg (param), notify_detached (notify), standalone (true)
{
create ();
/* This is a neverending/high-priority thread */
::SetThreadPriority (h, THREAD_PRIORITY_HIGHEST);
zap_h ();
}
cygthread (LPTHREAD_START_ROUTINE start, LPVOID param, const char *name, HANDLE notify = NULL)
: __name (name), func (start), arglen (0), arg (param), notify_detached (notify), standalone (false)
{
create ();
}
cygthread (LPVOID_THREAD_START_ROUTINE start, unsigned n, LPVOID param, const char *name, HANDLE notify = NULL)
: __name (name), func ((LPTHREAD_START_ROUTINE) start), arglen (n),
arg (param), notify_detached (notify), standalone (true)
{
create ();
/* This is a neverending/high-priority thread */
::SetThreadPriority (h, THREAD_PRIORITY_HIGHEST);
zap_h ();
}
cygthread () {};
static void init ();
bool detach (HANDLE = NULL);
operator HANDLE ();
void * operator new (size_t);
static cygthread *freerange ();
static void terminate ();
bool SetThreadPriority (int nPriority) {return ::SetThreadPriority (h, nPriority);}
void zap_h ()
{
CloseHandle (h);
h = NULL;
}
};
#define cygself NULL
#endif /*_CYGTHREAD_H*/