aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNIIBE Yutaka <[email protected]>2024-07-05 02:36:26 +0000
committerNIIBE Yutaka <[email protected]>2024-07-05 02:36:26 +0000
commit9c276e762a25262cd635e97f5aad4b09fa41b427 (patch)
tree02f0728c45fd447e8ad6e23c913996920f5473f4 /src
parentUse gpgrt_b64dec in libgpg-error. (diff)
downloadgpgme-9c276e762a25262cd635e97f5aad4b09fa41b427.tar.gz
gpgme-9c276e762a25262cd635e97f5aad4b09fa41b427.zip
Don't use ath_self, but get thread ID directly.
* src/debug.c [HAVE_W32_SYSTEM or __linux] (tid_log_callback): Use native thread ID call for Windows and Linux, ifdef-out-ed. (debug_init): Only call gpgrt_log_set_pid_suffix_cb for relevant systems. -- Signed-off-by: NIIBE Yutaka <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/debug.c25
-rw-r--r--src/w32-util.c3
2 files changed, 22 insertions, 6 deletions
diff --git a/src/debug.c b/src/debug.c
index b6dc4457..2a87305b 100644
--- a/src/debug.c
+++ b/src/debug.c
@@ -43,8 +43,12 @@
#endif
#include <assert.h>
+#ifdef HAVE_W32_SYSTEM
+#include <winsock2.h>
+#include <windows.h>
+#endif
+
#include "util.h"
-#include "ath.h"
#include "sema.h"
#include "sys-util.h"
#include "debug.h"
@@ -138,20 +142,31 @@ safe_to_use_debug_file (void)
}
+#if defined(HAVE_W32_SYSTEM) || defined(__linux)
static int
tid_log_callback (unsigned long *rvalue)
{
int len = sizeof (*rvalue);
uintptr_t thread;
- thread = ath_self ();
+#ifdef HAVE_W32_SYSTEM
+ thread = (uintptr_t)GetCurrentThreadId ();
+#elif defined(__linux)
+ thread = (uintptr_t)gettid ();
+#endif
if (sizeof (thread) < len)
- len = sizeof (thread);
+ {
+ int zerolen = len;
+
+ len = sizeof (thread);
+ zerolen -= len;
+ memset (rvalue + len, 0, zerolen);
+ }
memcpy (rvalue, &thread, len);
return 2; /* Use use hex representation. */
}
-
+#endif
static void
@@ -217,7 +232,9 @@ debug_init (void)
| GPGRT_LOG_WITH_PID);
gpgrt_log_set_prefix (*gpgrt_log_get_prefix (NULL)?NULL:"gpgme",
flags);
+#if defined(HAVE_W32_SYSTEM) || defined(__linux)
gpgrt_log_set_pid_suffix_cb (tid_log_callback);
+#endif
}
}
diff --git a/src/w32-util.c b/src/w32-util.c
index c661fb4b..1b805bdc 100644
--- a/src/w32-util.c
+++ b/src/w32-util.c
@@ -60,7 +60,6 @@
#include <shlobj.h>
#include "util.h"
-#include "ath.h"
#include "sema.h"
#include "debug.h"
#include "sys-util.h"
@@ -858,7 +857,7 @@ my_mkstemp (char *tmpl)
random_time_bits = (((uint64_t)ft.dwHighDateTime << 32)
| (uint64_t)ft.dwLowDateTime);
}
- value += random_time_bits ^ ath_self ();
+ value += random_time_bits ^ ((uintptr_t)GetCurrentThreadId ());
for (count = 0; count < attempts; value += 7777, ++count)
{