-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4262cc4
commit 59eaedb
Showing
45 changed files
with
8,618 additions
and
8,116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,29 @@ | ||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * | ||
* Copyright by The HDF Group. * | ||
* Copyright by the Board of Trustees of the University of Illinois. * | ||
* All rights reserved. * | ||
* * | ||
* This file is part of HDF5. The full HDF5 copyright notice, including * | ||
* terms governing use, modification, and redistribution, is contained in * | ||
* 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. * | ||
* distribution tree, or in https://www.hdfgroup.org/licenses. * | ||
* If you do not have access to either file, you may request a copy from * | ||
* [email protected]. * | ||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | ||
|
||
/*------------------------------------------------------------------------- | ||
* | ||
* Created: H5TSprivate.h | ||
* May 2 2000 | ||
* Chee Wai LEE | ||
* Created: H5TSprivate.h | ||
* | ||
* Purpose: Private non-prototype header. | ||
* | ||
* Modifications: | ||
* Purpose: Thread-safety abstractions used by the library | ||
* | ||
*------------------------------------------------------------------------- | ||
*/ | ||
#ifndef H5TSprivate_H_ | ||
#define H5TSprivate_H_ | ||
|
||
/* Public headers needed by this file */ | ||
#ifdef LATER | ||
#include "H5TSpublic.h" /*Public API prototypes */ | ||
#endif /* LATER */ | ||
#ifdef H5_HAVE_THREADSAFE | ||
/* Include package's public headers */ | ||
#include "H5TSdevelop.h" | ||
|
||
#ifdef H5_HAVE_WIN_THREADS | ||
|
||
|
@@ -39,6 +33,8 @@ | |
typedef struct H5TS_mutex_struct { | ||
CRITICAL_SECTION CriticalSection; | ||
} H5TS_mutex_t; | ||
|
||
/* Portability wrappers around Windows Threads types */ | ||
typedef CRITICAL_SECTION H5TS_mutex_simple_t; | ||
typedef HANDLE H5TS_thread_t; | ||
typedef HANDLE H5TS_attr_t; | ||
|
@@ -51,7 +47,7 @@ typedef INIT_ONCE H5TS_once_t; | |
#define H5TS_SCOPE_PROCESS 0 | ||
#define H5TS_CALL_CONV WINAPI | ||
|
||
/* Functions */ | ||
/* Portability function aliases */ | ||
#define H5TS_get_thread_local_value(key) TlsGetValue(key) | ||
#define H5TS_set_thread_local_value(key, value) TlsSetValue(key, value) | ||
#define H5TS_attr_init(attr_ptr) 0 | ||
|
@@ -68,6 +64,8 @@ H5_DLL void H5TS_win32_process_exit(void); | |
H5_DLL herr_t H5TS_win32_thread_enter(void); | ||
H5_DLL herr_t H5TS_win32_thread_exit(void); | ||
|
||
#define H5TS_thread_id() ((uint64_t)GetCurrentThreadId()) | ||
|
||
#else /* H5_HAVE_WIN_THREADS */ | ||
|
||
/* Library level data structures */ | ||
|
@@ -78,7 +76,12 @@ typedef struct H5TS_mutex_struct { | |
pthread_mutex_t atomic_lock; /* lock for atomicity of new mechanism */ | ||
pthread_cond_t cond_var; /* condition variable */ | ||
unsigned int lock_count; | ||
|
||
pthread_mutex_t atomic_lock2; /* lock for attempt_lock_count */ | ||
unsigned int attempt_lock_count; | ||
} H5TS_mutex_t; | ||
|
||
/* Portability wrappers around pthread types */ | ||
typedef pthread_t H5TS_thread_t; | ||
typedef pthread_attr_t H5TS_attr_t; | ||
typedef pthread_mutex_t H5TS_mutex_simple_t; | ||
|
@@ -90,7 +93,7 @@ typedef pthread_once_t H5TS_once_t; | |
#define H5TS_SCOPE_PROCESS PTHREAD_SCOPE_PROCESS | ||
#define H5TS_CALL_CONV /* unused - Windows only */ | ||
|
||
/* Functions */ | ||
/* Portability function aliases */ | ||
#define H5TS_get_thread_local_value(key) pthread_getspecific(key) | ||
#define H5TS_set_thread_local_value(key, value) pthread_setspecific(key, value) | ||
#define H5TS_attr_init(attr_ptr) pthread_attr_init((attr_ptr)) | ||
|
@@ -101,27 +104,34 @@ typedef pthread_once_t H5TS_once_t; | |
#define H5TS_mutex_lock_simple(mutex) pthread_mutex_lock(mutex) | ||
#define H5TS_mutex_unlock_simple(mutex) pthread_mutex_unlock(mutex) | ||
|
||
/* Pthread-only routines */ | ||
H5_DLL uint64_t H5TS_thread_id(void); | ||
H5_DLL void H5TS_pthread_first_thread_init(void); | ||
|
||
#endif /* H5_HAVE_WIN_THREADS */ | ||
|
||
/* External global variables */ | ||
extern H5TS_once_t H5TS_first_init_g; | ||
extern H5TS_key_t H5TS_errstk_key_g; | ||
extern H5TS_key_t H5TS_funcstk_key_g; | ||
extern H5TS_key_t H5TS_apictx_key_g; | ||
|
||
#if defined c_plusplus || defined __cplusplus | ||
extern "C" { | ||
#endif /* c_plusplus || __cplusplus */ | ||
|
||
H5_DLL void H5TS_pthread_first_thread_init(void); | ||
H5_DLL herr_t H5TS_mutex_lock(H5TS_mutex_t *mutex); | ||
H5_DLL herr_t H5TS_mutex_unlock(H5TS_mutex_t *mutex); | ||
H5_DLL herr_t H5TS_cancel_count_inc(void); | ||
H5_DLL herr_t H5TS_cancel_count_dec(void); | ||
/* Library-scope global variables */ | ||
extern H5TS_once_t H5TS_first_init_g; /* Library initialization */ | ||
extern H5TS_key_t H5TS_errstk_key_g; /* Error stacks */ | ||
#ifdef H5_HAVE_CODESTACK | ||
extern H5TS_key_t H5TS_funcstk_key_g; /* Function stacks */ | ||
#endif /* H5_HAVE_CODESTACK */ | ||
extern H5TS_key_t H5TS_apictx_key_g; /* API contexts */ | ||
|
||
/* Library-scope routines */ | ||
/* (Only used within H5private.h macros) */ | ||
H5_DLL herr_t H5TS_mutex_lock(H5TS_mutex_t *mutex); | ||
H5_DLL herr_t H5TS_mutex_unlock(H5TS_mutex_t *mutex); | ||
H5_DLL herr_t H5TS_cancel_count_inc(void); | ||
H5_DLL herr_t H5TS_cancel_count_dec(void); | ||
|
||
/* Testing routines */ | ||
H5_DLL H5TS_thread_t H5TS_create_thread(void *(*func)(void *), H5TS_attr_t *attr, void *udata); | ||
|
||
#if defined c_plusplus || defined __cplusplus | ||
} | ||
#endif /* c_plusplus || __cplusplus */ | ||
#else /* H5_HAVE_THREADSAFE */ | ||
|
||
#define H5TS_thread_id() ((uint64_t)0) | ||
|
||
#endif /* H5_HAVE_THREADSAFE */ | ||
|
||
#endif /* H5TSprivate_H_ */ |
Oops, something went wrong.