Fix Windows build

This commit is contained in:
Nicolas Williams
2016-04-16 16:45:26 -05:00
parent 3d4fbf9aac
commit e2137c63f5
4 changed files with 20 additions and 29 deletions

View File

@@ -85,8 +85,8 @@ static HEIMDAL_THREAD_LOCAL struct tls_values values;
#define DEAD_KEY ((void *)8)
static void
del_tls_for_thread(void *unused)
void
heim_w32_service_thread_detach(void *unused)
{
tls_keys *key_defs;
void (*dtor)(void*);
@@ -124,7 +124,7 @@ pthread_once_t pt_once = PTHREAD_ONCE_INIT;
static void
atexit_del_tls_for_thread(void)
{
del_tls_for_thread(NULL);
heim_w32_service_thread_detach(NULL);
}
static void
@@ -134,7 +134,7 @@ create_pt_key(void)
/* The main thread may not execute TLS destructors */
atexit(atexit_del_tls_for_thread);
ret = pthread_key_create(&pt_key, del_tls_for_thread);
ret = pthread_key_create(&pt_key, heim_w32_service_thread_detach);
if (ret != 0)
err(1, "pthread_key_create() failed");
}
@@ -319,30 +319,6 @@ heim_w32_getspecific(HEIM_PRIV_thread_key key)
return values.values[key];
}
#ifdef WIN32
BOOL WINAPI DllMain(HINSTANCE hinstDLL,
DWORD fdwReason,
LPVOID lpvReserved)
{
switch (fdwReason) {
case DLL_PROCESS_ATTACH:
return TRUE;
case DLL_PROCESS_DETACH:
return FALSE;
case DLL_THREAD_ATTACH:
return FALSE;
case DLL_THREAD_DETACH:
del_tls_for_thread(NULL);
return FALSE;
}
return FALSE;
}
#endif /* WIN32 */
#else
static char dummy;
#endif /* HEIM_WIN32_TLS */

View File

@@ -418,4 +418,14 @@ void _bsearch_file_info(bsearch_file_handle bfh, size_t *page_sz,
size_t *max_sz, int *blockwise);
void _bsearch_file_close(bsearch_file_handle *bfh);
/*
* Thread-specific keys
*/
int heim_w32_key_create(unsigned long *, void (*)(void *));
int heim_w32_delete_key(unsigned long);
int heim_w32_setspecific(unsigned long, void *);
void *heim_w32_getspecific(unsigned long);
void heim_w32_service_thread_detach(void *);
#endif /* HEIM_BASE_H */

View File

@@ -33,7 +33,9 @@
* SUCH DAMAGE.
*/
#if defined(HEIM_BASE_MAINTAINER) && !defined(WIN33) && defined(ENABLE_PTHREAD_SUPPORT)
#if defined(HEIM_BASE_MAINTAINER) && defined(ENABLE_PTHREAD_SUPPORT)
#define HEIM_WIN32_TLS
#elif defined(WIN32)
#define HEIM_WIN32_TLS
#endif

View File

@@ -31,6 +31,8 @@
#include<windows.h>
extern void heim_w32_service_thread_detach(void *);
HINSTANCE _krb5_hInstance = NULL;
#if NTDDI_VERSION >= NTDDI_VISTA
@@ -65,6 +67,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL,
return FALSE;
case DLL_THREAD_DETACH:
heim_w32_service_thread_detach(NULL);
return FALSE;
}