1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 2 * Copyright by The HDF Group. * 3 * Copyright by the Board of Trustees of the University of Illinois. * 4 * All rights reserved. * 5 * * 6 * This file is part of HDF5. The full HDF5 copyright notice, including * 7 * terms governing use, modification, and redistribution, is contained in * 8 * the COPYING file, which can be found at the root of the source code * 9 * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * 10 * If you do not have access to either file, you may request a copy from * 11 * help@hdfgroup.org. * 12 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 13 14 /*------------------------------------------------------------------------- 15 * 16 * Created: H5TSprivate.h 17 * May 2 2000 18 * Chee Wai LEE 19 * 20 * Purpose: Private non-prototype header. 21 * 22 * Modifications: 23 * 24 *------------------------------------------------------------------------- 25 */ 26 #ifndef H5TSprivate_H_ 27 #define H5TSprivate_H_ 28 29 /* Public headers needed by this file */ 30 #ifdef LATER 31 #include "H5TSpublic.h" /*Public API prototypes */ 32 #endif /* LATER */ 33 34 #ifdef H5_HAVE_WIN_THREADS 35 36 /* Library level data structures */ 37 38 /* Mutexes, Threads, and Attributes */ 39 typedef struct H5TS_mutex_struct { 40 CRITICAL_SECTION CriticalSection; 41 } H5TS_mutex_t; 42 typedef CRITICAL_SECTION H5TS_mutex_simple_t; 43 typedef HANDLE H5TS_thread_t; 44 typedef HANDLE H5TS_attr_t; 45 typedef DWORD H5TS_key_t; 46 typedef INIT_ONCE H5TS_once_t; 47 48 /* Defines */ 49 /* not used on windows side, but need to be defined to something */ 50 #define H5TS_SCOPE_SYSTEM 0 51 #define H5TS_SCOPE_PROCESS 0 52 #define H5TS_CALL_CONV WINAPI 53 54 /* Functions */ 55 #define H5TS_get_thread_local_value(key) TlsGetValue( key ) 56 #define H5TS_set_thread_local_value(key, value) TlsSetValue( key, value ) 57 #define H5TS_attr_init(attr_ptr) 0 58 #define H5TS_attr_setscope(attr_ptr, scope) 0 59 #define H5TS_attr_destroy(attr_ptr) 0 60 #define H5TS_wait_for_thread(thread) WaitForSingleObject(thread, INFINITE) 61 #define H5TS_mutex_init(mutex) InitializeCriticalSection(mutex) 62 #define H5TS_mutex_lock_simple(mutex) EnterCriticalSection(mutex) 63 #define H5TS_mutex_unlock_simple(mutex) LeaveCriticalSection(mutex) 64 65 /* Functions called from DllMain */ 66 H5_DLL BOOL CALLBACK H5TS_win32_process_enter(PINIT_ONCE InitOnce, PVOID Parameter, PVOID *lpContex); 67 H5_DLL void H5TS_win32_process_exit(void); 68 H5_DLL herr_t H5TS_win32_thread_enter(void); 69 H5_DLL herr_t H5TS_win32_thread_exit(void); 70 71 72 73 #else /* H5_HAVE_WIN_THREADS */ 74 75 /* Library level data structures */ 76 77 /* Mutexes, Threads, and Attributes */ 78 typedef struct H5TS_mutex_struct { 79 pthread_t owner_thread; /* current lock owner */ 80 pthread_mutex_t atomic_lock; /* lock for atomicity of new mechanism */ 81 pthread_cond_t cond_var; /* condition variable */ 82 unsigned int lock_count; 83 } H5TS_mutex_t; 84 typedef pthread_t H5TS_thread_t; 85 typedef pthread_attr_t H5TS_attr_t; 86 typedef pthread_mutex_t H5TS_mutex_simple_t; 87 typedef pthread_key_t H5TS_key_t; 88 typedef pthread_once_t H5TS_once_t; 89 90 /* Scope Definitions */ 91 #define H5TS_SCOPE_SYSTEM PTHREAD_SCOPE_SYSTEM 92 #define H5TS_SCOPE_PROCESS PTHREAD_SCOPE_PROCESS 93 #define H5TS_CALL_CONV /* unused - Windows only */ 94 95 /* Functions */ 96 #define H5TS_get_thread_local_value(key) pthread_getspecific( key ) 97 #define H5TS_set_thread_local_value(key, value) pthread_setspecific( key, value ) 98 #define H5TS_attr_init(attr_ptr) pthread_attr_init((attr_ptr)) 99 #define H5TS_attr_setscope(attr_ptr, scope) pthread_attr_setscope(attr_ptr, scope) 100 #define H5TS_attr_destroy(attr_ptr) pthread_attr_destroy(attr_ptr) 101 #define H5TS_wait_for_thread(thread) pthread_join(thread, NULL) 102 #define H5TS_mutex_init(mutex) pthread_mutex_init(mutex, NULL) 103 #define H5TS_mutex_lock_simple(mutex) pthread_mutex_lock(mutex) 104 #define H5TS_mutex_unlock_simple(mutex) pthread_mutex_unlock(mutex) 105 106 #endif /* H5_HAVE_WIN_THREADS */ 107 108 /* External global variables */ 109 extern H5TS_once_t H5TS_first_init_g; 110 extern H5TS_key_t H5TS_errstk_key_g; 111 extern H5TS_key_t H5TS_funcstk_key_g; 112 extern H5TS_key_t H5TS_apictx_key_g; 113 114 #if defined c_plusplus || defined __cplusplus 115 extern "C" 116 { 117 #endif /* c_plusplus || __cplusplus */ 118 119 H5_DLL void H5TS_pthread_first_thread_init(void); 120 H5_DLL herr_t H5TS_mutex_lock(H5TS_mutex_t *mutex); 121 H5_DLL herr_t H5TS_mutex_unlock(H5TS_mutex_t *mutex); 122 H5_DLL herr_t H5TS_cancel_count_inc(void); 123 H5_DLL herr_t H5TS_cancel_count_dec(void); 124 H5_DLL H5TS_thread_t H5TS_create_thread(void *(*func)(void *), H5TS_attr_t * attr, void *udata); 125 126 #if defined c_plusplus || defined __cplusplus 127 } 128 #endif /* c_plusplus || __cplusplus */ 129 130 #endif /* H5TSprivate_H_ */ 131 132