]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Change the isc_thread_self() return type to uintptr_t
authorOndřej Surý <ondrej@sury.org>
Tue, 16 Feb 2021 18:54:04 +0000 (19:54 +0100)
committerOndřej Surý <ondrej@isc.org>
Fri, 26 Feb 2021 20:14:17 +0000 (21:14 +0100)
The pthread_self(), thrd_current() or GetCurrentThreadId() could
actually be a pointer, so we should rather convert the value into
uintptr_t instead of unsigned long.

(cherry picked from commit a0181056a88d4a8ed8998f42225c0ea4e9bb7b99)

lib/isc/pthreads/include/isc/thread.h
lib/isc/rwlock.c
lib/isc/task.c
lib/isc/trampoline.c
lib/isc/win32/condition.c
lib/isc/win32/include/isc/condition.h
lib/isc/win32/include/isc/thread.h
lib/ns/query.c

index bc95381d7b7b44affb07b512623dfea1733654b8..51bf96af3ac38f6ad0ff6e4e2d3ee13e6daf897b 100644 (file)
@@ -55,7 +55,7 @@ isc_thread_setname(isc_thread_t thread, const char *name);
 isc_result_t
 isc_thread_setaffinity(int cpu);
 
-#define isc_thread_self (unsigned long)pthread_self
+#define isc_thread_self (uintptr_t) pthread_self
 
 /***
  *** Thread-Local Storage
index f21b4d05269a978d266161b45356565ffb86e889..3441ce5c140f495386099ec05cf45a40ac0c6d36 100644 (file)
@@ -175,7 +175,7 @@ isc__rwlock_lock(isc_rwlock_t *rwl, isc_rwlocktype_t type);
 static void
 print_lock(const char *operation, isc_rwlock_t *rwl, isc_rwlocktype_t type) {
        fprintf(stderr,
-               "rwlock %p thread %lu %s(%s): "
+               "rwlock %p thread %" PRIuPTR " %s(%s): "
                "write_requests=%u, write_completions=%u, "
                "cnt_and_flag=0x%x, readers_waiting=%u, "
                "write_granted=%u, write_quota=%u\n",
index da0f4d90e522e1e332cfff1475f2c75c9d14f8e6..a618d5b65b1299d71efcdcc2e0dddf626a9e8803 100644 (file)
  */
 
 #ifdef ISC_TASK_TRACE
-#define XTRACE(m)                                                            \
-       fprintf(stderr, "task %p thread %lu: %s\n", task, isc_thread_self(), \
-               (m))
-#define XTTRACE(t, m) \
-       fprintf(stderr, "task %p thread %lu: %s\n", (t), isc_thread_self(), (m))
+#define XTRACE(m)                                                  \
+       fprintf(stderr, "task %p thread %" PRIuPTR ": %s\n", task, \
+               isc_thread_self(), (m))
+#define XTTRACE(t, m)                                             \
+       fprintf(stderr, "task %p thread %" PRIuPTR ": %s\n", (t), \
+               isc_thread_self(), (m))
 #define XTHREADTRACE(m) \
-       fprintf(stderr, "thread %lu: %s\n", isc_thread_self(), (m))
+       fprintf(stderr, "thread %" PRIuPTR ": %s\n", isc_thread_self(), (m))
 #else /* ifdef ISC_TASK_TRACE */
 #define XTRACE(m)
 #define XTTRACE(t, m)
index 200594d0689777069112d89cb6ee37e647b79d70..9d3e9cf8a36aaf9b85e438f417a4a84a3e63a56a 100644 (file)
@@ -26,7 +26,7 @@
 
 struct isc__trampoline {
        int tid; /* const */
-       isc_thread_t self;
+       uintptr_t self;
        isc_threadfunc_t start;
        isc_threadarg_t arg;
 };
index e0945d4d0b85fd6a36d8d515094b3fdbb42a9857..9b28ef2f289ca4a1754569b1bdbcea728c518466 100644 (file)
@@ -92,7 +92,7 @@ register_thread(unsigned long thrd, isc_condition_t *gblcond,
 }
 
 static isc_result_t
-find_thread_condition(unsigned long thrd, isc_condition_t *cond,
+find_thread_condition(uintptr_t thrd, isc_condition_t *cond,
                      isc_condition_thread_t **threadcondp) {
        isc_condition_thread_t *threadcond;
 
index 39a1420b183c9ee42ca8be4ec8581b9d49d4de83..fc4e96c8f3fa48664cced92fe17ab7414c477462 100644 (file)
@@ -22,8 +22,8 @@
 typedef struct isc_condition_thread isc_condition_thread_t;
 
 struct isc_condition_thread {
-       unsigned long th;
-       HANDLE        handle[2];
+       uintptr_t th;
+       HANDLE    handle[2];
        ISC_LINK(isc_condition_thread_t) link;
 };
 
index 3b0eb0631f5a1543ed8e6d46aeee3bb3dc4dc005..b361b9f9daedada56de0bdbe3eeddf4bf86da97d 100644 (file)
@@ -12,6 +12,7 @@
 #ifndef ISC_THREAD_H
 #define ISC_THREAD_H 1
 
+#include <inttypes.h>
 #include <windows.h>
 
 #include <isc/lang.h>
@@ -68,7 +69,7 @@ typedef DWORD  isc_threadresult_t;
 typedef void * isc_threadarg_t;
 typedef isc_threadresult_t(WINAPI *isc_threadfunc_t)(isc_threadarg_t);
 
-#define isc_thread_self (unsigned long)GetCurrentThreadId
+#define isc_thread_self (uintptr_t) GetCurrentThreadId
 
 ISC_LANG_BEGINDECLS
 
index c0887111710b9c74747f25720dbea23d75bb4bd1..6bb0bb8523e1f3b7bed94af6ab39549d118ff677 100644 (file)
@@ -160,18 +160,17 @@ client_trace(ns_client_t *client, int level, const char *message) {
                                             sizeof(tbuf));
                        isc_log_write(ns_lctx, NS_LOGCATEGORY_CLIENT,
                                      NS_LOGMODULE_QUERY, level,
-                                     "query client=%p thread=0x%lx "
+                                     "query client=%p thread=0x%" PRIxPTR
                                      "(%s/%s): %s",
-                                     client, (unsigned long)isc_thread_self(),
-                                     qbuf, tbuf, message);
+                                     client, isc_thread_self(), qbuf, tbuf,
+                                     message);
                }
        } else {
                isc_log_write(ns_lctx, NS_LOGCATEGORY_CLIENT,
                              NS_LOGMODULE_QUERY, level,
-                             "query client=%p thread=0x%lx "
+                             "query client=%p thread=0x%" PRIxPTR
                              "(<unknown-query>): %s",
-                             client, (unsigned long)isc_thread_self(),
-                             message);
+                             client, isc_thread_self(), message);
        }
 }
 #define CTRACE(l, m)  client_trace(client, l, m)