1e1051a39Sopenharmony_ci/* 2e1051a39Sopenharmony_ci * Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved. 3e1051a39Sopenharmony_ci * 4e1051a39Sopenharmony_ci * Licensed under the Apache License 2.0 (the "License"). You may not use 5e1051a39Sopenharmony_ci * this file except in compliance with the License. You can obtain a copy 6e1051a39Sopenharmony_ci * in the file LICENSE in the source distribution or at 7e1051a39Sopenharmony_ci * https://www.openssl.org/source/license.html 8e1051a39Sopenharmony_ci */ 9e1051a39Sopenharmony_ci 10e1051a39Sopenharmony_ci#include "e_os.h" 11e1051a39Sopenharmony_ci#include "crypto/cryptlib.h" 12e1051a39Sopenharmony_ci 13e1051a39Sopenharmony_ci#if defined(_WIN32) || defined(__CYGWIN__) 14e1051a39Sopenharmony_ci# ifdef __CYGWIN__ 15e1051a39Sopenharmony_ci/* pick DLL_[PROCESS|THREAD]_[ATTACH|DETACH] definitions */ 16e1051a39Sopenharmony_ci# include <windows.h> 17e1051a39Sopenharmony_ci/* 18e1051a39Sopenharmony_ci * this has side-effect of _WIN32 getting defined, which otherwise is 19e1051a39Sopenharmony_ci * mutually exclusive with __CYGWIN__... 20e1051a39Sopenharmony_ci */ 21e1051a39Sopenharmony_ci# endif 22e1051a39Sopenharmony_ci 23e1051a39Sopenharmony_ci/* 24e1051a39Sopenharmony_ci * All we really need to do is remove the 'error' state when a thread 25e1051a39Sopenharmony_ci * detaches 26e1051a39Sopenharmony_ci */ 27e1051a39Sopenharmony_ci 28e1051a39Sopenharmony_ciBOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved); 29e1051a39Sopenharmony_ciBOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) 30e1051a39Sopenharmony_ci{ 31e1051a39Sopenharmony_ci switch (fdwReason) { 32e1051a39Sopenharmony_ci case DLL_PROCESS_ATTACH: 33e1051a39Sopenharmony_ci OPENSSL_cpuid_setup(); 34e1051a39Sopenharmony_ci break; 35e1051a39Sopenharmony_ci case DLL_THREAD_ATTACH: 36e1051a39Sopenharmony_ci break; 37e1051a39Sopenharmony_ci case DLL_THREAD_DETACH: 38e1051a39Sopenharmony_ci OPENSSL_thread_stop(); 39e1051a39Sopenharmony_ci break; 40e1051a39Sopenharmony_ci case DLL_PROCESS_DETACH: 41e1051a39Sopenharmony_ci break; 42e1051a39Sopenharmony_ci } 43e1051a39Sopenharmony_ci return TRUE; 44e1051a39Sopenharmony_ci} 45e1051a39Sopenharmony_ci#endif 46e1051a39Sopenharmony_ci 47