newlib-cygwin/winsup/cygwin/init.cc

39 lines
883 B
C++
Raw Normal View History

2001-09-12 04:01:02 +08:00
/* init.cc
2000-02-18 03:38:33 +08:00
Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
2000-02-18 03:38:33 +08:00
This file is part of Cygwin.
This software is a copyrighted work licensed under the terms of the
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */
#include "winsup.h"
#include <stdlib.h>
#include "thread.h"
#include "perprocess.h"
2000-02-18 03:38:33 +08:00
int NO_COPY dynamically_loaded;
extern "C" int
WINAPI dll_entry (HANDLE h, DWORD reason, void *static_load)
2000-02-18 03:38:33 +08:00
{
switch (reason)
{
case DLL_PROCESS_ATTACH:
cygwin_hmodule = (HMODULE) h;
2000-02-18 03:38:33 +08:00
dynamically_loaded = (static_load == NULL);
break;
case DLL_PROCESS_DETACH:
break;
2000-02-18 03:38:33 +08:00
case DLL_THREAD_ATTACH:
2002-11-05 Thomas Pfaff <tpfaff@gmx.net> * dcrt0.cc (dll_crt0_1): Add call to pthread::initMainThread to initialize mainthread when it is safe to call new. * init.cc (dll_entry): Change call to store reents in tls key. * thread.cc (_reent_clib) : Change call to get reents from tls key. (_reent_winsup): Ditto. (MTinterface::Init): Key handling changed. Remove initialization of member variables. (MTinterface::fixup_after_fork): Reinitialize mainthread object after fork. Reset threadount to 1. (pthread::initMainThread): Create mainthread object dynamically. and initialize with valid handles. (pthread::self): Remove calls to create thread objects. (pthread::setTlsSelfPointer): Change call to store thread self handle in tls key. (pthread::getTlsSelfPointer): New static method. (pthread::exit): Remove setTlsSelfPointer call. (pthread::initCurrentThread): New method. (pthread::thread_init_wrapper): Change call to store thread self handle in tls key. (pthread::join): Check for a valid joiner. (pthreadNull::pthreadNull): Mark Null object as detached. (pthreadNull::exit): Terminate thread via ExitThread. * thread.h (pthread::initMainThread): Change parameter in function call. (pthread::getTlsSelfPointer): New static method. (pthread::initCurrentThread): New method. (MTinterface::reent_key): Remove. (MTinterface::thread_self_dwTlsIndex): Ditto.. (MTinterface::indexallocated): Ditto. (MTinterface::mainthread): Ditto. (MTinterface::reent_key): New member. (MTinterface::thread_self_key): Ditto. (MTinterface::MTinterface): Initialize all members.
2002-11-24 21:54:14 +08:00
if (MT_INTERFACE->reent_key.set (&MT_INTERFACE->reents))
api_fatal ("thread initialization failed");
2000-02-18 03:38:33 +08:00
break;
case DLL_THREAD_DETACH:
/* not invoked */;
2000-02-18 03:38:33 +08:00
break;
}
return 1;
}