andre@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
andre@0: /* This Source Code Form is subject to the terms of the Mozilla Public
andre@0:  * License, v. 2.0. If a copy of the MPL was not distributed with this
andre@0:  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
andre@0: 
andre@0: #ifndef NSPR_STATIC  /* See the end of w95thred.c. */
andre@0: 
andre@0: /*
andre@0:  * The DLL entry point (DllMain) for NSPR.
andre@0:  *
andre@0:  * This is used to detach threads that were automatically attached by
andre@0:  * nspr.
andre@0:  */
andre@0: 
andre@0: #include <windows.h>
andre@0: #include <primpl.h>
andre@0: 
andre@0: BOOL WINAPI DllMain(
andre@0:     HINSTANCE hinstDLL,
andre@0:     DWORD fdwReason,
andre@0:     LPVOID lpvReserved)
andre@0: {
andre@0: PRThread *me;
andre@0: 
andre@0:     switch (fdwReason) {
andre@0:         case DLL_PROCESS_ATTACH:
andre@0:             break;
andre@0:         case DLL_THREAD_ATTACH:
andre@0:             break;
andre@0:         case DLL_THREAD_DETACH:
andre@0:             if (_pr_initialized) {
andre@0:                 me = _MD_GET_ATTACHED_THREAD();
andre@0:                 if ((me != NULL) && (me->flags & _PR_ATTACHED))
andre@0:                     _PRI_DetachThread();
andre@0:             }
andre@0:             break;
andre@0:         case DLL_PROCESS_DETACH:
andre@0:             break;
andre@0:     }
andre@0:     return TRUE;
andre@0: }
andre@0: 
andre@0: #endif