summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Young <dyoung@hdfgroup.org>2020-02-03 22:23:06 (GMT)
committerQuincey Koziol <koziol@koziol.gov>2020-05-06 20:37:42 (GMT)
commit524af38af8877957308832dbe346aa84c7dea356 (patch)
treecc458a85aa3703e9caa8db0f5ce050615429f6ea /src
parentbb3e1a5cafd0c35358e341836b758ea3b747f495 (diff)
downloadhdf5-524af38af8877957308832dbe346aa84c7dea356.zip
hdf5-524af38af8877957308832dbe346aa84c7dea356.tar.gz
hdf5-524af38af8877957308832dbe346aa84c7dea356.tar.bz2
Change thread IDs to uint64_t from unsigned long, per Quincey's suggestion.
Fix a typo in the H5TS_thread_init() comment and reword some ID properties.
Diffstat (limited to 'src')
-rw-r--r--src/H5CS.c2
-rw-r--r--src/H5Eint.c4
-rw-r--r--src/H5TS.c16
-rw-r--r--src/H5TSprivate.h4
4 files changed, 13 insertions, 13 deletions
diff --git a/src/H5CS.c b/src/H5CS.c
index f429d98..3fccce4 100644
--- a/src/H5CS.c
+++ b/src/H5CS.c
@@ -145,7 +145,7 @@ H5CS_print_stack(const H5CS_t *fstack, FILE *stream)
HDfprintf(stream, "HDF5-DIAG: Function stack from %s ", H5_lib_vers_info_g);
/* try show the process or thread id in multiple processes cases*/
- HDfprintf(stream, "thread %lu.", H5TS_thread_id());
+ HDfprintf(stream, "thread %" PRIu64 ".", H5TS_thread_id());
if(fstack && fstack->nused>0)
HDfprintf(stream, " Back trace follows.");
HDfputc('\n', stream);
diff --git a/src/H5Eint.c b/src/H5Eint.c
index aba912e..7e144c8 100644
--- a/src/H5Eint.c
+++ b/src/H5Eint.c
@@ -260,7 +260,7 @@ H5E__walk1_cb(int n, H5E_error1_t *err_desc, void *client_data)
HDfprintf(stream, "thread 0");
} /* end block */
#else
- HDfprintf(stream, "thread %lu", H5TS_thread_id());
+ HDfprintf(stream, "thread %" PRIu64, H5TS_thread_id());
#endif
HDfprintf(stream, ":\n");
} /* end if */
@@ -390,7 +390,7 @@ H5E__walk2_cb(unsigned n, const H5E_error2_t *err_desc, void *client_data)
HDfprintf(stream, "thread 0");
} /* end block */
#else
- HDfprintf(stream, "thread %lu", H5TS_thread_id());
+ HDfprintf(stream, "thread %" PRIu64, H5TS_thread_id());
#endif
HDfprintf(stream, ":\n");
} /* end if */
diff --git a/src/H5TS.c b/src/H5TS.c
index aa60eba..7a801e2 100644
--- a/src/H5TS.c
+++ b/src/H5TS.c
@@ -47,12 +47,12 @@ typedef struct _tid h5_tid_t;
struct _tid {
h5_tid_t *next;
- unsigned long id;
+ uint64_t id;
};
/* Pointer to first free thread ID record or NULL. */
static h5_tid_t *tid_next_free = NULL;
-static unsigned long tid_next_id = 0;
+static uint64_t tid_next_id = 0;
/* Mutual exclusion for access to tid_next_free and tid_next_id. */
static pthread_mutex_t tid_mtx;
@@ -118,18 +118,18 @@ tid_init(void)
pthread_key_create(&tid_key, tid_destructor);
}
-/* Return an integer identifier, ID, for the current thread satisfies the
+/* Return an integer identifier, ID, for the current thread satisfying the
* following properties:
*
- * 1 1 <= ID <= ULONG_MAX
- * 2 The ID is constant over the thread's lifetime.
+ * 1 1 <= ID <= UINT64_MAX
+ * 2 ID is constant over the thread's lifetime.
* 3 No two threads share an ID during their lifetimes.
* 4 A thread's ID is available for reuse as soon as it is joined.
*
* ID 0 is reserved. H5TS_thread_id() returns 0 if the library was not built
* with thread safety or if an error prevents it from assigning an ID.
*/
-unsigned long
+uint64_t
H5TS_thread_id(void)
{
h5_tid_t *tid = pthread_getspecific(tid_key);
@@ -149,7 +149,7 @@ H5TS_thread_id(void)
pthread_mutex_lock(&tid_mtx);
if ((tid = tid_next_free) != NULL)
tid_next_free = tid->next;
- else if (tid_next_id != ULONG_MAX) {
+ else if (tid_next_id != UINT64_MAX) {
tid = &proto_tid;
tid->id = ++tid_next_id;
}
@@ -641,7 +641,7 @@ H5TS_create_thread(void *(*func)(void *), H5TS_attr_t *attr, void *udata)
#else /* H5_HAVE_THREADSAFE */
-unsigned long
+uint64_t
H5TS_thread_id(void)
{
return 0;
diff --git a/src/H5TSprivate.h b/src/H5TSprivate.h
index 76cf8f1..f22ed52 100644
--- a/src/H5TSprivate.h
+++ b/src/H5TSprivate.h
@@ -68,7 +68,7 @@ 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() ((unsigned long)GetCurrentThreadId())
+#define H5TS_thread_id() ((uint64_t)GetCurrentThreadId())
#else /* H5_HAVE_WIN_THREADS */
@@ -102,7 +102,7 @@ typedef pthread_once_t H5TS_once_t;
#define H5TS_mutex_init(mutex) pthread_mutex_init(mutex, NULL)
#define H5TS_mutex_lock_simple(mutex) pthread_mutex_lock(mutex)
#define H5TS_mutex_unlock_simple(mutex) pthread_mutex_unlock(mutex)
-H5_DLL unsigned long H5TS_thread_id(void);
+H5_DLL uint64_t H5TS_thread_id(void);
#endif /* H5_HAVE_WIN_THREADS */