diff options
Diffstat (limited to 'src/H5TS.c')
-rw-r--r-- | src/H5TS.c | 29 |
1 files changed, 21 insertions, 8 deletions
@@ -5,12 +5,10 @@ * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * - * the files COPYING and Copyright.html. COPYING can be found at the root * - * of the source code distribution tree; Copyright.html can be found at the * - * root level of an installed copy of the electronic HDF5 document set and * - * is linked from the top-level documents page. It can also be found at * - * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * - * access to either file, you may request a copy from help@hdfgroup.org. * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* private headers */ @@ -36,6 +34,7 @@ H5TS_once_t H5TS_first_init_g = PTHREAD_ONCE_INIT; #endif /* H5_HAVE_WIN_THREADS */ H5TS_key_t H5TS_errstk_key_g; H5TS_key_t H5TS_funcstk_key_g; +H5TS_key_t H5TS_apictx_key_g; H5TS_key_t H5TS_cancel_key_g; @@ -111,6 +110,9 @@ H5TS_pthread_first_thread_init(void) /* initialize key for thread-specific function stacks */ pthread_key_create(&H5TS_funcstk_key_g, H5TS_key_destructor); + /* initialize key for thread-specific API contexts */ + pthread_key_create(&H5TS_apictx_key_g, H5TS_key_destructor); + /* initialize key for thread cancellability mechanism */ pthread_key_create(&H5TS_cancel_key_g, H5TS_key_destructor); } @@ -264,8 +266,7 @@ H5TS_cancel_count_inc(void) cancel_counter = (H5TS_cancel_t *)HDcalloc(1, sizeof(H5TS_cancel_t)); if (!cancel_counter) { - H5E_push_stack(NULL, "H5TS_cancel_count_inc", __FILE__, __LINE__, - H5E_ERR_CLS_g, H5E_RESOURCE, H5E_NOSPACE, "memory allocation failed"); + HERROR(H5E_RESOURCE, H5E_NOSPACE, "memory allocation failed"); return FAIL; } @@ -358,6 +359,10 @@ H5TS_win32_process_enter(PINIT_ONCE InitOnce, PVOID Parameter, PVOID *lpContex) ret_value = FALSE; #endif /* H5_HAVE_CODESTACK */ + /* Set up thread local storage */ + if(TLS_OUT_OF_INDEXES == (H5TS_apictx_key_g = TlsAlloc())) + ret_value = FALSE; + return ret_value; } /* H5TS_win32_process_enter() */ #endif /* H5_HAVE_WIN_THREADS */ @@ -428,6 +433,9 @@ H5TS_win32_process_exit(void) TlsFree(H5TS_funcstk_key_g); #endif /* H5_HAVE_CODESTACK */ + /* Clean up per-process thread local storage */ + TlsFree(H5TS_apictx_key_g); + return; } /* H5TS_win32_process_exit() */ #endif /* H5_HAVE_WIN_THREADS */ @@ -471,6 +479,11 @@ H5TS_win32_thread_exit(void) LocalFree((HLOCAL)lpvData); #endif /* H5_HAVE_CODESTACK */ + /* Clean up per-thread thread local storage */ + lpvData = TlsGetValue(H5TS_apictx_key_g); + if(lpvData) + LocalFree((HLOCAL)lpvData); + return ret_value; } /* H5TS_win32_thread_exit() */ #endif /* H5_HAVE_WIN_THREADS */ |