]> 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@sury.org>
Thu, 25 Feb 2021 15:21:10 +0000 (16:21 +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.

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 66c6e1c439d4deb881a229047d18ab19cf08b692..037a44cf5b704bd59c236c6636d6abd3e615cfe0 100644 (file)
@@ -52,6 +52,6 @@ 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
 
 ISC_LANG_ENDDECLS
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 c8ce5a4cade73658e86d23b67a89f0bcb19bda0d..009e8d136b0df0d15ee25fa1f309de12bf697235 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 0f835f97cf59a129dfb8e517a61176d5fb239cc4..0859ff6fbbeed1133fbe5efd468dcbb251a00e83 100644 (file)
@@ -93,7 +93,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 49776b8daa3f707e7d94fab5e5767747ec494390..1927bda4de77f31f3b22e249d1882a89cdcffe74 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 52e40922c94e997690f603e76bdd36ce50ebc761..96150d29a846d9f2b468548c337d95cfc0dbc09b 100644 (file)
@@ -161,18 +161,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)